Interface ContentItemService
- All Known Implementing Classes:
ContentItemServiceImpl
public interface ContentItemService
- Author:
- Elbert Bautista (elbertbautista)
-
Method Summary
Modifier and TypeMethodDescriptioncreateContentItemDTOFromContentItem(boolean secure, Map<String, Object> args, ContentItem ci) Creates a ContentItemDTO from the passed in ContentItem and caches itReturns 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.When passing in theContentItemDTOto the post retrieval method we clone the DTO to prevent unwanted changes to the original.List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>hydrateForeignLookups(List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> dtos) StructuredContentDTOobjects are sometimes cached in the StructuredContentService.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 versionvoidsetStructuredContentForDTO(ContentItem contentItem, boolean isSecure, ContentItemDTO ciDto) AddsStructuredContentDTOtoContentItemDTO.
-
Method Details
-
findContentItemById
Returns theContentItemthat has the given id- Parameters:
id-- Returns:
- the
ContentItem
-
saveContentItem
Saves aContentItemand returns the saved version- Parameters:
contentItem-- Returns:
- the saved
ContentItem
-
findOverrideContentItemByContentItemId
Returns the appropriateOverrideContentItemfor the givenContentItemid- Parameters:
contentItemId-- Returns:
- the
OverrideContentItem
-
readOverrideContentItemById
Returns theOverrideContentItemthat has the given id- Parameters:
id-- Returns:
- the
OverrideContentItem
-
generateContentItemByOverrideContentItem
Creates 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.
- Parameters:
overrideContentItem-- Returns:
- the generated
ContentItem
-
findAllOverrideContentItemsByContentItemId
Returns a list of allOverrideContentItems- Parameters:
id-- Returns:
- the list of all
OverrideContentItems
-
createContentItemDTOFromContentItem
ContentItemDTO createContentItemDTOFromContentItem(boolean secure, Map<String, Object> args, ContentItem ci) Creates a ContentItemDTO from the passed in ContentItem and caches it- Parameters:
secure-args-ci-- Returns:
-
getClonedContentItemDTO
When 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.- Parameters:
ciDto-- Returns:
-
postRetrievalContentItemModification
ContentItemDTO postRetrievalContentItemModification(ContentItemDTO ciDto, String name, boolean secure, Map<String, Object> args) Used 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.- Parameters:
ciDto-name-secure-args-- Returns:
-
hydrateForeignLookups
List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> hydrateForeignLookups(List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> dtos) StructuredContentDTOobjects 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.- Parameters:
dtos-- Returns:
- the same list that was passed in
-
removeContentItemFromCache
Removes the passed in contentItem (and its associated StructuredContent items) from cache- Parameters:
contentItem-
-
setStructuredContentForDTO
AddsStructuredContentDTOtoContentItemDTO. First looks at Cache, then goes to database.- Parameters:
contentItem-ciDto-isSecure-
-