org.broadleafcommerce.cms.page.service
Class PageServiceImpl

java.lang.Object
  extended by org.broadleafcommerce.cms.common.AbstractContentService
      extended by org.broadleafcommerce.cms.page.service.PageServiceImpl
All Implemented Interfaces:
PageService, SandBoxItemListener

@Service(value="blPageService")
public class PageServiceImpl
extends AbstractContentService
implements PageService, SandBoxItemListener

Created by bpolster.


Field Summary
protected  List<ArchivedPagePublisher> archivedPageListeners
           
protected  boolean automaticallyApproveAndPromotePages
           
protected  LocaleService localeService
           
protected  net.sf.ehcache.Cache pageCache
           
protected  PageDao pageDao
           
protected  List<PageRuleProcessor> pageRuleProcessors
           
protected  SandBoxDao sandBoxDao
           
protected  SandBoxItemDao sandBoxItemDao
           
protected  StaticAssetService staticAssetService
           
 
Constructor Summary
PageServiceImpl()
           
 
Method Summary
 Page addPage(Page page, SandBox destinationSandbox)
          This method is intended to be called from within the CMS admin only.
protected  PageDTO buildPageDTOInternal(Page page, boolean secure)
           
protected  List<PageDTO> buildPageDTOList(List<Page> pageList, boolean secure)
          Converts a list of pages to a list of pageDTOs.
Internally calls buildPageDTO(...).
protected  String buildRuleExpression(Page page)
           
 Long countPages(SandBox sandbox, org.hibernate.Criteria c)
           
 void deletePage(Page page, SandBox destinationSandbox)
          If deleting and item where page.originalPageId != null then the item is deleted from the database.
protected  PageDTO evaluatePageRules(List<PageDTO> pageDTOList, Map<String,Object> ruleDTOs)
           
 Page findPageById(Long pageId)
          Returns the page with the passed in id.
 PageDTO findPageByURI(SandBox currentSandbox, Locale locale, String uri, Map<String,Object> ruleDTOs, boolean secure)
          Retrieve the page if one is available for the passed in uri.
 Map<String,PageField> findPageFieldsByPageId(Long pageId)
          Returns the page-fields associated with the passed in page-id.
 List<Page> findPages(SandBox sandbox, org.hibernate.Criteria c)
           
 PageTemplate findPageTemplateById(Long id)
          Returns the page template with the passed in id.
 List<ArchivedPagePublisher> getArchivedPageListeners()
           
 boolean isAutomaticallyApproveAndPromotePages()
           
 void itemPromoted(SandBoxItem sandBoxItem, SandBox destinationSandBox)
           
 void itemRejected(SandBoxItem sandBoxItem, SandBox destinationSandBox)
           
 void itemReverted(SandBoxItem sandBoxItem)
           
protected  List<PageDTO> mergePages(List<PageDTO> productionPageList, List<Page> sandboxPageList, boolean secure)
           
protected  boolean passesPageRules(PageDTO page, Map<String,Object> ruleDTOs)
           
