Class BucketStore

java.lang.Object
com.adobe.testing.s3mock.store.BucketStore

public class BucketStore extends Object
Stores buckets and their metadata created in S3Mock. API Reference
  • Constructor Details

    • BucketStore

      public BucketStore(File rootFolder, boolean retainFilesOnExit, DateTimeFormatter s3ObjectDateFormat, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
  • Method Details

    • listBuckets

      public List<BucketMetadata> listBuckets()
      Lists all BucketMetadata managed by this store.
      Returns:
      List of all BucketMetadata.
    • getBucketMetadata

      public BucketMetadata getBucketMetadata(String bucketName)
      Retrieves BucketMetadata identified by its name.
      Parameters:
      bucketName - name of the bucket to be retrieved
      Returns:
      the BucketMetadata or null if not found
    • addToBucket

      public UUID addToBucket(String key, String bucketName)
      Adds key to a bucket.
      Parameters:
      key - the key to add
      bucketName - name of the bucket to be retrieved
      Returns:
      UUID assigned to key
    • lookupKeysInBucket

      public List<UUID> lookupKeysInBucket(String prefix, String bucketName)
      Look up keys by prefix in a bucket.
      Parameters:
      prefix - the prefix to filter on
      bucketName - name of the bucket to be retrieved
      Returns:
      List of UUIDs of keys matching the prefix
    • removeFromBucket

      public boolean removeFromBucket(String key, String bucketName)
      Removes key from a bucket.
      Parameters:
      key - the key to remove
      bucketName - name of the bucket to be retrieved
      Returns:
      true if key existed and was removed
    • storeObjectLockConfiguration

      public void storeObjectLockConfiguration(String bucketName, ObjectLockConfiguration configuration)
    • storeBucketLifecycleConfiguration

      public void storeBucketLifecycleConfiguration(String bucketName, BucketLifecycleConfiguration configuration)
    • createBucket

      public BucketMetadata createBucket(String bucketName, boolean objectLockEnabled)
      Creates a new bucket.
      Parameters:
      bucketName - of the Bucket to be created.
      Returns:
      the newly created Bucket.
      Throws:
      IllegalStateException - if the bucket cannot be created or the bucket already exists but is not a directory.
    • doesBucketExist

      public Boolean doesBucketExist(String bucketName)
      Checks if the specified bucket exists. Amazon S3 buckets are named in a global namespace; use this method to determine if a specified bucket name already exists, and therefore can't be used to create a new bucket.
      Parameters:
      bucketName - of the bucket to check for existence
      Returns:
      true if Bucket exists
    • isObjectLockEnabled

      public Boolean isObjectLockEnabled(String bucketName)
    • isBucketEmpty

      public boolean isBucketEmpty(String bucketName)
      Checks if the specified bucket exists and if it is empty.
      Parameters:
      bucketName - of the bucket to check for existence
      Returns:
      true if Bucket is empty
    • deleteBucket

      public boolean deleteBucket(String bucketName)
      Deletes a Bucket and all of its contents. TODO: in S3, all objects within a bucket must be deleted before deleting a bucket!
      Parameters:
      bucketName - of the bucket to be deleted.
      Returns:
      true if deletion succeeded.