Add Atmos-specific MD5 checksum header

Tested against Atmos Online.
This commit is contained in:
Andrew Gaul 2013-06-20 15:26:23 -07:00
parent 6cc8e36f43
commit b2016703ad
4 changed files with 17 additions and 7 deletions

View File

@ -22,7 +22,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Inject;
import javax.inject.Singleton;
import com.google.common.io.BaseEncoding;
import org.jclouds.atmos.domain.AtmosObject;
import org.jclouds.atmos.reference.AtmosHeaders;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.Binder;
@ -47,6 +50,13 @@ public class BindMetadataToHeaders implements Binder {
checkNotNull(object.getPayload(), "object payload");
checkArgument(object.getPayload().getContentMetadata().getContentLength() != null,
"contentLength must be set, streaming not supported");
byte[] contentMD5 = object.getContentMetadata().getContentMD5();
if (contentMD5 != null) {
request = (R) request.toBuilder()
.addHeader(AtmosHeaders.CHECKSUM, "MD5/0/" +
BaseEncoding.base16().encode(contentMD5))
.build();
}
return metaBinder.bindToRequest(request, object.getUserMetadata());
}
}

View File

@ -35,5 +35,6 @@ public interface AtmosHeaders {
public static final String GROUP_ACL = "x-emc-groupacl";
public static final String UID = "x-emc-uid";
public static final String TOKEN = "x-emc-token";
public static final String CHECKSUM = "x-emc-wschecksum";
}

View File

@ -99,7 +99,12 @@ public class AtmosBlobRequestSignerTest extends BaseAsyncClientTest<AtmosAsyncCl
"POST https://accesspoint.atmosonline.com/rest/namespace/container/name HTTP/1.1");
assertNonPayloadHeadersEqual(
request,
"Accept: */*\nDate: Thu, 05 Jun 2008 16:38:19 GMT\nExpect: 100-continue\nx-emc-signature: 7Cbdnu+YA5rG9J/C9RlHk07mU7w=\nx-emc-uid: identity\n");
"Accept: */*\n" +
"Date: Thu, 05 Jun 2008 16:38:19 GMT\n" +
"Expect: 100-continue\n" +
"x-emc-signature: DTzbKA9a0TAawWFEbC4D76wTq3A=\n" +
"x-emc-uid: identity\n" +
"x-emc-wschecksum: MD5/0/00020408\n");
assertContentHeadersEqual(request, "text/plain", null, null, null, 2L, new byte[] { 0, 2, 4, 8 }, new Date(1000));

View File

@ -24,7 +24,6 @@ import java.util.concurrent.ExecutionException;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.domain.BlobMetadata;
import org.jclouds.blobstore.integration.internal.BaseBlobIntegrationTest;
import org.testng.SkipException;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@ -113,11 +112,6 @@ public class AtmosIntegrationLiveTest extends BaseBlobIntegrationTest {
assertEquals(metadata.getContentMetadata().getContentMD5(), null);
}
@Override
public void testPutIncorrectContentMD5() throws InterruptedException, IOException {
throw new SkipException("not yet implemented");
}
@Test(enabled = false)
// problem with the stub and md5, live is fine
public void testMetadata() {