JCLOUDS-651: Swift support for conditional copies

This commit is contained in:
Andrew Gaul 2016-02-12 03:07:51 -08:00
parent 6cdb1216a7
commit 7eb46cce36
2 changed files with 30 additions and 1 deletions

View File

@ -253,6 +253,21 @@ public class RegionScopedSwiftBlobStore implements BlobStore {
CopyOptions options) {
ObjectApi objectApi = api.getObjectApi(regionId, toContainer);
org.jclouds.openstack.swift.v1.options.CopyOptions swiftOptions = new org.jclouds.openstack.swift.v1.options.CopyOptions();
if (options.ifMatch() != null) {
swiftOptions.ifMatch(options.ifMatch());
}
if (options.ifNoneMatch() != null) {
throw new UnsupportedOperationException("Swift does not support ifNoneMatch");
}
if (options.ifModifiedSince() != null) {
swiftOptions.ifModifiedSince(options.ifModifiedSince());
}
if (options.ifUnmodifiedSince() != null) {
swiftOptions.ifUnmodifiedSince(options.ifUnmodifiedSince());
}
Map<String, String> systemMetadata = Maps.newHashMap();
ContentMetadata contentMetadata = options.contentMetadata();
Map<String, String> userMetadata = options.userMetadata();
@ -307,7 +322,7 @@ public class RegionScopedSwiftBlobStore implements BlobStore {
userMetadata = metadata.getMetadata();
}
objectApi.copy(toName, fromContainer, fromName, userMetadata, systemMetadata);
objectApi.copy(toName, fromContainer, fromName, userMetadata, systemMetadata, swiftOptions);
// TODO: Swift copy object *appends* user metadata, does not overwrite
return objectApi.getWithoutBody(toName).getETag();

View File

@ -100,6 +100,20 @@ public class SwiftBlobIntegrationLiveTest extends BaseBlobIntegrationTest {
super.testPutBlobAccessMultipart();
}
@Override
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testCopyIfNoneMatch() throws Exception {
super.testCopyIfNoneMatch();
}
@Override
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testCopyIfNoneMatchNegative() throws Exception {
super.testCopyIfNoneMatchNegative();
}
// TODO: testCopyIfModifiedSinceNegative throws HTTP 304 not 412 error
@Override
protected long getMinimumMultipartBlobSize() {
return 1;