Package com.totvs.tjf.storage
Class GoogleCloudStorageService
- java.lang.Object
-
- com.totvs.tjf.storage.GoogleCloudStorageService
-
- All Implemented Interfaces:
com.totvs.tjf.storage.StorageService
@Component public class GoogleCloudStorageService extends Object implements com.totvs.tjf.storage.StorageService
This class gives supports to the Google Cloud Storage
-
-
Constructor Summary
Constructors Constructor Description GoogleCloudStorageService(GoogleCloudStorageProperties applicationProperties, Optional<com.totvs.tjf.storage.PropertiesProvider> propertiesProvider)
Creates an instance of GoogleCloudStorageService
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
createBucket(String bucketName, com.totvs.tjf.storage.Property... properties)
Creates a BucketString
createDeleteSignedUrl(String bucketName, String blobName, String expiresIn, com.totvs.tjf.storage.Property... properties)
Creates a delete signed urlString
createDownloadSignedUrl(String bucketName, String blobName, String expiresIn, com.totvs.tjf.storage.Property... properties)
Creates a download signed urlString
createUploadSignedUrl(String bucketName, String blobName, String type, String expiresIn, com.totvs.tjf.storage.Property... properties)
Creates a upload signed urlvoid
deleteBucket(String bucketName, com.totvs.tjf.storage.Property... properties)
Deletes a Bucketvoid
deleteObject(String bucketName, String name, com.totvs.tjf.storage.Property... properties)
Deletes an objectboolean
hasBucket(String bucketName, com.totvs.tjf.storage.Property... properties)
Checks if the Bucket existsString[]
listObjects(String bucketName, String startsWith, com.totvs.tjf.storage.Property... properties)
List object's names based on an optional prefix stringbyte[]
loadObject(String bucketName, String name, com.totvs.tjf.storage.Property... properties)
Loads the object's contentList<com.google.cloud.storage.Blob>
loadObjectsByIds(String bucketName, List<String> blobIds, com.totvs.tjf.storage.Property... properties)
Loads the content of all ids informedList<com.google.cloud.storage.Blob>
loadObjectsByIds(List<com.google.cloud.storage.BlobId> blobIds, com.totvs.tjf.storage.Property... properties)
Loads the content of all ids informedvoid
saveObject(String bucketName, String name, String type, byte[] content, com.totvs.tjf.storage.Property... properties)
Saves an object
-
-
-
Constructor Detail
-
GoogleCloudStorageService
public GoogleCloudStorageService(GoogleCloudStorageProperties applicationProperties, Optional<com.totvs.tjf.storage.PropertiesProvider> propertiesProvider)
Creates an instance of GoogleCloudStorageService- Parameters:
applicationProperties
- static application propertiespropertiesProvider
- application properties provider
-
-
Method Detail
-
createBucket
public void createBucket(String bucketName, com.totvs.tjf.storage.Property... properties) throws IOException
Creates a Bucket- Specified by:
createBucket
in interfacecom.totvs.tjf.storage.StorageService
- Parameters:
bucketName
- the bucket's nameproperties
- specific connection properties- Throws:
IOException
- an IO exception of this operation
-
hasBucket
public boolean hasBucket(String bucketName, com.totvs.tjf.storage.Property... properties) throws IOException
Checks if the Bucket exists- Specified by:
hasBucket
in interfacecom.totvs.tjf.storage.StorageService
- Parameters:
bucketName
- the bucket's nameproperties
- specific connection properties- Returns:
- boolean true if buckets exists or false if not
- Throws:
IOException
- an IO exception of this operation
-
deleteBucket
public void deleteBucket(String bucketName, com.totvs.tjf.storage.Property... properties) throws IOException, com.totvs.tjf.storage.ObjectNotFoundException
Deletes a Bucket- Specified by:
deleteBucket
in interfacecom.totvs.tjf.storage.StorageService
- Parameters:
bucketName
- the bucket's nameproperties
- specific connection properties- Throws:
IOException
- an IO exception of this operationcom.totvs.tjf.storage.ObjectNotFoundException
- an object not found exception
-
saveObject
public void saveObject(String bucketName, String name, String type, byte[] content, com.totvs.tjf.storage.Property... properties) throws IOException, com.totvs.tjf.storage.ObjectNotFoundException
Saves an object- Specified by:
saveObject
in interfacecom.totvs.tjf.storage.StorageService
- Parameters:
bucketName
- the bucket's namename
- the object's nametype
- the object's mime typecontent
- the object's contentproperties
- specific connection properties- Throws:
IOException
- an IO exception of this operationcom.totvs.tjf.storage.ObjectNotFoundException
- an object not found exception
-
loadObject
public byte[] loadObject(String bucketName, String name, com.totvs.tjf.storage.Property... properties) throws IOException, com.totvs.tjf.storage.ObjectNotFoundException
Loads the object's content- Specified by:
loadObject
in interfacecom.totvs.tjf.storage.StorageService
- Parameters:
bucketName
- the bucket's namename
- the object's nameproperties
- specific connection properties- Returns:
- byte[] the object's content
- Throws:
IOException
- an IO exception of this operationcom.totvs.tjf.storage.ObjectNotFoundException
- an object not found exception
-
loadObjectsByIds
public List<com.google.cloud.storage.Blob> loadObjectsByIds(String bucketName, List<String> blobIds, com.totvs.tjf.storage.Property... properties) throws IOException
Loads the content of all ids informed- Specified by:
loadObjectsByIds
in interfacecom.totvs.tjf.storage.StorageService
- Parameters:
bucketName
- bucket nameblobIds
- list of stringsproperties
- specific connection properties- Returns:
- multitype:Blob a list of all the objects content
- Throws:
IOException
- an IO exception of this operation
-
loadObjectsByIds
public List<com.google.cloud.storage.Blob> loadObjectsByIds(List<com.google.cloud.storage.BlobId> blobIds, com.totvs.tjf.storage.Property... properties) throws IOException
Loads the content of all ids informed- Specified by:
loadObjectsByIds
in interfacecom.totvs.tjf.storage.StorageService
- Parameters:
blobIds
- list of BlobIdproperties
- specific connection properties- Returns:
- multitype:Blob a list of all the objects content
- Throws:
IOException
- an IO exception of this operation- See Also:
BlobId
-
deleteObject
public void deleteObject(String bucketName, String name, com.totvs.tjf.storage.Property... properties) throws IOException, com.totvs.tjf.storage.ObjectNotFoundException
Deletes an object- Specified by:
deleteObject
in interfacecom.totvs.tjf.storage.StorageService
- Parameters:
bucketName
- the bucket's namename
- the object's nameproperties
- specific connection properties- Throws:
IOException
- an IO exception of this operationcom.totvs.tjf.storage.ObjectNotFoundException
- an object not found exception
-
listObjects
public String[] listObjects(String bucketName, String startsWith, com.totvs.tjf.storage.Property... properties) throws IOException, com.totvs.tjf.storage.ObjectNotFoundException
List object's names based on an optional prefix string- Specified by:
listObjects
in interfacecom.totvs.tjf.storage.StorageService
- Parameters:
bucketName
- the bucket's namestartsWith
- a prefix stringproperties
- specific connection properties- Returns:
- string[] a list of object's names
- Throws:
IOException
- an IO exception of this operationcom.totvs.tjf.storage.ObjectNotFoundException
- an object not found exception
-
createDownloadSignedUrl
public String createDownloadSignedUrl(String bucketName, String blobName, String expiresIn, com.totvs.tjf.storage.Property... properties) throws IOException, com.totvs.tjf.storage.ObjectNotFoundException
Creates a download signed url- Specified by:
createDownloadSignedUrl
in interfacecom.totvs.tjf.storage.StorageService
- Parameters:
bucketName
- the bucket's nameblobName
- the object's nameproperties
- specific connection properties- Returns:
- the signed url
- Throws:
IOException
- an IO exception of this operationcom.totvs.tjf.storage.ObjectNotFoundException
- an object not found exception
-
createDeleteSignedUrl
public String createDeleteSignedUrl(String bucketName, String blobName, String expiresIn, com.totvs.tjf.storage.Property... properties) throws IOException, com.totvs.tjf.storage.ObjectNotFoundException
Creates a delete signed url- Specified by:
createDeleteSignedUrl
in interfacecom.totvs.tjf.storage.StorageService
- Parameters:
bucketName
- the bucket's nameblobName
- the object's nameproperties
- specific connection properties- Returns:
- string the signed url
- Throws:
IOException
- an IO exception of this operationcom.totvs.tjf.storage.ObjectNotFoundException
- an object not found exception
-
createUploadSignedUrl
public String createUploadSignedUrl(String bucketName, String blobName, String type, String expiresIn, com.totvs.tjf.storage.Property... properties) throws IOException, com.totvs.tjf.storage.ObjectNotFoundException
Creates a upload signed url- Specified by:
createUploadSignedUrl
in interfacecom.totvs.tjf.storage.StorageService
- Parameters:
bucketName
- the bucket's nameblobName
- the object's nametype
- the object's mimetypeproperties
- specific connection properties- Returns:
- string the signed url
- Throws:
IOException
- an IO exception of this operationcom.totvs.tjf.storage.ObjectNotFoundException
- an object not found exception
-
-