Package org.craftercms.core.store.impl
Class AbstractFileBasedContentStoreAdapter
- java.lang.Object
-
- org.craftercms.core.store.impl.AbstractCachedContentStoreAdapter
-
- org.craftercms.core.store.impl.AbstractFileBasedContentStoreAdapter
-
- All Implemented Interfaces:
ContentStoreAdapter
- Direct Known Subclasses:
FileSystemContentStoreAdapter
public abstract class AbstractFileBasedContentStoreAdapter extends AbstractCachedContentStoreAdapter
File-based content store adapter. Takes away common stuff from actual implementations, like handling metadata files and loading descriptor DOMs.- Author:
- Alfonso Vásquez
-
-
Field Summary
Fields Modifier and Type Field Description protected Stringcharsetstatic StringDEFAULT_CHARSETprotected StringdescriptorFileExtensionprotected StringmetadataFileExtensionprotected org.craftercms.commons.validation.validators.Validator<String>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
Constructors Constructor Description AbstractFileBasedContentStoreAdapter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected org.dom4j.io.SAXReadercreateXmlReader()Creates and configures an XML SAX reader.booleandoExists(Context context, CachingOptions cachingOptions, String path)protected ContentdoFindContent(Context context, CachingOptions cachingOptions, String path)protected ItemdoFindItem(Context context, CachingOptions cachingOptions, String path, boolean withDescriptor)protected List<Item>doFindItems(Context context, CachingOptions cachingOptions, String path)protected abstract FilefindFile(Context context, CachingOptions cachingOptions, String path)Returns theFileat the given path, returning null if not found.protected abstract List<File>getChildren(Context context, CachingOptions cachingOptions, File dir)Returns the list of children of the given directory.protected abstract ContentgetContent(Context context, CachingOptions cachingOptions, File file)Returns theContentfor the given file.voidsetCharset(String charset)voidsetDescriptorFileExtension(String descriptorFileExtension)voidsetMetadataFileExtension(String metadataFileExtension)voidsetPathValidator(org.craftercms.commons.validation.validators.Validator<String> pathValidator)protected voidvalidatePath(String path)-
Methods inherited from class org.craftercms.core.store.impl.AbstractCachedContentStoreAdapter
exists, findContent, findItem, findItems, setCacheTemplate, setDefaultCachingOptions
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.craftercms.core.store.ContentStoreAdapter
createContext, destroyContext, validate
-
-
-
-
Field Detail
-
DEFAULT_CHARSET
public static final String DEFAULT_CHARSET
- See Also:
- Constant Field Values
-
pathValidator
protected org.craftercms.commons.validation.validators.Validator<String> pathValidator
-
charset
protected String charset
-
descriptorFileExtension
protected String descriptorFileExtension
-
metadataFileExtension
protected String metadataFileExtension
-
-
Method Detail
-
setCharset
public void setCharset(String charset)
-
setPathValidator
public void setPathValidator(org.craftercms.commons.validation.validators.Validator<String> pathValidator)
-
setDescriptorFileExtension
public void setDescriptorFileExtension(String descriptorFileExtension)
-
setMetadataFileExtension
public void setMetadataFileExtension(String metadataFileExtension)
-
doExists
public boolean doExists(Context context, CachingOptions cachingOptions, String path) throws InvalidScopeException, StoreException
- Specified by:
doExistsin classAbstractCachedContentStoreAdapter- Throws:
InvalidScopeExceptionStoreException
-
doFindContent
protected Content doFindContent(Context context, CachingOptions cachingOptions, String path) throws InvalidContextException, StoreException
- Specified by:
doFindContentin classAbstractCachedContentStoreAdapter- Throws:
InvalidContextExceptionStoreException
-
doFindItem
protected Item doFindItem(Context context, CachingOptions cachingOptions, String path, boolean withDescriptor) throws InvalidContextException, PathNotFoundException, XmlFileParseException, StoreException
- Specified by:
doFindItemin classAbstractCachedContentStoreAdapter- Throws:
InvalidContextExceptionPathNotFoundExceptionXmlFileParseExceptionStoreException
-
doFindItems
protected List<Item> doFindItems(Context context, CachingOptions cachingOptions, String path) throws InvalidContextException, PathNotFoundException, XmlFileParseException, StoreException
- Specified by:
doFindItemsin classAbstractCachedContentStoreAdapter- Throws:
InvalidContextExceptionPathNotFoundExceptionXmlFileParseExceptionStoreException
-
createXmlReader
protected org.dom4j.io.SAXReader createXmlReader()
Creates and configures an XML SAX reader.
-
validatePath
protected void validatePath(String path) throws StoreException
- Throws:
StoreException
-
getContent
protected abstract Content getContent(Context context, CachingOptions cachingOptions, File file) throws InvalidContextException, StoreException
Returns theContentfor the given file.
-
findFile
protected abstract File findFile(Context context, CachingOptions cachingOptions, String path) throws InvalidContextException, StoreException
Returns theFileat the given path, returning null if not found.
-
getChildren
protected abstract List<File> getChildren(Context context, CachingOptions cachingOptions, File dir) throws InvalidContextException, StoreException
Returns the list of children of the given directory.
-
-