Interface ObjectStorageOperations<I,O,D>

Type Parameters:
I - Cloud vendor-specific upload request class or builder.
O - Cloud vendor-specific upload response.
D - Cloud vendor-specific delete response.
All Known Implementing Classes:
AwsS3Operations, AzureBlobStorageOperations, GoogleCloudStorageOperations, LocalStorageOperations, OracleCloudStorageOperations

public interface ObjectStorageOperations<I,O,D>
Main interface for object storage operations.
Since:
1.0
Author:
Pavol Gressa
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    copy(@NonNull String sourceKey, @NonNull String destinationKey)
    Copies an object stored at sourceKey to destinationKey, within the same object storage (bucket/container).
    delete(@NonNull String key)
    Deletes an object from the object storage.
    default boolean
    exists(@NonNull String key)
    Checks whether an entry with the given key exists in the object storage.
    default @NonNull Set<String>
    Lists the objects that exist in the object storage.
    <E extends ObjectStorageEntry<?>>
    @NonNull Optional<E>
    retrieve(@NonNull String key)
    Gets the object from object storage.
    @NonNull UploadResponse<O>
    upload(@NonNull UploadRequest request)
    Uploads an object to the object storage.
    @NonNull UploadResponse<O>
    upload(@NonNull UploadRequest request, @NonNull Consumer<I> requestConsumer)
    Uploads an object to the object storage.
  • Method Details

    • upload

      @NonNull @NonNull UploadResponse<O> upload(@NonNull @NonNull UploadRequest request)
      Uploads an object to the object storage. If there is an existing entry, it will be updated.
      Parameters:
      request - the upload request
      Returns:
      the upload response
      Throws:
      ObjectStorageException - if there was a failure storing the object
    • upload

      @NonNull @NonNull UploadResponse<O> upload(@NonNull @NonNull UploadRequest request, @NonNull @NonNull Consumer<I> requestConsumer)
      Uploads an object to the object storage. If there is an existing entry, it will be updated.
      Parameters:
      request - the upload request
      requestConsumer - Upload request builder consumer
      Returns:
      the upload response
      Throws:
      ObjectStorageException - if there was a failure storing the object
    • retrieve

      @NonNull <E extends ObjectStorageEntry<?>> @NonNull Optional<E> retrieve(@NonNull @NonNull String key)
      Gets the object from object storage.
      Type Parameters:
      E - an instance of ObjectStorageEntry.
      Parameters:
      key - the object path in the format /foo/bar/file
      Returns:
      the object, or empty optional if the object does not exist
      Throws:
      ObjectStorageException - if there was a failure retrieving the object
    • delete

      @NonNull D delete(@NonNull @NonNull String key)
      Deletes an object from the object storage.
      Parameters:
      key - object path in the format /foo/bar/file
      Returns:
      Cloud vendor-specific delete response.
      Throws:
      ObjectStorageException - if there was a failure deleting the object
    • exists

      default boolean exists(@NonNull @NonNull String key)
      Checks whether an entry with the given key exists in the object storage.
      Parameters:
      key - object path in the format /foo/bar/file
      Returns:
      true if the entry exists, false otherwise.
      Since:
      1.1.0
    • listObjects

      @NonNull default @NonNull Set<String> listObjects()
      Lists the objects that exist in the object storage.
      Returns:
      a list of keys (paths) of the existing objects, if any, or an empty list otherwise.
      Since:
      1.1.0
    • copy

      default void copy(@NonNull @NonNull String sourceKey, @NonNull @NonNull String destinationKey)
      Copies an object stored at sourceKey to destinationKey, within the same object storage (bucket/container). If the destination exists, it will be overwritten.
      Parameters:
      sourceKey - the key of the source object
      destinationKey - the key of the destination object
      Since:
      1.1.0