Package com.adobe.testing.s3mock.store
Class BucketStore
java.lang.Object
com.adobe.testing.s3mock.store.BucketStore
Stores buckets and their metadata created in S3Mock.
API Reference
-
Constructor Summary
ConstructorsConstructorDescriptionBucketStore(File rootFolder, boolean retainFilesOnExit, DateTimeFormatter s3ObjectDateFormat, com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptionaddToBucket(String key, String bucketName) Adds key to a bucket.createBucket(String bucketName, boolean objectLockEnabled) Creates a new bucket.booleandeleteBucket(String bucketName) Deletes a Bucket and all of its contents.doesBucketExist(String bucketName) Checks if the specified bucket exists.getBucketMetadata(String bucketName) Retrieves BucketMetadata identified by its name.booleanisBucketEmpty(String bucketName) Checks if the specified bucket exists and if it is empty.isObjectLockEnabled(String bucketName) Lists all BucketMetadata managed by this store.lookupKeysInBucket(String prefix, String bucketName) Look up keys by prefix in a bucket.booleanremoveFromBucket(String key, String bucketName) Removes key from a bucket.voidstoreBucketLifecycleConfiguration(String bucketName, BucketLifecycleConfiguration configuration) voidstoreObjectLockConfiguration(String bucketName, ObjectLockConfiguration configuration)
-
Constructor Details
-
BucketStore
public BucketStore(File rootFolder, boolean retainFilesOnExit, DateTimeFormatter s3ObjectDateFormat, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
listBuckets
Lists all BucketMetadata managed by this store.- Returns:
- List of all BucketMetadata.
-
getBucketMetadata
Retrieves BucketMetadata identified by its name.- Parameters:
bucketName- name of the bucket to be retrieved- Returns:
- the BucketMetadata or null if not found
-
addToBucket
Adds key to a bucket.- Parameters:
key- the key to addbucketName- name of the bucket to be retrieved- Returns:
- UUID assigned to key
-
lookupKeysInBucket
Look up keys by prefix in a bucket.- Parameters:
prefix- the prefix to filter onbucketName- name of the bucket to be retrieved- Returns:
- List of UUIDs of keys matching the prefix
-
removeFromBucket
Removes key from a bucket.- Parameters:
key- the key to removebucketName- name of the bucket to be retrieved- Returns:
- true if key existed and was removed
-
storeObjectLockConfiguration
-
storeBucketLifecycleConfiguration
public void storeBucketLifecycleConfiguration(String bucketName, BucketLifecycleConfiguration configuration) -
createBucket
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
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
-
isBucketEmpty
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
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.
-