public class GoogleCloudStorageImpl extends Object implements GoogleCloudStorage
| Modifier and Type | Class and Description |
|---|---|
static interface |
GoogleCloudStorageImpl.BackOffFactory
A factory for producing BackOff objects.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
BUCKET_EMPTY_MAX_RETRIES |
static int |
BUCKET_EMPTY_WAIT_TIME_MS |
static String |
PATH_DELIMITER |
MAX_RESULTS_UNLIMITED| Modifier | Constructor and Description |
|---|---|
protected |
GoogleCloudStorageImpl() |
|
GoogleCloudStorageImpl(GoogleCloudStorageOptions options,
com.google.api.client.auth.oauth2.Credential credential)
Constructs an instance of GoogleCloudStorageImpl.
|
|
GoogleCloudStorageImpl(GoogleCloudStorageOptions options,
com.google.api.services.storage.Storage gcs)
Constructs an instance of GoogleCloudStorageImpl.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
See
GoogleCloudStorage.close() for details about expected behavior. |
void |
compose(String bucketName,
List<String> sources,
String destination,
String contentType)
Composes inputs into a single GCS object.
|
void |
copy(String srcBucketName,
List<String> srcObjectNames,
String dstBucketName,
List<String> dstObjectNames)
See
GoogleCloudStorage.copy(String, List, String, List) for details
about expected behavior. |
WritableByteChannel |
create(StorageResourceId resourceId)
See
GoogleCloudStorage.create(StorageResourceId) for details about expected behavior. |
WritableByteChannel |
create(StorageResourceId resourceId,
CreateObjectOptions options)
Creates and opens an object for writing.
|
void |
create(String bucketName)
See
GoogleCloudStorage.create(String) for details about expected
behavior. |
void |
create(String bucketName,
CreateBucketOptions options)
See
GoogleCloudStorage.create(String, CreateBucketOptions) for
details about expected behavior. |
void |
createEmptyObject(StorageResourceId resourceId)
See
GoogleCloudStorage.createEmptyObject(StorageResourceId) for details about
expected behavior. |
void |
createEmptyObject(StorageResourceId resourceId,
CreateObjectOptions options)
Creates an empty object, useful for placeholders representing, for example, directories.
|
void |
createEmptyObjects(List<StorageResourceId> resourceIds)
See
GoogleCloudStorage.createEmptyObjects(List) for details about
expected behavior. |
void |
createEmptyObjects(List<StorageResourceId> resourceIds,
CreateObjectOptions options)
Creates a list of empty objects; see
GoogleCloudStorage.createEmptyObject(StorageResourceId) for
the single-item version of this method. |
static GoogleCloudStorageItemInfo |
createItemInfoForInferredDirectory(StorageResourceId resourceId)
Helper for creating a "found" GoogleCloudStorageItemInfo
for an inferred directory.
|
protected static GoogleCloudStorageItemInfo |
createItemInfoForNotFound(StorageResourceId resourceId)
Helper for creating a "not found" GoogleCloudStorageItemInfo for a StorageResourceId.
|
void |
deleteBuckets(List<String> bucketNames)
See
GoogleCloudStorage#deleteBuckets(List for details about expected behavior. |
void |
deleteObjects(List<StorageResourceId> fullObjectNames)
See
GoogleCloudStorage#deleteObjects(List for details about
expected behavior. |
GoogleCloudStorageItemInfo |
getItemInfo(StorageResourceId resourceId)
See
GoogleCloudStorage.getItemInfo(StorageResourceId) for details about expected
behavior. |
List<GoogleCloudStorageItemInfo> |
getItemInfos(List<StorageResourceId> resourceIds)
See
GoogleCloudStorage#getItemInfos(List for details about expected
behavior. |
GoogleCloudStorageOptions |
getOptions()
Retrieve the options that were used to create this GoogleCloudStorage.
|
List<GoogleCloudStorageItemInfo> |
listBucketInfo()
See
GoogleCloudStorage.listBucketInfo() for details about expected behavior. |
List<String> |
listBucketNames()
See
GoogleCloudStorage.listBucketNames() for details about expected behavior. |
List<GoogleCloudStorageItemInfo> |
listObjectInfo(String bucketName,
String objectNamePrefix,
String delimiter)
See
GoogleCloudStorage.listObjectInfo(String, String, String)
for details about expected behavior. |
List<GoogleCloudStorageItemInfo> |
listObjectInfo(String bucketName,
String objectNamePrefix,
String delimiter,
long maxResults)
See
GoogleCloudStorage.listObjectInfo(String, String, String, long)
for details about expected behavior. |
List<String> |
listObjectNames(String bucketName,
String objectNamePrefix,
String delimiter)
See
GoogleCloudStorage.listObjectNames(String, String, String)
for details about expected behavior. |
List<String> |
listObjectNames(String bucketName,
String objectNamePrefix,
String delimiter,
long maxResults)
See
GoogleCloudStorage.listObjectNames(String, String, String, long)
for details about expected behavior. |
SeekableByteChannel |
open(StorageResourceId resourceId)
See
GoogleCloudStorage.open(StorageResourceId) for details about expected behavior. |
List<GoogleCloudStorageItemInfo> |
updateItems(List<UpdatableItemInfo> itemInfoList)
Attempt to update metadata of the objects referenced within the passed itemInfo objects.
|
static void |
validateCopyArguments(String srcBucketName,
List<String> srcObjectNames,
String dstBucketName,
List<String> dstObjectNames,
GoogleCloudStorage gcsImpl)
Validates basic argument constraints like non-null, non-empty Strings, using
Preconditions in addition to checking for src/dst bucket existence and compatibility of bucket
properties such as location and storage-class. |
void |
waitForBucketEmpty(String bucketName)
See
GoogleCloudStorage.waitForBucketEmpty(String) for details about expected behavior. |
public static final String PATH_DELIMITER
public static final int BUCKET_EMPTY_MAX_RETRIES
public static final int BUCKET_EMPTY_WAIT_TIME_MS
public GoogleCloudStorageImpl(GoogleCloudStorageOptions options, com.google.api.client.auth.oauth2.Credential credential) throws IOException
credential - OAuth2 credential that allows access to GCSIOException - on IO errorpublic GoogleCloudStorageImpl(GoogleCloudStorageOptions options, com.google.api.services.storage.Storage gcs)
gcs - Preconstructed Storage to use for I/O.protected GoogleCloudStorageImpl()
public GoogleCloudStorageOptions getOptions()
GoogleCloudStoragegetOptions in interface GoogleCloudStoragepublic WritableByteChannel create(StorageResourceId resourceId, CreateObjectOptions options) throws IOException
GoogleCloudStoragecreate in interface GoogleCloudStorageresourceId - identifies a StorageObjectoptions - Options to use when creating the objectIOException - on IO errorpublic WritableByteChannel create(StorageResourceId resourceId) throws IOException
GoogleCloudStorage.create(StorageResourceId) for details about expected behavior.create in interface GoogleCloudStorageresourceId - identifies a StorageObjectIOException - on IO errorpublic void createEmptyObject(StorageResourceId resourceId, CreateObjectOptions options) throws IOException
GoogleCloudStoragecreateEmptyObject in interface GoogleCloudStorageresourceId - identifies a StorageObjectoptions - options to use when creating the objectIOException - on IO errorpublic void createEmptyObject(StorageResourceId resourceId) throws IOException
GoogleCloudStorage.createEmptyObject(StorageResourceId) for details about
expected behavior.createEmptyObject in interface GoogleCloudStorageresourceId - identifies a StorageObjectIOException - on IO errorpublic void createEmptyObjects(List<StorageResourceId> resourceIds, CreateObjectOptions options) throws IOException
GoogleCloudStorageGoogleCloudStorage.createEmptyObject(StorageResourceId) for
the single-item version of this method. Implementations may use different flow than the
single-item version for greater efficiency.createEmptyObjects in interface GoogleCloudStorageIOExceptionpublic void createEmptyObjects(List<StorageResourceId> resourceIds) throws IOException
GoogleCloudStorage.createEmptyObjects(List) for details about
expected behavior.createEmptyObjects in interface GoogleCloudStorageIOExceptionpublic SeekableByteChannel open(StorageResourceId resourceId) throws IOException
GoogleCloudStorage.open(StorageResourceId) for details about expected behavior.open in interface GoogleCloudStorageresourceId - identifies a StorageObjectFileNotFoundException - if the given object does not existIOException - if object exists but cannot be openedpublic void create(String bucketName) throws IOException
GoogleCloudStorage.create(String) for details about expected
behavior.create in interface GoogleCloudStoragebucketName - name of the bucket to createIOException - on IO errorpublic void create(String bucketName, CreateBucketOptions options) throws IOException
GoogleCloudStorage.create(String, CreateBucketOptions) for
details about expected behavior.create in interface GoogleCloudStoragebucketName - name of the bucket to createoptions - options to use when creating bucketIOException - on IO errorpublic void deleteBuckets(List<String> bucketNames) throws IOException
GoogleCloudStorage#deleteBuckets(List) for details about expected behavior.deleteBuckets in interface GoogleCloudStoragebucketNames - name of the buckets to deleteFileNotFoundException - if the given bucket does not existIOException - on IO errorpublic void deleteObjects(List<StorageResourceId> fullObjectNames) throws IOException
GoogleCloudStorage#deleteObjects(List) for details about
expected behavior.deleteObjects in interface GoogleCloudStoragefullObjectNames - names of objects to delete with their respective bucketNames.FileNotFoundException - if the given object does not existIOException - if object exists but cannot be deletedpublic static void validateCopyArguments(String srcBucketName, List<String> srcObjectNames, String dstBucketName, List<String> dstObjectNames, GoogleCloudStorage gcsImpl) throws IOException
Preconditions in addition to checking for src/dst bucket existence and compatibility of bucket
properties such as location and storage-class.gcsImpl - A GoogleCloudStorage for retrieving bucket info via getItemInfo, but only if
srcBucketName != dstBucketName; passed as a parameter so that this static method can be
used by other implementations of GoogleCloudStorage that want to preserve the validation
behavior of GoogleCloudStorageImpl, including disallowing cross-location copies.IOExceptionpublic void copy(String srcBucketName, List<String> srcObjectNames, String dstBucketName, List<String> dstObjectNames) throws IOException
GoogleCloudStorage.copy(String, List, String, List) for details
about expected behavior.copy in interface GoogleCloudStoragesrcBucketName - name of the bucket containing the objects to copysrcObjectNames - names of the objects to copydstBucketName - name of the bucket to copy todstObjectNames - names of the objects after copyFileNotFoundException - if the source object or the destination bucket does not existIOException - in all other error casespublic List<String> listBucketNames() throws IOException
GoogleCloudStorage.listBucketNames() for details about expected behavior.listBucketNames in interface GoogleCloudStorageIOExceptionpublic List<GoogleCloudStorageItemInfo> listBucketInfo() throws IOException
GoogleCloudStorage.listBucketInfo() for details about expected behavior.listBucketInfo in interface GoogleCloudStorageIOExceptionpublic List<String> listObjectNames(String bucketName, String objectNamePrefix, String delimiter) throws IOException
GoogleCloudStorage.listObjectNames(String, String, String)
for details about expected behavior.listObjectNames in interface GoogleCloudStoragebucketName - bucket nameobjectNamePrefix - object name prefix or null if all objects in the bucket are desireddelimiter - delimiter to use (typically "/"), otherwise nullIOException - on IO errorpublic List<String> listObjectNames(String bucketName, String objectNamePrefix, String delimiter, long maxResults) throws IOException
GoogleCloudStorage.listObjectNames(String, String, String, long)
for details about expected behavior.listObjectNames in interface GoogleCloudStoragebucketName - bucket nameobjectNamePrefix - object name prefix or null if all objects in the bucket are desireddelimiter - delimiter to use (typically "/"), otherwise nullmaxResults - maximum number of results to return,
unlimited if negative or zeroIOException - on IO errorpublic List<GoogleCloudStorageItemInfo> listObjectInfo(String bucketName, String objectNamePrefix, String delimiter) throws IOException
GoogleCloudStorage.listObjectInfo(String, String, String)
for details about expected behavior.listObjectInfo in interface GoogleCloudStoragebucketName - bucket nameobjectNamePrefix - object name prefix or null if all objects in the bucket are desireddelimiter - delimiter to use (typically "/"), otherwise nullIOException - on IO errorpublic List<GoogleCloudStorageItemInfo> listObjectInfo(String bucketName, String objectNamePrefix, String delimiter, long maxResults) throws IOException
GoogleCloudStorage.listObjectInfo(String, String, String, long)
for details about expected behavior.listObjectInfo in interface GoogleCloudStoragebucketName - bucket nameobjectNamePrefix - object name prefix or null if all objects in the bucket are desireddelimiter - delimiter to use (typically "/"), otherwise nullmaxResults - maximum number of results to return,
unlimited if negative or zeroIOException - on IO errorpublic static GoogleCloudStorageItemInfo createItemInfoForInferredDirectory(StorageResourceId resourceId)
protected static GoogleCloudStorageItemInfo createItemInfoForNotFound(StorageResourceId resourceId)
public List<GoogleCloudStorageItemInfo> getItemInfos(List<StorageResourceId> resourceIds) throws IOException
GoogleCloudStorage#getItemInfos(List) for details about expected
behavior.getItemInfos in interface GoogleCloudStorageresourceIds - names of the GCS StorageObjects or Buckets for which to retrieve info.IOException - on IO errorpublic List<GoogleCloudStorageItemInfo> updateItems(List<UpdatableItemInfo> itemInfoList) throws IOException
GoogleCloudStorageupdateItems in interface GoogleCloudStorageIOException - on IO errorpublic GoogleCloudStorageItemInfo getItemInfo(StorageResourceId resourceId) throws IOException
GoogleCloudStorage.getItemInfo(StorageResourceId) for details about expected
behavior.getItemInfo in interface GoogleCloudStorageresourceId - identifies either root, a Bucket, or a StorageObjectIOException - on IO errorpublic void close()
GoogleCloudStorage.close() for details about expected behavior.close in interface GoogleCloudStoragepublic void waitForBucketEmpty(String bucketName) throws IOException
GoogleCloudStorage.waitForBucketEmpty(String) for details about expected behavior.waitForBucketEmpty in interface GoogleCloudStorageIOExceptionpublic void compose(String bucketName, List<String> sources, String destination, String contentType) throws IOException
GoogleCloudStoragecompose in interface GoogleCloudStoragebucketName - name of the bucket containing the sources and the destinationsources - names of the objects to be composeddestination - name of the resulting objectcontentType - content-type of composed objectIOException - if the Compose operation was unsuccessfulCopyright © 2016. All rights reserved.