org.broadleafcommerce.cms.structure.service
Class StructuredContentServiceImpl

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

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

Author:
bpolster

Field Summary
protected  List<ArchivedStructuredContentPublisher> archivedStructuredContentListeners
           
protected  boolean automaticallyApproveAndPromoteStructuredContent
           
protected  List<StructuredContentRuleProcessor> contentRuleProcessors
           
protected  SandBoxDao sandBoxDao
           
protected  SandBoxItemDao sandBoxItemDao
           
protected  StaticAssetService staticAssetService
           
protected  net.sf.ehcache.Cache structuredContentCache
           
protected  StructuredContentDao structuredContentDao
           
 
Constructor Summary
StructuredContentServiceImpl()
           
 
Method Summary
 StructuredContent addStructuredContent(StructuredContent content, SandBox destinationSandbox)
          This method is intended to be called from within the CMS admin only.
protected  StructuredContentDTO buildStructuredContentDTO(StructuredContent sc, boolean secure)
          Converts a StructuredContent into a StructuredContentDTO.
protected  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(...).
 Long countContentItems(SandBox sandbox, org.hibernate.Criteria c)
          Follows the same rules as findContentItems.
 void deleteStructuredContent(StructuredContent content, SandBox destinationSandbox)
          If deleting and item where content.originalItemId != null then the item is deleted from the database.
 List<StructuredContent> findContentItems(SandBox sandbox, org.hibernate.Criteria c)
          This method is intended to be called solely from the CMS admin.
 Map<String,StructuredContentField> findFieldsByContentId(Long contentId)
          Returns the fields associated with the passed in contentId.
 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<ArchivedStructuredContentPublisher> getArchivedStructuredContentListeners()
           
 List<StructuredContentRuleProcessor> getContentRuleProcessors()
           
 boolean isAutomaticallyApproveAndPromoteStructuredContent()
           
 void itemPromoted(SandBoxItem sandBoxItem, SandBox destinationSandBox)
           
 void itemRejected(SandBoxItem sandBoxItem, SandBox destinationSandBox)
           
 void itemReverted(SandBoxItem sandBoxItem)
           
 List<StructuredContentDTO> lookupStructuredContentItemsByName(SandBox sandBox, String contentName, Locale locale, Integer count, Map<String,Object> ruleDTOs, boolean secure)
          This method returns content by name only.
 List<StructuredContentDTO> lookupStructuredContentItemsByName(SandBox sandBox, 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(SandBox sandBox, 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  void productionItemArchived(StructuredContent sc)
           
 void removeItemFromCache(String nameKey, String typeKey)
          Call to evict both secure and non-secure SC items matching the passed in key.
 void removeStructuredContentFromCache(StructuredContent sc)
          Call to evict an item from the cache.
 List<StructuredContentType> retrieveAllStructuredContentTypes()
           
 void setArchivedStructuredContentListeners(List<ArchivedStructuredContentPublisher> archivedStructuredContentListeners)
           
 void setAutomaticallyApproveAndPromoteStructuredContent(boolean automaticallyApproveAndPromoteStructuredContent)
           
 void setContentRuleProcessors(List<StructuredContentRuleProcessor> contentRuleProcessors)
           
 StructuredContent updateStructuredContent(StructuredContent content, SandBox destSandbox)
          This method is intended to be called from within the CMS admin only.
 
Methods inherited from class org.broadleafcommerce.cms.common.AbstractContentService
countItems, findItems
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

structuredContentDao

protected StructuredContentDao structuredContentDao

sandBoxItemDao

protected SandBoxItemDao sandBoxItemDao

sandBoxDao

protected SandBoxDao sandBoxDao

staticAssetService

protected StaticAssetService staticAssetService

contentRuleProcessors

protected List<StructuredContentRuleProcessor> contentRuleProcessors

automaticallyApproveAndPromoteStructuredContent

@Value(value="${automatically.approve.structured.content}")
protected boolean automaticallyApproveAndPromoteStructuredContent

structuredContentCache

protected net.sf.ehcache.Cache structuredContentCache

archivedStructuredContentListeners

protected List<ArchivedStructuredContentPublisher> archivedStructuredContentListeners
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

findFieldsByContentId

public Map<String,StructuredContentField> findFieldsByContentId(Long contentId)
Description copied from interface: StructuredContentService
Returns the fields associated with the passed in contentId. This is preferred over the direct access from the ContentItem so that the two items can be cached distinctly

Specified by:
findFieldsByContentId in interface StructuredContentService
Parameters:
contentId - - The id of the content.
Returns:
Map of fields for this content id

findContentItems

public List<StructuredContent> findContentItems(SandBox sandbox,
                                                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:
sandbox - - the sandbox to find structured content items (null indicates items that are in production for sites that are single tenant.
c - - the criteria used to search for content
Returns:

countContentItems

public Long countContentItems(SandBox sandbox,
                              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

addStructuredContent

public StructuredContent addStructuredContent(StructuredContent content,
                                              SandBox destinationSandbox)
Description copied from interface: StructuredContentService
This method is intended to be called from within the CMS admin only. Adds the passed in contentItem to the DB. Creates a sandbox/site if one doesn't already exist.

Specified by:
addStructuredContent in interface StructuredContentService

updateStructuredContent

public StructuredContent updateStructuredContent(StructuredContent content,
                                                 SandBox destSandbox)
Description copied from interface: StructuredContentService
This method is intended to be called from within the CMS admin only. Updates the structuredContent according to the following rules: 1. If sandbox has changed from null to a value This means that the user is editing an item in production and the edit is taking place in a sandbox. Clone the item and add it to the new sandbox and set the cloned item's originalItemId to the id of the item being updated. 2. If the sandbox has changed from one value to another This means that the user is moving the item from one sandbox to another. Update the siteId for the item to the one associated with the new sandbox 3. If the sandbox has changed from a value to null This means that the item is moving from the sandbox to production. If the item has an originalItemId, then update that item by setting it's archived flag to true. Then, update the siteId of the item being updated to be the siteId of the original item. 4. If the sandbox is the same then just update the item.

Specified by:
updateStructuredContent in interface StructuredContentService

deleteStructuredContent

public void deleteStructuredContent(StructuredContent content,
                                    SandBox destinationSandbox)
Description copied from interface: StructuredContentService
If deleting and item where content.originalItemId != null then the item is deleted from the database. If the originalItemId is null, then this method marks the items as deleted within the passed in sandbox.

Specified by:
deleteStructuredContent in interface StructuredContentService

buildStructuredContentDTOList

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

Parameters:
structuredContentList -
secure -
Returns:

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

Parameters:
sc -
secure -
Returns:

lookupStructuredContentItemsByType

public List<StructuredContentDTO> lookupStructuredContentItemsByType(SandBox sandBox,
                                                                     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:
sandBox - - the sandbox to find structured content items (null indicates items that are in production for sites that are single tenant.
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(SandBox sandBox,
                                                                     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:
sandBox - - the sandbox to find structured content items (null indicates items that are in production for sites that are single tenant.
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(SandBox sandBox,
                                                                     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:
sandBox - - the sandbox to find structured content items (null indicates items that are in production for sites that are single tenant.
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

productionItemArchived

protected void productionItemArchived(StructuredContent sc)

itemPromoted

public void itemPromoted(SandBoxItem sandBoxItem,
                         SandBox destinationSandBox)
Specified by:
itemPromoted in interface SandBoxItemListener

itemRejected

public void itemRejected(SandBoxItem sandBoxItem,
                         SandBox destinationSandBox)
Specified by:
itemRejected in interface SandBoxItemListener

itemReverted

public void itemReverted(SandBoxItem sandBoxItem)
Specified by:
itemReverted in interface SandBoxItemListener

getContentRuleProcessors

public List<StructuredContentRuleProcessor> getContentRuleProcessors()

setContentRuleProcessors

public void setContentRuleProcessors(List<StructuredContentRuleProcessor> contentRuleProcessors)

removeStructuredContentFromCache

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

Parameters:
sc -

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 -
typeKey - - key for a type of content item

getArchivedStructuredContentListeners

public List<ArchivedStructuredContentPublisher> getArchivedStructuredContentListeners()

setArchivedStructuredContentListeners

public void setArchivedStructuredContentListeners(List<ArchivedStructuredContentPublisher> archivedStructuredContentListeners)

isAutomaticallyApproveAndPromoteStructuredContent

public boolean isAutomaticallyApproveAndPromoteStructuredContent()
Specified by:
isAutomaticallyApproveAndPromoteStructuredContent in interface StructuredContentService

setAutomaticallyApproveAndPromoteStructuredContent

public void setAutomaticallyApproveAndPromoteStructuredContent(boolean automaticallyApproveAndPromoteStructuredContent)
Specified by:
setAutomaticallyApproveAndPromoteStructuredContent in interface StructuredContentService


Copyright © 2013. All Rights Reserved.