JCLOUDS-457: uploadPart return type fix

The uploadPart method now returns HashCode instead
of String.
This commit is contained in:
Roman C. Coedo 2014-07-04 00:25:28 +02:00 committed by Andrew Gaul
parent 327a7b0a6b
commit ff83778fb7
4 changed files with 9 additions and 8 deletions

View File

@ -201,7 +201,7 @@ public interface GlacierAsyncClient extends Closeable {
@PUT @PUT
@Path("/-/vaults/{vault}/multipart-uploads/{uploadId}") @Path("/-/vaults/{vault}/multipart-uploads/{uploadId}")
@ResponseParser(ParseMultipartUploadTreeHashHeader.class) @ResponseParser(ParseMultipartUploadTreeHashHeader.class)
ListenableFuture<String> uploadPart( ListenableFuture<HashCode> uploadPart(
@ParamValidators(VaultNameValidator.class) @PathParam("vault") String vaultName, @ParamValidators(VaultNameValidator.class) @PathParam("vault") String vaultName,
@PathParam("uploadId") String uploadId, @PathParam("uploadId") String uploadId,
@BinderParam(BindContentRangeToHeaders.class) ContentRange range, @BinderParam(BindContentRangeToHeaders.class) ContentRange range,

View File

@ -157,7 +157,7 @@ public interface GlacierClient extends Closeable {
* upload. * upload.
* @see <a href="http://docs.aws.amazon.com/amazonglacier/latest/dev/api-upload-part.html" /> * @see <a href="http://docs.aws.amazon.com/amazonglacier/latest/dev/api-upload-part.html" />
*/ */
String uploadPart(String vaultName, String uploadId, ContentRange range, Payload payload); HashCode uploadPart(String vaultName, String uploadId, ContentRange range, Payload payload);
/** /**
* Completes the multipart upload. * Completes the multipart upload.

View File

@ -23,16 +23,17 @@ import org.jclouds.http.HttpException;
import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponse;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.hash.HashCode;
/** /**
* Parses the tree hash header from the HttpResponse. * Parses the tree hash header from the HttpResponse.
*/ */
public class ParseMultipartUploadTreeHashHeader implements Function<HttpResponse, String> { public class ParseMultipartUploadTreeHashHeader implements Function<HttpResponse, HashCode> {
@Override @Override
public String apply(HttpResponse from) { public HashCode apply(HttpResponse from) {
String id = from.getFirstHeaderOrNull(GlacierHeaders.TREE_HASH); String treehash = from.getFirstHeaderOrNull(GlacierHeaders.TREE_HASH);
if (id == null) if (treehash == null)
throw new HttpException("Did not receive Tree hash"); throw new HttpException("Did not receive Tree hash");
return id; return HashCode.fromString(treehash);
} }
} }

View File

@ -89,7 +89,7 @@ public class GlacierClientMockTest {
private static final String VAULT_ARN3 = VAULT_ARN_PREFIX + VAULT_NAME3; 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_ID = "NkbByEejwEggmBz2fTHgJrg0XBoDfjP4q6iu87-TjhqG6eGoOY9Z8i1_AUyUsuhPAdTqLHy8pTl5nfCFJmDl2yEZONi5L26Omw12vcs01MNGntHEQL8MBfGlqrEXAMPLEArchiveId";
private static final String ARCHIVE_LOCATION = VAULT_LOCATION + "/archives/" + ARCHIVE_ID; 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 DESCRIPTION = "test description";
private static final String MULTIPART_UPLOAD_LOCATION = VAULT_LOCATION + "/multipart-uploads/" + ARCHIVE_ID; private static final String MULTIPART_UPLOAD_LOCATION = VAULT_LOCATION + "/multipart-uploads/" + ARCHIVE_ID;
private static final String MULTIPART_UPLOAD_ID = "OW2fM5iVylEpFEMM9_HpKowRapC3vn5sSL39_396UW9zLFUWVrnRHaPjUJddQ5OxSHVXjYtrN47NBZ-khxOjyEXAMPLE"; private static final String MULTIPART_UPLOAD_ID = "OW2fM5iVylEpFEMM9_HpKowRapC3vn5sSL39_396UW9zLFUWVrnRHaPjUJddQ5OxSHVXjYtrN47NBZ-khxOjyEXAMPLE";