public class SimpleThreadedStorageService
extends java.lang.Object
StorageService
implementation.
This class provides a simplified interface to the ThreadedStorageService
service.
It will block while doing its work, return the results of an operation when it is finished,
and throw an exception if anything goes wrong.
For a non-blocking multi-threading service that is more powerful, but also more complicated,
see ThreadedStorageService
.
Constructor and Description |
---|
SimpleThreadedStorageService(StorageService service)
Construct a multi-threaded service based on a StorageService.
|
Modifier and Type | Method and Description |
---|---|
java.util.Map[] |
copyObjects(java.lang.String sourceBucketName,
java.lang.String destinationBucketName,
java.lang.String[] sourceObjectKeys,
StorageObject[] destinationObjects,
boolean replaceMetadata)
Copies multiple objects within or between buckets.
|
StorageBucket[] |
createBuckets(java.lang.String[] bucketNames)
Creates multiple buckets.
|
void |
deleteObjects(java.lang.String bucketName,
StorageObject[] objects)
Deletes multiple objects
|
void |
downloadObjects(java.lang.String bucketName,
DownloadPackage[] downloadPackages)
A convenience method to download multiple objects from S3 to pre-existing output streams, which
is particularly useful for downloading objects to files.
|
void |
downloadObjects(java.lang.String bucketName,
DownloadPackage[] downloadPackages,
ErrorPermitter errorPermitter)
A convenience method to download multiple objects from S3 to pre-existing output streams, which
is particularly useful for downloading objects to files.
|
StorageObject[] |
getObjectACLs(java.lang.String bucketName,
StorageObject[] objects)
Retrieves Access Control List (ACL) settings for multiple objects.
|
StorageObject[] |
getObjects(java.lang.String bucketName,
StorageObject[] objects)
Retrieves multiple objects (including details and data).
|
StorageObject[] |
getObjects(java.lang.String bucketName,
StorageObject[] objects,
ErrorPermitter errorPermitter)
Retrieves multiple objects (including details and data).
|
StorageObject[] |
getObjects(java.lang.String bucketName,
java.lang.String[] objectKeys)
Retrieves multiple objects (including details and data).
|
StorageObject[] |
getObjectsHeads(java.lang.String bucketName,
StorageObject[] objects)
Retrieves details of multiple objects (details only, no data)
|
StorageObject[] |
getObjectsHeads(java.lang.String bucketName,
java.lang.String[] objectKeys)
Retrieves details of multiple objects (details only, no data)
|
StorageObject[] |
getObjectsHeads(java.lang.String bucketName,
java.lang.String[] objectKeys,
ErrorPermitter errorPermitter)
Retrieves details of multiple objects (details only, no data)
|
StorageObject[] |
putACLs(java.lang.String bucketName,
StorageObject[] objects)
Updates/sets Access Control List (ACL) settings for multiple objects.
|
StorageObject[] |
putObjects(java.lang.String bucketName,
StorageObject[] objects)
Creates/uploads multiple objects.
|
static StorageObject[] |
reorderStorageObjects(java.lang.String[] objectKeys,
java.util.List<StorageObject> unorderedObjects)
Re-order a list of
StorageObject s to match the ordering of an array of
object key names. |
protected void |
throwError(StorageServiceEventAdaptor adaptor)
Utility method to check an
StorageServiceEventAdaptor for the occurrence of an error,
and if one is present to throw it. |
public SimpleThreadedStorageService(StorageService service)
service
- a StorageService implementation that will be used to perform S3 requests.protected void throwError(StorageServiceEventAdaptor adaptor) throws ServiceException
StorageServiceEventAdaptor
for the occurrence of an error,
and if one is present to throw it.adaptor
- ServiceException
public StorageBucket[] createBuckets(java.lang.String[] bucketNames) throws ServiceException
bucketNames
- name of the buckets to create.ServiceException
public StorageObject[] putObjects(java.lang.String bucketName, StorageObject[] objects) throws ServiceException
bucketName
- the bucket where objects will be stored.objects
- the objects to create/upload.ServiceException
public java.util.Map[] copyObjects(java.lang.String sourceBucketName, java.lang.String destinationBucketName, java.lang.String[] sourceObjectKeys, StorageObject[] destinationObjects, boolean replaceMetadata) throws ServiceException
sourceBucketName
- the name of the bucket containing the objects that will be copied.destinationBucketName
- the name of the bucket to which the objects will be copied. The destination
bucket may be the same as the source bucket.sourceObjectKeys
- the key names of the objects that will be copied.destinationObjects
- objects that will be created by the copy operation. The AccessControlList
setting of each object will determine the access permissions of the
resultant object, and if the replaceMetadata flag is true the metadata
items in each object will also be applied to the resultant object.replaceMetadata
- if true, the metadata items in the destination objects will be stored
in S3 by using the REPLACE metadata copying option. If false, the metadata
items will be copied unchanged from the original objects using the COPY
metadata copying option.sServiceException
public void deleteObjects(java.lang.String bucketName, StorageObject[] objects) throws ServiceException
bucketName
- name of the bucket containing the objects to delete.objects
- the objects to delete.ServiceException
public StorageObject[] getObjects(java.lang.String bucketName, StorageObject[] objects) throws ServiceException
StorageObject.getDataInputStream()
.bucketName
- name of the bucket containing the objects.objects
- the objects to retrieve.ServiceException
public StorageObject[] getObjects(java.lang.String bucketName, StorageObject[] objects, ErrorPermitter errorPermitter) throws ServiceException
StorageObject.getDataInputStream()
.bucketName
- name of the bucket containing the objects.objects
- the objects to retrieve.errorPermitter
- callback handler to decide which errors will cause a ThrowableBearingStorageObject
to pass through the system instead of raising an exception and aborting the operation.ServiceException
public StorageObject[] getObjects(java.lang.String bucketName, java.lang.String[] objectKeys) throws ServiceException
StorageObject.getDataInputStream()
.bucketName
- name of the bucket containing the objects.objectKeys
- the key names of the objects to retrieve.ServiceException
public StorageObject[] getObjectsHeads(java.lang.String bucketName, StorageObject[] objects) throws ServiceException
bucketName
- name of the bucket containing the objects.objects
- the objects to retrieve.ServiceException
public StorageObject[] getObjectsHeads(java.lang.String bucketName, java.lang.String[] objectKeys) throws ServiceException
bucketName
- name of the bucket containing the objects.objectKeys
- the key names of the objects to retrieve.ServiceException
public StorageObject[] getObjectsHeads(java.lang.String bucketName, java.lang.String[] objectKeys, ErrorPermitter errorPermitter) throws ServiceException
bucketName
- name of the bucket containing the objects.objectKeys
- the key names of the objects to retrieve.errorPermitter
- callback handler to decide which errors will cause a ThrowableBearingStorageObject
to pass through the system instead of raising an exception and aborting the operation.ServiceException
public StorageObject[] getObjectACLs(java.lang.String bucketName, StorageObject[] objects) throws ServiceException
bucketName
- name of the bucket containing the objects.objects
- the objects whose ACLs will be retrieved.ServiceException
public StorageObject[] putACLs(java.lang.String bucketName, StorageObject[] objects) throws ServiceException
bucketName
- name of the bucket containing the objects.objects
- objects containing ACL settings that will be updated/set.ServiceException
public void downloadObjects(java.lang.String bucketName, DownloadPackage[] downloadPackages) throws ServiceException
bucketName
- name of the bucket containing the objectsdownloadPackages
- an array of download package objects that manage the output of data for an object.ServiceException
public void downloadObjects(java.lang.String bucketName, DownloadPackage[] downloadPackages, ErrorPermitter errorPermitter) throws ServiceException
bucketName
- name of the bucket containing the objectsdownloadPackages
- an array of download package objects that manage the output of data for an object.errorPermitter
- callback handler to decide which errors will cause a ThrowableBearingStorageObject
to pass through the system instead of raising an exception and aborting the operation.ServiceException
public static StorageObject[] reorderStorageObjects(java.lang.String[] objectKeys, java.util.List<StorageObject> unorderedObjects)
StorageObject
s to match the ordering of an array of
object key names.objectKeys
- a list of object key names with the ordering you want to apply to the StorageObject
s.unorderedObjects
- an unordered list of storage objects with key names matching the given array of object key
names, and exactly the same number of objects as the object key names array.StorageObject
s ordered to match the given object key name array.