From 4f32e863ad2552d6fb941a536b91e1e18a35c462 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Thu, 6 Aug 2015 11:23:21 -0700 Subject: [PATCH] JCLOUDS-883: Replace metadata during Swift copy Previously Swift copy would append metadata instead of replacing it. --- .../org/jclouds/openstack/swift/v1/features/ObjectApi.java | 3 ++- .../jclouds/openstack/swift/v1/reference/SwiftHeaders.java | 1 + .../blobstore/integration/SwiftBlobIntegrationLiveTest.java | 5 ----- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ObjectApi.java b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ObjectApi.java index 0257b2288a..3d41c4a780 100644 --- a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ObjectApi.java +++ b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ObjectApi.java @@ -19,6 +19,7 @@ package org.jclouds.openstack.swift.v1.features; import static com.google.common.net.HttpHeaders.EXPECT; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.OBJECT_COPY_FROM; +import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.OBJECT_COPY_FRESH_METADATA; import java.util.Map; @@ -309,7 +310,7 @@ public interface ObjectApi { @Named("object:copy") @PUT @Path("/{destinationObject}") - @Headers(keys = OBJECT_COPY_FROM, values = "/{sourceContainer}/{sourceObject}") + @Headers(keys = {OBJECT_COPY_FROM, OBJECT_COPY_FRESH_METADATA}, values = {"/{sourceContainer}/{sourceObject}", "True"}) @Fallback(FalseOnKeyNotFound.class) boolean copy(@PathParam("destinationObject") String destinationObject, @PathParam("sourceContainer") String sourceContainer, diff --git a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/reference/SwiftHeaders.java b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/reference/SwiftHeaders.java index 23c61c04d0..a2ee08fb1f 100644 --- a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/reference/SwiftHeaders.java +++ b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/reference/SwiftHeaders.java @@ -71,6 +71,7 @@ public final class SwiftHeaders { public static final String CONTAINER_WEB_MODE = "X-Web-Mode"; public static final String OBJECT_COPY_FROM = "X-Copy-From"; + public static final String OBJECT_COPY_FRESH_METADATA = "X-Fresh-Metadata"; public static final String OBJECT_DELETE_AFTER = "X-Delete-After"; public static final String OBJECT_DELETE_AT = "X-Delete-At"; public static final String OBJECT_MANIFEST = "X-Object-Manifest"; diff --git a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobIntegrationLiveTest.java b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobIntegrationLiveTest.java index 510c0efb5b..e25306f9f0 100644 --- a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobIntegrationLiveTest.java +++ b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobIntegrationLiveTest.java @@ -79,11 +79,6 @@ public class SwiftBlobIntegrationLiveTest extends BaseBlobIntegrationTest { throw new SkipException("unsupported in swift"); } - @Override - public void testCopyBlobReplaceMetadata() throws Exception { - throw new SkipException("Swift only supports appending to user metadata, not replacing it"); - } - @Override protected long getMinimumMultipartBlobSize() { return 1;