Class ContentItemServiceImpl
java.lang.Object
com.broadleafcommerce.advancedcms.service.ContentItemServiceImpl
- All Implemented Interfaces:
ContentItemService
@Repository("blContentItemService")
public class ContentItemServiceImpl
extends Object
implements ContentItemService
- Author:
- Elbert Bautista (elbertbautista)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected javax.cache.CacheManagerprotected ContentItemDaoprotected ContentZoneServiceExtensionManagerprotected static final Stringprotected org.broadleafcommerce.common.dao.GenericEntityDaoprotected OverrideContentServiceprotected ContentZoneQueryExtensionHandlerprotected org.broadleafcommerce.common.sandbox.SandBoxHelperprotected org.broadleafcommerce.common.cache.StatisticsServiceprotected javax.cache.Cacheprotected org.broadleafcommerce.cms.structure.service.StructuredContentService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddStructuredContentDTOsToCache(ContentItemDTO contentItemDto, ContentItem item, boolean secure) protected StringbuildCacheKey(ContentItemDTO contentItemDto, ContentItem item) buildCacheKeys(ContentItemDTO contentItemDto, ContentItem item) protected StringbuildMapKey(ContentItemDTO contentItemDto, boolean secure, org.broadleafcommerce.common.web.BroadleafRequestContext context) protected ContentItemDTOcreateContentItemDto(ContentItem contentItem) Creates theContentItemDTOgiven a contentItem.createContentItemDTOFromContentItem(boolean secure, Map<String, Object> args, ContentItem ci) Creates a ContentItemDTO from the passed in ContentItem and caches itprotected List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>createStructuredContentDTOs(ContentItem ci, boolean isSecure) CreatesStructuredContentDTOobjects.findAllOverrideContentItemsByContentItemId(Long contentItemId) Returns a list of allOverrideContentItemsReturns theContentItemthat has the given idfindOverrideContentItemByContentItemId(Long contentItemId) Returns the appropriateOverrideContentItemfor the givenContentItemidgenerateContentItemByOverrideContentItem(OverrideContentItem overrideContentItem) Creates a transientContentItemthat takes into consideration the overrides present in the givenOverrideContentItem.protected List<StructuredContentContentItemXref>generateContentItemFields(OverrideContentItem overrideContentItem, ContentItem clonedCI) protected List<StructuredContentContentItemXref>generateSCCIXref(OverrideContentItem overrideContentItem, ContentItem clonedCI) protected StringgetCacheKey(String cacheKey, org.broadleafcommerce.common.extension.ResultType resultType) getCacheKeys(String cacheKey, org.broadleafcommerce.common.extension.ResultType resultType) When passing in theContentItemDTOto the post retrieval method we clone the DTO to prevent unwanted changes to the original.protected booleanprotected org.broadleafcommerce.common.extension.ResultTypegetResultType(Object object) protected javax.cache.CacheList<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>hydrateForeignLookups(List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> dtos) StructuredContentDTOobjects are sometimes cached in the StructuredContentService.protected booleanisMasterContentData(org.broadleafcommerce.common.structure.dto.StructuredContentDTO scDto) protected booleanisValueObjectTranslatable(Object value) protected List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>lookupStructuredContentDTOsFromCache(ContentItemDTO contentItemDto, ContentItem item, boolean secure) postRetrievalContentItemModification(ContentItemDTO ciDto, String name, boolean secure, Map<String, Object> args) Used to modify theContentItemDTOcreated.Returns theOverrideContentItemthat has the given idbooleanremoveContentItemFromCache(ContentItem contentItem) Removes the passed in contentItem (and its associated StructuredContent items) from cachesaveContentItem(ContentItem contentItem) Saves aContentItemand returns the saved versionprotected voidprotected voidsetStructuredContentDTOTranslations(ContentItem contentItem, List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> dtos) voidsetStructuredContentForDTO(ContentItem contentItem, boolean isSecure, ContentItemDTO ciDto) AddsStructuredContentDTOtoContentItemDTOprotected voidsortDTOsByPriority(List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> dtos) protected voidtranslateStructuredContentDTO(org.broadleafcommerce.common.structure.dto.StructuredContentDTO dto, ContentItem contentItem) protected List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>utilizeCache(ContentItem contentItem, boolean isSecure, ContentItemDTO ciDto)
-
Field Details
-
FOREIGN_LOOKUP
- See Also:
-
contentItemDao
-
overrideContentService
-
extensionManager
-
queryExtensionManager
-
genericDao
protected org.broadleafcommerce.common.dao.GenericEntityDao genericDao -
statisticsService
protected org.broadleafcommerce.common.cache.StatisticsService statisticsService -
structuredContentService
protected org.broadleafcommerce.cms.structure.service.StructuredContentService structuredContentService -
sandBoxHelper
protected org.broadleafcommerce.common.sandbox.SandBoxHelper sandBoxHelper -
cacheManager
protected javax.cache.CacheManager cacheManager -
structuredContentMapCache
protected javax.cache.Cache structuredContentMapCache
-
-
Constructor Details
-
ContentItemServiceImpl
public ContentItemServiceImpl()
-
-
Method Details
-
getIncludeNonOverriddenSCItemsFlag
protected boolean getIncludeNonOverriddenSCItemsFlag() -
findContentItemById
Description copied from interface:ContentItemServiceReturns theContentItemthat has the given id- Specified by:
findContentItemByIdin interfaceContentItemService- Returns:
- the
ContentItem
-
findOverrideContentItemByContentItemId
Description copied from interface:ContentItemServiceReturns the appropriateOverrideContentItemfor the givenContentItemid- Specified by:
findOverrideContentItemByContentItemIdin interfaceContentItemService- Returns:
- the
OverrideContentItem
-
saveContentItem
Description copied from interface:ContentItemServiceSaves aContentItemand returns the saved version- Specified by:
saveContentItemin interfaceContentItemService- Returns:
- the saved
ContentItem
-
readOverrideContentItemById
Description copied from interface:ContentItemServiceReturns theOverrideContentItemthat has the given id- Specified by:
readOverrideContentItemByIdin interfaceContentItemService- Returns:
- the
OverrideContentItem
-
generateContentItemByOverrideContentItem
public ContentItem generateContentItemByOverrideContentItem(OverrideContentItem overrideContentItem) Description copied from interface:ContentItemServiceCreates a transientContentItemthat takes into consideration the overrides present in the givenOverrideContentItem. This method will iterate through theOverrideSCItems in the override content item and generate a content item that has the overrides in place.This method is used to allow downstream code to only think about rendering a content item and not have to worry about handling things differently if there is an override content item present.
- Specified by:
generateContentItemByOverrideContentItemin interfaceContentItemService- Returns:
- the generated
ContentItem
-
generateContentItemFields
protected List<StructuredContentContentItemXref> generateContentItemFields(OverrideContentItem overrideContentItem, ContentItem clonedCI) -
generateSCCIXref
protected List<StructuredContentContentItemXref> generateSCCIXref(OverrideContentItem overrideContentItem, ContentItem clonedCI) -
findAllOverrideContentItemsByContentItemId
Description copied from interface:ContentItemServiceReturns a list of allOverrideContentItems- Specified by:
findAllOverrideContentItemsByContentItemIdin interfaceContentItemService- Returns:
- the list of all
OverrideContentItems
-
createContentItemDTOFromContentItem
public ContentItemDTO createContentItemDTOFromContentItem(boolean secure, Map<String, Object> args, ContentItem ci) Description copied from interface:ContentItemServiceCreates a ContentItemDTO from the passed in ContentItem and caches it- Specified by:
createContentItemDTOFromContentItemin interfaceContentItemService- Returns:
-
setStructuredContentForDTO
public void setStructuredContentForDTO(ContentItem contentItem, boolean isSecure, ContentItemDTO ciDto) AddsStructuredContentDTOtoContentItemDTO- Specified by:
setStructuredContentForDTOin interfaceContentItemService- Parameters:
contentItem-ciDto-isSecure-
-
utilizeCache
protected List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> utilizeCache(ContentItem contentItem, boolean isSecure, ContentItemDTO ciDto) -
setMasterStructuredContentDTOs
-
isMasterContentData
protected boolean isMasterContentData(org.broadleafcommerce.common.structure.dto.StructuredContentDTO scDto) -
createStructuredContentDTOs
protected List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> createStructuredContentDTOs(ContentItem ci, boolean isSecure) CreatesStructuredContentDTOobjects.- Parameters:
ci-isSecure-- Returns:
-
setStructuredContentDTOTranslations
protected void setStructuredContentDTOTranslations(ContentItem contentItem, List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> dtos) - Parameters:
contentItem-dtos-
-
translateStructuredContentDTO
protected void translateStructuredContentDTO(org.broadleafcommerce.common.structure.dto.StructuredContentDTO dto, ContentItem contentItem) - Parameters:
dto-contentItem-
-
isValueObjectTranslatable
- Parameters:
value-- Returns:
-
sortDTOsByPriority
protected void sortDTOsByPriority(List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> dtos) -
getClonedContentItemDTO
Description copied from interface:ContentItemServiceWhen passing in theContentItemDTOto the post retrieval method we clone the DTO to prevent unwanted changes to the original. With this hook point implementors can override this behavior if needed.- Specified by:
getClonedContentItemDTOin interfaceContentItemService- Returns:
-
postRetrievalContentItemModification
public ContentItemDTO postRetrievalContentItemModification(ContentItemDTO ciDto, String name, boolean secure, Map<String, Object> args) Description copied from interface:ContentItemServiceUsed to modify theContentItemDTOcreated. This allows for a hook point to allow implementors to add custom logic to change, add, remove any element(s) in this DTO. The default implementation does not make any modifications. One example would be to modify theStructuredContentDTOthat has been retrieved with the ContentItem. The list can be filtered, reordered, etc.- Specified by:
postRetrievalContentItemModificationin interfaceContentItemService- Returns:
-
hydrateForeignLookups
public List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> hydrateForeignLookups(List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> dtos) Description copied from interface:ContentItemServiceStructuredContentDTOobjects are sometimes cached in the StructuredContentService. Furthermore, this cached version contains information about the kind of value the DTO might hold. In the cases where the value is a foreign key lookup, we want to get the object that it represents and set that as the internal value. However, since these DTOs are not Hibernate entities and are possibly stored in a cache, we need to load the target object on each request to avoid lazy initialization exceptions. This method performs that hydration.- Specified by:
hydrateForeignLookupsin interfaceContentItemService- Returns:
- the same list that was passed in
-
lookupStructuredContentDTOsFromCache
protected List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> lookupStructuredContentDTOsFromCache(ContentItemDTO contentItemDto, ContentItem item, boolean secure) -
buildCacheKey
-
buildCacheKeys
-
buildMapKey
protected String buildMapKey(ContentItemDTO contentItemDto, boolean secure, org.broadleafcommerce.common.web.BroadleafRequestContext context) -
getCacheKey
-
getCacheKeys
-
getResultType
-
removeContentItemFromCache
Description copied from interface:ContentItemServiceRemoves the passed in contentItem (and its associated StructuredContent items) from cache- Specified by:
removeContentItemFromCachein interfaceContentItemService
-
addStructuredContentDTOsToCache
protected void addStructuredContentDTOsToCache(ContentItemDTO contentItemDto, ContentItem item, boolean secure) -
getStructuredContentMapCache
protected javax.cache.Cache getStructuredContentMapCache() -
createContentItemDto
Creates theContentItemDTOgiven a contentItem.
-