From 6cd7d9058ef5e173e7e1e709c0afd20adba5e4ae Mon Sep 17 00:00:00 2001 From: wangbinhui Date: Thu, 11 May 2017 11:51:09 +0800 Subject: [PATCH] To offer the way to get response headers from Download/Upload API call --- .../client/core/AbstractStoredObject.java | 11 +++++++++++ .../object/AbstractDownloadObjectCommand.java | 1 + .../impl/object/AbstractObjectCommand.java | 19 +++++++++++++++++++ .../javaswift/joss/model/StoredObject.java | 4 +++- 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/javaswift/joss/client/core/AbstractStoredObject.java b/src/main/java/org/javaswift/joss/client/core/AbstractStoredObject.java index fcae344b..31a680ba 100644 --- a/src/main/java/org/javaswift/joss/client/core/AbstractStoredObject.java +++ b/src/main/java/org/javaswift/joss/client/core/AbstractStoredObject.java @@ -1,5 +1,6 @@ package org.javaswift.joss.client.core; +import org.apache.http.Header; import org.javaswift.joss.command.shared.factory.StoredObjectCommandFactory; import org.javaswift.joss.exception.CommandException; import org.javaswift.joss.headers.Metadata; @@ -26,6 +27,8 @@ public abstract class AbstractStoredObject extends AbstractObjectStoreEntity extends AbstractSecureCommand { + private StoredObject object; + public AbstractObjectCommand(Account account, HttpClient httpClient, Access access, StoredObject object) { super(account, httpClient, getURL(access, object), access.getToken()); + this.object = object; + } + + public StoredObject getStoredObject() { + return object; + } + + public void populateResponseHeaders(HttpResponse response) { + object.setResponseHeaders(response.getAllHeaders()); + } + + protected N getReturnObject(HttpResponse response) throws IOException { + populateResponseHeaders(response); + return null; // returns null by default } } diff --git a/src/main/java/org/javaswift/joss/model/StoredObject.java b/src/main/java/org/javaswift/joss/model/StoredObject.java index 63fc5b86..df2e542a 100644 --- a/src/main/java/org/javaswift/joss/model/StoredObject.java +++ b/src/main/java/org/javaswift/joss/model/StoredObject.java @@ -1,5 +1,6 @@ package org.javaswift.joss.model; +import org.apache.http.Header; import org.javaswift.joss.instructions.DownloadInstructions; import org.javaswift.joss.instructions.UploadInstructions; @@ -266,5 +267,6 @@ public interface StoredObject extends ObjectStoreEntity, Comparable