mirror of https://github.com/apache/jclouds.git
made blobmetadata parser name accessible for testing
This commit is contained in:
parent
00d172ce2f
commit
897dc000d5
|
@ -53,7 +53,7 @@ public class ParseSystemAndUserMetadataFromHeaders implements Function<HttpRespo
|
||||||
private final DateService dateParser;
|
private final DateService dateParser;
|
||||||
private final Provider<MutableBlobMetadata> metadataFactory;
|
private final Provider<MutableBlobMetadata> metadataFactory;
|
||||||
|
|
||||||
private String key;
|
private String name;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ParseSystemAndUserMetadataFromHeaders(Provider<MutableBlobMetadata> metadataFactory, DateService dateParser,
|
public ParseSystemAndUserMetadataFromHeaders(Provider<MutableBlobMetadata> metadataFactory, DateService dateParser,
|
||||||
|
@ -65,11 +65,12 @@ public class ParseSystemAndUserMetadataFromHeaders implements Function<HttpRespo
|
||||||
|
|
||||||
public MutableBlobMetadata apply(HttpResponse from) {
|
public MutableBlobMetadata apply(HttpResponse from) {
|
||||||
checkNotNull(from, "request");
|
checkNotNull(from, "request");
|
||||||
checkState(key != null, "key must be initialized by now");
|
checkState(name != null, "name must be initialized by now");
|
||||||
|
|
||||||
MutableBlobMetadata to = metadataFactory.get();
|
MutableBlobMetadata to = metadataFactory.get();
|
||||||
to.setName(key);
|
to.setName(name);
|
||||||
HttpUtils.copy(from.getPayload().getContentMetadata(), to.getContentMetadata());
|
if (from.getPayload() != null)
|
||||||
|
HttpUtils.copy(from.getPayload().getContentMetadata(), to.getContentMetadata());
|
||||||
addETagTo(from, to);
|
addETagTo(from, to);
|
||||||
parseLastModifiedOrThrowException(from, to);
|
parseLastModifiedOrThrowException(from, to);
|
||||||
addUserMetadataTo(from, to);
|
addUserMetadataTo(from, to);
|
||||||
|
@ -115,12 +116,11 @@ public class ParseSystemAndUserMetadataFromHeaders implements Function<HttpRespo
|
||||||
|
|
||||||
public ParseSystemAndUserMetadataFromHeaders setContext(HttpRequest request) {
|
public ParseSystemAndUserMetadataFromHeaders setContext(HttpRequest request) {
|
||||||
checkArgument(request instanceof GeneratedHttpRequest<?>, "note this handler requires a GeneratedHttpRequest");
|
checkArgument(request instanceof GeneratedHttpRequest<?>, "note this handler requires a GeneratedHttpRequest");
|
||||||
setName(getNameFor(GeneratedHttpRequest.class.cast(request)));
|
return setName(getNameFor(GeneratedHttpRequest.class.cast(request)));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
public ParseSystemAndUserMetadataFromHeaders setName(String name) {
|
||||||
void setName(String key) {
|
this.name = checkNotNull(name, "name");
|
||||||
this.key = checkNotNull(key, "key");
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue