Class StructuredContentServiceImpl
java.lang.Object
org.broadleafcommerce.cms.structure.service.StructuredContentServiceImpl
- All Implemented Interfaces:
StructuredContentService
@Service("blStructuredContentService")
public class StructuredContentServiceImpl
extends Object
implements StructuredContentService
- Author:
- bpolster
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static Stringprotected javax.cache.CacheManagerprotected List<RuleProcessor<StructuredContentDTO>>protected EntityConfigurationprotected StructuredContentServiceExtensionManagerprotected static final Stringprotected LocaleServiceprotected static final org.apache.commons.logging.Logprotected StaticAssetPathServiceprotected StaticAssetServiceprotected StatisticsServiceprotected javax.cache.Cacheprotected StructuredContentDao -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidvoidaddStructuredContentListToCache(String key, List<StructuredContentDTO> scDTOList) protected voidbuildFieldValues(StructuredContent sc, StructuredContentDTO scDTO, boolean secure) Parses the givenStructuredContentinto itsStructuredContentDTOrepresentation.protected voidbuildFieldValueWithCmsPrefix(String originalValue, StructuredContentDTO scDTO, boolean secure, String fieldKey) protected List<ItemCriteriaDTO>protected StringbuildNameKey(SandBox currentSandbox, Long site, Locale locale, String contentType, String contentName) protected StringbuildNameKey(SandBox currentSandbox, Long site, Locale locale, String contentType, String contentName, Boolean secure) Builds the DTO cache key based on the single SC item name.protected StringbuildNameKey(SandBox sandBox, StructuredContent sc) protected StringbuildNameKey(SandBox sandBox, StructuredContent sc, Boolean secure) protected StringbuildStructuredContentDTO(StructuredContent sc, boolean secure) Converts a StructuredContent into a StructuredContentDTO.buildStructuredContentDTOList(List<StructuredContent> structuredContentList, boolean secure) Converts a list of structured content items to a list of structured content DTOs.
Internally calls buildStructuredContentDTO(...).buildTypeKey(SandBox currentSandbox, Long site, Locale locale, String contentType) Builds the cache key for DTOLists based on the SC Type.protected StringbuildTypeKey(SandBox sandBox, StructuredContent sc) buildTypeKeyWithSecure(SandBox currentSandbox, Long site, Locale locale, String contentType, Boolean secure) Builds the cache key for DTOLists based on the SC Type.convertToDtos(List<StructuredContent> scs, boolean isSecure) Converts a list of StructuredContent objects into their correspondingStructuredContentDTOs.evaluateAndPriortizeContent(List<StructuredContentDTO> structuredContentList, int count, Map<String, Object> ruleDTOs) Finds all content items regardless of theSandboxthey are a member offindLanguageOnlyLocale(Locale locale) findStructuredContentById(Long contentId) Returns the StructuredContent item associated with the passed in id.Returns theStructuredContentTypeassociated with the passed in id.Returns theStructuredContentTypeassociated with the passed in String value.protected StructuredContentDTOjavax.cache.CachegetStructuredContentItemsByContentName(String contentName, Locale locale, boolean secure) First attempts to retrieveStructuredContentDTOfrom cache before making calls to databaseprotected booleanhasCmsPrefix(String originalValue, String cmsPrefix) lookupStructuredContentItemsByName(String contentName, Locale locale, Integer count, Map<String, Object> ruleDTOs, boolean secure) This method returns content by name only.lookupStructuredContentItemsByName(StructuredContentType contentType, String contentName, Locale locale, Integer count, Map<String, Object> ruleDTOs, boolean secure) This method returns content by name and type.lookupStructuredContentItemsByType(StructuredContentType contentType, Locale locale, Integer count, Map<String, Object> ruleDTOs, boolean secure) This method returns content
Returns active content items for the passed in sandbox that match the passed in type.protected List<StructuredContentDTO>modifyStructuredContentDtoList(List<StructuredContentDTO> structuredContentList) protected booleanprocessContentRules(StructuredContentDTO sc, Map<String, Object> ruleDTOs) protected List<StructuredContentDTO>processUnprioritizedContent(List<StructuredContentDTO> structuredContentList, Map<String, Object> ruleDTOs) voidremoveItemFromCache(String nameKey, String typeKey) Call to evict both secure and non-secure SC items matching the passed in keys.booleanCall to evict both secure and non-secure SC items matching the passed in key.voidremoveStructuredContentFromCache(SandBox sandBox, StructuredContent sc) Call to evict an item from the cache.Saves the given type and returns the merged instancevoidsetContentRuleProcessors(List<RuleProcessor<StructuredContentDTO>> contentRuleProcessors)
-
Field Details
-
LOG
protected static final org.apache.commons.logging.Log LOG -
FOREIGN_LOOKUP
- See Also:
-
AND
-
structuredContentDao
-
staticAssetService
-
staticAssetPathService
-
localeService
-
contentRuleProcessors
-
entityConfiguration
-
extensionManager
-
statisticsService
-
cacheManager
protected javax.cache.CacheManager cacheManager -
structuredContentCache
protected javax.cache.Cache structuredContentCache
-
-
Constructor Details
-
StructuredContentServiceImpl
public StructuredContentServiceImpl()
-
-
Method Details
-
findStructuredContentById
Description copied from interface:StructuredContentServiceReturns the StructuredContent item associated with the passed in id.- Specified by:
findStructuredContentByIdin interfaceStructuredContentService- Parameters:
contentId- - The id of the content item.- Returns:
- The associated structured content item.
-
findStructuredContentTypeById
Description copied from interface:StructuredContentServiceReturns theStructuredContentTypeassociated with the passed in id.- Specified by:
findStructuredContentTypeByIdin interfaceStructuredContentService- Parameters:
id- - The id of the content type.- Returns:
- The associated
StructuredContentType.
-
findStructuredContentTypeByName
Description copied from interface:StructuredContentServiceReturns theStructuredContentTypeassociated with the passed in String value.- Specified by:
findStructuredContentTypeByNamein interfaceStructuredContentService- Parameters:
name- - The name of the content type.- Returns:
- The associated
StructuredContentType.
-
retrieveAllStructuredContentTypes
- Specified by:
retrieveAllStructuredContentTypesin interfaceStructuredContentService- Returns:
- a list of all
StructuredContentTypes
-
findAllContentItems
Description copied from interface:StructuredContentServiceFinds all content items regardless of theSandboxthey are a member of- Specified by:
findAllContentItemsin interfaceStructuredContentService- Returns:
-
saveStructuredContentType
Saves the given type and returns the merged instance- Specified by:
saveStructuredContentTypein interfaceStructuredContentService
-
buildStructuredContentDTOList
public List<StructuredContentDTO> buildStructuredContentDTOList(List<StructuredContent> structuredContentList, boolean secure) Converts a list of structured content items to a list of structured content DTOs.
Internally calls buildStructuredContentDTO(...).- Specified by:
buildStructuredContentDTOListin interfaceStructuredContentService- Parameters:
structuredContentList-secure-- Returns:
-
evaluateAndPriortizeContent
public List<StructuredContentDTO> evaluateAndPriortizeContent(List<StructuredContentDTO> structuredContentList, int count, Map<String, Object> ruleDTOs) - Specified by:
evaluateAndPriortizeContentin interfaceStructuredContentService
-
processUnprioritizedContent
protected List<StructuredContentDTO> processUnprioritizedContent(List<StructuredContentDTO> structuredContentList, Map<String, Object> ruleDTOs) -
processContentRules
-
modifyStructuredContentDtoList
protected List<StructuredContentDTO> modifyStructuredContentDtoList(List<StructuredContentDTO> structuredContentList) -
lookupStructuredContentItemsByType
public List<StructuredContentDTO> lookupStructuredContentItemsByType(StructuredContentType contentType, Locale locale, Integer count, Map<String, Object> ruleDTOs, boolean secure) Description copied from interface:StructuredContentServiceThis method returns content
Returns active content items for the passed in sandbox that match the passed in type.
The SandBox parameter impacts the results as follows. If aSandBoxTypeof production is passed in, only those items in that SandBox are returned.
If a non-production SandBox is passed in, then the method will return the items associatd with the related production SandBox and then merge in the results of the passed in SandBox.
The secure item is used in cases where the structured content item contains an image path that needs to be rewritten to use https.- Specified by:
lookupStructuredContentItemsByTypein interfaceStructuredContentService- Parameters:
contentType- - the type of content to returncount- - the max number of content items to returnruleDTOs- - a Map of objects that will be used in MVEL processing.secure- - set to true if the request is being served over https- Returns:
- - The matching items
- See Also:
-
org.broadleafcommerce.cms.web.structure.DisplayContentTag
-
lookupStructuredContentItemsByName
public List<StructuredContentDTO> lookupStructuredContentItemsByName(StructuredContentType contentType, String contentName, Locale locale, Integer count, Map<String, Object> ruleDTOs, boolean secure) Description copied from interface:StructuredContentServiceThis method returns content by name and type.
Returns active content items for the passed in sandbox that match the passed in type.
The SandBox parameter impacts the results as follows. If aSandBoxTypeof production is passed in, only those items in that SandBox are returned.
If a non-production SandBox is passed in, then the method will return the items associatd with the related production SandBox and then merge in the results of the passed in SandBox.- Specified by:
lookupStructuredContentItemsByNamein interfaceStructuredContentService- Parameters:
contentType- - the type of content to returncontentName- - the name of content to returncount- - the max number of content items to returnruleDTOs- - a Map of objects that will be used in MVEL processing.secure- - set to true if the request is being served over https- Returns:
- - The matching items
- See Also:
-
org.broadleafcommerce.cms.web.structure.DisplayContentTag
-
convertToDtos
Description copied from interface:StructuredContentServiceConverts a list of StructuredContent objects into their correspondingStructuredContentDTOs. This method will utilize a cache in production mode, and it will additionally hydrate the returnedStructuredContentDTOobjects via the#hydrateForeignLookups(List)method.- Specified by:
convertToDtosin interfaceStructuredContentService- Returns:
- the list of
StructuredContentDTOs
-
lookupStructuredContentItemsByName
public List<StructuredContentDTO> lookupStructuredContentItemsByName(String contentName, Locale locale, Integer count, Map<String, Object> ruleDTOs, boolean secure) Description copied from interface:StructuredContentServiceThis method returns content by name only.
Returns active content items for the passed in sandbox that match the passed in type.
The SandBox parameter impacts the results as follows. If aSandBoxTypeof production is passed in, only those items in that SandBox are returned.
If a non-production SandBox is passed in, then the method will return the items associatd with the related production SandBox and then merge in the results of the passed in SandBox.- Specified by:
lookupStructuredContentItemsByNamein interfaceStructuredContentService- Parameters:
contentName- - the name of content to returncount- - the max number of content items to returnruleDTOs- - a Map of objects that will be used in MVEL processing.secure- - set to true if the request is being served over https- Returns:
- - The matching items
- See Also:
-
org.broadleafcommerce.cms.web.structure.DisplayContentTag
-
getContentRuleProcessors
-
setContentRuleProcessors
public void setContentRuleProcessors(List<RuleProcessor<StructuredContentDTO>> contentRuleProcessors) -
removeStructuredContentFromCache
Description copied from interface:StructuredContentServiceCall to evict an item from the cache.- Specified by:
removeStructuredContentFromCachein interfaceStructuredContentService
-
removeItemFromCacheByKey
Description copied from interface:StructuredContentServiceCall to evict both secure and non-secure SC items matching the passed in key.- Specified by:
removeItemFromCacheByKeyin interfaceStructuredContentService- Returns:
-
removeItemFromCache
Description copied from interface:StructuredContentServiceCall to evict both secure and non-secure SC items matching the passed in keys.- Specified by:
removeItemFromCachein interfaceStructuredContentService
-
findLanguageOnlyLocale
- Specified by:
findLanguageOnlyLocalein interfaceStructuredContentService
-
getStructuredContentCache
public javax.cache.Cache getStructuredContentCache()- Specified by:
getStructuredContentCachein interfaceStructuredContentService
-
buildRuleExpression
-
buildItemCriteriaDTOList
-
buildFieldValues
Parses the givenStructuredContentinto itsStructuredContentDTOrepresentation. This will also format the values fromStructuredContentDTO.getValues()into their actual data types. For instance, if the givenStructuredContenthas a DATE field, then this method will ensure that the resulting object in the values map of the DTO is aDaterather than just a String representing a date. Current support of parsing field types is: DATE -DateBOOLEAN -BooleanDECIMAL -BigDecimalINTEGER -IntegerMONEY -MoneyAll other fields are treated as strings. This will also fix URL strings that have the CMS prefix (like images) by prepending the standard CMS prefix with the particular environment prefix- Parameters:
sc-scDTO-secure-
-
hasCmsPrefix
-
buildFieldValueWithCmsPrefix
protected void buildFieldValueWithCmsPrefix(String originalValue, StructuredContentDTO scDTO, boolean secure, String fieldKey) -
buildStructuredContentDTO
Converts a StructuredContent into a StructuredContentDTO. If the item contains fields with broadleaf cms urls, the urls are converted to utilize the domain. The StructuredContentDTO is built via theEntityConfiguration. To override the actual type that is returned, include an override in an applicationContext like any other entity override.- Specified by:
buildStructuredContentDTOin interfaceStructuredContentService- Parameters:
sc-secure-- Returns:
-
buildNameKey
-
buildNameKey
-
buildNameKey
-
buildNameKey
protected String buildNameKey(SandBox currentSandbox, Long site, Locale locale, String contentType, String contentName, Boolean secure) Builds the DTO cache key based on the single SC item name.- Parameters:
currentSandbox-site-locale-contentType-contentName-secure-- Returns:
- cache key for single SC item DTO
-
buildTypeKey
-
buildTypeKey
Description copied from interface:StructuredContentServiceBuilds the cache key for DTOLists based on the SC Type.- Specified by:
buildTypeKeyin interfaceStructuredContentService- Returns:
- cache key for DTOList
-
buildTypeKeyWithSecure
public String buildTypeKeyWithSecure(SandBox currentSandbox, Long site, Locale locale, String contentType, Boolean secure) Description copied from interface:StructuredContentServiceBuilds the cache key for DTOLists based on the SC Type.- Specified by:
buildTypeKeyWithSecurein interfaceStructuredContentService- Returns:
- cache key for DTOList
-
addStructuredContentListToCache
- Specified by:
addStructuredContentListToCachein interfaceStructuredContentService
-
addSingleStructuredContentToCache
-
getSingleStructuredContentFromCache
-
getStructuredContentListFromCache
- Specified by:
getStructuredContentListFromCachein interfaceStructuredContentService
-
getStructuredContentItemsByContentName
public List<StructuredContentDTO> getStructuredContentItemsByContentName(String contentName, Locale locale, boolean secure) Description copied from interface:StructuredContentServiceFirst attempts to retrieveStructuredContentDTOfrom cache before making calls to database- Specified by:
getStructuredContentItemsByContentNamein interfaceStructuredContentService- Parameters:
contentName- (Name of ContentItem- Returns:
-