diff --git a/apis/s3/src/main/java/org/jclouds/s3/binders/BindObjectMetadataToRequest.java b/apis/s3/src/main/java/org/jclouds/s3/binders/BindObjectMetadataToRequest.java index 1f96b7a252..84948e13ed 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/binders/BindObjectMetadataToRequest.java +++ b/apis/s3/src/main/java/org/jclouds/s3/binders/BindObjectMetadataToRequest.java @@ -54,8 +54,8 @@ public class BindObjectMetadataToRequest implements Binder { request = metadataPrefixer.bindToRequest(request, md.getUserMetadata()); Builder headers = ImmutableMultimap.builder(); - if (md.getCacheControl() != null) { - headers.put(HttpHeaders.CACHE_CONTROL, md.getCacheControl()); + if (md.getContentMetadata().getCacheControl() != null) { + headers.put(HttpHeaders.CACHE_CONTROL, md.getContentMetadata().getCacheControl()); } if (md.getContentMetadata().getContentDisposition() != null) { diff --git a/apis/s3/src/main/java/org/jclouds/s3/binders/BindS3ObjectMetadataToRequest.java b/apis/s3/src/main/java/org/jclouds/s3/binders/BindS3ObjectMetadataToRequest.java index f35ff5c7d2..d35a3e65d3 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/binders/BindS3ObjectMetadataToRequest.java +++ b/apis/s3/src/main/java/org/jclouds/s3/binders/BindS3ObjectMetadataToRequest.java @@ -27,8 +27,6 @@ import org.jclouds.http.HttpRequest; import org.jclouds.rest.Binder; import org.jclouds.s3.domain.S3Object; -import com.google.common.net.HttpHeaders; - @Singleton public class BindS3ObjectMetadataToRequest implements Binder { protected final BindMapToHeadersWithPrefix metadataPrefixer; @@ -53,10 +51,6 @@ public class BindS3ObjectMetadataToRequest implements Binder { request = metadataPrefixer.bindToRequest(request, s3Object.getMetadata().getUserMetadata()); - if (s3Object.getMetadata().getCacheControl() != null) { - request = (R) request.toBuilder() - .replaceHeader(HttpHeaders.CACHE_CONTROL, s3Object.getMetadata().getCacheControl()).build(); - } return request; } } diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java index 4cb5ea27e3..fbb481c62c 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java @@ -278,6 +278,11 @@ public class S3BlobStore extends BaseBlobStore { Optional contentMetadata = options.getContentMetadata(); if (contentMetadata.isPresent()) { + String cacheControl = contentMetadata.get().getCacheControl(); + if (cacheControl != null) { + s3Options.cacheControl(cacheControl); + } + String contentDisposition = contentMetadata.get().getContentDisposition(); if (contentDisposition != null) { s3Options.contentDisposition(contentDisposition); diff --git a/apis/s3/src/main/java/org/jclouds/s3/domain/MutableObjectMetadata.java b/apis/s3/src/main/java/org/jclouds/s3/domain/MutableObjectMetadata.java index 5af1025953..8ec9a7100f 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/domain/MutableObjectMetadata.java +++ b/apis/s3/src/main/java/org/jclouds/s3/domain/MutableObjectMetadata.java @@ -59,7 +59,10 @@ public interface MutableObjectMetadata extends ObjectMetadata { * Can be used to specify caching behavior along the request/reply chain. * * @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html?sec14.9. + * + * @deprecated call getContentMetadata().setCacheControl(String) instead */ + @Deprecated void setCacheControl(String cacheControl); @Override diff --git a/apis/s3/src/main/java/org/jclouds/s3/domain/ObjectMetadata.java b/apis/s3/src/main/java/org/jclouds/s3/domain/ObjectMetadata.java index 10e56f5100..d7dd3941e0 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/domain/ObjectMetadata.java +++ b/apis/s3/src/main/java/org/jclouds/s3/domain/ObjectMetadata.java @@ -63,7 +63,10 @@ public interface ObjectMetadata extends Comparable { * Can be used to specify caching behavior along the request/reply chain. * * @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html?sec14.9. + * + * @deprecated call getContentMetadata().getCacheControl() instead */ + @Deprecated String getCacheControl(); Date getLastModified(); diff --git a/apis/s3/src/main/java/org/jclouds/s3/domain/ObjectMetadataBuilder.java b/apis/s3/src/main/java/org/jclouds/s3/domain/ObjectMetadataBuilder.java index ba6c938e09..e142ca7bd8 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/domain/ObjectMetadataBuilder.java +++ b/apis/s3/src/main/java/org/jclouds/s3/domain/ObjectMetadataBuilder.java @@ -42,7 +42,6 @@ public class ObjectMetadataBuilder { private String bucket; private URI uri; private StorageClass storageClass = StorageClass.STANDARD; - private String cacheControl; private Date lastModified; private String eTag; private CanonicalUser owner; @@ -84,7 +83,7 @@ public class ObjectMetadataBuilder { } public ObjectMetadataBuilder cacheControl(String cacheControl) { - this.cacheControl = cacheControl; + contentMetadataBuilder.cacheControl(cacheControl); return this; } @@ -130,7 +129,6 @@ public class ObjectMetadataBuilder { public ObjectMetadata build() { MutableObjectMetadataImpl toReturn = new MutableObjectMetadataImpl(); toReturn.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(contentMetadataBuilder.build())); - toReturn.setCacheControl(cacheControl); toReturn.setKey(key); toReturn.setBucket(bucket); toReturn.setUri(uri); diff --git a/apis/s3/src/main/java/org/jclouds/s3/domain/internal/MutableObjectMetadataImpl.java b/apis/s3/src/main/java/org/jclouds/s3/domain/internal/MutableObjectMetadataImpl.java index e2692cb521..6fc329f5b6 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/domain/internal/MutableObjectMetadataImpl.java +++ b/apis/s3/src/main/java/org/jclouds/s3/domain/internal/MutableObjectMetadataImpl.java @@ -108,11 +108,12 @@ public class MutableObjectMetadataImpl implements MutableObjectMetadata { } /** - *{@inheritDoc} + * @deprecated call getContentMetadata().getCacheControl() instead */ + @Deprecated @Override public String getCacheControl() { - return cacheControl; + return contentMetadata.getCacheControl(); } /** @@ -148,11 +149,12 @@ public class MutableObjectMetadataImpl implements MutableObjectMetadata { } /** - *{@inheritDoc} + * @deprecated call getContentMetadata().setCacheControl(String) instead */ + @Deprecated @Override public void setCacheControl(String cacheControl) { - this.cacheControl = cacheControl; + contentMetadata.setCacheControl(cacheControl); } /** diff --git a/apis/s3/src/main/java/org/jclouds/s3/options/CopyObjectOptions.java b/apis/s3/src/main/java/org/jclouds/s3/options/CopyObjectOptions.java index 2370bf549e..374278d5d8 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/options/CopyObjectOptions.java +++ b/apis/s3/src/main/java/org/jclouds/s3/options/CopyObjectOptions.java @@ -72,6 +72,7 @@ import com.google.common.net.HttpHeaders; public class CopyObjectOptions extends BaseHttpRequestOptions { private static final DateService dateService = new SimpleDateFormatDateService(); public static final CopyObjectOptions NONE = new CopyObjectOptions(); + private String cacheControl; private String contentDisposition; private String contentEncoding; private String contentLanguage; @@ -255,6 +256,10 @@ public class CopyObjectOptions extends BaseHttpRequestOptions { returnVal.put(entry.getKey().replace(DEFAULT_AMAZON_HEADERTAG, headerTag), entry.getValue()); } boolean replace = false; + if (cacheControl != null) { + returnVal.put(HttpHeaders.CACHE_CONTROL, cacheControl); + replace = true; + } if (contentDisposition != null) { returnVal.put(HttpHeaders.CONTENT_DISPOSITION, contentDisposition); replace = true; @@ -284,6 +289,11 @@ public class CopyObjectOptions extends BaseHttpRequestOptions { return returnVal.build(); } + public CopyObjectOptions cacheControl(String cacheControl) { + this.cacheControl = checkNotNull(cacheControl, "cacheControl"); + return this; + } + public CopyObjectOptions contentDisposition(String contentDisposition) { this.contentDisposition = checkNotNull(contentDisposition, "contentDisposition"); return this; @@ -354,6 +364,11 @@ public class CopyObjectOptions extends BaseHttpRequestOptions { return options.ifSourceETagDoesntMatch(eTag); } + public static CopyObjectOptions cacheControl(String cacheControl) { + CopyObjectOptions options = new CopyObjectOptions(); + return options.cacheControl(cacheControl); + } + public static CopyObjectOptions contentDisposition(String contentDisposition) { CopyObjectOptions options = new CopyObjectOptions(); return options.contentDisposition(contentDisposition); diff --git a/apis/s3/src/test/java/org/jclouds/s3/binders/BindS3ObjectMetadataToRequestTest.java b/apis/s3/src/test/java/org/jclouds/s3/binders/BindS3ObjectMetadataToRequestTest.java index b65c2b9c10..229f4a18e4 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/binders/BindS3ObjectMetadataToRequestTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/binders/BindS3ObjectMetadataToRequestTest.java @@ -62,7 +62,6 @@ public class BindS3ObjectMetadataToRequestTest extends BaseS3ClientTest