Package com.adobe.testing.s3mock.store
Class ObjectStore
java.lang.Object
com.adobe.testing.s3mock.store.ObjectStore
Stores objects and their metadata created in S3Mock.
-
Constructor Summary
ConstructorsConstructorDescriptionObjectStore(boolean retainFilesOnExit, DateTimeFormatter s3ObjectDateFormat, com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptioncopyS3Object(BucketMetadata sourceBucket, UUID sourceId, BucketMetadata destinationBucket, UUID destinationId, String destinationKey, Map<String, String> encryptionHeaders, Map<String, String> userMetadata) Copies an object to another bucket and encrypted object.booleandeleteObject(BucketMetadata bucket, UUID id) Removes an object key from a bucket.getS3ObjectMetadata(BucketMetadata bucket, UUID id) Retrieves S3ObjectMetadata for a UUID of a key from a bucket.pretendToCopyS3Object(BucketMetadata sourceBucket, UUID sourceId, Map<String, String> userMetadata) If source and destination is the same, pretend we copied - S3 does the same.readAcl(BucketMetadata bucket, UUID id) voidstoreAcl(BucketMetadata bucket, UUID id, AccessControlPolicy policy) Store ACL for a given object.voidstoreLegalHold(BucketMetadata bucket, UUID id, LegalHold legalHold) Store legal hold for a given object.voidstoreObjectTags(BucketMetadata bucket, UUID id, List<Tag> tags) Store tags for a given object.voidstoreRetention(BucketMetadata bucket, UUID id, Retention retention) Store retention for a given object.storeS3ObjectMetadata(BucketMetadata bucket, UUID id, String key, String contentType, Map<String, String> storeHeaders, InputStream dataStream, boolean useV4ChunkedWithSigningFormat, Map<String, String> userMetadata, Map<String, String> encryptionHeaders, String etag, List<Tag> tags, ChecksumAlgorithm checksumAlgorithm, String checksum, Owner owner) Stores an object inside a Bucket.
-
Constructor Details
-
ObjectStore
public ObjectStore(boolean retainFilesOnExit, DateTimeFormatter s3ObjectDateFormat, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
storeS3ObjectMetadata
public S3ObjectMetadata storeS3ObjectMetadata(BucketMetadata bucket, UUID id, String key, String contentType, Map<String, String> storeHeaders, InputStream dataStream, boolean useV4ChunkedWithSigningFormat, Map<String, String> userMetadata, Map<String, String> encryptionHeaders, String etag, List<Tag> tags, ChecksumAlgorithm checksumAlgorithm, String checksum, Owner owner) Stores an object inside a Bucket.- Parameters:
bucket- Bucket to store the object in.id- object IDkey- object key to be stored.contentType- The Content Type.storeHeaders- Various headers to store, like Content Encoding.dataStream- The InputStream to store.useV4ChunkedWithSigningFormat- Iftrue, V4-style signing is enabled.userMetadata- User metadata to store for this object, will be available for the object with the key prefixed with "x-amz-meta-".etag- the etag. If null, etag will be computed by this method.tags- The tags to store.- Returns:
S3ObjectMetadata.
-
storeObjectTags
Store tags for a given object.- Parameters:
bucket- Bucket the object is stored in.id- object ID to store tags for.tags- List of tag objects.
-
storeLegalHold
Store legal hold for a given object.- Parameters:
bucket- Bucket the object is stored in.id- object ID to store tags for.legalHold- the legal hold.
-
storeAcl
Store ACL for a given object.- Parameters:
bucket- Bucket the object is stored in.id- object ID to store tags for.policy- the ACL.
-
readAcl
-
storeRetention
Store retention for a given object.- Parameters:
bucket- Bucket the object is stored in.id- object ID to store tags for.retention- the retention.
-
getS3ObjectMetadata
Retrieves S3ObjectMetadata for a UUID of a key from a bucket.- Parameters:
bucket- Bucket from which to retrieve the object.id- ID of the object key.- Returns:
- S3ObjectMetadata or null if not found
-
copyS3Object
public CopyObjectResult copyS3Object(BucketMetadata sourceBucket, UUID sourceId, BucketMetadata destinationBucket, UUID destinationId, String destinationKey, Map<String, String> encryptionHeaders, Map<String, String> userMetadata) Copies an object to another bucket and encrypted object.- Parameters:
sourceBucket- bucket to copy from.sourceId- source object ID.destinationBucket- destination bucket.destinationId- destination object ID.destinationKey- destination object key.userMetadata- User metadata to store for destination object- Returns:
CopyObjectResultor null if source couldn't be found.
-
pretendToCopyS3Object
public CopyObjectResult pretendToCopyS3Object(BucketMetadata sourceBucket, UUID sourceId, Map<String, String> userMetadata) If source and destination is the same, pretend we copied - S3 does the same. This does not change the modificationDate. Also, this would need to increment the version if/when we support versioning. -
deleteObject
Removes an object key from a bucket.- Parameters:
bucket- bucket containing the object.id- object to be deleted.- Returns:
- true if deletion succeeded.
-