org.broadleafcommerce.cms.structure.service
Class StructuredContentServiceImpl

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

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

Author:
bpolster

Field Summary
protected  SandBoxDao sandBoxDao
           
protected  SandBoxItemDao sandBoxItemDao
           
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.
 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<StructuredContentRuleProcessor> getContentRuleProcessors()
           
 void itemPromoted(SandBoxItem sandBoxItem, SandBox destinationSandBox)
           
 void itemRejected(SandBoxItem sandBoxItem, SandBox destinationSandBox)
           
 void itemReverted(SandBoxItem sandBoxItem)
           
 List<StructuredContent> lookupStructuredContentItemsByName(SandBox sandBox, StructuredContentType contentType, String contentName, Locale locale, Integer count, Map<String,Object> ruleDTOs)
          This method returns content
Returns active content items for the passed in sandbox that match the passed in type.
 List<StructuredContent> lookupStructuredContentItemsByType(SandBox sandBox, StructuredContentType contentType, Locale locale, Integer count, Map<String,Object> ruleDTOs)
          This method returns content
Returns active content items for the passed in sandbox that match the passed in type.
 List<StructuredContentType> retrieveAllStructuredContentTypes()
           
 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 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
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

lookupStructuredContentItemsByType

public List<StructuredContent> lookupStructuredContentItemsByType(SandBox sandBox,
                                                                  StructuredContentType contentType,
                                                                  Locale locale,
                                                                  Integer count,
                                                                  Map<String,Object> ruleDTOs)
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.

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.
Returns:
- The matching items
See Also:
DisplayContentTag

lookupStructuredContentItemsByName

public List<StructuredContent> lookupStructuredContentItemsByName(SandBox sandBox,
                                                                  StructuredContentType contentType,
                                                                  String contentName,
                                                                  Locale locale,
                                                                  Integer count,
                                                                  Map<String,Object> ruleDTOs)
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.

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.
Returns:
- The matching items
See Also:
DisplayContentTag

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)


Copyright © 2011. All Rights Reserved.