mirror of https://github.com/apache/jclouds.git
Improve use of Splitter in Atmos code
This commit is contained in:
parent
4c07702d29
commit
53134dfa4e
|
@ -31,7 +31,7 @@ import org.jclouds.date.DateService;
|
|||
import org.jclouds.http.HttpResponse;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.base.Splitter;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
|
@ -48,12 +48,7 @@ public class ParseSystemMetadataFromHeaders implements Function<HttpResponse, Sy
|
|||
public SystemMetadata apply(HttpResponse from) {
|
||||
checkNotNull(from, "http response");
|
||||
String meta = checkNotNull(from.getFirstHeaderOrNull(AtmosHeaders.META), AtmosHeaders.META);
|
||||
Map<String, String> metaMap = Maps.newHashMap();
|
||||
String[] metas = meta.split(", ");
|
||||
for (String entry : metas) {
|
||||
String[] entrySplit = entry.split("=");
|
||||
metaMap.put(entrySplit[0], entrySplit[1]);
|
||||
}
|
||||
Map<String, String> metaMap = Splitter.on(", ").withKeyValueSeparator('=').split(meta);
|
||||
assert metaMap.size() >= 12 : String.format("Should be 12 entries in %s", metaMap);
|
||||
byte[] md5 = metaMap.containsKey("content-md5") ? base16().lowerCase().decode(metaMap.get("content-md5")) : null;
|
||||
return new SystemMetadata(md5, dateService.iso8601SecondsDateParse(checkNotNull(metaMap.get("atime"), "atime")),
|
||||
|
|
|
@ -33,7 +33,6 @@ import com.google.common.base.Splitter;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
|
@ -63,13 +62,7 @@ public class ParseUserMetadataFromHeaders implements Function<HttpResponse, User
|
|||
return new UserMetadata(meta, listableMeta, tags, listableTags);
|
||||
}
|
||||
|
||||
// TODO: change to guava
|
||||
private Map<String, String> getMetaMap(String meta) {
|
||||
Builder<String, String> metaMap = ImmutableMap.builder();
|
||||
for (String entry : Splitter.on(", ").split(meta)) {
|
||||
String[] entrySplit = entry.split("=");
|
||||
metaMap.put(entrySplit[0], entrySplit[1]);
|
||||
}
|
||||
return metaMap.build();
|
||||
private static Map<String, String> getMetaMap(String meta) {
|
||||
return Splitter.on(", ").withKeyValueSeparator('=').split(meta);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue