public abstract class RestStorageService extends StorageService implements AWSRequestAuthorizer
This class uses properties obtained through Jets3tProperties
. For more information on
these properties please refer to
JetS3t Configuration
Modifier and Type | Class and Description |
---|---|
protected static class |
RestStorageService.HTTP_METHOD |
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.httpclient.HttpConnectionManager |
connectionManager |
protected org.apache.commons.httpclient.auth.CredentialsProvider |
credentialsProvider |
protected java.lang.String |
defaultStorageClass |
protected org.apache.commons.httpclient.HttpClient |
httpClient |
BUCKET_STATUS__ALREADY_CLAIMED, BUCKET_STATUS__DOES_NOT_EXIST, BUCKET_STATUS__MY_BUCKET, credentials, jets3tProperties, timeOffset
Constructor and Description |
---|
RestStorageService(ProviderCredentials credentials)
Constructs the service and initialises the properties.
|
RestStorageService(ProviderCredentials credentials,
java.lang.String invokingApplicationDescription,
org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider)
Constructs the service and initialises the properties.
|
RestStorageService(ProviderCredentials credentials,
java.lang.String invokingApplicationDescription,
org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider,
Jets3tProperties jets3tProperties)
Constructs the service and initialises the properties.
|
RestStorageService(ProviderCredentials credentials,
java.lang.String invokingApplicationDescription,
org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider,
Jets3tProperties jets3tProperties,
org.apache.commons.httpclient.HostConfiguration hostConfig)
Constructs the service and initialises the properties.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addMetadataToHeaders(org.apache.commons.httpclient.HttpMethodBase httpMethod,
java.util.Map<java.lang.String,java.lang.Object> metadata)
Adds all valid metadata name and value pairs as HTTP headers to the given HTTP method.
|
protected void |
addRequestHeadersToConnection(org.apache.commons.httpclient.HttpMethodBase httpMethod,
java.util.Map<java.lang.String,java.lang.Object> requestHeaders)
Adds the provided request headers to the connection.
|
protected java.lang.String |
addRequestParametersToUrlPath(java.lang.String urlPath,
java.util.Map<java.lang.String,java.lang.String> requestParameters)
Adds all the provided request parameters to a URL in GET request format.
|
void |
authorizeHttpRequest(org.apache.commons.httpclient.HttpMethod httpMethod)
Authorizes an HTTP request by signing it.
|
int |
checkBucketStatus(java.lang.String bucketName)
Find out the status of a bucket with the given name.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
copyObjectImpl(java.lang.String sourceBucketName,
java.lang.String sourceObjectKey,
java.lang.String destinationBucketName,
java.lang.String destinationObjectKey,
AccessControlList acl,
java.util.Map<java.lang.String,java.lang.Object> destinationMetadata,
java.util.Calendar ifModifiedSince,
java.util.Calendar ifUnmodifiedSince,
java.lang.String[] ifMatchTags,
java.lang.String[] ifNoneMatchTags,
java.lang.String versionId,
java.lang.String destinationObjectStorageClass)
Copy an object within your account.
|
protected StorageBucket |
createBucketImpl(java.lang.String bucketName,
java.lang.String location,
AccessControlList acl)
Creates a bucket.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
createObjectImpl(java.lang.String bucketName,
java.lang.String objectKey,
java.lang.String contentType,
org.apache.commons.httpclient.methods.RequestEntity requestEntity,
java.util.Map<java.lang.String,java.lang.Object> metadata,
java.util.Map<java.lang.String,java.lang.String> requestParams,
AccessControlList acl,
java.lang.String storageClass) |
protected void |
deleteBucketImpl(java.lang.String bucketName) |
protected void |
deleteObjectImpl(java.lang.String bucketName,
java.lang.String objectKey,
java.lang.String versionId,
java.lang.String multiFactorSerialNumber,
java.lang.String multiFactorAuthCode) |
void |
deleteObjectWithSignedUrl(java.lang.String signedDeleteUrl)
Deletes an object using a pre-signed DELETE URL generated for that object.
|
protected StorageOwner |
getAccountOwnerImpl() |
protected AccessControlList |
getBucketAclImpl(java.lang.String bucketName) |
org.apache.commons.httpclient.auth.CredentialsProvider |
getCredentialsProvider() |
org.apache.commons.httpclient.HttpClient |
getHttpClient() |
org.apache.commons.httpclient.HttpConnectionManager |
getHttpConnectionManager() |
protected AccessControlList |
getObjectAclImpl(java.lang.String bucketName,
java.lang.String objectKey) |
protected AccessControlList |
getObjectAclImpl(java.lang.String bucketName,
java.lang.String objectKey,
java.lang.String versionId) |
AccessControlList |
getObjectAclWithSignedUrl(java.lang.String signedAclUrl)
Gets an object's ACL details using a pre-signed GET URL generated for that object.
|
protected StorageObject |
getObjectDetailsImpl(java.lang.String bucketName,
java.lang.String objectKey,
java.util.Calendar ifModifiedSince,
java.util.Calendar ifUnmodifiedSince,
java.lang.String[] ifMatchTags,
java.lang.String[] ifNoneMatchTags,
java.lang.String versionId) |
S3Object |
getObjectDetailsWithSignedUrl(java.lang.String signedHeadUrl)
Gets an object's details using a pre-signed HEAD URL generated for that object.
|
protected StorageObject |
getObjectImpl(java.lang.String bucketName,
java.lang.String objectKey,
java.util.Calendar ifModifiedSince,
java.util.Calendar ifUnmodifiedSince,
java.lang.String[] ifMatchTags,
java.lang.String[] ifNoneMatchTags,
java.lang.Long byteRangeStart,
java.lang.Long byteRangeEnd,
java.lang.String versionId) |
S3Object |
getObjectWithSignedUrl(java.lang.String signedGetUrl)
Gets an object using a pre-signed GET URL generated for that object.
|
protected HttpClientAndConnectionManager |
initHttpConnection(org.apache.commons.httpclient.HostConfiguration hostConfig)
Initialise HttpClient and HttpConnectionManager objects with the configuration settings
appropriate for communicating with S3.
|
boolean |
isBucketAccessible(java.lang.String bucketName)
Indicates whether a bucket exists and is accessible to a service user.
|
protected abstract boolean |
isTargettingGoogleStorageService() |
protected boolean |
isXmlContentType(java.lang.String contentType) |
protected StorageBucket[] |
listAllBucketsImpl() |
protected StorageObjectsChunk |
listObjectsChunkedImpl(java.lang.String bucketName,
java.lang.String prefix,
java.lang.String delimiter,
long maxListingLength,
java.lang.String priorLastKey,
boolean completeListing)
Lists objects in a bucket up to the maximum listing length specified.
|
protected StorageObject[] |
listObjectsImpl(java.lang.String bucketName,
java.lang.String prefix,
java.lang.String delimiter,
long maxListingLength)
Lists objects in a bucket.
|
protected StorageObjectsChunk |
listObjectsInternal(java.lang.String bucketName,
java.lang.String prefix,
java.lang.String delimiter,
long maxListingLength,
boolean automaticallyMergeChunks,
java.lang.String priorLastKey,
java.lang.String priorLastVersion) |
protected void |
performRequest(org.apache.commons.httpclient.HttpMethodBase httpMethod,
int[] expectedResponseCodes)
Performs an HTTP/S request by invoking the provided HttpMethod object.
|
protected org.apache.commons.httpclient.HttpMethodBase |
performRestDelete(java.lang.String bucketName,
java.lang.String objectKey,
java.util.Map<java.lang.String,java.lang.String> requestParameters,
java.lang.String multiFactorSerialNumber,
java.lang.String multiFactorAuthCode)
Performs an HTTP DELETE request using the
performRequest(org.apache.commons.httpclient.HttpMethodBase, int[]) method. |
protected org.apache.commons.httpclient.HttpMethodBase |
performRestGet(java.lang.String bucketName,
java.lang.String objectKey,
java.util.Map<java.lang.String,java.lang.String> requestParameters,
java.util.Map<java.lang.String,java.lang.Object> requestHeaders)
Performs an HTTP GET request using the
performRequest(org.apache.commons.httpclient.HttpMethodBase, int[]) method. |
protected org.apache.commons.httpclient.HttpMethodBase |
performRestHead(java.lang.String bucketName,
java.lang.String objectKey,
java.util.Map<java.lang.String,java.lang.String> requestParameters,
java.util.Map<java.lang.String,java.lang.Object> requestHeaders)
Performs an HTTP HEAD request using the
performRequest(org.apache.commons.httpclient.HttpMethodBase, int[]) method. |
protected org.apache.commons.httpclient.methods.PostMethod |
performRestPost(java.lang.String bucketName,
java.lang.String objectKey,
java.util.Map<java.lang.String,java.lang.Object> metadata,
java.util.Map<java.lang.String,java.lang.String> requestParameters,
org.apache.commons.httpclient.methods.RequestEntity requestEntity,
boolean autoRelease)
Performs an HTTP POST request using the
performRequest(org.apache.commons.httpclient.HttpMethodBase, int[]) method. |
protected org.apache.commons.httpclient.HttpMethodBase |
performRestPostWithXmlBuilder(java.lang.String bucketName,
java.lang.String objectKey,
java.util.Map<java.lang.String,java.lang.Object> metadata,
java.util.Map<java.lang.String,java.lang.String> requestParameters,
com.jamesmurty.utils.XMLBuilder builder) |
protected HttpMethodAndByteCount |
performRestPut(java.lang.String bucketName,
java.lang.String objectKey,
java.util.Map<java.lang.String,java.lang.Object> metadata,
java.util.Map<java.lang.String,java.lang.String> requestParameters,
org.apache.commons.httpclient.methods.RequestEntity requestEntity,
boolean autoRelease)
Performs an HTTP PUT request using the
performRequest(org.apache.commons.httpclient.HttpMethodBase, int[]) method. |
protected HttpMethodAndByteCount |
performRestPutWithXmlBuilder(java.lang.String bucketName,
java.lang.String objectKey,
java.util.Map<java.lang.String,java.lang.Object> metadata,
java.util.Map<java.lang.String,java.lang.String> requestParameters,
com.jamesmurty.utils.XMLBuilder builder) |
protected boolean |
prepareCannedAcl(java.util.Map<java.lang.String,java.lang.Object> metadata,
AccessControlList acl)
Prepares the metadata with a canned representation of the given ACL, if
an ACL is provided and can be represented with a HTTP header.
|
protected void |
prepareStorageClass(java.util.Map<java.lang.String,java.lang.Object> metadata,
java.lang.String storageClass,
java.lang.String objectKey) |
protected void |
putAclImpl(java.lang.String bucketName,
java.lang.String objectKey,
AccessControlList acl,
java.lang.String versionId) |
protected void |
putBucketAclImpl(java.lang.String bucketName,
AccessControlList acl) |
protected void |
putObjectAclImpl(java.lang.String bucketName,
java.lang.String objectKey,
AccessControlList acl,
java.lang.String versionId) |
void |
putObjectAclWithSignedUrl(java.lang.String signedAclUrl,
AccessControlList acl)
Sets an object's ACL details using a pre-signed PUT URL generated for that object.
|
protected StorageObject |
putObjectImpl(java.lang.String bucketName,
StorageObject object)
Beware of high memory requirements when creating large S3 objects when the Content-Length
is not set in the object.
|
protected void |
putObjectWithRequestEntityImpl(java.lang.String bucketName,
StorageObject object,
org.apache.commons.httpclient.methods.RequestEntity requestEntity,
java.util.Map<java.lang.String,java.lang.String> requestParams) |
S3Object |
putObjectWithSignedUrl(java.lang.String signedPutUrl,
S3Object object)
Puts an object using a pre-signed PUT URL generated for that object.
|
void |
setCredentialsProvider(org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider)
Sets the credentials provider this service will use to authenticate itself.
|
void |
setHttpClient(org.apache.commons.httpclient.HttpClient httpClient)
Replaces the service's default HTTP client.
|
void |
setHttpConnectionManager(org.apache.commons.httpclient.HttpConnectionManager httpConnectionManager)
Replaces the service's default HTTP connection manager.
|
protected org.apache.commons.httpclient.HttpMethodBase |
setupConnection(RestStorageService.HTTP_METHOD method,
java.lang.String bucketName,
java.lang.String objectKey,
java.util.Map<java.lang.String,java.lang.String> requestParameters)
Creates an
HttpMethod object to handle a particular connection method. |
protected void |
shutdownImpl()
Shut down all connections managed by the underlying HttpConnectionManager.
|
protected void |
verifyExpectedAndActualETagValues(java.lang.String expectedETag,
StorageObject uploadedObject)
Compares the expected and actual ETag value for an uploaded object, and throws an
ServiceException if these values do not match.
|
assertAuthenticatedConnection, assertValidBucket, assertValidObject, assertValidObject, copyObject, copyObject, createBucket, createBucket, deleteBucket, deleteBucket, deleteObject, getAccountOwner, getBucket, getBucketAcl, getCurrentTimeWithOffset, getDisableDnsBuckets, getEnableStorageClasses, getEndpoint, getHttpPort, getHttpsOnly, getHttpsPort, getInternalErrorRetryMax, getInvokingApplicationDescription, getJetS3tProperties, getObject, getObject, getObjectAcl, getObjectDetails, getObjectDetails, getOrCreateBucket, getProviderCredentials, getResourceParameterNames, getRestHeaderPrefix, getRestMetadataPrefix, getSignatureIdentifier, getVirtualPath, getXmlResponseSaxParser, isAuthenticatedConnection, isHttpsOnly, isObjectInBucket, isShutdown, listAllBuckets, listObjects, listObjects, listObjects, listObjectsChunked, listObjectsChunked, moveObject, newBucket, newObject, putBucketAcl, putBucketAcl, putObject, putObjectAcl, putObjectAcl, renameMetadataKeys, renameObject, shutdown, sleepOnInternalError, updateObjectMetadata
protected org.apache.commons.httpclient.HttpClient httpClient
protected org.apache.commons.httpclient.HttpConnectionManager connectionManager
protected org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider
protected java.lang.String defaultStorageClass
public RestStorageService(ProviderCredentials credentials)
credentials
- the user credentials to use when communicating with S3, may be null in which case the
communication is done as an anonymous user.public RestStorageService(ProviderCredentials credentials, java.lang.String invokingApplicationDescription, org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider)
credentials
- the S3 user credentials to use when communicating with S3, may be null in which case the
communication is done as an anonymous user.invokingApplicationDescription
- a short description of the application using the service, suitable for inclusion in a
user agent string for REST/HTTP requests. Ideally this would include the application's
version number, for example: Cockpit/0.7.3
or My App Name/1.0
credentialsProvider
- an implementation of the HttpClient CredentialsProvider interface, to provide a means for
prompting for credentials when necessary.public RestStorageService(ProviderCredentials credentials, java.lang.String invokingApplicationDescription, org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider, Jets3tProperties jets3tProperties)
credentials
- the S3 user credentials to use when communicating with S3, may be null in which case the
communication is done as an anonymous user.invokingApplicationDescription
- a short description of the application using the service, suitable for inclusion in a
user agent string for REST/HTTP requests. Ideally this would include the application's
version number, for example: Cockpit/0.7.3
or My App Name/1.0
credentialsProvider
- an implementation of the HttpClient CredentialsProvider interface, to provide a means for
prompting for credentials when necessary.jets3tProperties
- JetS3t properties that will be applied within this service.public RestStorageService(ProviderCredentials credentials, java.lang.String invokingApplicationDescription, org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider, Jets3tProperties jets3tProperties, org.apache.commons.httpclient.HostConfiguration hostConfig)
credentials
- the S3 user credentials to use when communicating with S3, may be null in which case the
communication is done as an anonymous user.invokingApplicationDescription
- a short description of the application using the service, suitable for inclusion in a
user agent string for REST/HTTP requests. Ideally this would include the application's
version number, for example: Cockpit/0.7.3
or My App Name/1.0
credentialsProvider
- an implementation of the HttpClient CredentialsProvider interface, to provide a means for
prompting for credentials when necessary.jets3tProperties
- JetS3t properties that will be applied within this service.hostConfig
- Custom HTTP host configuration; e.g to register a custom Protocol Socket Factoryprotected abstract boolean isTargettingGoogleStorageService()
protected void shutdownImpl() throws ServiceException
shutdownImpl
in class StorageService
ServiceException
protected HttpClientAndConnectionManager initHttpConnection(org.apache.commons.httpclient.HostConfiguration hostConfig)
RestUtils.initHttpConnection(org.jets3t.service.impl.rest.httpclient.AWSRequestAuthorizer,
org.apache.commons.httpclient.HostConfiguration, org.jets3t.service.Jets3tProperties, String, org.apache.commons.httpclient.auth.CredentialsProvider)
.
To alter the low-level behaviour of the HttpClient library, override this method in a subclass and apply your own settings before returning the objects.
hostConfig
- Custom HTTP host configuration; e.g to register a custom Protocol Socket Factorypublic org.apache.commons.httpclient.HttpConnectionManager getHttpConnectionManager()
public void setHttpConnectionManager(org.apache.commons.httpclient.HttpConnectionManager httpConnectionManager)
httpConnectionManager
- the connection manager that will replace the default manager created by
the class constructor.public org.apache.commons.httpclient.HttpClient getHttpClient()
public void setHttpClient(org.apache.commons.httpclient.HttpClient httpClient)
httpClient
- the client that will replace the default client created by
the class constructor.public org.apache.commons.httpclient.auth.CredentialsProvider getCredentialsProvider()
public void setCredentialsProvider(org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider)
initHttpConnection(org.apache.commons.httpclient.HostConfiguration)
method
is called.credentialsProvider
- protected boolean isXmlContentType(java.lang.String contentType)
contentType
- protected void performRequest(org.apache.commons.httpclient.HttpMethodBase httpMethod, int[] expectedResponseCodes) throws ServiceException
httpMethod
- the object containing a request target and all other information necessary to perform the
requestexpectedResponseCodes
- the HTTP response code(s) that indicates a successful request. If the response code received
does not match this value an error must have occurred, so an exception is thrown.ServiceException
- all exceptions are wrapped in a ServiceException. Depending on the kind of error that
occurred, this exception may contain additional error information available from an XML
error response document.public void authorizeHttpRequest(org.apache.commons.httpclient.HttpMethod httpMethod) throws java.lang.Exception
HttpMethod
object as an Authorization header.authorizeHttpRequest
in interface AWSRequestAuthorizer
httpMethod
- the request objectServiceException
java.lang.Exception
protected java.lang.String addRequestParametersToUrlPath(java.lang.String urlPath, java.util.Map<java.lang.String,java.lang.String> requestParameters) throws ServiceException
urlPath
- the target URLrequestParameters
- the parameters to add to the URL as GET request params.ServiceException
protected void addRequestHeadersToConnection(org.apache.commons.httpclient.HttpMethodBase httpMethod, java.util.Map<java.lang.String,java.lang.Object> requestHeaders)
httpMethod
- the connection objectrequestHeaders
- the request headers to add as name/value pairs.protected void addMetadataToHeaders(org.apache.commons.httpclient.HttpMethodBase httpMethod, java.util.Map<java.lang.String,java.lang.Object> metadata) throws ServiceException
The metadata values are verified to ensure that keys contain only ASCII characters,
and that items are not accidentally duplicated due to use of different capitalization.
If either of these verification tests fails, an ServiceException
is thrown.
httpMethod
- metadata
- ServiceException
protected void verifyExpectedAndActualETagValues(java.lang.String expectedETag, StorageObject uploadedObject) throws ServiceException
expectedETag
- uploadedObject
- ServiceException
protected org.apache.commons.httpclient.HttpMethodBase performRestHead(java.lang.String bucketName, java.lang.String objectKey, java.util.Map<java.lang.String,java.lang.String> requestParameters, java.util.Map<java.lang.String,java.lang.Object> requestHeaders) throws ServiceException
performRequest(org.apache.commons.httpclient.HttpMethodBase, int[])
method.bucketName
- the bucket's nameobjectKey
- the object's key name, may be null if the operation is on a bucket only.requestParameters
- parameters to add to the request URL as GET paramsrequestHeaders
- headers to add to the requestServiceException
protected org.apache.commons.httpclient.HttpMethodBase performRestGet(java.lang.String bucketName, java.lang.String objectKey, java.util.Map<java.lang.String,java.lang.String> requestParameters, java.util.Map<java.lang.String,java.lang.Object> requestHeaders) throws ServiceException
performRequest(org.apache.commons.httpclient.HttpMethodBase, int[])
method.bucketName
- the bucket's nameobjectKey
- the object's key name, may be null if the operation is on a bucket only.requestParameters
- parameters to add to the request URL as GET paramsrequestHeaders
- headers to add to the requestServiceException
protected HttpMethodAndByteCount performRestPut(java.lang.String bucketName, java.lang.String objectKey, java.util.Map<java.lang.String,java.lang.Object> metadata, java.util.Map<java.lang.String,java.lang.String> requestParameters, org.apache.commons.httpclient.methods.RequestEntity requestEntity, boolean autoRelease) throws ServiceException
performRequest(org.apache.commons.httpclient.HttpMethodBase, int[])
method.bucketName
- the name of the bucket the object will be stored in.objectKey
- the key (name) of the object to be stored.metadata
- map of name/value pairs to add as metadata to any S3 objects created.requestParameters
- parameters to add to the request URL as GET paramsrequestEntity
- an HttpClient object that encapsulates the object and data contents that will be
uploaded. This object supports the resending of object data, when possible.autoRelease
- if true, the HTTP Method object will be released after the request has
completed and the connection will be closed. If false, the object will
not be released and the caller must take responsibility for doing this.ServiceException
protected org.apache.commons.httpclient.methods.PostMethod performRestPost(java.lang.String bucketName, java.lang.String objectKey, java.util.Map<java.lang.String,java.lang.Object> metadata, java.util.Map<java.lang.String,java.lang.String> requestParameters, org.apache.commons.httpclient.methods.RequestEntity requestEntity, boolean autoRelease) throws ServiceException
performRequest(org.apache.commons.httpclient.HttpMethodBase, int[])
method.bucketName
- the name of the bucket the object will be stored in.objectKey
- the key (name) of the object to be stored.metadata
- map of name/value pairs to add as metadata to any S3 objects created.requestParameters
- parameters to add to the request URL as GET paramsrequestEntity
- an HttpClient object that encapsulates the object and data contents that will be
uploaded. This object supports the re-sending of object data, when possible.autoRelease
- if true, the HTTP Method object will be released after the request has
completed and the connection will be closed. If false, the object will
not be released and the caller must take responsibility for doing this.ServiceException
protected org.apache.commons.httpclient.HttpMethodBase performRestDelete(java.lang.String bucketName, java.lang.String objectKey, java.util.Map<java.lang.String,java.lang.String> requestParameters, java.lang.String multiFactorSerialNumber, java.lang.String multiFactorAuthCode) throws ServiceException
performRequest(org.apache.commons.httpclient.HttpMethodBase, int[])
method.bucketName
- the bucket's nameobjectKey
- the object's key name, may be null if the operation is on a bucket only.ServiceException
protected HttpMethodAndByteCount performRestPutWithXmlBuilder(java.lang.String bucketName, java.lang.String objectKey, java.util.Map<java.lang.String,java.lang.Object> metadata, java.util.Map<java.lang.String,java.lang.String> requestParameters, com.jamesmurty.utils.XMLBuilder builder) throws ServiceException
ServiceException
protected org.apache.commons.httpclient.HttpMethodBase performRestPostWithXmlBuilder(java.lang.String bucketName, java.lang.String objectKey, java.util.Map<java.lang.String,java.lang.Object> metadata, java.util.Map<java.lang.String,java.lang.String> requestParameters, com.jamesmurty.utils.XMLBuilder builder) throws ServiceException
ServiceException
protected org.apache.commons.httpclient.HttpMethodBase setupConnection(RestStorageService.HTTP_METHOD method, java.lang.String bucketName, java.lang.String objectKey, java.util.Map<java.lang.String,java.lang.String> requestParameters) throws ServiceException
HttpMethod
object to handle a particular connection method.method
- the HTTP method/connection-type to use, must be one of: PUT, HEAD, GET, DELETEbucketName
- the bucket's nameobjectKey
- the object's key name, may be null if the operation is on a bucket only.ServiceException
public boolean isBucketAccessible(java.lang.String bucketName) throws ServiceException
StorageService
Caution: This check started to cause issues in situations where you need to
immediately create a bucket when it does not exist. To conditionally create a bucket,
use the StorageService.getOrCreateBucket(String)
method instead.
This method can be performed by anonymous services.
Implementation notes
This method can be implemented by attempting to list the objects in a bucket. If the listing is successful return true, if the listing failed for any reason return false.
isBucketAccessible
in class StorageService
bucketName
- the bucket to check.ServiceException
public int checkBucketStatus(java.lang.String bucketName) throws ServiceException
StorageService
Caveats:
StorageService.BUCKET_STATUS__MY_BUCKET
.S3 can act strangely when you use this method in some circumstances. If you check the status of a bucket and find that it does not exist, then create the bucket, the service will continue to tell you the bucket does not exists for up to 30 seconds. This problem has something to do with connection caching (I think).
This S3 quirk makes it a bad idea to use this method to check for a bucket's
existence before creating that bucket. Use the StorageService.getOrCreateBucket(String)
method for this purpose instead.
checkBucketStatus
in class StorageService
StorageService.BUCKET_STATUS__MY_BUCKET
if you already own the bucket,
StorageService.BUCKET_STATUS__DOES_NOT_EXIST
if the bucket does not yet exist, or
StorageService.BUCKET_STATUS__ALREADY_CLAIMED
if someone else has
already created a bucket with the given name.ServiceException
protected StorageBucket[] listAllBucketsImpl() throws ServiceException
listAllBucketsImpl
in class StorageService
ServiceException
protected StorageOwner getAccountOwnerImpl() throws ServiceException
getAccountOwnerImpl
in class StorageService
ServiceException
protected StorageObject[] listObjectsImpl(java.lang.String bucketName, java.lang.String prefix, java.lang.String delimiter, long maxListingLength) throws ServiceException
StorageService
The implementation of this method is expected to return all the objects
in a bucket, not a subset. This may require repeating the list operation if the
first one doesn't include all the available objects, such as when the number of objects
is greater than maxListingLength
.
listObjectsImpl
in class StorageService
prefix
- only objects with a key that starts with this prefix will be listed, may be null.delimiter
- only list objects with key names up to this delimiter, may be null.ServiceException
protected StorageObjectsChunk listObjectsChunkedImpl(java.lang.String bucketName, java.lang.String prefix, java.lang.String delimiter, long maxListingLength, java.lang.String priorLastKey, boolean completeListing) throws ServiceException
StorageService
Implementation notes The implementation of this method returns only as many objects as requested in the chunk size. It is the responsibility of the caller to build a complete object listing from multiple chunks, should this be necessary.
listObjectsChunkedImpl
in class StorageService
prefix
- only objects with a key that starts with this prefix will be listed, may be null.delimiter
- only list objects with key names up to this delimiter, may be null.ServiceException
protected StorageObjectsChunk listObjectsInternal(java.lang.String bucketName, java.lang.String prefix, java.lang.String delimiter, long maxListingLength, boolean automaticallyMergeChunks, java.lang.String priorLastKey, java.lang.String priorLastVersion) throws ServiceException
ServiceException
protected void deleteObjectImpl(java.lang.String bucketName, java.lang.String objectKey, java.lang.String versionId, java.lang.String multiFactorSerialNumber, java.lang.String multiFactorAuthCode) throws ServiceException
deleteObjectImpl
in class StorageService
ServiceException
protected AccessControlList getObjectAclImpl(java.lang.String bucketName, java.lang.String objectKey) throws ServiceException
ServiceException
protected AccessControlList getObjectAclImpl(java.lang.String bucketName, java.lang.String objectKey, java.lang.String versionId) throws ServiceException
getObjectAclImpl
in class StorageService
ServiceException
protected AccessControlList getBucketAclImpl(java.lang.String bucketName) throws ServiceException
getBucketAclImpl
in class StorageService
ServiceException
protected void putObjectAclImpl(java.lang.String bucketName, java.lang.String objectKey, AccessControlList acl, java.lang.String versionId) throws ServiceException
putObjectAclImpl
in class StorageService
ServiceException
protected void putBucketAclImpl(java.lang.String bucketName, AccessControlList acl) throws ServiceException
putBucketAclImpl
in class StorageService
ServiceException
protected void putAclImpl(java.lang.String bucketName, java.lang.String objectKey, AccessControlList acl, java.lang.String versionId) throws ServiceException
ServiceException
protected StorageBucket createBucketImpl(java.lang.String bucketName, java.lang.String location, AccessControlList acl) throws ServiceException
StorageService
The implementing method must populate the bucket object's metadata with the results of the
operation before returning the object. It must also apply any AccessControlList
settings included with the bucket.
createBucketImpl
in class StorageService
bucketName
- the name of the bucket to create.location
- the geographical location where the bucket will be stored (if applicable for the target
service). A null string value will cause the bucket to be stored in the default location.acl
- an access control object representing the initial acl values for the bucket.
May be null, in which case the default permissions are applied.ServiceException
protected void deleteBucketImpl(java.lang.String bucketName) throws ServiceException
deleteBucketImpl
in class StorageService
ServiceException
protected StorageObject putObjectImpl(java.lang.String bucketName, StorageObject object) throws ServiceException
putObjectImpl
in class StorageService
ServiceException
protected void putObjectWithRequestEntityImpl(java.lang.String bucketName, StorageObject object, org.apache.commons.httpclient.methods.RequestEntity requestEntity, java.util.Map<java.lang.String,java.lang.String> requestParams) throws ServiceException
ServiceException
protected java.util.Map<java.lang.String,java.lang.Object> createObjectImpl(java.lang.String bucketName, java.lang.String objectKey, java.lang.String contentType, org.apache.commons.httpclient.methods.RequestEntity requestEntity, java.util.Map<java.lang.String,java.lang.Object> metadata, java.util.Map<java.lang.String,java.lang.String> requestParams, AccessControlList acl, java.lang.String storageClass) throws ServiceException
ServiceException
protected boolean prepareCannedAcl(java.util.Map<java.lang.String,java.lang.Object> metadata, AccessControlList acl)
metadata
- acl
- protected void prepareStorageClass(java.util.Map<java.lang.String,java.lang.Object> metadata, java.lang.String storageClass, java.lang.String objectKey)
protected java.util.Map<java.lang.String,java.lang.Object> copyObjectImpl(java.lang.String sourceBucketName, java.lang.String sourceObjectKey, java.lang.String destinationBucketName, java.lang.String destinationObjectKey, AccessControlList acl, java.util.Map<java.lang.String,java.lang.Object> destinationMetadata, java.util.Calendar ifModifiedSince, java.util.Calendar ifUnmodifiedSince, java.lang.String[] ifMatchTags, java.lang.String[] ifNoneMatchTags, java.lang.String versionId, java.lang.String destinationObjectStorageClass) throws ServiceException
StorageService
copyObjectImpl
in class StorageService
sourceBucketName
- the name of the bucket that contains the original object.sourceObjectKey
- the key name of the original object.destinationBucketName
- the name of the destination bucket to which the object will be copied.destinationObjectKey
- the key name for the copied object.acl
- the access control settings that will be applied to the copied object.
If this parameter is null, the default (private) ACL setting will be
applied to the copied object.destinationMetadata
- metadata items to apply to the copied object. If this parameter is null,
the metadata will be copied unchanged from the original object. If this
parameter is not null, the copied object will have only the supplied
metadata.ServiceException
protected StorageObject getObjectDetailsImpl(java.lang.String bucketName, java.lang.String objectKey, java.util.Calendar ifModifiedSince, java.util.Calendar ifUnmodifiedSince, java.lang.String[] ifMatchTags, java.lang.String[] ifNoneMatchTags, java.lang.String versionId) throws ServiceException
getObjectDetailsImpl
in class StorageService
ServiceException
protected StorageObject getObjectImpl(java.lang.String bucketName, java.lang.String objectKey, java.util.Calendar ifModifiedSince, java.util.Calendar ifUnmodifiedSince, java.lang.String[] ifMatchTags, java.lang.String[] ifNoneMatchTags, java.lang.Long byteRangeStart, java.lang.Long byteRangeEnd, java.lang.String versionId) throws ServiceException
getObjectImpl
in class StorageService
ServiceException
public S3Object putObjectWithSignedUrl(java.lang.String signedPutUrl, S3Object object) throws ServiceException
SignedUrlHandler
.
This operation does not required any S3 functionality as it merely uploads the object by performing a standard HTTP PUT using the signed URL.
signedPutUrl
- a signed PUT URL generated with
S3Service.createSignedPutUrl(String, String, java.util.Map, org.jets3t.service.security.ProviderCredentials, java.util.Date)
.object
- the object to upload, which must correspond to the object for which the URL was signed.
The object must have the correct content length set, and to apply a non-standard
ACL policy only the REST canned ACLs can be used
(eg AccessControlList.REST_CANNED_PUBLIC_READ_WRITE
).ServiceException
public void deleteObjectWithSignedUrl(java.lang.String signedDeleteUrl) throws ServiceException
SignedUrlHandler
.
This operation does not required any S3 functionality as it merely deletes the object by performing a standard HTTP DELETE using the signed URL.
signedDeleteUrl
- a signed DELETE URL generated with S3Service.createSignedDeleteUrl(java.lang.String, java.lang.String, java.util.Date, boolean)
.ServiceException
public S3Object getObjectWithSignedUrl(java.lang.String signedGetUrl) throws ServiceException
SignedUrlHandler
.
This operation does not required any S3 functionality as it merely uploads the object by performing a standard HTTP GET using the signed URL.
signedGetUrl
- a signed GET URL generated with
S3Service.createSignedGetUrl(String, String, org.jets3t.service.security.ProviderCredentials, java.util.Date)
.ServiceException
public S3Object getObjectDetailsWithSignedUrl(java.lang.String signedHeadUrl) throws ServiceException
SignedUrlHandler
.
This operation does not required any S3 functionality as it merely uploads the object by performing a standard HTTP HEAD using the signed URL.
signedHeadUrl
- a signed HEAD URL generated with
S3Service.createSignedHeadUrl(String, String, org.jets3t.service.security.ProviderCredentials, java.util.Date)
.ServiceException
public AccessControlList getObjectAclWithSignedUrl(java.lang.String signedAclUrl) throws ServiceException
SignedUrlHandler
.signedAclUrl
- a signed URL generated with S3Service.createSignedUrl(String, String, String, String, java.util.Map, org.jets3t.service.security.ProviderCredentials, long, boolean)
.ServiceException
public void putObjectAclWithSignedUrl(java.lang.String signedAclUrl, AccessControlList acl) throws ServiceException
SignedUrlHandler
.signedAclUrl
- a signed URL generated with S3Service.createSignedUrl(String, String, String, String, java.util.Map, org.jets3t.service.security.ProviderCredentials, long, boolean)
.acl
- the ACL settings to apply to the object represented by the signed URL.ServiceException