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 voidcreateBucket(String bucketName, com.totvs.tjf.storage.Property... properties)Creates a BucketStringcreateDeleteSignedUrl(String bucketName, String blobName, String expiresIn, com.totvs.tjf.storage.Property... properties)Creates a delete signed urlStringcreateDownloadSignedUrl(String bucketName, String blobName, String expiresIn, com.totvs.tjf.storage.Property... properties)Creates a download signed urlStringcreateUploadSignedUrl(String bucketName, String blobName, String type, String expiresIn, com.totvs.tjf.storage.Property... properties)Creates a upload signed urlvoiddeleteBucket(String bucketName, com.totvs.tjf.storage.Property... properties)Deletes a BucketvoiddeleteObject(String bucketName, String name, com.totvs.tjf.storage.Property... properties)Deletes an objectbooleanhasBucket(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 informedvoidsaveObject(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:
createBucketin 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:
hasBucketin 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:
deleteBucketin 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:
saveObjectin 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:
loadObjectin 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:
loadObjectsByIdsin 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:
loadObjectsByIdsin 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:
deleteObjectin 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:
listObjectsin 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:
createDownloadSignedUrlin 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:
createDeleteSignedUrlin 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:
createUploadSignedUrlin 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
-
-