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<org.broadleafcommerce.common.rule.RuleProcessor<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>>protected org.broadleafcommerce.common.persistence.EntityConfigurationprotected StructuredContentServiceExtensionManagerprotected static final Stringprotected org.broadleafcommerce.common.locale.service.LocaleServiceprotected static final org.apache.commons.logging.Logprotected org.broadleafcommerce.common.file.service.StaticAssetPathServiceprotected StaticAssetServiceprotected org.broadleafcommerce.common.cache.StatisticsServiceprotected javax.cache.Cacheprotected StructuredContentDao -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddSingleStructuredContentToCache(String key, org.broadleafcommerce.common.structure.dto.StructuredContentDTO scDTO) voidaddStructuredContentListToCache(String key, List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> scDTOList) protected voidbuildFieldValues(StructuredContent sc, org.broadleafcommerce.common.structure.dto.StructuredContentDTO scDTO, boolean secure) Parses the givenStructuredContentinto itsStructuredContentDTOrepresentation.protected voidbuildFieldValueWithCmsPrefix(String originalValue, org.broadleafcommerce.common.structure.dto.StructuredContentDTO scDTO, boolean secure, String fieldKey) protected List<org.broadleafcommerce.common.structure.dto.ItemCriteriaDTO>protected StringbuildNameKey(org.broadleafcommerce.common.sandbox.domain.SandBox currentSandbox, Long site, org.broadleafcommerce.common.locale.domain.Locale locale, String contentType, String contentName) protected StringbuildNameKey(org.broadleafcommerce.common.sandbox.domain.SandBox currentSandbox, Long site, org.broadleafcommerce.common.locale.domain.Locale locale, String contentType, String contentName, Boolean secure) Builds the DTO cache key based on the single SC item name.protected StringbuildNameKey(org.broadleafcommerce.common.sandbox.domain.SandBox sandBox, StructuredContent sc) protected StringbuildNameKey(org.broadleafcommerce.common.sandbox.domain.SandBox sandBox, StructuredContent sc, Boolean secure) protected Stringorg.broadleafcommerce.common.structure.dto.StructuredContentDTObuildStructuredContentDTO(StructuredContent sc, boolean secure) Converts a StructuredContent into a StructuredContentDTO.List<org.broadleafcommerce.common.structure.dto.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(org.broadleafcommerce.common.sandbox.domain.SandBox currentSandbox, Long site, org.broadleafcommerce.common.locale.domain.Locale locale, String contentType) Builds the cache key for DTOLists based on the SC Type.protected StringbuildTypeKey(org.broadleafcommerce.common.sandbox.domain.SandBox sandBox, StructuredContent sc) buildTypeKeyWithSecure(org.broadleafcommerce.common.sandbox.domain.SandBox currentSandbox, Long site, org.broadleafcommerce.common.locale.domain.Locale locale, String contentType, Boolean secure) Builds the cache key for DTOLists based on the SC Type.List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>convertToDtos(List<StructuredContent> scs, boolean isSecure) Converts a list of StructuredContent objects into their correspondingStructuredContentDTOs.List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>evaluateAndPriortizeContent(List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> structuredContentList, int count, Map<String, Object> ruleDTOs) Finds all content items regardless of theSandboxthey are a member oforg.broadleafcommerce.common.locale.domain.LocalefindLanguageOnlyLocale(org.broadleafcommerce.common.locale.domain.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.List<org.broadleafcommerce.common.rule.RuleProcessor<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>>protected org.broadleafcommerce.common.structure.dto.StructuredContentDTOjavax.cache.CacheList<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>getStructuredContentItemsByContentName(String contentName, org.broadleafcommerce.common.locale.domain.Locale locale, boolean secure) First attempts to retrieveStructuredContentDTOfrom cache before making calls to databaseList<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>protected booleanhasCmsPrefix(String originalValue, String cmsPrefix) List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>lookupStructuredContentItemsByName(String contentName, org.broadleafcommerce.common.locale.domain.Locale locale, Integer count, Map<String, Object> ruleDTOs, boolean secure) This method returns content by name only.List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>lookupStructuredContentItemsByName(StructuredContentType contentType, String contentName, org.broadleafcommerce.common.locale.domain.Locale locale, Integer count, Map<String, Object> ruleDTOs, boolean secure) This method returns content by name and type.List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>lookupStructuredContentItemsByType(StructuredContentType contentType, org.broadleafcommerce.common.locale.domain.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<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>modifyStructuredContentDtoList(List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> structuredContentList) protected booleanprocessContentRules(org.broadleafcommerce.common.structure.dto.StructuredContentDTO sc, Map<String, Object> ruleDTOs) protected List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>processUnprioritizedContent(List<org.broadleafcommerce.common.structure.dto.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(org.broadleafcommerce.common.sandbox.domain.SandBox sandBox, StructuredContent sc) Call to evict an item from the cache.Saves the given type and returns the merged instancevoidsetContentRuleProcessors(List<org.broadleafcommerce.common.rule.RuleProcessor<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>> contentRuleProcessors)
-
Field Details
-
LOG
protected static final org.apache.commons.logging.Log LOG -
FOREIGN_LOOKUP
- See Also:
-
AND
-
structuredContentDao
-
staticAssetService
-
staticAssetPathService
protected org.broadleafcommerce.common.file.service.StaticAssetPathService staticAssetPathService -
localeService
protected org.broadleafcommerce.common.locale.service.LocaleService localeService -
contentRuleProcessors
protected List<org.broadleafcommerce.common.rule.RuleProcessor<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>> contentRuleProcessors -
entityConfiguration
protected org.broadleafcommerce.common.persistence.EntityConfiguration entityConfiguration -
extensionManager
-
statisticsService
protected org.broadleafcommerce.common.cache.StatisticsService 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<org.broadleafcommerce.common.structure.dto.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<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> evaluateAndPriortizeContent(List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> structuredContentList, int count, Map<String, Object> ruleDTOs) - Specified by:
evaluateAndPriortizeContentin interfaceStructuredContentService
-
processUnprioritizedContent
-
processContentRules
-
modifyStructuredContentDtoList
-
lookupStructuredContentItemsByType
public List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> lookupStructuredContentItemsByType(StructuredContentType contentType, org.broadleafcommerce.common.locale.domain.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<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> lookupStructuredContentItemsByName(StructuredContentType contentType, String contentName, org.broadleafcommerce.common.locale.domain.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
public List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> convertToDtos(List<StructuredContent> scs, boolean isSecure) 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<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> lookupStructuredContentItemsByName(String contentName, org.broadleafcommerce.common.locale.domain.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
public List<org.broadleafcommerce.common.rule.RuleProcessor<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>> getContentRuleProcessors() -
setContentRuleProcessors
public void setContentRuleProcessors(List<org.broadleafcommerce.common.rule.RuleProcessor<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>> contentRuleProcessors) -
removeStructuredContentFromCache
public void removeStructuredContentFromCache(org.broadleafcommerce.common.sandbox.domain.SandBox sandBox, StructuredContent sc) 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
public org.broadleafcommerce.common.locale.domain.Locale findLanguageOnlyLocale(org.broadleafcommerce.common.locale.domain.Locale locale) - Specified by:
findLanguageOnlyLocalein interfaceStructuredContentService
-
getStructuredContentCache
public javax.cache.Cache getStructuredContentCache()- Specified by:
getStructuredContentCachein interfaceStructuredContentService
-
buildRuleExpression
-
buildItemCriteriaDTOList
protected List<org.broadleafcommerce.common.structure.dto.ItemCriteriaDTO> buildItemCriteriaDTOList(StructuredContent sc) -
buildFieldValues
protected void buildFieldValues(StructuredContent sc, org.broadleafcommerce.common.structure.dto.StructuredContentDTO scDTO, boolean secure) 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
-
buildStructuredContentDTO
public org.broadleafcommerce.common.structure.dto.StructuredContentDTO buildStructuredContentDTO(StructuredContent sc, boolean secure) 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
protected String buildNameKey(org.broadleafcommerce.common.sandbox.domain.SandBox sandBox, StructuredContent sc) -
buildNameKey
protected String buildNameKey(org.broadleafcommerce.common.sandbox.domain.SandBox sandBox, StructuredContent sc, Boolean secure) -
buildNameKey
-
buildNameKey
protected String buildNameKey(org.broadleafcommerce.common.sandbox.domain.SandBox currentSandbox, Long site, org.broadleafcommerce.common.locale.domain.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
protected String buildTypeKey(org.broadleafcommerce.common.sandbox.domain.SandBox sandBox, StructuredContent sc) -
buildTypeKey
public String buildTypeKey(org.broadleafcommerce.common.sandbox.domain.SandBox currentSandbox, Long site, org.broadleafcommerce.common.locale.domain.Locale locale, String contentType) 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(org.broadleafcommerce.common.sandbox.domain.SandBox currentSandbox, Long site, org.broadleafcommerce.common.locale.domain.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
public void addStructuredContentListToCache(String key, List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> scDTOList) - Specified by:
addStructuredContentListToCachein interfaceStructuredContentService
-
addSingleStructuredContentToCache
protected void addSingleStructuredContentToCache(String key, org.broadleafcommerce.common.structure.dto.StructuredContentDTO scDTO) -
getSingleStructuredContentFromCache
protected org.broadleafcommerce.common.structure.dto.StructuredContentDTO getSingleStructuredContentFromCache(String key) -
getStructuredContentListFromCache
public List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> getStructuredContentListFromCache(String key) - Specified by:
getStructuredContentListFromCachein interfaceStructuredContentService
-
getStructuredContentItemsByContentName
public List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> getStructuredContentItemsByContentName(String contentName, org.broadleafcommerce.common.locale.domain.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:
-