org.jclouds.s3.options
Class CopyObjectOptions

java.lang.Object
  extended by org.jclouds.http.options.BaseHttpRequestOptions
      extended by org.jclouds.s3.options.CopyObjectOptions
All Implemented Interfaces:
HttpRequestOptions

public class CopyObjectOptions
extends BaseHttpRequestOptions

Contains options supported in the REST API for the COPY object operation.

Usage

The recommended way to instantiate a CopyObjectOptions object is to statically import CopyObjectOptions.Builder.* and invoke a static creation method followed by an instance mutator (if needed):

import static org.jclouds.s3.commands.options.CopyObjectOptions.Builder.*

S3Client connection = // get connection

Multimap metadata = LinkedHashMultimap.create(); metadata.put("x-amz-meta-adrian", "foo");

// this will copy the object, provided it wasn't modified since yesterday. // it will not use metadata from the source, and instead use what we pass in. Future object = connection.copyObject("sourceBucket", "objectName", "destinationBucket", "destinationName", overrideMetadataWith(meta). ifSourceModifiedSince(new Date().minusDays(1)) );

Author:
Adrian Cole
See Also:

Nested Class Summary
static class CopyObjectOptions.Builder
           
 
Field Summary
static CopyObjectOptions NONE
           
 
Fields inherited from class org.jclouds.http.options.BaseHttpRequestOptions
formParameters, headers, matrixParameters, pathSuffix, payload, queryParameters
 
Constructor Summary
CopyObjectOptions()
           
 
Method Summary
 com.google.common.collect.Multimap<String,String> buildRequestHeaders()
          Builds headers representing options.
 CannedAccessPolicy getAcl()
           
 String getIfMatch()
          For use in the request header: x-amz-copy-source-if-match

Copies the object if its payload tag (ETag) matches the specified tag; otherwise return a 412 (precondition failed).

 String getIfModifiedSince()
          For use in the header x-amz-copy-source-if-unmodified-since

Copies the object if it hasn't been modified since the specified time; otherwise returns a 412 (precondition failed).

 String getIfNoneMatch()
          For use in the request header: x-amz-copy-source-if-none-match

Copies the object if its payload tag (ETag) is different than the specified Etag; otherwise returns a 412 (failed condition).

 String getIfUnmodifiedSince()
          For use in the header x-amz-copy-source-if-modified-since

Copies the object if it has been modified since the specified time; otherwise returns a 412 (failed condition).

 Map<String,String> getMetadata()
          When not null, contains the header [x-amz-copy-source-if-unmodified-since] -> [REPLACE] and metadata headers passed in from the users.
 CopyObjectOptions ifSourceETagDoesntMatch(String eTag)
          The object should not have a eTag hash corresponding with the parameter eTag.
 CopyObjectOptions ifSourceETagMatches(String eTag)
          The object's eTag hash should match the parameter eTag.
 CopyObjectOptions ifSourceModifiedSince(Date ifModifiedSince)
          Only return the object if it has changed since this time.
 CopyObjectOptions ifSourceUnmodifiedSince(Date ifUnmodifiedSince)
          Only return the object if it hasn't changed since this time.
 CopyObjectOptions overrideAcl(CannedAccessPolicy acl)
          Override the default ACL (private) with the specified one.
 CopyObjectOptions overrideMetadataWith(Map<String,String> metadata)
          Use the provided metadata instead of what is on the source object.
 void setHeaderTag(String headerTag)
           
 void setMetadataPrefix(String metadataPrefix)
           
 
Methods inherited from class org.jclouds.http.options.BaseHttpRequestOptions
buildFormParameters, buildMatrixParameters, buildPathSuffix, buildQueryParameters, buildStringPayload, equals, getFirstFormOrNull, getFirstHeaderOrNull, getFirstMatrixOrNull, getFirstQueryOrNull, hashCode, replaceHeader, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final CopyObjectOptions NONE
Constructor Detail

CopyObjectOptions

public CopyObjectOptions()
Method Detail

setMetadataPrefix

@Inject
public void setMetadataPrefix(@Named(value="jclouds.blobstore.metaprefix")
                                     String metadataPrefix)

