Class ObjectStore

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

public class ObjectStore extends Object
Stores objects and their metadata created in S3Mock.
  • 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 ID
      key - object key to be stored.
      contentType - The Content Type.
      storeHeaders - Various headers to store, like Content Encoding.
      dataStream - The InputStream to store.
      useV4ChunkedWithSigningFormat - If true, 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

      public void storeObjectTags(BucketMetadata bucket, UUID id, List<Tag> tags)
      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

      public void storeLegalHold(BucketMetadata bucket, UUID id, LegalHold legalHold)
      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

      public void storeAcl(BucketMetadata bucket, UUID id, AccessControlPolicy policy)
      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

      public AccessControlPolicy readAcl(BucketMetadata bucket, UUID id)
    • storeRetention

      public void storeRetention(BucketMetadata bucket, UUID id, Retention retention)
      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

      public S3ObjectMetadata getS3ObjectMetadata(BucketMetadata bucket, UUID id)
      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:
      CopyObjectResult or 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

      public boolean deleteObject(BucketMetadata bucket, UUID id)
      Removes an object key from a bucket.
      Parameters:
      bucket - bucket containing the object.
      id - object to be deleted.
      Returns:
      true if deletion succeeded.