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 Details

    • LOG

      protected static final org.apache.commons.logging.Log LOG
    • FOREIGN_LOOKUP

      protected static final String FOREIGN_LOOKUP
      See Also:
    • AND

      protected static String AND
    • structuredContentDao

      protected StructuredContentDao structuredContentDao
    • staticAssetService

      protected StaticAssetService staticAssetService
    • staticAssetPathService

      protected org.broadleafcommerce.common.file.service.StaticAssetPathService staticAssetPathService
    • localeService

      protected org.broadleafcommerce.common.locale.service.LocaleService localeService
    • contentRuleProcessors

      protected List<org.broadleafcommerce.common.rule.RuleProcessor<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>> contentRuleProcessors
    • entityConfiguration

      protected org.broadleafcommerce.common.persistence.EntityConfiguration entityConfiguration
    • extensionManager

      protected StructuredContentServiceExtensionManager extensionManager
    • statisticsService

      protected org.broadleafcommerce.common.cache.StatisticsService statisticsService
    • cacheManager

      protected javax.cache.CacheManager cacheManager
    • structuredContentCache

      protected javax.cache.Cache structuredContentCache
  • Constructor Details

    • StructuredContentServiceImpl

      public StructuredContentServiceImpl()
  • Method Details

    • findStructuredContentById

      public StructuredContent findStructuredContentById(Long contentId)
      Description copied from interface: StructuredContentService
      Returns the StructuredContent item associated with the passed in id.
      Specified by:
      findStructuredContentById in interface StructuredContentService
      Parameters:
      contentId - - The id of the content item.
      Returns:
      The associated structured content item.
    • findStructuredContentTypeById

      public StructuredContentType findStructuredContentTypeById(Long id)
      Description copied from interface: StructuredContentService
      Returns the StructuredContentType associated with the passed in id.
      Specified by:
      findStructuredContentTypeById in interface StructuredContentService
      Parameters:
      id - - The id of the content type.
      Returns:
      The associated StructuredContentType.
    • findStructuredContentTypeByName

      public StructuredContentType findStructuredContentTypeByName(String name)
      Description copied from interface: StructuredContentService
      Returns the StructuredContentType associated with the passed in String value.
      Specified by:
      findStructuredContentTypeByName in interface StructuredContentService
      Parameters:
      name - - The name of the content type.
      Returns:
      The associated StructuredContentType.
    • retrieveAllStructuredContentTypes

      public List<StructuredContentType> retrieveAllStructuredContentTypes()
      Specified by:
      retrieveAllStructuredContentTypes in interface StructuredContentService
      Returns:
      a list of all StructuredContentTypes
    • findAllContentItems

      public List<StructuredContent> findAllContentItems()
      Description copied from interface: StructuredContentService
      Finds all content items regardless of the Sandbox they are a member of
      Specified by:
      findAllContentItems in interface StructuredContentService
      Returns:
    • saveStructuredContentType

      public StructuredContentType saveStructuredContentType(StructuredContentType type)
      Saves the given type and returns the merged instance
      Specified by:
      saveStructuredContentType in interface StructuredContentService
    • buildStructuredContentDTOList

      public List<org.broadleafcommerce.common.structure.dto.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 interface StructuredContentService
      Parameters:
      structuredContentList -
      secure -
      Returns:
    • evaluateAndPriortizeContent

      public List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> evaluateAndPriortizeContent(List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> structuredContentList, int count, Map<String,Object> ruleDTOs)
      Specified by:
      evaluateAndPriortizeContent in interface StructuredContentService
    • processUnprioritizedContent

      protected List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> processUnprioritizedContent(List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> structuredContentList, Map<String,Object> ruleDTOs)
    • processContentRules

      protected boolean processContentRules(org.broadleafcommerce.common.structure.dto.StructuredContentDTO sc, Map<String,Object> ruleDTOs)
    • modifyStructuredContentDtoList

      protected List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> modifyStructuredContentDtoList(List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> structuredContentList)
    • lookupStructuredContentItemsByType

      public List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> lookupStructuredContentItemsByType(StructuredContentType contentType, org.broadleafcommerce.common.locale.domain.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 a SandBoxType 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 interface StructuredContentService
      Parameters:
      contentType - - the type of content to return
      count - - the max number of content items to return
      ruleDTOs - - 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<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> lookupStructuredContentItemsByName(StructuredContentType contentType, String contentName, org.broadleafcommerce.common.locale.domain.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 a SandBoxType 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 interface StructuredContentService
      Parameters:
      contentType - - the type of content to return
      contentName - - the name of content to return
      count - - the max number of content items to return
      ruleDTOs - - 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

      public List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> convertToDtos(List<StructuredContent> scs, boolean isSecure)
      Description copied from interface: StructuredContentService
      Converts a list of StructuredContent objects into their corresponding StructuredContentDTOs. This method will utilize a cache in production mode, and it will additionally hydrate the returned StructuredContentDTO objects via the #hydrateForeignLookups(List) method.
      Specified by:
      convertToDtos in interface StructuredContentService
      Returns:
      the list of StructuredContentDTOs
    • lookupStructuredContentItemsByName

      public List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> lookupStructuredContentItemsByName(String contentName, org.broadleafcommerce.common.locale.domain.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 a SandBoxType 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 interface StructuredContentService
      Parameters:
      contentName - - the name of content to return
      count - - the max number of content items to return
      ruleDTOs - - 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

      public List<org.broadleafcommerce.common.rule.RuleProcessor<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>> getContentRuleProcessors()
    • setContentRuleProcessors

      public void setContentRuleProcessors(List<org.broadleafcommerce.common.rule.RuleProcessor<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>> contentRuleProcessors)
    • removeStructuredContentFromCache

      public void removeStructuredContentFromCache(org.broadleafcommerce.common.sandbox.domain.SandBox sandBox, StructuredContent sc)
      Description copied from interface: StructuredContentService
      Call to evict an item from the cache.
      Specified by:
      removeStructuredContentFromCache in interface StructuredContentService
    • removeItemFromCacheByKey

      public boolean removeItemFromCacheByKey(String key)
      Description copied from interface: StructuredContentService
      Call to evict both secure and non-secure SC items matching the passed in key.
      Specified by:
      removeItemFromCacheByKey in interface StructuredContentService
      Returns:
    • removeItemFromCache

      public void removeItemFromCache(String nameKey, String typeKey)
      Description copied from interface: StructuredContentService
      Call to evict both secure and non-secure SC items matching the passed in keys.
      Specified by:
      removeItemFromCache in interface StructuredContentService
    • findLanguageOnlyLocale

      public org.broadleafcommerce.common.locale.domain.Locale findLanguageOnlyLocale(org.broadleafcommerce.common.locale.domain.Locale locale)
      Specified by:
      findLanguageOnlyLocale in interface StructuredContentService
    • getStructuredContentCache

      public javax.cache.Cache getStructuredContentCache()
      Specified by:
      getStructuredContentCache in interface StructuredContentService
    • buildRuleExpression

      protected String buildRuleExpression(StructuredContent sc)
    • buildItemCriteriaDTOList

      protected List<org.broadleafcommerce.common.structure.dto.ItemCriteriaDTO> buildItemCriteriaDTOList(StructuredContent sc)
    • buildFieldValues

      protected void buildFieldValues(StructuredContent sc, org.broadleafcommerce.common.structure.dto.StructuredContentDTO scDTO, boolean secure)
      Parses the given 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 prefix

      Parameters:
      sc -
      scDTO -
      secure -
    • hasCmsPrefix

      protected boolean hasCmsPrefix(String originalValue, String cmsPrefix)
    • buildFieldValueWithCmsPrefix

      protected void buildFieldValueWithCmsPrefix(String originalValue, org.broadleafcommerce.common.structure.dto.StructuredContentDTO scDTO, boolean secure, String fieldKey)
    • buildStructuredContentDTO

      public org.broadleafcommerce.common.structure.dto.StructuredContentDTO buildStructuredContentDTO(StructuredContent sc, boolean secure)
      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 the EntityConfiguration. To override the actual type that is returned, include an override in an applicationContext like any other entity override.

      Specified by:
      buildStructuredContentDTO in interface StructuredContentService
      Parameters:
      sc -
      secure -
      Returns:
    • buildNameKey

      protected String buildNameKey(org.broadleafcommerce.common.sandbox.domain.SandBox sandBox, StructuredContent sc)
    • buildNameKey

      protected String buildNameKey(org.broadleafcommerce.common.sandbox.domain.SandBox sandBox, StructuredContent sc, Boolean secure)
    • buildNameKey

      protected String buildNameKey(org.broadleafcommerce.common.sandbox.domain.SandBox currentSandbox, Long site, org.broadleafcommerce.common.locale.domain.Locale locale, String contentType, String contentName)
    • buildNameKey

      protected String buildNameKey(org.broadleafcommerce.common.sandbox.domain.SandBox currentSandbox, Long site, org.broadleafcommerce.common.locale.domain.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

      protected String buildTypeKey(org.broadleafcommerce.common.sandbox.domain.SandBox sandBox, StructuredContent sc)
    • buildTypeKey

      public String buildTypeKey(org.broadleafcommerce.common.sandbox.domain.SandBox currentSandbox, Long site, org.broadleafcommerce.common.locale.domain.Locale locale, String contentType)
      Description copied from interface: StructuredContentService
      Builds the cache key for DTOLists based on the SC Type.
      Specified by:
      buildTypeKey in interface StructuredContentService
      Returns:
      cache key for DTOList
    • buildTypeKeyWithSecure

      public String buildTypeKeyWithSecure(org.broadleafcommerce.common.sandbox.domain.SandBox currentSandbox, Long site, org.broadleafcommerce.common.locale.domain.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 interface StructuredContentService
      Returns:
      cache key for DTOList
    • addStructuredContentListToCache

      public void addStructuredContentListToCache(String key, List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> scDTOList)
      Specified by:
      addStructuredContentListToCache in interface StructuredContentService
    • addSingleStructuredContentToCache

      protected void addSingleStructuredContentToCache(String key, org.broadleafcommerce.common.structure.dto.StructuredContentDTO scDTO)
    • getSingleStructuredContentFromCache

      protected org.broadleafcommerce.common.structure.dto.StructuredContentDTO getSingleStructuredContentFromCache(String key)
    • getStructuredContentListFromCache

      public List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> getStructuredContentListFromCache(String key)
      Specified by:
      getStructuredContentListFromCache in interface StructuredContentService
    • getStructuredContentItemsByContentName

      public List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> getStructuredContentItemsByContentName(String contentName, org.broadleafcommerce.common.locale.domain.Locale locale, boolean secure)
      Description copied from interface: StructuredContentService
      First attempts to retrieve StructuredContentDTO from cache before making calls to database
      Specified by:
      getStructuredContentItemsByContentName in interface StructuredContentService
      Parameters:
      contentName - (Name of ContentItem
      Returns: