org.jets3t.service.multi
Class SimpleThreadedStorageService

java.lang.Object
  extended by org.jets3t.service.multi.SimpleThreadedStorageService

public class SimpleThreadedStorageService
extends java.lang.Object

S3 service wrapper that performs multiple S3 requests at a time using multi-threading and an underlying thread-safe 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 Summary
SimpleThreadedStorageService(StorageService service)
          Construct a multi-threaded service based on a StorageService.
 
Method Summary
 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.
 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, 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[] 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.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleThreadedStorageService

public SimpleThreadedStorageService(StorageService service)
Construct a multi-threaded service based on a StorageService.

Parameters:
service - a StorageService implementation that will be used to perform S3 requests.
Method Detail

throwError

protected void throwError(StorageServiceEventAdaptor adaptor)
                   throws ServiceException
Utility method to check an StorageServiceEventAdaptor for the occurrence of an error, and if one is present to throw it.

Parameters:
adaptor -
Throws:
ServiceException

createBuckets

public StorageBucket[] createBuckets(java.lang.String[] bucketNames)
                              throws ServiceException
Creates multiple buckets.

Parameters:
bucketNames - name of the buckets to create.
Returns:
the created buckets.
Throws:
ServiceException

putObjects

public StorageObject[] putObjects(java.lang.String bucketName,
                                  StorageObject[] objects)
                           throws ServiceException
Creates/uploads multiple objects.

Parameters:
bucketName - the bucket where objects will be stored.
objects - the objects to create/upload.
Returns:
the created/uploaded objects.
Throws:
ServiceException

copyObjects

public java.util.Map[] copyObjects(java.lang.String sourceBucketName,
                                   java.lang.String destinationBucketName,
                                   java.lang.String[] sourceObjectKeys,
                                   StorageObject[] destinationObjects,
                                   boolean replaceMetadata)
                            throws ServiceException
Copies multiple objects within or between buckets.

Parameters:
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.s
Throws:
ServiceException

deleteObjects

public void deleteObjects(java.lang.String bucketName,
                          StorageObject[] objects)
                   throws ServiceException
Deletes multiple objects

Parameters:
bucketName - name of the bucket containing the objects to delete.
objects - the objects to delete.
Throws:
ServiceException

getObjects

public StorageObject[] getObjects(java.lang.String bucketName,
                                  StorageObject[] objects)
                           throws ServiceException
Retrieves multiple objects (including details and data). The objects' data will be stored in temporary files, and can be retrieved using StorageObject.getDataInputStream().

Parameters:
bucketName - name of the bucket containing the objects.
objects - the objects to retrieve.
Returns:
the retrieved objects.
Throws:
ServiceException

getObjects

public StorageObject[] getObjects(java.lang.String bucketName,
                                  java.lang.String[] objectKeys)
                           throws ServiceException
Retrieves multiple objects (including details and data). The objects' data will be stored in temporary files, and can be retrieved using StorageObject.getDataInputStream().

Parameters:
bucketName - name of the bucket containing the objects.
objectKeys - the key names of the objects to retrieve.
Returns:
the retrieved objects.
Throws:
ServiceException

getObjectsHeads

public StorageObject[] getObjectsHeads(java.lang.String bucketName,
                                       StorageObject[] objects)
                                throws ServiceException
Retrieves details of multiple objects (details only, no data)

Parameters:
bucketName - name of the bucket containing the objects.
objects - the objects to retrieve.
Returns:
objects populated with the details retrieved.
Throws:
ServiceException

getObjectsHeads

public StorageObject[] getObjectsHeads(java.lang.String bucketName,
                                       java.lang.String[] objectKeys)
                                throws ServiceException
Retrieves details of multiple objects (details only, no data)

Parameters:
bucketName - name of the bucket containing the objects.
objectKeys - the key names of the objects to retrieve.
Returns:
objects populated with the details retrieved.
Throws:
ServiceException

getObjectACLs

public StorageObject[] getObjectACLs(java.lang.String bucketName,
                                     StorageObject[] objects)
                              throws ServiceException
Retrieves Access Control List (ACL) settings for multiple objects.

Parameters:
bucketName - name of the bucket containing the objects.
objects - the objects whose ACLs will be retrieved.
Returns:
objects including the ACL information retrieved.
Throws:
ServiceException

putACLs

public StorageObject[] putACLs(java.lang.String bucketName,
                               StorageObject[] objects)
                        throws ServiceException
Updates/sets Access Control List (ACL) settings for multiple objects.

Parameters:
bucketName - name of the bucket containing the objects.
objects - objects containing ACL settings that will be updated/set.
Returns:
objects whose ACL settings were updated/set.
Throws:
ServiceException

downloadObjects

public void downloadObjects(java.lang.String bucketName,
                            DownloadPackage[] downloadPackages)
                     throws ServiceException
A convenience method to download multiple objects from S3 to pre-existing output streams, which is particularly useful for downloading objects to files.

Parameters:
bucketName - name of the bucket containing the objects
downloadPackages - an array of download package objects that manage the output of data for an object.
Throws:
ServiceException