Package org.duracloud.s3storage
Class S3StorageProvider
java.lang.Object
org.duracloud.storage.provider.StorageProviderBase
org.duracloud.s3storage.S3StorageProvider
- All Implemented Interfaces:
StorageProvider
Provides content storage backed by Amazon's Simple Storage Service.
- Author:
- Bill Branan
-
Nested Class Summary
Nested classes/interfaces inherited from class org.duracloud.storage.provider.StorageProviderBase
StorageProviderBase.SpaceDeleteWorker -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected static final com.amazonaws.services.s3.model.StorageClassprotected static final Stringprotected static final Stringstatic final Stringprotected static final intprotected com.amazonaws.services.s3.AmazonS3Fields inherited from class org.duracloud.storage.provider.StorageProviderBase
ACL_DELIM, ACL_GROUP_READ, ACL_GROUP_WRITE, ACL_USER_READ, ACL_USER_WRITEFields inherited from interface org.duracloud.storage.provider.StorageProvider
DEFAULT_MAX_RESULTS, DEFAULT_MIMETYPE, ISO8601_DATE_FORMAT, PROPERTIES_BUCKET, PROPERTIES_CONTENT_CHECKSUM, PROPERTIES_CONTENT_CREATOR, PROPERTIES_CONTENT_FILE_CREATED, PROPERTIES_CONTENT_FILE_LAST_ACCESSED, PROPERTIES_CONTENT_FILE_MODIFIED, PROPERTIES_CONTENT_FILE_PATH, PROPERTIES_CONTENT_MD5, PROPERTIES_CONTENT_MIMETYPE, PROPERTIES_CONTENT_MODIFIED, PROPERTIES_CONTENT_SIZE, PROPERTIES_COPY_SOURCE, PROPERTIES_COPY_SOURCE_STORE, PROPERTIES_HLS_STREAMING_HOST, PROPERTIES_HLS_STREAMING_TYPE, PROPERTIES_SPACE_ACL, PROPERTIES_SPACE_ACL_GROUP, PROPERTIES_SPACE_ACL_PUBLIC, PROPERTIES_SPACE_COUNT, PROPERTIES_SPACE_CREATED, PROPERTIES_SPACE_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionS3StorageProvider(com.amazonaws.services.s3.AmazonS3 s3Client, String accessKey, Map<String, String> options) S3StorageProvider(String accessKey, String secretKey) -
Method Summary
Modifier and TypeMethodDescriptionaddContent(String spaceId, String contentId, String contentMimeType, Map<String, String> userProperties, long contentSize, String contentChecksum, InputStream content) addHiddenContent(String spaceId, String contentId, String contentMimeType, InputStream content) Adds content to a hidden space.copyContent(String sourceSpaceId, String sourceContentId, String destSpaceId, String destContentId) protected com.amazonaws.services.s3.model.BucketcreateBucket(String spaceId) createHiddenSpace(String spaceId, int expirationInDays) Creates a "hidden" space.voidcreateSpace(String spaceId) protected static StringdecodeHeaderKey(String userMetaName) protected static StringdecodeHeaderValue(String userMetaValue) voiddeleteContent(String spaceId, String contentId) protected StringdoesContentExistWithExpectedChecksum(String bucketName, String contentId, String expectedChecksum) protected voiddoSetSpaceProperties(String spaceId, Map<String, String> spaceProperties) protected static StringencodeHeaderKey(String userMetaName) Ensures compliance with https://tools.ietf.org/html/rfc5987#section-3.2.2protected static StringencodeHeaderValue(String userMetaValue) Ensures compliance with https://tools.ietf.org/html/rfc5987#section-3.2.2protected StringformattedDate(Date date) getAllSpaceProperties(String spaceId) protected StringgetBucketCreationDate(String bucketName) getBucketName(String spaceId) Gets the name of an existing bucket based on a space ID.getContent(String spaceId, String contentId) getContent(String spaceId, String contentId, String range) getContentProperties(String spaceId, String contentId) protected StringgetETagValue(String etag) protected StringgetHiddenBucketName(String spaceId) protected StringgetNewBucketName(String spaceId) getSpaceContents(String spaceId, String prefix) getSpaceContentsChunked(String spaceId, String prefix, long maxResults, String marker) protected StringgetSpaceCount(String spaceId, int maxCount) protected StringgetSpaceFree(String name) Replaces all spaces with "%20"protected StringgetSpaceId(String bucketName) Converts a bucket name into what could be passed in as a space ID.getSpaceProperties(String spaceId) protected StoragePolicyDefines the storage policy for the primary S3 provider.protected StringgetWithSpace(String name) Converts "%20" back to spacesprotected booleanDetermines if an S3 bucket is a DuraCloud spaceprepContentProperties(com.amazonaws.services.s3.model.ObjectMetadata objMetadata) removeCalculatedProperties(Map<String, String> contentProperties) voidremoveSpace(String spaceId) voidvoidsetSpaceLifecycle(String bucketName, com.amazonaws.services.s3.model.BucketLifecycleConfiguration config) Sets a lifecycle policy on an S3 bucket based on the given configurationprotected booleanspaceExists(String spaceId) protected voidthrowIfContentNotExist(String bucketName, String contentId) protected voidupdateObjectProperties(String bucketName, String contentId, com.amazonaws.services.s3.model.ObjectMetadata objMetadata) protected voidwait(int seconds) Methods inherited from class org.duracloud.storage.provider.StorageProviderBase
deleteSpace, deleteSpaceSync, getSpaceACLs, getSpaceDeleteWorker, packACLs, setNewSpaceProperties, setNewSpaceProperties, setSpaceACLs, setWrappedStorageProvider, throwIfSpaceNotExist, throwIfSpaceNotExist, unpackACLs
-
Field Details
-
MAX_ITEM_COUNT
protected static final int MAX_ITEM_COUNT- See Also:
-
DEFAULT_STORAGE_CLASS
protected static final com.amazonaws.services.s3.model.StorageClass DEFAULT_STORAGE_CLASS -
HIDDEN_SPACE_PREFIX
- See Also:
-
HEADER_VALUE_PREFIX
-
HEADER_KEY_SUFFIX
- See Also:
-
accessKeyId
-
s3Client
protected com.amazonaws.services.s3.AmazonS3 s3Client
-
-
Constructor Details
-
S3StorageProvider
-
S3StorageProvider
-
S3StorageProvider
-
-
Method Details
-
getStorageProviderType
-
getSpaces
-
getSpaceContents
-
getSpaceContentsChunked
-
spaceExists
- Specified by:
spaceExistsin classStorageProviderBase
-
createSpace
-
createBucket
-
getHiddenBucketName
-
createHiddenSpace
Creates a "hidden" space. This space will not be returned by the StorageProvider.getSpaces() method. It can be accessed using the getSpace* methods. You must know the name of the space in order to access it.- Parameters:
spaceId- The spaceIdexpirationInDays- The number of days before content in the space is automatically deleted.- Returns:
-
getStoragePolicy
Defines the storage policy for the primary S3 provider. Subclasses can define different policy choices.- Returns:
- storage policy to set, or null if no policy should be defined
-
setSpaceLifecycle
public void setSpaceLifecycle(String bucketName, com.amazonaws.services.s3.model.BucketLifecycleConfiguration config) Sets a lifecycle policy on an S3 bucket based on the given configuration- Parameters:
bucketName- name of the bucket to updateconfig- bucket lifecycle configuration
-
getNewBucketName
-
formattedDate
-
removeSpace
- Specified by:
removeSpacein classStorageProviderBase
-
getAllSpaceProperties
- Specified by:
getAllSpacePropertiesin classStorageProviderBase
-
getSpaceCount
-
getBucketCreationDate
-
doSetSpaceProperties
- Specified by:
doSetSpacePropertiesin classStorageProviderBase
-
replaceInMapValues
-
addHiddenContent
public String addHiddenContent(String spaceId, String contentId, String contentMimeType, InputStream content) Adds content to a hidden space.- Parameters:
spaceId- hidden spaceIdcontentId-contentMimeType-content-- Returns:
-
addContent
-
doesContentExistWithExpectedChecksum
-
wait
protected void wait(int seconds) -
copyContent
-
getContent
-
getContent
-
deleteContent
-
setContentProperties
-
removeCalculatedProperties
- Overrides:
removeCalculatedPropertiesin classStorageProviderBase
-
throwIfContentNotExist
-
updateObjectProperties
-
getContentProperties
-
getSpaceProperties
- Specified by:
getSpacePropertiesin interfaceStorageProvider- Overrides:
getSpacePropertiesin classStorageProviderBase
-
prepContentProperties
-
getETagValue
-
getBucketName
Gets the name of an existing bucket based on a space ID. If no bucket with this spaceId exists, throws a NotFoundException- Parameters:
spaceId- the space Id to convert into an S3 bucket name- Returns:
- S3 bucket name of a given DuraCloud space
- Throws:
NotFoundException- if no bucket matches this spaceID
-
getSpaceId
Converts a bucket name into what could be passed in as a space ID.- Parameters:
bucketName- name of the S3 bucket- Returns:
- the DuraCloud space name equivalent to a given S3 bucket Id
-
isSpace
Determines if an S3 bucket is a DuraCloud space- Parameters:
bucketName- name of the S3 bucket- Returns:
- true if the given S3 bucket name is named according to the DuraCloud space naming conventions, false otherwise
-
getSpaceFree
Replaces all spaces with "%20"- Parameters:
name- string with possible space- Returns:
- converted to string without spaces
-
getWithSpace
Converts "%20" back to spaces- Parameters:
name- string- Returns:
- converted to spaces
-
encodeHeaderValue
Ensures compliance with https://tools.ietf.org/html/rfc5987#section-3.2.2- Parameters:
userMetaValue-- Returns:
-
decodeHeaderValue
-
encodeHeaderKey
Ensures compliance with https://tools.ietf.org/html/rfc5987#section-3.2.2- Parameters:
userMetaName-- Returns:
-
decodeHeaderKey
-