Package org.craftercms.engine.store.s3
Class S3ContentStoreAdapter
java.lang.Object
org.craftercms.core.store.impl.AbstractCachedContentStoreAdapter
org.craftercms.core.store.impl.AbstractFileBasedContentStoreAdapter
org.craftercms.engine.store.AbstractCachedFileBasedContentStoreAdapter
org.craftercms.engine.store.s3.S3ContentStoreAdapter
- All Implemented Interfaces:
org.craftercms.core.store.ContentStoreAdapter
,org.springframework.beans.factory.DisposableBean
,org.springframework.beans.factory.InitializingBean
public class S3ContentStoreAdapter
extends AbstractCachedFileBasedContentStoreAdapter
implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
Implementation of
ContentStoreAdapter
to read files from AWS S3.- Author:
- joseross
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final String[]
protected software.amazon.awssdk.services.s3.S3Client
protected final S3ClientBuilder
protected final int
static final String
Fields inherited from class org.craftercms.engine.store.AbstractCachedFileBasedContentStoreAdapter
CONST_KEY_ELEM_CHILDREN, CONST_KEY_ELEM_FILE
Fields inherited from class org.craftercms.core.store.impl.AbstractFileBasedContentStoreAdapter
charset, DEFAULT_CHARSET, descriptorFileExtension, metadataFileExtension, pathValidator
Fields inherited from class org.craftercms.core.store.impl.AbstractCachedContentStoreAdapter
cacheTemplate, CONST_KEY_ELEM_CONTENT, CONST_KEY_ELEM_EXISTS, CONST_KEY_ELEM_ITEM, CONST_KEY_ELEM_ITEMS, defaultCachingOptions
-
Constructor Summary
ConstructorsConstructorDescriptionS3ContentStoreAdapter
(org.springframework.validation.Validator pathValidator, String descriptorFileExtension, String metadataFileExtension, org.craftercms.core.util.cache.CacheTemplate cacheTemplate, S3ClientBuilder clientBuilder, int contentMaxLength, String[] cacheAllowedPaths) -
Method Summary
Modifier and TypeMethodDescriptionvoid
org.craftercms.core.service.Context
createContext
(String id, String rootFolderPath, boolean mergingOn, boolean cacheOn, int maxAllowedItemsInCache, boolean ignoreHiddenFiles, Map<String, String> configurationVariables) void
destroy()
void
destroyContext
(org.craftercms.core.service.Context context) protected org.craftercms.core.store.impl.File
doFindFile
(org.craftercms.core.service.Context context, String path) protected List
<org.craftercms.core.store.impl.File> doGetChildren
(org.craftercms.core.service.Context context, org.craftercms.core.store.impl.File dir) protected org.craftercms.core.service.Content
getContent
(org.craftercms.core.service.Context context, org.craftercms.core.service.CachingOptions cachingOptions, org.craftercms.core.store.impl.File file) protected boolean
isResultEmpty
(software.amazon.awssdk.services.s3.model.ListObjectsV2Response result) Check if the result of listing S3 object response is emptyboolean
validate
(org.craftercms.core.service.Context context) Methods inherited from class org.craftercms.engine.store.AbstractCachedFileBasedContentStoreAdapter
findFile, getChildren
Methods inherited from class org.craftercms.core.store.impl.AbstractFileBasedContentStoreAdapter
createXmlReader, doExists, doFindContent, doFindItem, doFindItems, setCharset, validatePath
Methods inherited from class org.craftercms.core.store.impl.AbstractCachedContentStoreAdapter
exists, findContent, findItem, findItems, setDefaultCachingOptions
-
Field Details
-
DELIMITER
- See Also:
-
clientBuilder
-
client
protected software.amazon.awssdk.services.s3.S3Client client -
contentMaxLength
protected final int contentMaxLength -
cacheAllowedPaths
-
-
Constructor Details
-
S3ContentStoreAdapter
@ConstructorProperties({"pathValidator","descriptorFileExtension","metadataFileExtension","cacheTemplate","clientBuilder","contentMaxLength","cacheAllowedPaths"}) public S3ContentStoreAdapter(org.springframework.validation.Validator pathValidator, String descriptorFileExtension, String metadataFileExtension, org.craftercms.core.util.cache.CacheTemplate cacheTemplate, S3ClientBuilder clientBuilder, int contentMaxLength, String[] cacheAllowedPaths)
-
-
Method Details
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
destroy
public void destroy()- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
-
isResultEmpty
protected boolean isResultEmpty(software.amazon.awssdk.services.s3.model.ListObjectsV2Response result) Check if the result of listing S3 object response is empty- Parameters:
result
- instance ofListObjectsV2Response
- Returns:
- true if the result is empty, false otherwise
-
createContext
public org.craftercms.core.service.Context createContext(String id, String rootFolderPath, boolean mergingOn, boolean cacheOn, int maxAllowedItemsInCache, boolean ignoreHiddenFiles, Map<String, String> configurationVariables) throws org.craftercms.core.exception.RootFolderNotFoundException, org.craftercms.core.exception.StoreException, org.craftercms.core.exception.AuthenticationException- Specified by:
createContext
in interfaceorg.craftercms.core.store.ContentStoreAdapter
- Throws:
org.craftercms.core.exception.RootFolderNotFoundException
org.craftercms.core.exception.StoreException
org.craftercms.core.exception.AuthenticationException
-
getContent
protected org.craftercms.core.service.Content getContent(org.craftercms.core.service.Context context, org.craftercms.core.service.CachingOptions cachingOptions, org.craftercms.core.store.impl.File file) throws org.craftercms.core.exception.InvalidContextException, org.craftercms.core.exception.StoreException - Specified by:
getContent
in classorg.craftercms.core.store.impl.AbstractFileBasedContentStoreAdapter
- Throws:
org.craftercms.core.exception.InvalidContextException
org.craftercms.core.exception.StoreException
-
doFindFile
protected org.craftercms.core.store.impl.File doFindFile(org.craftercms.core.service.Context context, String path) throws org.craftercms.core.exception.InvalidContextException, org.craftercms.core.exception.StoreException - Specified by:
doFindFile
in classAbstractCachedFileBasedContentStoreAdapter
- Throws:
org.craftercms.core.exception.InvalidContextException
org.craftercms.core.exception.StoreException
-
doGetChildren
protected List<org.craftercms.core.store.impl.File> doGetChildren(org.craftercms.core.service.Context context, org.craftercms.core.store.impl.File dir) throws org.craftercms.core.exception.InvalidContextException, org.craftercms.core.exception.StoreException - Specified by:
doGetChildren
in classAbstractCachedFileBasedContentStoreAdapter
- Throws:
org.craftercms.core.exception.InvalidContextException
org.craftercms.core.exception.StoreException
-
validate
public boolean validate(org.craftercms.core.service.Context context) throws org.craftercms.core.exception.StoreException, org.craftercms.core.exception.AuthenticationException - Specified by:
validate
in interfaceorg.craftercms.core.store.ContentStoreAdapter
- Throws:
org.craftercms.core.exception.StoreException
org.craftercms.core.exception.AuthenticationException
-
destroyContext
public void destroyContext(org.craftercms.core.service.Context context) throws org.craftercms.core.exception.StoreException, org.craftercms.core.exception.AuthenticationException - Specified by:
destroyContext
in interfaceorg.craftercms.core.store.ContentStoreAdapter
- Throws:
org.craftercms.core.exception.StoreException
org.craftercms.core.exception.AuthenticationException
-