Interface ContentItemService

All Known Implementing Classes:
ContentItemServiceImpl

public interface ContentItemService
Author:
Elbert Bautista (elbertbautista)
  • Method Details

    • findContentItemById

      ContentItem findContentItemById(Long id)
      Returns the ContentItem that has the given id
      Parameters:
      id -
      Returns:
      the ContentItem
    • saveContentItem

      ContentItem saveContentItem(ContentItem contentItem)
      Saves a ContentItem and returns the saved version
      Parameters:
      contentItem -
      Returns:
      the saved ContentItem
    • findOverrideContentItemByContentItemId

      OverrideContentItem findOverrideContentItemByContentItemId(Long contentItemId)
      Returns the appropriate OverrideContentItem for the given ContentItem id
      Parameters:
      contentItemId -
      Returns:
      the OverrideContentItem
    • readOverrideContentItemById

      OverrideContentItem readOverrideContentItemById(Long id)
      Returns the OverrideContentItem that has the given id
      Parameters:
      id -
      Returns:
      the OverrideContentItem
    • generateContentItemByOverrideContentItem

      ContentItem generateContentItemByOverrideContentItem(OverrideContentItem overrideContentItem)
      Creates a transient ContentItem that takes into consideration the overrides present in the given OverrideContentItem. This method will iterate through the OverrideSCItems 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

      List<OverrideContentItem> findAllOverrideContentItemsByContentItemId(Long id)
      Returns a list of all OverrideContentItems
      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

      ContentItemDTO getClonedContentItemDTO(ContentItemDTO ciDto)
      When passing in the ContentItemDTO to 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 the ContentItemDTO created. 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 the StructuredContentDTO that 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)
      StructuredContentDTO objects 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

      boolean removeContentItemFromCache(ContentItem contentItem)
      Removes the passed in contentItem (and its associated StructuredContent items) from cache
      Parameters:
      contentItem -
    • setStructuredContentForDTO

      void setStructuredContentForDTO(ContentItem contentItem, boolean isSecure, ContentItemDTO ciDto)
      Adds StructuredContentDTO to ContentItemDTO. First looks at Cache, then goes to database.
      Parameters:
      contentItem -
      ciDto -
      isSecure -