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.S3Clientprotected final S3ClientBuilderprotected final intstatic final StringFields inherited from class org.craftercms.engine.store.AbstractCachedFileBasedContentStoreAdapter
CONST_KEY_ELEM_CHILDREN, CONST_KEY_ELEM_FILEFields inherited from class org.craftercms.core.store.impl.AbstractFileBasedContentStoreAdapter
charset, DEFAULT_CHARSET, descriptorFileExtension, metadataFileExtension, pathValidatorFields 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 TypeMethodDescriptionvoidorg.craftercms.core.service.ContextcreateContext(String id, String rootFolderPath, boolean mergingOn, boolean cacheOn, int maxAllowedItemsInCache, boolean ignoreHiddenFiles, Map<String, String> configurationVariables) voiddestroy()voiddestroyContext(org.craftercms.core.service.Context context) protected org.craftercms.core.store.impl.FiledoFindFile(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.ContentgetContent(org.craftercms.core.service.Context context, org.craftercms.core.service.CachingOptions cachingOptions, org.craftercms.core.store.impl.File file) protected booleanisResultEmpty(software.amazon.awssdk.services.s3.model.ListObjectsV2Response result) Check if the result of listing S3 object response is emptybooleanvalidate(org.craftercms.core.service.Context context) Methods inherited from class org.craftercms.engine.store.AbstractCachedFileBasedContentStoreAdapter
findFile, getChildrenMethods inherited from class org.craftercms.core.store.impl.AbstractFileBasedContentStoreAdapter
createXmlReader, doExists, doFindContent, doFindItem, doFindItems, setCharset, validatePathMethods 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:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
destroy
public void destroy()- Specified by:
destroyin 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:
createContextin interfaceorg.craftercms.core.store.ContentStoreAdapter- Throws:
org.craftercms.core.exception.RootFolderNotFoundExceptionorg.craftercms.core.exception.StoreExceptionorg.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:
getContentin classorg.craftercms.core.store.impl.AbstractFileBasedContentStoreAdapter- Throws:
org.craftercms.core.exception.InvalidContextExceptionorg.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:
doFindFilein classAbstractCachedFileBasedContentStoreAdapter- Throws:
org.craftercms.core.exception.InvalidContextExceptionorg.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:
doGetChildrenin classAbstractCachedFileBasedContentStoreAdapter- Throws:
org.craftercms.core.exception.InvalidContextExceptionorg.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:
validatein interfaceorg.craftercms.core.store.ContentStoreAdapter- Throws:
org.craftercms.core.exception.StoreExceptionorg.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:
destroyContextin interfaceorg.craftercms.core.store.ContentStoreAdapter- Throws:
org.craftercms.core.exception.StoreExceptionorg.craftercms.core.exception.AuthenticationException
-