public class GoogleStorageService extends RestStorageService
This class uses properties obtained through Jets3tProperties
. For more information on
these properties please refer to
JetS3t Configuration
BUCKET_STATUS__ALREADY_CLAIMED, BUCKET_STATUS__DOES_NOT_EXIST, BUCKET_STATUS__MY_BUCKET
Constructor and Description |
---|
GoogleStorageService(ProviderCredentials credentials)
Constructs the service and initialises the properties.
|
GoogleStorageService(ProviderCredentials credentials,
String invokingApplicationDescription,
org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider)
Constructs the service and initialises the properties.
|
GoogleStorageService(ProviderCredentials credentials,
String invokingApplicationDescription,
org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider,
Jets3tProperties jets3tProperties)
Constructs the service and initialises the properties.
|
GoogleStorageService(ProviderCredentials credentials,
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 |
---|---|
GSBucket |
createBucket(String bucketName)
Creates a bucket.
|
GSAccessControlList |
getBucketAcl(String bucketName)
Retrieves the access control settings of a bucket.
|
String |
getEndpoint() |
GSObject |
getObject(String bucketName,
String objectKey)
Returns an object representing the details and data of an item in a service,
without applying any preconditions.
|
GSObject |
getObject(String bucketName,
String objectKey,
Calendar ifModifiedSince,
Calendar ifUnmodifiedSince,
String[] ifMatchTags,
String[] ifNoneMatchTags,
Long byteRangeStart,
Long byteRangeEnd)
Returns an object representing the details and data of an item that meets any given preconditions.
|
GSObject |
getObjectDetails(String bucketName,
String objectKey)
Returns an object representing the details of an item in without the object's data, and
without applying any preconditions.
|
List<String> |
getResourceParameterNames() |
String |
getRestHeaderPrefix() |
String |
getRestMetadataPrefix() |
GSBucket[] |
listAllBuckets()
Lists the buckets belonging to the service user.
|
GSObject[] |
listObjects(String bucketName)
Lists the objects in a bucket.
|
GSObject[] |
listObjects(String bucketName,
String prefix,
String delimiter)
Lists the objects in a bucket matching a prefix and delimiter.
|
void |
putBucketAcl(GSBucket bucket)
Applies access control settings to a bucket.
|
void |
putBucketAcl(String bucketName,
GSAccessControlList acl)
Applies access control settings to a bucket.
|
GSObject |
putObject(String bucketName,
GSObject object) |
authorizeHttpRequest, checkBucketStatus, deleteObjectWithSignedUrl, getCredentialsProvider, getHttpClient, getHttpConnectionManager, getObjectAclWithSignedUrl, getObjectDetailsWithSignedUrl, getObjectWithSignedUrl, isBucketAccessible, putObjectAclWithSignedUrl, putObjectWithSignedUrl, setCredentialsProvider, setHttpClient, setHttpConnectionManager
copyObject, copyObject, createBucket, deleteBucket, deleteBucket, deleteObject, getAccountOwner, getBucket, getCurrentTimeWithOffset, getInternalErrorRetryMax, getInvokingApplicationDescription, getJetS3tProperties, getObjectAcl, getObjectDetails, getOrCreateBucket, getProviderCredentials, isAuthenticatedConnection, isHttpsOnly, isObjectInBucket, isShutdown, listObjects, listObjectsChunked, listObjectsChunked, moveObject, putBucketAcl, putBucketAcl, putObject, putObjectAcl, putObjectAcl, renameMetadataKeys, renameObject, shutdown, updateObjectMetadata
public GoogleStorageService(ProviderCredentials credentials) throws ServiceException
credentials
- the user credentials to use when communicating with Google Storage, may be null in which case the
communication is done as an anonymous user.ServiceException
public GoogleStorageService(ProviderCredentials credentials, String invokingApplicationDescription, org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider) throws ServiceException
credentials
- the user credentials to use when communicating with Google Storage, 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.ServiceException
public GoogleStorageService(ProviderCredentials credentials, String invokingApplicationDescription, org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider, Jets3tProperties jets3tProperties) throws ServiceException
credentials
- the user credentials to use when communicating with Google Storage, 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.ServiceException
public GoogleStorageService(ProviderCredentials credentials, String invokingApplicationDescription, org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider, Jets3tProperties jets3tProperties, org.apache.commons.httpclient.HostConfiguration hostConfig) throws ServiceException
credentials
- the user credentials to use when communicating with Google Storage, 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 FactoryServiceException
public String getEndpoint()
getEndpoint
in class StorageService
public String getRestHeaderPrefix()
getRestHeaderPrefix
in class StorageService
public String getRestMetadataPrefix()
getRestMetadataPrefix
in class StorageService
public List<String> getResourceParameterNames()
getResourceParameterNames
in class StorageService
public GSBucket[] listAllBuckets() throws ServiceException
StorageService
This method cannot be performed by anonymous services, and will fail with an exception if the service is not authenticated.
listAllBuckets
in class StorageService
ServiceException
public GSObject[] listObjects(String bucketName) throws ServiceException
StorageService
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.
listObjects
in class StorageService
bucketName
- the name of the bucket whose contents will be listed.ServiceException
public GSObject[] listObjects(String bucketName, String prefix, String delimiter) throws ServiceException
StorageService
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
StorageService.listObjectsChunked(String, String, String, long, String, boolean)
method instead of this one to obtain both object and path values.
listObjects
in class StorageService
bucketName
- the name of the bucket whose contents will be listed.prefix
- only objects with a key that starts with this prefix will be listeddelimiter
- 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.ServiceException
public GSBucket createBucket(String bucketName) throws ServiceException
StorageService
StorageService.getOrCreateBucket(String)
in situations where the bucket may already exist.
This method cannot be performed by anonymous services.createBucket
in class StorageService
bucketName
- the name of the bucket to create.ServiceException
public GSAccessControlList getBucketAcl(String bucketName) throws ServiceException
StorageService
getBucketAcl
in class StorageService
bucketName
- the name of the bucket whose access control settings will be returned.ServiceException
public void putBucketAcl(String bucketName, GSAccessControlList acl) throws ServiceException
bucketName
- a name of the bucket with ACL settings to apply.ServiceException
public void putBucketAcl(GSBucket bucket) throws ServiceException
bucket
- a bucket with ACL settings to apply.ServiceException
public GSObject getObject(String bucketName, String objectKey) throws ServiceException
StorageService
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.
getObject
in class StorageService
bucketName
- the name of the bucket containing the object.objectKey
- the key identifying the object.ServiceException
public GSObject putObject(String bucketName, GSObject object) throws ServiceException
ServiceException
public GSObject getObject(String bucketName, String objectKey, Calendar ifModifiedSince, Calendar ifUnmodifiedSince, String[] ifMatchTags, String[] ifNoneMatchTags, Long byteRangeStart, Long byteRangeEnd) throws ServiceException
StorageService
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 StorageService.assertValidBucket(org.jets3t.service.model.StorageBucket, java.lang.String)
assertion.
getObject
in class StorageService
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.ServiceException
public GSObject getObjectDetails(String bucketName, String objectKey) throws ServiceException
StorageService
This method can be performed by anonymous services. Anonymous services can get a publicly-readable object's details.
getObjectDetails
in class StorageService
bucketName
- the name of the bucket containing the object.objectKey
- the key identifying the object.ServiceException