org.broadleafcommerce.cms.structure.service
Class StructuredContentServiceImpl

java.lang.Object
  extended by org.broadleafcommerce.cms.structure.service.StructuredContentServiceImpl
All Implemented Interfaces:
StructuredContentService

@Service(value="blStructuredContentService")
public class StructuredContentServiceImpl
extends Object
implements StructuredContentService

Author:
bpolster

Field Summary
protected static String AND
           
protected  List<RuleProcessor<StructuredContentDTO>> contentRuleProcessors
           
protected  EntityConfiguration entityConfiguration
           
protected  StructuredContentServiceExtensionManager extensionManager
           
protected  LocaleService localeService
           
protected static org.apache.commons.logging.Log LOG
           
protected  StaticAssetPathService staticAssetPathService
           
protected  StaticAssetService staticAssetService
           
protected  StatisticsService statisticsService
           
protected  net.sf.ehcache.Cache structuredContentCache
           
protected  StructuredContentDao structuredContentDao
           
 
Constructor Summary
StructuredContentServiceImpl()
           
 
Method Summary
 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  List<ItemCriteriaDTO> buildItemCriteriaDTOList(StructuredContent sc)
           
protected  String buildNameKey(SandBox currentSandbox, Locale locale, String contentType, String contentName)
           
protected  String buildNameKey(SandBox sandBox, StructuredContent sc)
           
protected  String buildRuleExpression(StructuredContent sc)
           
protected  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, Locale locale, String contentType)
           
protected  String buildTypeKey(SandBox sandBox, StructuredContent sc)
           
 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()
           
 net.sf.ehcache.Cache getStructuredContentCache()
           
 List<StructuredContentDTO> getStructuredContentListFromCache(String key)
           
 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  boolean processContentRules(StructuredContentDTO sc, Map<String,Object> ruleDTOs)
           
 void removeItemFromCache(String nameKey, String typeKey)
          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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

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

AND

protected static String AND

structuredContentDao

protected StructuredContentDao structuredContentDao

staticAssetService

protected StaticAssetService staticAssetService

staticAssetPathService

protected StaticAssetPathService staticAssetPathService

localeService

protected LocaleService localeService

contentRuleProcessors

protected List<RuleProcessor<StructuredContentDTO>> contentRuleProcessors

entityConfiguration

protected EntityConfiguration entityConfiguration

extensionManager

protected StructuredContentServiceExtensionManager extensionManager

statisticsService

protected StatisticsService statisticsService

structuredContentCache

protected net.sf.ehcache.Cache structuredContentCache
Constructor Detail

StructuredContentServiceImpl

public StructuredContentServiceImpl()
Method Detail

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

findContentItems

public List<StructuredContent> findContentItems(org.hibernate.Criteria c)
Description copied from interface: StructuredContentService
This method is intended to be called solely from the CMS admin. Similar methods exist that are intended for other clients (e.g. lookupStructuredContentItemsBy....
Returns content items for the passed in sandbox that match the passed in criteria. The criteria acts as a where clause to be used in the search for content items. Implementations should automatically add criteria such that no archived items are returned from this method.
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:
findContentItems in interface StructuredContentService
Parameters:
c - - the criteria used to search for content
Returns:

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:

countContentItems

public Long countContentItems(org.hibernate.Criteria c)
Description copied from interface: StructuredContentService
Follows the same rules as findContentItems.

Specified by:
countContentItems in interface StructuredContentService
Returns:
the count of items in this sandbox that match the passed in Criteria

saveStructuredContentType

public StructuredContentType saveStructuredContentType(StructuredContentType type)
Saves the given type and returns the merged instance

Specified by:
saveStructuredContentType in interface StructuredContentService

buildStructuredContentDTOList

public 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(...).

Specified by:
buildStructuredContentDTOList in interface StructuredContentService
Parameters:
structuredContentList -
secure -
Returns:
See Also:
#buildStructuredContentDTO(StructuredContent, boolean)}

evaluateAndPriortizeContent

public List<StructuredContentDTO> evaluateAndPriortizeContent(List<StructuredContentDTO> structuredContentList,
                                                              int count,
                                                              Map<String,Object> ruleDTOs)
Specified by:
evaluateAndPriortizeContent in interface StructuredContentService

lookupStructuredContentItemsByType

public List<StructuredContentDTO> lookupStructuredContentItemsByType(StructuredContentType contentType,
                                                                     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:
DisplayContentTag

lookupStructuredContentItemsByName

public List<StructuredContentDTO> lookupStructuredContentItemsByName(StructuredContentType contentType,
                                                                     String contentName,
                                                                     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:
DisplayContentTag

lookupStructuredContentItemsByName

public List<StructuredContentDTO> lookupStructuredContentItemsByName(String contentName,
                                                                     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:
DisplayContentTag

getContentRuleProcessors

public List<RuleProcessor<StructuredContentDTO>> getContentRuleProcessors()

setContentRuleProcessors

public void setContentRuleProcessors(List<RuleProcessor<StructuredContentDTO>> contentRuleProcessors)

removeStructuredContentFromCache

public void removeStructuredContentFromCache(SandBox sandBox,
                                             StructuredContent sc)
Call to evict an item from the cache.

Specified by:
removeStructuredContentFromCache in interface StructuredContentService
Parameters:
sc -

findLanguageOnlyLocale

public Locale findLanguageOnlyLocale(Locale locale)
Specified by:
findLanguageOnlyLocale in interface StructuredContentService

getStructuredContentCache

public net.sf.ehcache.Cache getStructuredContentCache()
Specified by:
getStructuredContentCache in interface StructuredContentService

removeItemFromCache

public void removeItemFromCache(String nameKey,
                                String typeKey)
Call to evict both secure and non-secure SC items matching the passed in key.

Specified by:
removeItemFromCache in interface StructuredContentService
Parameters:
nameKey -

buildRuleExpression

protected String buildRuleExpression(StructuredContent sc)

buildItemCriteriaDTOList

protected List<ItemCriteriaDTO> buildItemCriteriaDTOList(StructuredContent sc)

buildFieldValues

protected void buildFieldValues(StructuredContent sc,
                                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 -
See Also:
StaticAssetService#getStaticAssetEnvironmentUrlPrefix()}

buildStructuredContentDTO

protected 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.

Parameters:
sc -
secure -
Returns:

processContentRules

protected boolean processContentRules(StructuredContentDTO sc,
                                      Map<String,Object> ruleDTOs)

buildTypeKey

public String buildTypeKey(SandBox currentSandbox,
                           Locale locale,
                           String contentType)
Specified by:
buildTypeKey in interface StructuredContentService

buildNameKey

protected String buildNameKey(SandBox sandBox,
                              StructuredContent sc)

buildTypeKey

protected String buildTypeKey(SandBox sandBox,
                              StructuredContent sc)

buildNameKey

protected String buildNameKey(SandBox currentSandbox,
                              Locale locale,
                              String contentType,
                              String contentName)

addStructuredContentListToCache

public void addStructuredContentListToCache(String key,
                                            List<StructuredContentDTO> scDTOList)
Specified by:
addStructuredContentListToCache in interface StructuredContentService

getStructuredContentListFromCache

public List<StructuredContentDTO> getStructuredContentListFromCache(String key)
Specified by:
getStructuredContentListFromCache in interface StructuredContentService


Copyright © 2013. All Rights Reserved.