From ff83778fb7a7b9fd122b3ff825a10fface255b33 Mon Sep 17 00:00:00 2001 From: "Roman C. Coedo" Date: Fri, 4 Jul 2014 00:25:28 +0200 Subject: [PATCH] JCLOUDS-457: uploadPart return type fix The uploadPart method now returns HashCode instead of String. --- .../java/org/jclouds/glacier/GlacierAsyncClient.java | 2 +- .../main/java/org/jclouds/glacier/GlacierClient.java | 2 +- .../functions/ParseMultipartUploadTreeHashHeader.java | 11 ++++++----- .../org/jclouds/glacier/GlacierClientMockTest.java | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/apis/glacier/src/main/java/org/jclouds/glacier/GlacierAsyncClient.java b/apis/glacier/src/main/java/org/jclouds/glacier/GlacierAsyncClient.java index 541a3f4683..a1c1939984 100644 --- a/apis/glacier/src/main/java/org/jclouds/glacier/GlacierAsyncClient.java +++ b/apis/glacier/src/main/java/org/jclouds/glacier/GlacierAsyncClient.java @@ -201,7 +201,7 @@ public interface GlacierAsyncClient extends Closeable { @PUT @Path("/-/vaults/{vault}/multipart-uploads/{uploadId}") @ResponseParser(ParseMultipartUploadTreeHashHeader.class) - ListenableFuture uploadPart( + ListenableFuture uploadPart( @ParamValidators(VaultNameValidator.class) @PathParam("vault") String vaultName, @PathParam("uploadId") String uploadId, @BinderParam(BindContentRangeToHeaders.class) ContentRange range, diff --git a/apis/glacier/src/main/java/org/jclouds/glacier/GlacierClient.java b/apis/glacier/src/main/java/org/jclouds/glacier/GlacierClient.java index da6fe7da07..7826370339 100644 --- a/apis/glacier/src/main/java/org/jclouds/glacier/GlacierClient.java +++ b/apis/glacier/src/main/java/org/jclouds/glacier/GlacierClient.java @@ -157,7 +157,7 @@ public interface GlacierClient extends Closeable { * upload. * @see */ - String uploadPart(String vaultName, String uploadId, ContentRange range, Payload payload); + HashCode uploadPart(String vaultName, String uploadId, ContentRange range, Payload payload); /** * Completes the multipart upload. diff --git a/apis/glacier/src/main/java/org/jclouds/glacier/functions/ParseMultipartUploadTreeHashHeader.java b/apis/glacier/src/main/java/org/jclouds/glacier/functions/ParseMultipartUploadTreeHashHeader.java index d779b4896e..64417c7d91 100644 --- a/apis/glacier/src/main/java/org/jclouds/glacier/functions/ParseMultipartUploadTreeHashHeader.java +++ b/apis/glacier/src/main/java/org/jclouds/glacier/functions/ParseMultipartUploadTreeHashHeader.java @@ -23,16 +23,17 @@ import org.jclouds.http.HttpException; import org.jclouds.http.HttpResponse; import com.google.common.base.Function; +import com.google.common.hash.HashCode; /** * Parses the tree hash header from the HttpResponse. */ -public class ParseMultipartUploadTreeHashHeader implements Function { +public class ParseMultipartUploadTreeHashHeader implements Function { @Override - public String apply(HttpResponse from) { - String id = from.getFirstHeaderOrNull(GlacierHeaders.TREE_HASH); - if (id == null) + public HashCode apply(HttpResponse from) { + String treehash = from.getFirstHeaderOrNull(GlacierHeaders.TREE_HASH); + if (treehash == null) throw new HttpException("Did not receive Tree hash"); - return id; + return HashCode.fromString(treehash); } } diff --git a/apis/glacier/src/test/java/org/jclouds/glacier/GlacierClientMockTest.java b/apis/glacier/src/test/java/org/jclouds/glacier/GlacierClientMockTest.java index cec3c24623..9ae400ad0b 100644 --- a/apis/glacier/src/test/java/org/jclouds/glacier/GlacierClientMockTest.java +++ b/apis/glacier/src/test/java/org/jclouds/glacier/GlacierClientMockTest.java @@ -89,7 +89,7 @@ public class GlacierClientMockTest { private static final String VAULT_ARN3 = VAULT_ARN_PREFIX + VAULT_NAME3; private static final String ARCHIVE_ID = "NkbByEejwEggmBz2fTHgJrg0XBoDfjP4q6iu87-TjhqG6eGoOY9Z8i1_AUyUsuhPAdTqLHy8pTl5nfCFJmDl2yEZONi5L26Omw12vcs01MNGntHEQL8MBfGlqrEXAMPLEArchiveId"; private static final String ARCHIVE_LOCATION = VAULT_LOCATION + "/archives/" + ARCHIVE_ID; - private static final String TREEHASH = "beb0fe31a1c7ca8c6c04d574ea906e3f97b31fdca7571defb5b44dca89b5af60"; + private static final HashCode TREEHASH = HashCode.fromString("beb0fe31a1c7ca8c6c04d574ea906e3f97b31fdca7571defb5b44dca89b5af60"); private static final String DESCRIPTION = "test description"; private static final String MULTIPART_UPLOAD_LOCATION = VAULT_LOCATION + "/multipart-uploads/" + ARCHIVE_ID; private static final String MULTIPART_UPLOAD_ID = "OW2fM5iVylEpFEMM9_HpKowRapC3vn5sSL39_396UW9zLFUWVrnRHaPjUJddQ5OxSHVXjYtrN47NBZ-khxOjyEXAMPLE";