setHeaderTag

@Inject
public void setHeaderTag(@Named(value="jclouds.aws.header.tag")
                                String headerTag)

overrideAcl

public CopyObjectOptions overrideAcl(CannedAccessPolicy acl)
Override the default ACL (private) with the specified one.

See Also:
CannedAccessPolicy

getAcl

public CannedAccessPolicy getAcl()
See Also:
overrideAcl(CannedAccessPolicy)

getIfModifiedSince

public String getIfModifiedSince()
For use in the header x-amz-copy-source-if-unmodified-since

Copies the object if it hasn't been modified since the specified time; otherwise returns a 412 (precondition failed).

This header can be used with x-amz-copy-source-if-match, but cannot be used with other conditional copy headers.

Returns:
valid HTTP date
See Also:
, ifSourceModifiedSince(Date)

getIfUnmodifiedSince

public String getIfUnmodifiedSince()
For use in the header x-amz-copy-source-if-modified-since

Copies the object if it has been modified since the specified time; otherwise returns a 412 (failed condition).

This header can be used with x-amz-copy-source-if-none-match, but cannot be used with other conditional copy headers.

Returns:
valid HTTP date
See Also:
, ifSourceUnmodifiedSince(Date)

getIfMatch

public String getIfMatch()
For use in the request header: x-amz-copy-source-if-match

Copies the object if its payload tag (ETag) matches the specified tag; otherwise return a 412 (precondition failed).

This header can be used with x-amz-copy-source-if-unmodified-since, but cannot be used with other conditional copy headers.

See Also:
ifSourceETagMatches(String)

getIfNoneMatch

public String getIfNoneMatch()
For use in the request header: x-amz-copy-source-if-none-match

Copies the object if its payload tag (ETag) is different than the specified Etag; otherwise returns a 412 (failed condition).

This header can be used with x-amz-copy-source-if-modified-since, but cannot be used with other conditional copy headers.

See Also:
ifSourceETagDoesntMatch(String)

getMetadata

public Map<String,String> getMetadata()
When not null, contains the header [x-amz-copy-source-if-unmodified-since] -> [REPLACE] and metadata headers passed in from the users.

See Also:
#overrideMetadataWith(Multimap)

ifSourceModifiedSince

public CopyObjectOptions ifSourceModifiedSince(Date ifModifiedSince)
Only return the object if it has changed since this time.

Not compatible with ifSourceETagMatches(String) or ifSourceUnmodifiedSince(Date)


ifSourceUnmodifiedSince

public CopyObjectOptions ifSourceUnmodifiedSince(Date ifUnmodifiedSince)
Only return the object if it hasn't changed since this time.

Not compatible with ifSourceETagDoesntMatch(String) or ifSourceModifiedSince(Date)


ifSourceETagMatches

public CopyObjectOptions ifSourceETagMatches(String eTag)
                                      throws UnsupportedEncodingException
The object's eTag hash should match the parameter eTag.

Not compatible with ifSourceETagDoesntMatch(String) or ifSourceModifiedSince(Date)

Parameters:
eTag - hash representing the payload
Throws:
UnsupportedEncodingException

ifSourceETagDoesntMatch

public CopyObjectOptions ifSourceETagDoesntMatch(String eTag)
                                          throws UnsupportedEncodingException
The object should not have a eTag hash corresponding with the parameter eTag.

Not compatible with ifSourceETagMatches(String) or ifSourceUnmodifiedSince(Date)

Parameters:
eTag - hash representing the payload
Throws:
UnsupportedEncodingException - if there was a problem converting this into an S3 eTag string

buildRequestHeaders

public com.google.common.collect.Multimap<String,String> buildRequestHeaders()
Description copied from class: BaseHttpRequestOptions
Builds headers representing options.

Specified by:
buildRequestHeaders in interface HttpRequestOptions
Overrides:
buildRequestHeaders in class BaseHttpRequestOptions
Returns:
multimap that may contain headers.

overrideMetadataWith

public CopyObjectOptions overrideMetadataWith(Map<String,String> metadata)
Use the provided metadata instead of what is on the source object.



Copyright © 2009-2011 jclouds. All Rights Reserved.