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 java.lang.Object
implements StructuredContentService

Created by 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.
 java.lang.Long countContentItems(SandBox sandbox, org.hibernate.Criteria c)
          Returns the count of items that match the passed in criteria.
 void deleteStructuredContent(StructuredContent content, SandBox destinationSandbox)
          If deleting and item where content.originalItemId != null then the item is deleted from the database.
 java.util.List<StructuredContent> findContentItems(SandBox sandbox, org.hibernate.Criteria c)
          Retuns content items for the passed in sandbox that match the passed in criteria.
 java.util.Map<java.lang.String,StructuredContentField> findFieldsByContentId(java.lang.Long contentId)
          Returns the fields associated with the passed in contentId.
 StructuredContent findStructuredContentById(java.lang.Long contentId)
          Returns the StructuredContent item associated with the passed in id.
 StructuredContentType findStructuredContentTypeById(java.lang.Long id)
           
 StructuredContentType findStructuredContentTypeByName(java.lang.String name)
           
 java.util.List<StructuredContentRuleProcessor> getContentRuleProcessors()
           
 void itemPromoted(SandBoxItem sandBoxItem, SandBox destinationSandBox)
           
 void itemRejected(SandBoxItem sandBoxItem, SandBox destinationSandBox)
           
 void itemReverted(SandBoxItem sandBoxItem)
           
 java.util.List<StructuredContent> lookupStructuredContentItemsByName(SandBox sandBox, StructuredContentType contentType, java.lang.String contentName, Locale locale, java.lang.Integer count, java.util.Map<java.lang.String,java.lang.Object> ruleDTOs)
           
 java.util.List<StructuredContent> lookupStructuredContentItemsByType(SandBox sandBox, StructuredContentType contentType, Locale locale, java.lang.Integer count, java.util.Map<java.lang.String,java.lang.Object> ruleDTOs)
           
 java.util.List<StructuredContentType> retrieveAllStructuredContentTypes()
          Returns the list of structured content types.
 void setContentRuleProcessors(java.util.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(java.lang.Long contentId)
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(java.lang.Long id)
Specified by:
findStructuredContentTypeById in interface StructuredContentService

findStructuredContentTypeByName

public StructuredContentType findStructuredContentTypeByName(java.lang.String name)
Specified by:
findStructuredContentTypeByName in interface StructuredContentService

retrieveAllStructuredContentTypes

public java.util.List<StructuredContentType> retrieveAllStructuredContentTypes()
Returns the list of structured content types.

Specified by:
retrieveAllStructuredContentTypes in interface StructuredContentService

findFieldsByContentId

public java.util.Map<java.lang.String,StructuredContentField> findFieldsByContentId(java.lang.Long contentId)
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 java.util.List<StructuredContent> findContentItems(SandBox sandbox,
                                                          org.hibernate.Criteria c)
Retuns content items for the passed in sandbox that match the passed in criteria.

Merges the sandbox content with the production content.

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.
Returns:

countContentItems

public java.lang.Long countContentItems(SandBox sandbox,
                                        org.hibernate.Criteria c)
Returns the count of items that match the passed in criteria. This counts the items in production + the new items in the sandbox - the existing items that have been deleted in the sandbox.

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)
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)
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)
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
Parameters:
content -
destinationSandbox -

lookupStructuredContentItemsByType

public java.util.List<StructuredContent> lookupStructuredContentItemsByType(SandBox sandBox,
                                                                            StructuredContentType contentType,
                                                                            Locale locale,
                                                                            java.lang.Integer count,
                                                                            java.util.Map<java.lang.String,java.lang.Object> ruleDTOs)
Specified by:
lookupStructuredContentItemsByType in interface StructuredContentService

lookupStructuredContentItemsByName

public java.util.List<StructuredContent> lookupStructuredContentItemsByName(SandBox sandBox,
                                                                            StructuredContentType contentType,
                                                                            java.lang.String contentName,
                                                                            Locale locale,
                                                                            java.lang.Integer count,
                                                                            java.util.Map<java.lang.String,java.lang.Object> ruleDTOs)
Specified by:
lookupStructuredContentItemsByName in interface StructuredContentService

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 java.util.List<StructuredContentRuleProcessor> getContentRuleProcessors()

setContentRuleProcessors

public void setContentRuleProcessors(java.util.List<StructuredContentRuleProcessor> contentRuleProcessors)


Copyright © 2011. All Rights Reserved.