Class StorageService

java.lang.Object
org.jets3t.service.StorageService
Direct Known Subclasses:
RestStorageService

public abstract class StorageService extends Object
A service that handles communication with a storage service, offering all the operations that can be performed on generic storage services.

This class must be extended by implementation classes that perform the communication with a specific service using a specific interface, such as REST or SOAP.

Implementations of StorageService must be thread-safe as they will probably be used by the multi-threaded service class ThreadedStorageService.

This class uses properties obtained through Jets3tProperties. For more information on these properties please refer to JetS3t Configuration

Author:
James Murty, Nikolas Coukouma
  • Field Details

    • BUCKET_STATUS__MY_BUCKET

      public static final int BUCKET_STATUS__MY_BUCKET
      Status code returned by checkBucketStatus(String) for a bucket that exists and is owned by the service user.
      See Also:
    • BUCKET_STATUS__DOES_NOT_EXIST

      public static final int BUCKET_STATUS__DOES_NOT_EXIST
      Status code returned by checkBucketStatus(String) for a bucket that does not exist.
      See Also:
    • BUCKET_STATUS__ALREADY_CLAIMED

      public static final int BUCKET_STATUS__ALREADY_CLAIMED
      Status code returned by checkBucketStatus(String) for a bucket that exists but is not owned by the service user (i.e. another user has already created this bucket in the service's namespace).
      See Also:
  • Method Details

    • shutdown

      public void shutdown() throws ServiceException
      Make a best-possible effort to shutdown and clean up any resources used by this service such as HTTP connections, connection pools, threads etc, although there is no guarantee that all such resources will indeed be fully cleaned up. After calling this method the service instance will no longer be usable -- a new instance must be created to do more work.
      Throws:
      ServiceException
    • isShutdown

      public boolean isShutdown()
      Returns:
      true if the shutdown() method has been used to shut down and clean up this service. If this function returns true this service instance can no longer be used to do work.
    • isAuthenticatedConnection

      public boolean isAuthenticatedConnection()
      Returns:
      true if this service has ProviderCredentials identifying a user, false if the service is acting as an anonymous user.
    • isHttpsOnly

      public boolean isHttpsOnly()
      Whether to use secure HTTPS or insecure HTTP for communicating with a service, as configured in the Jets3tProperties.
      Returns:
      true if this service should use only secure HTTPS communication channels. If false, the non-secure HTTP protocol will be used.
    • getInternalErrorRetryMax

      public int getInternalErrorRetryMax()
      Returns:
      The maximum number of times to retry when Internal Error (500) errors are encountered, as configured by the Jets3tProperties.
    • getJetS3tProperties

      public Jets3tProperties getJetS3tProperties()
      Returns:
      the JetS3t properties that will be used by this service.
    • getProviderCredentials

      public ProviderCredentials getProviderCredentials()
      Returns:
      the credentials identifying the service user, or null for anonymous.
    • getInvokingApplicationDescription

      public String getInvokingApplicationDescription()
      Returns:
      a description of the application using this service, suitable for inclusion in the user agent string of REST/HTTP requests.
    • listObjects

      public StorageObject[] listObjects(String bucketName) throws ServiceException
      Lists the objects in a bucket.

      The objects returned by this method contain only minimal information such as the object's size, ETag, and LastModified timestamp. To retrieve the objects' metadata you must perform follow-up getObject or getObjectDetails operations.

      This method can be performed by anonymous services. Anonymous services can only list the objects in a publicly-readable bucket.

      Parameters:
      bucketName - the name of the bucket whose contents will be listed.
      Returns:
      the set of objects contained in a bucket.
      Throws:
      ServiceException
    • listObjects

      public StorageObject[] listObjects(String bucketName, String prefix, String delimiter) throws ServiceException
      Lists the objects in a bucket matching a prefix and delimiter.

      The objects returned by this method contain only minimal information such as the object's size, ETag, and LastModified timestamp. To retrieve the objects' metadata you must perform follow-up getObject or getObjectDetails operations.

      This method can be performed by anonymous services. Anonymous services can only list the objects in a publicly-readable bucket.

      NOTE: If you supply a delimiter value that could cause virtual path "subdirectories" to be included in the results from the service, use the listObjectsChunked(String, String, String, long, String, boolean) method instead of this one to obtain both object and path values.

      Parameters:
      bucketName - the name of the bucket whose contents will be listed.
      prefix - only objects with a key that starts with this prefix will be listed
      delimiter - only list objects with key names up to this delimiter, may be null. See note above. Note: If a non-null delimiter is specified, the prefix must include enough text to reach the first occurrence of the delimiter in the bucket's keys, or no results will be returned.
      Returns:
      the set of objects contained in a bucket whose keys start with the given prefix.
      Throws:
      ServiceException
    • createBucket

      public StorageBucket createBucket(String bucketName) throws ServiceException
      Creates a bucket. Caution: Performing this operation unnecessarily when a bucket already exists may cause OperationAborted errors with the message "A conflicting conditional operation is currently in progress against this resource.". To avoid this error, use the getOrCreateBucket(String) in situations where the bucket may already exist. This method cannot be performed by anonymous services.
      Parameters:
      bucketName - the name of the bucket to create.
      Returns:
      the created bucket object. Note: the object returned has minimal information about the bucket that was created, including only the bucket's name.
      Throws:
      ServiceException
    • createBucket

      public StorageBucket createBucket(StorageBucket bucket) throws ServiceException
      Create a bucket with the Access Control List settings of the bucket object (if any).

      Caution: Performing this operation unnecessarily when a bucket already exists may cause OperationAborted errors with the message "A conflicting conditional operation is currently in progress against this resource.". To avoid this error, use the getOrCreateBucket(String) in situations where the bucket may already exist.

      This method cannot be performed by anonymous services.

      Parameters:
      bucket - the bucket to create, including optional ACL settings.
      Returns:
      the created bucket object. Note: the object returned has minimal information about the bucket that was created, including only the bucket's name.
      Throws:
      ServiceException
    • isObjectInBucket

      public boolean isObjectInBucket(String bucketName, String objectKey) throws ServiceException
      Convenience method to check whether an object exists in a bucket.
      Parameters:
      bucketName - the name of the bucket containing the object.
      objectKey - the key identifying the object.
      Returns:
      false if the object is not found in the bucket, true if the object exists (although it may be inaccessible to you).
      Throws:
      ServiceException
    • getObject

      public StorageObject getObject(String bucketName, String objectKey) throws ServiceException
      Returns an object representing the details and data of an item in a service, without applying any preconditions.

      This method can be performed by anonymous services. Anonymous services can get a publicly-readable object.

      Important: It is the caller's responsibility to close the object's data input stream. The data stream should be consumed and closed as soon as is practical as network connections may be held open until the streams are closed. Excessive unclosed streams can lead to connection starvation.

      Parameters:
      bucketName - the name of the bucket containing the object.
      objectKey - the key identifying the object.
      Returns:
      the object with the given key, including the object's data input stream.
      Throws:
      ServiceException
    • getObjectDetails

      public StorageObject getObjectDetails(String bucketName, String objectKey) throws ServiceException
      Returns an object representing the details of an item in without the object's data, and without applying any preconditions.

      This method can be performed by anonymous services. Anonymous services can get a publicly-readable object's details.

      Parameters:
      bucketName - the name of the bucket containing the object.
      objectKey - the key identifying the object.
      Returns:
      the object with the given key, including only general details and metadata (not the data input stream)
      Throws:
      ServiceException
    • listAllBuckets

      public StorageBucket[] listAllBuckets() throws ServiceException
      Lists the buckets belonging to the service user.

      This method cannot be performed by anonymous services, and will fail with an exception if the service is not authenticated.

      Returns:
      the list of buckets owned by the service user.
      Throws:
      ServiceException
    • getAccountOwner

      public StorageOwner getAccountOwner() throws ServiceException
      Returns the owner of an account, using information available in the bucket listing response.

      This method cannot be performed by anonymous services, and will fail with an exception if the service is not authenticated.

      Returns:
      the owner of the account.
      Throws:
      ServiceException
    • listObjects

      public StorageObject[] listObjects(String bucketName, String prefix, String delimiter, long maxListingLength) throws ServiceException
      Lists the objects in a bucket matching a prefix, while instructing the service to send response messages containing no more than a given number of object results.

      The objects returned by this method contain only minimal information such as the object's size, ETag, and LastModified timestamp. To retrieve the objects' metadata you must perform follow-up getObject or getObjectDetails operations.

      This method can be performed by anonymous services. Anonymous services can list the contents of a publicly-readable bucket.

      NOTE: If you supply a delimiter value that could cause virtual path "subdirectories" to be included in the results from the service, use the listObjectsChunked(String, String, String, long, String, boolean) method instead of this one to obtain both object and path values.

      Parameters:
      bucketName - the name of the the bucket whose contents will be listed.
      prefix - only objects with a key that starts with this prefix will be listed
      delimiter - only list objects with key names up to this delimiter, may be null. See note above.
      maxListingLength - the maximum number of objects to include in each result message. This value has no effect on the number of objects that will be returned by this method, because it will always return all the objects in the bucket.
      Returns:
      the set of objects contained in a bucket whose keys start with the given prefix.
      Throws:
      ServiceException
    • listObjectsChunked

      public StorageObjectsChunk listObjectsChunked(String bucketName, String prefix, String delimiter, long maxListingLength, String priorLastKey) throws ServiceException
      Lists the objects in a bucket matching a prefix, chunking the results into batches of a given size, and returning each chunk separately. It is the responsibility of the caller to building a complete bucket object listing by performing follow-up requests if necessary.

      The objects returned by this method contain only minimal information such as the object's size, ETag, and LastModified timestamp. To retrieve the objects' metadata you must perform follow-up getObject or getObjectDetails operations.

      This method can be performed by anonymous services. Anonymous services can list the contents of a publicly-readable bucket.

      Parameters:
      bucketName - the name of the the bucket whose contents will be listed.
      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.
      maxListingLength - the maximum number of objects to include in each result chunk
      priorLastKey - the last object key received in a prior call to this method. The next chunk of objects listed will start with the next object in the bucket after this key name. This parameter may be null, in which case the listing will start at the beginning of the bucket's object contents.
      Returns:
      the set of objects contained in a bucket whose keys start with the given prefix.
      Throws:
      ServiceException
    • listObjectsChunked

      public StorageObjectsChunk listObjectsChunked(String bucketName, String prefix, String delimiter, long maxListingLength, String priorLastKey, boolean completeListing) throws ServiceException
      Lists the objects in a bucket matching a prefix and also returns the common prefixes. Depending on the value of the completeListing variable, this method can be set to automatically perform follow-up requests to build a complete object listing, or to return only a partial listing.

      The objects returned by this method contain only minimal information such as the object's size, ETag, and LastModified timestamp. To retrieve the objects' metadata you must perform follow-up getObject or getObjectDetails operations.

      This method can be performed by anonymous services. Anonymous services can list the contents of a publicly-readable bucket.

      Parameters:
      bucketName - the name of the the bucket whose contents will be listed.
      prefix - only objects with a key that starts with this prefix will be listed, may be null.
      delimiter - only objects with a key that starts with this prefix will be listed, may be null.
      maxListingLength - the maximum number of objects to include in each result chunk
      priorLastKey - the last object key received in a prior call to this method. The next chunk of objects listed will start with the next object in the bucket after this key name. This parameter may be null, in which case the listing will start at the beginning of the bucket's object contents.
      completeListing - if true, the service class will automatically perform follow-up requests to build a complete bucket object listing.
      Returns:
      the set of objects contained in a bucket whose keys start with the given prefix.
      Throws:
      ServiceException
    • getBucket

      public StorageBucket getBucket(String bucketName) throws ServiceException
      Returns a bucket in your account by listing all your buckets (using listAllBuckets()), and looking for the named bucket in this list.

      This method cannot be performed by anonymous services.

      Parameters:
      bucketName -
      Returns:
      the bucket in your account, or null if you do not own the named bucket.
      Throws:
      ServiceException
    • getOrCreateBucket

      public StorageBucket getOrCreateBucket(String bucketName) throws ServiceException
      Returns a bucket in your account, and creates the bucket if it does not yet exist.
      Parameters:
      bucketName - the name of the bucket to retrieve or create.
      Returns:
      the bucket in your account.
      Throws:
      ServiceException
    • deleteBucket

      public void deleteBucket(StorageBucket bucket) throws ServiceException
      Deletes a bucket. Only the owner of a bucket may delete it.

      This method cannot be performed by anonymous services.

      Parameters:
      bucket - the bucket to delete.
      Throws:
      ServiceException
    • deleteBucket

      public void deleteBucket(String bucketName) throws ServiceException
      Deletes a bucket. Only the owner of a bucket may delete it.

      This method cannot be performed by anonymous services.

      Parameters:
      bucketName - the name of the bucket to delete.
      Throws:
      ServiceException
    • putObject

      public StorageObject putObject(String bucketName, StorageObject object) throws ServiceException
      Puts an object inside an existing bucket, creating a new object or overwriting an existing one with the same key. The Access Control List settings of the object (if any) will also be applied.

      This method can be performed by anonymous services. Anonymous services can put objects into a publicly-writable bucket.

      Parameters:
      bucketName - the name of the bucket inside which the object will be put.
      object - the object containing all information that will be written to the service. At very least this object must be valid. Beyond that it may contain: an input stream with the object's data content, metadata, and access control settings.

      Note: It is very important to set the object's Content-Length to match the size of the data input stream when possible, as this can remove the need to read data into memory to determine its size.

      Returns:
      the object populated with any metadata.
      Throws:
      ServiceException
    • copyObject

      public Map<String,Object> copyObject(String sourceBucketName, String sourceObjectKey, String destinationBucketName, StorageObject destinationObject, boolean replaceMetadata, Calendar ifModifiedSince, Calendar ifUnmodifiedSince, String[] ifMatchTags, String[] ifNoneMatchTags) throws ServiceException
      Copy an object. You can copy an object within a single bucket or between buckets, and can optionally update the object's metadata at the same time.

      This method cannot be performed by anonymous services. You must have read access to the source object and write access to the destination bucket.

      An object can be copied over itself, in which case you can update its metadata without making any other changes.

      Parameters:
      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.
      destinationObject - the object that will be created by the copy operation. If this item includes an AccessControlList setting the copied object will be assigned that ACL, otherwise the copied object will be assigned the default private ACL setting.
      replaceMetadata - If this parameter is true, the copied object will be assigned the metadata values present in the destinationObject. Otherwise, the copied object will have the same metadata as the original object.
      ifModifiedSince - a precondition specifying a date after which the object must have been modified, ignored if null.
      ifUnmodifiedSince - a precondition specifying a date after which the object must not have been modified, ignored if null.
      ifMatchTags - a precondition specifying an MD5 hash the object must match, ignored if null.
      ifNoneMatchTags - a precondition specifying an MD5 hash the object must not match, ignored if null.
      Returns:
      a map of the header and result information resulting from the object copy. The map includes the object's MD5 hash value (ETag), its size (Content-Length), and update timestamp (Last-Modified).
      Throws:
      ServiceException
    • copyObject

      public Map<String,Object> copyObject(String sourceBucketName, String sourceObjectKey, String destinationBucketName, StorageObject destinationObject, boolean replaceMetadata) throws ServiceException
      Copy an object. You can copy an object within a single bucket or between buckets, and can optionally update the object's metadata at the same time.

      This method cannot be performed by anonymous services. You must have read access to the source object and write access to the destination bucket.

      An object can be copied over itself, in which case you can update its metadata without making any other changes.

      Parameters:
      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.
      destinationObject - the object that will be created by the copy operation. If this item includes an AccessControlList setting the copied object will be assigned that ACL, otherwise the copied object will be assigned the default private ACL setting.
      replaceMetadata - If this parameter is true, the copied object will be assigned the metadata values present in the destinationObject. Otherwise, the copied object will have the same metadata as the original object.
      Returns:
      a map of the header and result information after the object copy. The map includes the object's MD5 hash value (ETag), its size (Content-Length), and update timestamp (Last-Modified).
      Throws:
      ServiceException
    • moveObject

      public Map<String,Object> moveObject(String sourceBucketName, String sourceObjectKey, String destinationBucketName, StorageObject destinationObject, boolean replaceMetadata) throws ServiceException
      Move an object. This method works by invoking the copyObject(String, String, String, StorageObject, boolean) method to copy the original object, then deletes the original object once the copy has succeeded.

      This method cannot be performed by anonymous services. You must have read access to the source object, write access to the destination bucket, and write access to the source bucket.

      If the copy operation succeeds but the delete operation fails, this method will not throw an exception but the result map object will contain an item named "DeleteException" with the exception thrown by the delete operation.

      Parameters:
      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.
      destinationObject - the object that will be created by the move operation. If this item includes an AccessControlList setting the copied object will be assigned that ACL, otherwise the copied object will be assigned the default private ACL setting.
      replaceMetadata - If this parameter is true, the copied object will be assigned the metadata values present in the destinationObject. Otherwise, the copied object will have the same metadata as the original object.
      Returns:
      a map of the header and result information after the object copy. The map includes the object's MD5 hash value (ETag), its size (Content-Length), and update timestamp (Last-Modified). If the object was successfully copied but the original could not be deleted, the map will also include an item named "DeleteException" with the exception thrown by the delete operation.
      Throws:
      ServiceException
    • renameObject

      public Map<String,Object> renameObject(String bucketName, String sourceObjectKey, StorageObject destinationObject) throws ServiceException
      Rename an object. This method works by invoking the moveObject(String, String, String, StorageObject, boolean) method to move the original object to a new key name.

      The original object's metadata is retained, but to apply an access control setting other than private you must specify an ACL in the destination object.

      This method cannot be performed by anonymous services. You must have write access to the source object and write access to the bucket.

      Parameters:
      bucketName - the name of the bucket containing the original object that will be copied.
      sourceObjectKey - the key name of the original object.
      destinationObject - the object that will be created by the rename operation. If this item includes an AccessControlList setting the copied object will be assigned that ACL, otherwise the copied object will be assigned the default private ACL setting.
      Returns:
      a map of the header and result information after the object copy. The map includes the object's MD5 hash value (ETag), its size (Content-Length), and update timestamp (Last-Modified). If the object was successfully copied but the original could not be deleted, the map will also include an item named "DeleteException" with the exception thrown by the delete operation.
      Throws:
      ServiceException
    • updateObjectMetadata

      public Map<String,Object> updateObjectMetadata(String bucketName, StorageObject object) throws ServiceException
      Update an object's metadata. This method works by invoking the copyObject(String, String, String, StorageObject, boolean) method to copy the original object over itself, applying the new metadata in the process.
      Parameters:
      bucketName - the name of the bucket containing the object that will be updated.
      object - the object that will be updated. If this item includes an AccessControlList setting the copied object will be assigned that ACL, otherwise the copied object will be assigned the default private ACL setting.
      Returns:
      a map of the header and result information after the object copy. The map includes the object's MD5 hash value (ETag), its size (Content-Length), and update timestamp (Last-Modified).
      Throws:
      ServiceException
    • deleteObject

      public void deleteObject(String bucketName, String objectKey) throws ServiceException
      Deletes an object from a bucket.

      This method can be performed by anonymous services. Anonymous services can delete objects from publicly-writable buckets.

      Parameters:
      bucketName - the name of the bucket containing the object to be deleted.
      objectKey - the key representing the object
      Throws:
      ServiceException
    • getObjectDetails

      public StorageObject getObjectDetails(String bucketName, String objectKey, Calendar ifModifiedSince, Calendar ifUnmodifiedSince, String[] ifMatchTags, String[] ifNoneMatchTags) throws ServiceException
      Returns an object representing the details of an item that meets any given preconditions. The object is returned without the object's data.

      An exception is thrown if any of the preconditions fail. Preconditions are only applied if they are non-null.

      This method can be performed by anonymous services. Anonymous services can get details of publicly-readable objects.

      Parameters:
      bucketName - the name of the bucket containing the object.
      objectKey - the key identifying the object.
      ifModifiedSince - a precondition specifying a date after which the object must have been modified, ignored if null.
      ifUnmodifiedSince - a precondition specifying a date after which the object must not have been modified, ignored if null.
      ifMatchTags - a precondition specifying an MD5 hash the object must match, ignored if null.
      ifNoneMatchTags - a precondition specifying an MD5 hash the object must not match, ignored if null.
      Returns:
      the object with the given key, including only general details and metadata (not the data input stream)
      Throws:
      ServiceException
    • getObject

      public StorageObject getObject(String bucketName, String objectKey, Calendar ifModifiedSince, Calendar ifUnmodifiedSince, String[] ifMatchTags, String[] ifNoneMatchTags, Long byteRangeStart, Long byteRangeEnd) throws ServiceException
      Returns an object representing the details and data of an item that meets any given preconditions.

      Important: It is the caller's responsibility to close the object's data input stream. The data stream should be consumed and closed as soon as is practical as network connections may be held open until the streams are closed. Excessive unclosed streams can lead to connection starvation.

      An exception is thrown if any of the preconditions fail. Preconditions are only applied if they are non-null.

      This method can be performed by anonymous services. Anonymous services can get a publicly-readable object.

      Implementation notes

      Implementations should use assertValidBucket(org.jets3t.service.model.StorageBucket, java.lang.String) assertion.

      Parameters:
      bucketName - the name of the bucket containing the object.
      objectKey - the key identifying the object.
      ifModifiedSince - a precondition specifying a date after which the object must have been modified, ignored if null.
      ifUnmodifiedSince - a precondition specifying a date after which the object must not have been modified, ignored if null.
      ifMatchTags - a precondition specifying an MD5 hash the object must match, ignored if null.
      ifNoneMatchTags - a precondition specifying an MD5 hash the object must not match, ignored if null.
      byteRangeStart - include only a portion of the object's data - starting at this point, ignored if null.
      byteRangeEnd - include only a portion of the object's data - ending at this point, ignored if null.
      Returns:
      the object with the given key, including only general details and metadata (not the data input stream)
      Throws:
      ServiceException
    • putObjectAcl

      public void putObjectAcl(String bucketName, StorageObject object) throws ServiceException
      Applies access control settings to an object. The ACL settings must be included with the object. This method can be performed by anonymous services, but can only succeed if the object's existing ACL already allows write access by the anonymous user. In general, you can only access the ACL of an object if the ACL already in place for that object allows you to do so.
      Parameters:
      bucketName - the name of the bucket containing the object to modify.
      object - the object with ACL settings that will be applied.
      Throws:
      ServiceException
    • putObjectAcl

      public void putObjectAcl(String bucketName, String objectKey, AccessControlList acl) throws ServiceException
      Applies access control settings to an object. The ACL settings must be included with the object. This method can be performed by anonymous services, but can only succeed if the object's existing ACL already allows write access by the anonymous user. In general, you can only access the ACL of an object if the ACL already in place for that object allows you to do so.
      Parameters:
      bucketName - the name of the bucket containing the object to modify.
      objectKey - the key name of the object with ACL settings that will be applied.
      acl - the ACL to apply.
      Throws:
      ServiceException
    • getObjectAcl

      public AccessControlList getObjectAcl(String bucketName, String objectKey) throws ServiceException
      Retrieves the access control settings of an object. This method can be performed by anonymous services, but can only succeed if the object's existing ACL already allows write access by the anonymous user. In general, you can only access the ACL of an object if the ACL already in place for that object allows you to do so.
      Parameters:
      bucketName - the name of the bucket whose ACL settings will be retrieved (if objectKey is null) or the name of the bucket containing the object whose ACL settings will be retrieved (if objectKey is non-null).
      objectKey - if non-null, the key of the object whose ACL settings will be retrieved. Ignored if null.
      Returns:
      the ACL settings of the bucket or object.
      Throws:
      ServiceException
    • putBucketAcl

      public void putBucketAcl(String bucketName, AccessControlList acl) throws ServiceException
      Applies access control settings to a bucket. The ACL settings must be included inside the bucket. This method can be performed by anonymous services, but can only succeed if the bucket's existing ACL already allows write access by the anonymous user. In general, you can only access the ACL of a bucket if the ACL already in place for that bucket allows you to do so.
      Parameters:
      bucketName - a name of the bucket with ACL settings to apply.
      acl - the ACL to apply.
      Throws:
      ServiceException
    • putBucketAcl

      public void putBucketAcl(StorageBucket bucket) throws ServiceException
      Applies access control settings to a bucket. The ACL settings must be included inside the bucket. This method can be performed by anonymous services, but can only succeed if the bucket's existing ACL already allows write access by the anonymous user. In general, you can only access the ACL of a bucket if the ACL already in place for that bucket allows you to do so.
      Parameters:
      bucket - a bucket with ACL settings to apply.
      Throws:
      ServiceException
    • getBucketAcl

      public AccessControlList getBucketAcl(String bucketName) throws ServiceException
      Retrieves the access control settings of a bucket. This method can be performed by anonymous services, but can only succeed if the bucket's existing ACL already allows write access by the anonymous user. In general, you can only access the ACL of a bucket if the ACL already in place for that bucket allows you to do so.
      Parameters:
      bucketName - the name of the bucket whose access control settings will be returned.
      Returns:
      the ACL settings of the bucket.
      Throws:
      ServiceException
    • getCurrentTimeWithOffset

      public Date getCurrentTimeWithOffset()
      Returns the current date and time, adjusted according to the time offset between your computer and an AWS server (as set by the RestUtils.getAWSTimeAdjustment() method).
      Returns:
      the current time, or the current time adjusted to match the AWS time if the RestUtils.getAWSTimeAdjustment() method has been invoked.
    • renameMetadataKeys

      public Map<String,Object> renameMetadataKeys(Map<String,Object> metadata)
      Renames metadata property names to be suitable for use as HTTP Headers. This is done by renaming any non-HTTP headers to have the a service-specific prefix and leaving the HTTP header names unchanged. The HTTP header names left unchanged are those found in RestUtils.HTTP_HEADER_METADATA_NAMES
      Parameters:
      metadata -
      Returns:
      a map of metadata property name/value pairs renamed to be suitable for use as HTTP headers.
    • isBucketAccessible

      public abstract boolean isBucketAccessible(String bucketName) throws ServiceException
      Indicates whether a bucket exists and is accessible to a service user.

      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 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.

      Parameters:
      bucketName - the bucket to check.
      Returns:
      true if the bucket exists and is accessible to the service user, false otherwise.
      Throws:
      ServiceException
    • checkBucketStatus

      public abstract int checkBucketStatus(String bucketName) throws ServiceException
      Find out the status of a bucket with the given name.

      Caveats:

      • If someone else owns the bucket but has made it public, this method will mistakenly return 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 getOrCreateBucket(String) method for this purpose instead.

      Parameters:
      bucketName -
      Returns:
      BUCKET_STATUS__MY_BUCKET if you already own the bucket, BUCKET_STATUS__DOES_NOT_EXIST if the bucket does not yet exist, or BUCKET_STATUS__ALREADY_CLAIMED if someone else has already created a bucket with the given name.
      Throws:
      ServiceException
    • getEndpoint

      public abstract String getEndpoint()
      Returns:
      the URL end-point of the target service.
    • getRestHeaderPrefix

      public abstract String getRestHeaderPrefix()
      Returns:
      the REST header prefix used by the target service.
    • getResourceParameterNames

      public abstract List<String> getResourceParameterNames()
      Returns:
      GET parameter names that represent specific resources in the target service, as opposed to representing REST operation "plumbing". For example the "acl" parameter might be used to represent a resource's access control list settings.
    • getRestMetadataPrefix

      public abstract String getRestMetadataPrefix()
      Returns:
      the REST header prefix used by the target service to identify metadata information.