protected  void productionItemArchived(Page page)
           
 void removePageFromCache(Page p)
          Call to evict an item from the cache.
 void removePageFromCache(String baseKey)
          Call to evict both secure and non-secure pages matching the passed in key.
 void setArchivedPageListeners(List<ArchivedPagePublisher> archivedPageListeners)
           
 void setAutomaticallyApproveAndPromotePages(boolean automaticallyApproveAndPromotePages)
           
 Page updatePage(Page page, 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

pageDao

protected PageDao pageDao

sandBoxItemDao

protected SandBoxItemDao sandBoxItemDao

sandBoxDao

protected SandBoxDao sandBoxDao

pageRuleProcessors

protected List<PageRuleProcessor> pageRuleProcessors

localeService

protected LocaleService localeService

staticAssetService

protected StaticAssetService staticAssetService

automaticallyApproveAndPromotePages

@Value(value="${automatically.approve.pages}")
protected boolean automaticallyApproveAndPromotePages

pageCache

protected net.sf.ehcache.Cache pageCache

archivedPageListeners

protected List<ArchivedPagePublisher> archivedPageListeners
Constructor Detail

PageServiceImpl

public PageServiceImpl()
Method Detail

findPageById

public Page findPageById(Long pageId)
Returns the page with the passed in id.

Specified by:
findPageById in interface PageService
Parameters:
pageId - - The id of the page.
Returns:
The associated page.

findPageTemplateById

public PageTemplate findPageTemplateById(Long id)
Description copied from interface: PageService
Returns the page template with the passed in id.

Specified by:
findPageTemplateById in interface PageService
Parameters:
id - - the id of the page template
Returns:
The associated page template.

findPageFieldsByPageId

public Map<String,PageField> findPageFieldsByPageId(Long pageId)
Returns the page-fields associated with the passed in page-id. This is preferred over the direct access from Page so that the two items can be cached distinctly

Specified by:
findPageFieldsByPageId in interface PageService
Parameters:
pageId - - The id of the page.
Returns:
The associated page.

addPage

public Page addPage(Page page,
                    SandBox destinationSandbox)
This method is intended to be called from within the CMS admin only.

Adds the passed in page to the DB.

Specified by:
addPage in interface PageService

updatePage

public Page updatePage(Page page,
                       SandBox destSandbox)
This method is intended to be called from within the CMS admin only.

Updates the page 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 page and add it to the new sandbox and set the cloned page's originalPageId to the id of the page 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 page 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 page has an originalPageId, then update that page by setting it's archived flag to true.

Then, update the siteId of the page being updated to be the siteId of the original page.

4. If the sandbox is the same then just update the page.

Specified by:
updatePage in interface PageService

deletePage

public void deletePage(Page page,
                       SandBox destinationSandbox)
If deleting and item where page.originalPageId != null then the item is deleted from the database.

If the originalPageId is null, then this method marks the items as deleted within the passed in sandbox.

Specified by:
deletePage in interface PageService
Parameters:
page -
destinationSandbox -

buildPageDTOList

protected List<PageDTO> buildPageDTOList(List<Page> pageList,
                                         boolean secure)
Converts a list of pages to a list of pageDTOs.
Internally calls buildPageDTO(...).

Parameters:
pageList -
secure -
Returns:

buildPageDTOInternal

protected PageDTO buildPageDTOInternal(Page page,
                                       boolean secure)

buildRuleExpression

protected String buildRuleExpression(Page page)

mergePages

protected List<PageDTO> mergePages(List<PageDTO> productionPageList,
                                   List<Page> sandboxPageList,
                                   boolean secure)

evaluatePageRules

protected PageDTO evaluatePageRules(List<PageDTO> pageDTOList,
                                    Map<String,Object> ruleDTOs)

passesPageRules

protected boolean passesPageRules(PageDTO page,
                                  Map<String,Object> ruleDTOs)

findPageByURI

public PageDTO findPageByURI(SandBox currentSandbox,
                             Locale locale,
                             String uri,
                             Map<String,Object> ruleDTOs,
                             boolean secure)
Retrieve the page if one is available for the passed in uri.

Specified by:
findPageByURI in interface PageService
Parameters:
currentSandbox - - current sandbox
locale - - current locale
uri - - the URI to return a page for
ruleDTOs - - ruleDTOs that are used as the data to process page rules
secure - - set to true if current request is over HTTPS
Returns:

findPages

public List<Page> findPages(SandBox sandbox,
                            org.hibernate.Criteria c)
Specified by:
findPages in interface PageService

countPages

public Long countPages(SandBox sandbox,
                       org.hibernate.Criteria c)
Specified by:
countPages in interface PageService

productionItemArchived

protected void productionItemArchived(Page page)

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

removePageFromCache

public void removePageFromCache(Page p)
Call to evict an item from the cache.

Parameters:
p -

removePageFromCache

public void removePageFromCache(String baseKey)
Call to evict both secure and non-secure pages matching the passed in key.

Specified by:
removePageFromCache in interface PageService
Parameters:
baseKey -

getArchivedPageListeners

public List<ArchivedPagePublisher> getArchivedPageListeners()
Specified by:
getArchivedPageListeners in interface PageService

setArchivedPageListeners

public void setArchivedPageListeners(List<ArchivedPagePublisher> archivedPageListeners)
Specified by:
setArchivedPageListeners in interface PageService

isAutomaticallyApproveAndPromotePages

public boolean isAutomaticallyApproveAndPromotePages()
Specified by:
isAutomaticallyApproveAndPromotePages in interface PageService

setAutomaticallyApproveAndPromotePages

public void setAutomaticallyApproveAndPromotePages(boolean automaticallyApproveAndPromotePages)
Specified by:
setAutomaticallyApproveAndPromotePages in interface PageService


Copyright © 2013. All Rights Reserved.