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 String
protected javax.cache.CacheManager
protected List<RuleProcessor<StructuredContentDTO>>
protected EntityConfiguration
protected StructuredContentServiceExtensionManager
protected static final String
protected LocaleService
protected static final org.apache.commons.logging.Log
protected StaticAssetPathService
protected StaticAssetService
protected StatisticsService
protected javax.cache.Cache
protected StructuredContentDao
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
addStructuredContentListToCache
(String key, List<StructuredContentDTO> scDTOList) protected void
buildFieldValues
(StructuredContent sc, StructuredContentDTO scDTO, boolean secure) Parses the givenStructuredContent
into itsStructuredContentDTO
representation.protected void
buildFieldValueWithCmsPrefix
(String originalValue, StructuredContentDTO scDTO, boolean secure, String fieldKey) protected List<ItemCriteriaDTO>
protected String
buildNameKey
(SandBox currentSandbox, Long site, Locale locale, String contentType, String contentName) 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.protected String
buildNameKey
(SandBox sandBox, StructuredContent sc) protected String
buildNameKey
(SandBox sandBox, StructuredContent sc, Boolean secure) protected String
buildStructuredContentDTO
(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 String
buildTypeKey
(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 correspondingStructuredContentDTO
s.evaluateAndPriortizeContent
(List<StructuredContentDTO> structuredContentList, int count, Map<String, Object> ruleDTOs) Finds all content items regardless of theSandbox
they are a member offindLanguageOnlyLocale
(Locale locale) findStructuredContentById
(Long contentId) Returns the StructuredContent item associated with the passed in id.Returns theStructuredContentType
associated with the passed in id.Returns theStructuredContentType
associated with the passed in String value.protected StructuredContentDTO
javax.cache.Cache
getStructuredContentItemsByContentName
(String contentName, Locale locale, boolean secure) First attempts to retrieveStructuredContentDTO
from cache before making calls to databaseprotected boolean
hasCmsPrefix
(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 boolean
processContentRules
(StructuredContentDTO sc, Map<String, Object> ruleDTOs) protected List<StructuredContentDTO>
processUnprioritizedContent
(List<StructuredContentDTO> structuredContentList, Map<String, Object> ruleDTOs) void
removeItemFromCache
(String nameKey, String typeKey) Call to evict both secure and non-secure SC items matching the passed in keys.boolean
Call to evict both secure and non-secure SC items matching the passed in key.void
removeStructuredContentFromCache
(SandBox sandBox, StructuredContent sc) Call to evict an item from the cache.Saves the given type and returns the merged instancevoid
setContentRuleProcessors
(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:StructuredContentService
Returns the StructuredContent item associated with the passed in id.- Specified by:
findStructuredContentById
in interfaceStructuredContentService
- Parameters:
contentId
- - The id of the content item.- Returns:
- The associated structured content item.
-
findStructuredContentTypeById
Description copied from interface:StructuredContentService
Returns theStructuredContentType
associated with the passed in id.- Specified by:
findStructuredContentTypeById
in interfaceStructuredContentService
- Parameters:
id
- - The id of the content type.- Returns:
- The associated
StructuredContentType
.
-
findStructuredContentTypeByName
Description copied from interface:StructuredContentService
Returns theStructuredContentType
associated with the passed in String value.- Specified by:
findStructuredContentTypeByName
in interfaceStructuredContentService
- Parameters:
name
- - The name of the content type.- Returns:
- The associated
StructuredContentType
.
-
retrieveAllStructuredContentTypes
- Specified by:
retrieveAllStructuredContentTypes
in interfaceStructuredContentService
- Returns:
- a list of all
StructuredContentType
s
-
findAllContentItems
Description copied from interface:StructuredContentService
Finds all content items regardless of theSandbox
they are a member of- Specified by:
findAllContentItems
in interfaceStructuredContentService
- Returns:
-
saveStructuredContentType
Saves the given type and returns the merged instance- Specified by:
saveStructuredContentType
in 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:
buildStructuredContentDTOList
in interfaceStructuredContentService
- Parameters:
structuredContentList
-secure
-- Returns:
-
evaluateAndPriortizeContent
public List<StructuredContentDTO> evaluateAndPriortizeContent(List<StructuredContentDTO> structuredContentList, int count, Map<String, Object> ruleDTOs) - Specified by:
evaluateAndPriortizeContent
in 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:StructuredContentService
This 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 aSandBoxType
of 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:
lookupStructuredContentItemsByType
in 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:StructuredContentService
This 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 aSandBoxType
of 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:
lookupStructuredContentItemsByName
in 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:StructuredContentService
Converts a list of StructuredContent objects into their correspondingStructuredContentDTO
s. This method will utilize a cache in production mode, and it will additionally hydrate the returnedStructuredContentDTO
objects via the#hydrateForeignLookups(List)
method.- Specified by:
convertToDtos
in interfaceStructuredContentService
- Returns:
- the list of
StructuredContentDTO
s
-
lookupStructuredContentItemsByName
public List<StructuredContentDTO> lookupStructuredContentItemsByName(String contentName, Locale locale, Integer count, Map<String, Object> ruleDTOs, boolean secure) Description copied from interface:StructuredContentService
This 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 aSandBoxType
of 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:
lookupStructuredContentItemsByName
in 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:StructuredContentService
Call to evict an item from the cache.- Specified by:
removeStructuredContentFromCache
in interfaceStructuredContentService
-
removeItemFromCacheByKey
Description copied from interface:StructuredContentService
Call to evict both secure and non-secure SC items matching the passed in key.- Specified by:
removeItemFromCacheByKey
in interfaceStructuredContentService
- Returns:
-
removeItemFromCache
Description copied from interface:StructuredContentService
Call to evict both secure and non-secure SC items matching the passed in keys.- Specified by:
removeItemFromCache
in interfaceStructuredContentService
-
findLanguageOnlyLocale
- Specified by:
findLanguageOnlyLocale
in interfaceStructuredContentService
-
getStructuredContentCache
public javax.cache.Cache getStructuredContentCache()- Specified by:
getStructuredContentCache
in interfaceStructuredContentService
-
buildRuleExpression
-
buildItemCriteriaDTOList
-
buildFieldValues
Parses the givenStructuredContent
into itsStructuredContentDTO
representation. This will also format the values fromStructuredContentDTO.getValues()
into their actual data types. For instance, if the givenStructuredContent
has a DATE field, then this method will ensure that the resulting object in the values map of the DTO is aDate
rather than just a String representing a date. Current support of parsing field types is: DATE -Date
BOOLEAN -Boolean
DECIMAL -BigDecimal
INTEGER -Integer
MONEY -Money
All 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:
buildStructuredContentDTO
in 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:StructuredContentService
Builds the cache key for DTOLists based on the SC Type.- Specified by:
buildTypeKey
in interfaceStructuredContentService
- Returns:
- cache key for DTOList
-
buildTypeKeyWithSecure
public String buildTypeKeyWithSecure(SandBox currentSandbox, Long site, Locale locale, String contentType, Boolean secure) Description copied from interface:StructuredContentService
Builds the cache key for DTOLists based on the SC Type.- Specified by:
buildTypeKeyWithSecure
in interfaceStructuredContentService
- Returns:
- cache key for DTOList
-
addStructuredContentListToCache
- Specified by:
addStructuredContentListToCache
in interfaceStructuredContentService
-
addSingleStructuredContentToCache
-
getSingleStructuredContentFromCache
-
getStructuredContentListFromCache
- Specified by:
getStructuredContentListFromCache
in interfaceStructuredContentService
-
getStructuredContentItemsByContentName
public List<StructuredContentDTO> getStructuredContentItemsByContentName(String contentName, Locale locale, boolean secure) Description copied from interface:StructuredContentService
First attempts to retrieveStructuredContentDTO
from cache before making calls to database- Specified by:
getStructuredContentItemsByContentName
in interfaceStructuredContentService
- Parameters:
contentName
- (Name of ContentItem- Returns:
-