mirror of https://github.com/apache/jclouds.git
JCLOUDS-598: Populate Atmos MD5 from wschecksum
This commit is contained in:
parent
50026c8f2d
commit
a6337fdcc4
|
@ -45,7 +45,7 @@ public class ObjectToBlobMetadata implements Function<AtmosObject, MutableBlobMe
|
|||
private final ShareUrl shareUrl;
|
||||
|
||||
private static final Set<String> systemMetadata = ImmutableSet.of("atime", "mtime", "ctime", "itime", "type", "uid",
|
||||
"gid", "objectid", "objname", "size", "nlink", "policyname", "content-md5");
|
||||
"gid", "objectid", "objname", "size", "nlink", "policyname");
|
||||
|
||||
@Inject
|
||||
protected ObjectToBlobMetadata(AtmosObjectName objectName, ShareUrl shareUrl)
|
||||
|
@ -81,6 +81,7 @@ public class ObjectToBlobMetadata implements Function<AtmosObject, MutableBlobMe
|
|||
to.setSize(from.getContentMetadata().getContentLength());
|
||||
to.setTier(Tier.STANDARD);
|
||||
to.setETag(from.getSystemMetadata().getObjectID());
|
||||
to.getContentMetadata().setContentMD5(from.getSystemMetadata().getContentMD5());
|
||||
return to;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,16 @@ public class ParseSystemMetadataFromHeaders implements Function<HttpResponse, Sy
|
|||
String meta = checkNotNull(from.getFirstHeaderOrNull(AtmosHeaders.META), AtmosHeaders.META);
|
||||
Map<String, String> metaMap = Splitter.on(", ").withKeyValueSeparator('=').split(meta);
|
||||
assert metaMap.size() >= 12 : String.format("Should be 12 entries in %s", metaMap);
|
||||
byte[] md5 = metaMap.containsKey("content-md5") ? base16().lowerCase().decode(metaMap.get("content-md5")) : null;
|
||||
|
||||
byte[] md5 = null;
|
||||
String wschecksum = from.getFirstHeaderOrNull(AtmosHeaders.CHECKSUM);
|
||||
if (wschecksum != null) {
|
||||
String[] parts = wschecksum.split("/");
|
||||
if (parts[0].equalsIgnoreCase("MD5") && parts.length == 3) {
|
||||
md5 = base16().lowerCase().decode(parts[2]);
|
||||
}
|
||||
}
|
||||
|
||||
return new SystemMetadata(md5, dateService.iso8601SecondsDateParse(checkNotNull(metaMap.get("atime"), "atime")),
|
||||
dateService.iso8601SecondsDateParse(checkNotNull(metaMap.get("ctime"), "ctime")), checkNotNull(
|
||||
metaMap.get("gid"), "gid"), dateService.iso8601SecondsDateParse(checkNotNull(metaMap.get("itime"),
|
||||
|
|
|
@ -16,11 +16,6 @@
|
|||
*/
|
||||
package org.jclouds.atmos.blobstore.integration;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||
import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.SkipException;
|
||||
|
@ -31,11 +26,6 @@ public class AtmosContainerIntegrationLiveTest extends BaseContainerIntegrationT
|
|||
provider = "atmos";
|
||||
}
|
||||
|
||||
protected void checkMD5(BlobMetadata metadata) throws IOException {
|
||||
// atmos doesn't support MD5
|
||||
assertEquals(metadata.getContentMetadata().getContentMD5(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testDelimiter() throws Exception {
|
||||
throw new SkipException("Atmos does not use key names for markers");
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.jclouds.atmos.blobstore.integration;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
@ -87,12 +86,6 @@ public class AtmosIntegrationLiveTest extends BaseBlobIntegrationTest {
|
|||
super.testPutObjectStream();
|
||||
}
|
||||
|
||||
// not supported
|
||||
@Override
|
||||
protected void checkMD5(BlobMetadata metadata) throws IOException {
|
||||
assertEquals(metadata.getContentMetadata().getContentMD5(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testCreateBlobWithExpiry() throws InterruptedException {
|
||||
throw new SkipException("Expiration not yet implemented");
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
package org.jclouds.atmos.blobstore.integration;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.blobstore.integration.internal.BaseBlobLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -26,10 +24,4 @@ public class AtmosLiveTest extends BaseBlobLiveTest {
|
|||
public AtmosLiveTest() {
|
||||
provider = "atmos";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkMD5(String container, String name, byte[] md5) {
|
||||
// atmos does not support content-md5 yet
|
||||
assertEquals(view.getBlobStore().blobMetadata(container, name).getContentMetadata().getContentMD5(), null);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue