@Service(value="blStructuredContentService") public class StructuredContentServiceImpl extends Object implements StructuredContentService
Modifier and Type | Field and Description |
---|---|
protected static String |
AND |
protected javax.cache.CacheManager |
cacheManager |
protected List<RuleProcessor<StructuredContentDTO>> |
contentRuleProcessors |
protected EntityConfiguration |
entityConfiguration |
protected StructuredContentServiceExtensionManager |
extensionManager |
protected static String |
FOREIGN_LOOKUP |
protected LocaleService |
localeService |
protected static org.apache.commons.logging.Log |
LOG |
protected StaticAssetPathService |
staticAssetPathService |
protected StaticAssetService |
staticAssetService |
protected StatisticsService |
statisticsService |
protected javax.cache.Cache |
structuredContentCache |
protected StructuredContentDao |
structuredContentDao |
Constructor and Description |
---|
StructuredContentServiceImpl() |
Modifier and Type | Method and Description |
---|---|
protected void |
addSingleStructuredContentToCache(String key,
StructuredContentDTO scDTO) |
void |
addStructuredContentListToCache(String key,
List<StructuredContentDTO> scDTOList) |
protected void |
buildFieldValues(StructuredContent sc,
StructuredContentDTO scDTO,
boolean secure)
Parses the given
StructuredContent into its StructuredContentDTO representation. |
protected void |
buildFieldValueWithCmsPrefix(String originalValue,
StructuredContentDTO scDTO,
boolean secure,
String fieldKey) |
protected List<ItemCriteriaDTO> |
buildItemCriteriaDTOList(StructuredContent sc) |
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 |
buildRuleExpression(StructuredContent sc) |
StructuredContentDTO |
buildStructuredContentDTO(StructuredContent sc,
boolean secure)
Converts a StructuredContent into a StructuredContentDTO.
|
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(...). |
String |
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) |
String |
buildTypeKeyWithSecure(SandBox currentSandbox,
Long site,
Locale locale,
String contentType,
Boolean secure)
Builds the cache key for DTOLists based on the SC Type.
|
List<StructuredContentDTO> |
convertToDtos(List<StructuredContent> scs,
boolean isSecure)
Converts a list of StructuredContent objects into their corresponding
StructuredContentDTO s. |
Long |
countContentItems(org.hibernate.Criteria c)
Follows the same rules as
findContentItems . |
List<StructuredContentDTO> |
evaluateAndPriortizeContent(List<StructuredContentDTO> structuredContentList,
int count,
Map<String,Object> ruleDTOs) |
List<StructuredContent> |
findAllContentItems()
Finds all content items regardless of the
Sandbox they are a member of |
List<StructuredContent> |
findContentItems(org.hibernate.Criteria c)
This method is intended to be called solely from the CMS admin.
|
Locale |
findLanguageOnlyLocale(Locale locale) |
StructuredContent |
findStructuredContentById(Long contentId)
Returns the StructuredContent item associated with the passed in id.
|
StructuredContentType |
findStructuredContentTypeById(Long id)
Returns the
StructuredContentType associated with the passed in id. |
StructuredContentType |
findStructuredContentTypeByName(String name)
Returns the
StructuredContentType associated with the passed in
String value. |
List<RuleProcessor<StructuredContentDTO>> |
getContentRuleProcessors() |
protected StructuredContentDTO |
getSingleStructuredContentFromCache(String key) |
javax.cache.Cache |
getStructuredContentCache() |
List<StructuredContentDTO> |
getStructuredContentItemsByContentName(String contentName,
Locale locale,
boolean secure)
First attempts to retrieve
StructuredContentDTO from cache before making calls to database |
List<StructuredContentDTO> |
getStructuredContentListFromCache(String key) |
protected boolean |
hasCmsPrefix(String originalValue,
String cmsPrefix) |
List<StructuredContentDTO> |
lookupStructuredContentItemsByName(String contentName,
Locale locale,
Integer count,
Map<String,Object> ruleDTOs,
boolean secure)
This method returns content by name only.
|
List<StructuredContentDTO> |
lookupStructuredContentItemsByName(StructuredContentType contentType,
String contentName,
Locale locale,
Integer count,
Map<String,Object> ruleDTOs,
boolean secure)
This method returns content by name and type.
|
List<StructuredContentDTO> |
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 |
removeItemFromCacheByKey(String key)
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.
|
List<StructuredContentType> |
retrieveAllStructuredContentTypes() |
StructuredContentType |
saveStructuredContentType(StructuredContentType type)
Saves the given type and returns the merged instance
|
void |
setContentRuleProcessors(List<RuleProcessor<StructuredContentDTO>> contentRuleProcessors) |
protected static final org.apache.commons.logging.Log LOG
protected static String AND
protected static final String FOREIGN_LOOKUP
protected StructuredContentDao structuredContentDao
protected StaticAssetService staticAssetService
protected StaticAssetPathService staticAssetPathService
protected LocaleService localeService
protected List<RuleProcessor<StructuredContentDTO>> contentRuleProcessors
protected EntityConfiguration entityConfiguration
protected StructuredContentServiceExtensionManager extensionManager
protected StatisticsService statisticsService
protected javax.cache.CacheManager cacheManager
protected javax.cache.Cache structuredContentCache
public StructuredContent findStructuredContentById(Long contentId)
StructuredContentService
findStructuredContentById
in interface StructuredContentService
contentId
- - The id of the content item.public StructuredContentType findStructuredContentTypeById(Long id)
StructuredContentService
StructuredContentType
associated with the passed in id.findStructuredContentTypeById
in interface StructuredContentService
id
- - The id of the content type.StructuredContentType
.public StructuredContentType findStructuredContentTypeByName(String name)
StructuredContentService
StructuredContentType
associated with the passed in
String value.findStructuredContentTypeByName
in interface StructuredContentService
name
- - The name of the content type.StructuredContentType
.public List<StructuredContentType> retrieveAllStructuredContentTypes()
retrieveAllStructuredContentTypes
in interface StructuredContentService
StructuredContentType
spublic List<StructuredContent> findContentItems(org.hibernate.Criteria c)
StructuredContentService
SandBoxType
of
production is passed in, only those items in that SandBox are returned.
findContentItems
in interface StructuredContentService
c
- - the criteria used to search for contentpublic List<StructuredContent> findAllContentItems()
StructuredContentService
Sandbox
they are a member offindAllContentItems
in interface StructuredContentService
public Long countContentItems(org.hibernate.Criteria c)
StructuredContentService
findContentItems
.countContentItems
in interface StructuredContentService
public StructuredContentType saveStructuredContentType(StructuredContentType type)
saveStructuredContentType
in interface StructuredContentService
public List<StructuredContentDTO> buildStructuredContentDTOList(List<StructuredContent> structuredContentList, boolean secure)
buildStructuredContentDTOList
in interface StructuredContentService
structuredContentList
- secure
- #buildStructuredContentDTO(StructuredContent, boolean)}
public List<StructuredContentDTO> evaluateAndPriortizeContent(List<StructuredContentDTO> structuredContentList, int count, Map<String,Object> ruleDTOs)
evaluateAndPriortizeContent
in interface StructuredContentService
protected List<StructuredContentDTO> processUnprioritizedContent(List<StructuredContentDTO> structuredContentList, Map<String,Object> ruleDTOs)
protected boolean processContentRules(StructuredContentDTO sc, Map<String,Object> ruleDTOs)
protected List<StructuredContentDTO> modifyStructuredContentDtoList(List<StructuredContentDTO> structuredContentList)
public List<StructuredContentDTO> lookupStructuredContentItemsByType(StructuredContentType contentType, Locale locale, Integer count, Map<String,Object> ruleDTOs, boolean secure)
StructuredContentService
SandBoxType
of
production is passed in, only those items in that SandBox are returned.
lookupStructuredContentItemsByType
in interface StructuredContentService
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 httpsorg.broadleafcommerce.cms.web.structure.DisplayContentTag
public List<StructuredContentDTO> lookupStructuredContentItemsByName(StructuredContentType contentType, String contentName, Locale locale, Integer count, Map<String,Object> ruleDTOs, boolean secure)
StructuredContentService
SandBoxType
of
production is passed in, only those items in that SandBox are returned.
lookupStructuredContentItemsByName
in interface StructuredContentService
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 httpsorg.broadleafcommerce.cms.web.structure.DisplayContentTag
public List<StructuredContentDTO> convertToDtos(List<StructuredContent> scs, boolean isSecure)
StructuredContentService
StructuredContentDTO
s. This method
will utilize a cache in production mode, and it will additionally hydrate the returned StructuredContentDTO
objects via the #hydrateForeignLookups(List)
method.convertToDtos
in interface StructuredContentService
StructuredContentDTO
spublic List<StructuredContentDTO> lookupStructuredContentItemsByName(String contentName, Locale locale, Integer count, Map<String,Object> ruleDTOs, boolean secure)
StructuredContentService
SandBoxType
of
production is passed in, only those items in that SandBox are returned.
lookupStructuredContentItemsByName
in interface StructuredContentService
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 httpsorg.broadleafcommerce.cms.web.structure.DisplayContentTag
public List<RuleProcessor<StructuredContentDTO>> getContentRuleProcessors()
public void setContentRuleProcessors(List<RuleProcessor<StructuredContentDTO>> contentRuleProcessors)
public void removeStructuredContentFromCache(SandBox sandBox, StructuredContent sc)
StructuredContentService
removeStructuredContentFromCache
in interface StructuredContentService
public boolean removeItemFromCacheByKey(String key)
StructuredContentService
removeItemFromCacheByKey
in interface StructuredContentService
public void removeItemFromCache(String nameKey, String typeKey)
StructuredContentService
removeItemFromCache
in interface StructuredContentService
public Locale findLanguageOnlyLocale(Locale locale)
findLanguageOnlyLocale
in interface StructuredContentService
public javax.cache.Cache getStructuredContentCache()
getStructuredContentCache
in interface StructuredContentService
protected String buildRuleExpression(StructuredContent sc)
protected List<ItemCriteriaDTO> buildItemCriteriaDTOList(StructuredContent sc)
protected void buildFieldValues(StructuredContent sc, StructuredContentDTO scDTO, boolean secure)
StructuredContent
into its StructuredContentDTO
representation. This will also
format the values from StructuredContentDTO.getValues()
into their actual data types. For instance, if the
given StructuredContent
has a DATE field, then this method will ensure that the resulting object in the values
map of the DTO is a Date
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 prefixsc
- scDTO
- secure
- StaticAssetService#getStaticAssetEnvironmentUrlPrefix()}
protected void buildFieldValueWithCmsPrefix(String originalValue, StructuredContentDTO scDTO, boolean secure, String fieldKey)
public StructuredContentDTO buildStructuredContentDTO(StructuredContent sc, boolean secure)
EntityConfiguration
. To override the actual type that is returned,
include an override in an applicationContext like any other entity override.buildStructuredContentDTO
in interface StructuredContentService
sc
- secure
- protected String buildNameKey(SandBox sandBox, StructuredContent sc)
protected String buildNameKey(SandBox sandBox, StructuredContent sc, Boolean secure)
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)
currentSandbox
- site
- locale
- contentType
- contentName
- secure
- protected String buildTypeKey(SandBox sandBox, StructuredContent sc)
public String buildTypeKey(SandBox currentSandbox, Long site, Locale locale, String contentType)
StructuredContentService
buildTypeKey
in interface StructuredContentService
public String buildTypeKeyWithSecure(SandBox currentSandbox, Long site, Locale locale, String contentType, Boolean secure)
StructuredContentService
buildTypeKeyWithSecure
in interface StructuredContentService
public void addStructuredContentListToCache(String key, List<StructuredContentDTO> scDTOList)
addStructuredContentListToCache
in interface StructuredContentService
protected void addSingleStructuredContentToCache(String key, StructuredContentDTO scDTO)
protected StructuredContentDTO getSingleStructuredContentFromCache(String key)
public List<StructuredContentDTO> getStructuredContentListFromCache(String key)
getStructuredContentListFromCache
in interface StructuredContentService
public List<StructuredContentDTO> getStructuredContentItemsByContentName(String contentName, Locale locale, boolean secure)
StructuredContentService
StructuredContentDTO
from cache before making calls to databasegetStructuredContentItemsByContentName
in interface StructuredContentService
contentName
- (Name of ContentItemCopyright © 2022. All rights reserved.