public class ContentStoreServiceImpl extends AbstractCachedContentStoreService
ContentStoreService. Extends from
AbstractCachedContentStoreService to use caching.| Modifier and Type | Field and Description |
|---|---|
protected Map<String,Context> |
contexts
Map of open
Contexts |
protected DescriptorMerger |
merger
Merges a bunch of descriptors
|
protected DescriptorMergeStrategyResolver |
mergeStrategyResolver
Resolves the
DescriptorMergeStrategy to use for a particular descriptor. |
protected ItemProcessorResolver |
processorResolver
Resolves the
ItemProcessor to use for a particular Item. |
protected ContentStoreAdapterRegistry |
storeAdapterRegistry
Registry of
ContentStoreAdapters. |
cacheTemplate, CONST_KEY_ELEM_CHILDREN, CONST_KEY_ELEM_ITEM, CONST_KEY_ELEM_TREE, defaultCachingOptionsUNLIMITED_TREE_DEPTH| Constructor and Description |
|---|
ContentStoreServiceImpl()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Context |
createContext(String storeType,
String storeServerUrl,
String username,
String password,
String rootFolderPath,
boolean mergingOn,
boolean cacheOn,
int maxAllowedItemsInCache,
boolean ignoreHiddenFiles)
Returns a new context with the specified params, login in to a remote repository (if needed) and creating a
new cache scope associated to the context.
|
protected String |
createContextId(String storeType,
String storeServerUrl,
String username,
String password,
String rootFolderPath,
boolean cacheOn,
int maxAllowedItemsInCache,
boolean ignoreHiddenFiles) |
boolean |
destroyContext(Context context)
Destroys the specified context, login out of any remote repository (if a login was issued) and destroying the
cache scope associated to the context.
|
protected List<Item> |
doFilter(List<Item> items,
ItemFilter filter,
boolean runningBeforeProcessing)
Filters the given list of items by using the specified filter.
|
protected List<Item> |
doFindChildren(Context context,
CachingOptions cachingOptions,
String url,
Integer depth,
ItemFilter filter,
ItemProcessor processor)
Does the following:
Retrieves the children from the underlying repository (without their descriptors).
Filters the returned list if
ItemFilter.runBeforeProcessing() returns true.
Calls AbstractCachedContentStoreService.getTree(Context, String) or AbstractCachedContentStoreService.getItem(Context, String) for each item in the list
(depending on whether the item is a folder or not, and if depth is not null), to obtain the
merged and processed version of each item.
Filters the processed list if ItemFilter.runAfterProcessing() returns true.
Returns the final list of processed items.
|
protected List<Item> |
doFindChildren(Context context,
CachingOptions cachingOptions,
String url,
ItemFilter filter,
ItemProcessor processor) |
protected Item |
doFindItem(Context context,
CachingOptions cachingOptions,
String url,
ItemProcessor processor)
Returns the content store item for the given url, returning null if not found.
|
protected Tree |
doFindTree(Context context,
CachingOptions cachingOptions,
String url,
int depth,
ItemFilter filter,
ItemProcessor processor) |
protected Item |
doMerging(Context context,
CachingOptions cachingOptions,
Item item)
Executes merging for the specified
Item:
Gets the DescriptorMergeStrategy for the item's descriptor from
the DescriptorMergeStrategyResolver.
Gets the actual descriptors to merge from the returned merge strategy.
Retrieves the descriptor documents from the underlying repository.
Merges the descriptor documents.
Returns the item with the merged descriptor document.
|
protected Item |
doProcessing(Context context,
CachingOptions cachingOptions,
Item item,
ItemProcessor additionalProcessor)
Executes processing for the specified
Item:
Gets the main ItemProcessor for the item from the ItemProcessorResolver.
Calls the main processor's process method to process the item.
If an additional processor was passed to this method, the additional processor is also called.
Returns the processed item.
|
boolean |
exists(Context context,
String url)
Returns true if the file or folder at the specified URL exists
|
Content |
findContent(Context context,
CachingOptions cachingOptions,
String url)
Returns the content of the file for the given url, returning null if not found.
|
Content |
findContent(Context context,
String url)
Returns the content of the file for the given url, returning null if not found.
|
Content |
getContent(Context context,
CachingOptions cachingOptions,
String url)
Returns the content of the file for the given url.
|
Content |
getContent(Context context,
String url)
Returns the content of the file for the given url.
|
Context |
getContext(String contextId)
Returns the open
Context for the given ID, or null if no context found for the ID. |
void |
setMerger(DescriptorMerger merger)
Sets the
DescriptorMerger, which merges the primary descriptor with a list of other descriptors,
according to
the merge strategy. |
void |
setMergeStrategyResolver(DescriptorMergeStrategyResolver mergeStrategyResolver)
Sets the
DescriptorMergeStrategyResolver, which resolves the .DescriptorMergeStrategy to use for a particular
descriptor. |
void |
setProcessorResolver(ItemProcessorResolver processorResolver)
|
void |
setStoreAdapterRegistry(ContentStoreAdapterRegistry storeAdapterRegistry)
Registry of
ContentStoreAdapters. |
boolean |
validate(Context context)
Returns true if the specified context is still valid and usable.
|
findChildren, findChildren, findItem, findItem, findTree, findTree, findTree, getChildren, getChildren, getItem, getItem, getTree, getTree, getTree, setCacheTemplate, setDefaultCachingOptionsprotected ContentStoreAdapterRegistry storeAdapterRegistry
ContentStoreAdapters.protected DescriptorMergeStrategyResolver mergeStrategyResolver
DescriptorMergeStrategy to use for a particular descriptor.protected DescriptorMerger merger
protected ItemProcessorResolver processorResolver
ItemProcessor to use for a particular Item.public ContentStoreServiceImpl()
Contexts.public void setStoreAdapterRegistry(ContentStoreAdapterRegistry storeAdapterRegistry)
ContentStoreAdapters.public void setMergeStrategyResolver(DescriptorMergeStrategyResolver mergeStrategyResolver)
DescriptorMergeStrategyResolver, which resolves the .DescriptorMergeStrategy to use for a particular
descriptor.public void setMerger(DescriptorMerger merger)
DescriptorMerger, which merges the primary descriptor with a list of other descriptors,
according to
the merge strategy.public void setProcessorResolver(ItemProcessorResolver processorResolver)
public Context getContext(String contextId)
Context for the given ID, or null if no context found for the ID.public Context createContext(String storeType, String storeServerUrl, String username, String password, String rootFolderPath, boolean mergingOn, boolean cacheOn, int maxAllowedItemsInCache, boolean ignoreHiddenFiles) throws InvalidStoreTypeException, RootFolderNotFoundException, StoreException, AuthenticationException
public boolean validate(Context context) throws StoreException, AuthenticationException
ContentStoreServicepublic boolean destroyContext(Context context) throws InvalidContextException, StoreException, AuthenticationException
InvalidContextExceptionStoreExceptionAuthenticationExceptionpublic boolean exists(Context context, String url) throws InvalidContextException, PathNotFoundException, StoreException
ContentStoreServicecontext - the context with the store configuration (required)url - the url of the file (required)InvalidContextException - if the context is invalidPathNotFoundException - if the file the url points to can't be foundStoreException - if an error occurred while accessing the content storepublic Content findContent(Context context, String url) throws InvalidContextException, StoreException
ContentStoreServicecontext - the context with the store configuration (required)url - the url of the file (required)InvalidContextException - if the context is invalidStoreException - if an error occurred while accessing the content storepublic Content findContent(Context context, CachingOptions cachingOptions, String url) throws InvalidContextException, StoreException
ContentStoreServicecontext - the context with the store configuration (required)cachingOptions - the caching options for any caching operation done inside this service call (optional)url - the url of the file (required)InvalidContextException - if the context is invalidStoreException - if an error occurred while accessing the content storepublic Content getContent(Context context, String url) throws InvalidScopeException, PathNotFoundException, StoreException
context - the context with the store configuration (required)url - the url of the file (required)PathNotFoundException - if the file the url points to can't be foundStoreException - if an error occurred while accessing the content storeInvalidScopeExceptionpublic Content getContent(Context context, CachingOptions cachingOptions, String url) throws InvalidScopeException, PathNotFoundException, StoreException
context - the context with the store configuration (required)cachingOptions - the caching options for any caching operation done inside this service call (optional)url - the url of the file (required)PathNotFoundException - if the file the url points to can't be foundStoreException - if an error occurred while accessing the content storeInvalidScopeExceptionprotected Item doFindItem(Context context, CachingOptions cachingOptions, String url, ItemProcessor processor) throws InvalidContextException, XmlFileParseException, XmlMergeException, ItemProcessingException, StoreException
After acquiring the item from the ContentStoreAdapter, the item's descriptor is merged (according
to its DescriptorMergeStrategy) with related descriptors, and the
final item is then processed.
doFindItem in class AbstractCachedContentStoreServiceInvalidContextExceptionXmlFileParseExceptionXmlMergeExceptionItemProcessingExceptionStoreExceptionprotected List<Item> doFindChildren(Context context, CachingOptions cachingOptions, String url, ItemFilter filter, ItemProcessor processor) throws InvalidContextException, XmlFileParseException, XmlMergeException, ItemProcessingException, StoreException
doFindChildren in class AbstractCachedContentStoreServiceInvalidContextExceptionXmlFileParseExceptionXmlMergeExceptionItemProcessingExceptionStoreExceptionprotected Tree doFindTree(Context context, CachingOptions cachingOptions, String url, int depth, ItemFilter filter, ItemProcessor processor) throws InvalidContextException, XmlFileParseException, XmlMergeException, ItemProcessingException, StoreException
doFindTree in class AbstractCachedContentStoreServiceInvalidContextExceptionXmlFileParseExceptionXmlMergeExceptionItemProcessingExceptionStoreExceptionprotected List<Item> doFindChildren(Context context, CachingOptions cachingOptions, String url, Integer depth, ItemFilter filter, ItemProcessor processor) throws InvalidContextException, XmlFileParseException, XmlMergeException, ItemProcessingException, StoreException
ItemFilter.runBeforeProcessing() returns true.AbstractCachedContentStoreService.getTree(Context, String) or AbstractCachedContentStoreService.getItem(Context, String) for each item in the list
(depending on whether the item is a folder or not, and if depth is not null), to obtain the
merged and processed version of each item.ItemFilter.runAfterProcessing() returns true.protected Item doMerging(Context context, CachingOptions cachingOptions, Item item) throws CrafterException
Item:
DescriptorMergeStrategy for the item's descriptor from
the DescriptorMergeStrategyResolver.CrafterExceptionprotected Item doProcessing(Context context, CachingOptions cachingOptions, Item item, ItemProcessor additionalProcessor) throws ItemProcessingException
Item:
ItemProcessor for the item from the ItemProcessorResolver.process method to process the item.ItemProcessingExceptionprotected List<Item> doFilter(List<Item> items, ItemFilter filter, boolean runningBeforeProcessing)
runningBeforeProcessing flag
is passed to indicated the filter in which phase it is being executed (after or before processing).Copyright © 2018 CrafterCMS. All rights reserved.