org.broadleafcommerce.cms.file.service
Class StaticAssetServiceImpl

java.lang.Object
  extended by org.broadleafcommerce.cms.common.AbstractContentService
      extended by org.broadleafcommerce.cms.file.service.StaticAssetServiceImpl
All Implemented Interfaces:
StaticAssetService, SandBoxItemListener

@Service(value="blStaticAssetService")
public class StaticAssetServiceImpl
extends AbstractContentService
implements StaticAssetService

Created by bpolster.


Field Summary
protected  boolean automaticallyApproveAndPromoteStaticAssets
           
protected  SandBoxItemDao sandBoxItemDao
           
protected  StaticAssetDao staticAssetDao
           
protected  String staticAssetEnvironmentSecureUrlPrefix
           
protected  String staticAssetEnvironmentUrlPrefix
           
protected  StaticAssetStorageService staticAssetStorageService
           
protected  String staticAssetUrlPrefix
           
 
Constructor Summary
StaticAssetServiceImpl()
           
 
Method Summary
 StaticAsset addStaticAsset(StaticAsset staticAsset, SandBox destinationSandbox)
          This method is intended to be called from within the CMS admin only.
 String convertAssetPath(String assetPath, String contextPath, boolean secureRequest)
          This method will take in an assetPath (think image url) and prepend the staticAssetUrlPrefix if one exists.
 Long countAssets(SandBox sandbox, org.hibernate.Criteria c)
           
 void deleteStaticAsset(StaticAsset staticAsset, SandBox destinationSandbox)
          If deleting and item where page.originalPageId != null then the item is deleted from the database.
 List<StaticAsset> findAssets(SandBox sandbox, org.hibernate.Criteria c)
           
 StaticAsset findStaticAssetByFullUrl(String fullUrl, SandBox targetSandBox)
           
 StaticAsset findStaticAssetById(Long id)
           
 boolean getAutomaticallyApproveAndPromoteStaticAssets()
          If set to true, then this service will not use the SandBox concept and will instead automatically promote images to production as they are entered into the system.
 String getStaticAssetEnvironmentSecureUrlPrefix()
          Returns the secure value of the environment url prefix (e.g.
 String getStaticAssetEnvironmentUrlPrefix()
          Returns the value configured for the current environment for the static asset url prefix.
 String getStaticAssetUrlPrefix()
          Returns the value configured to mark an item as a static URL.
 void itemPromoted(SandBoxItem sandBoxItem, SandBox destinationSandBox)
           
 void itemRejected(SandBoxItem sandBoxItem, SandBox destinationSandBox)
           
 void itemReverted(SandBoxItem sandBoxItem)
           
 void setAutomaticallyApproveAndPromoteStaticAssets(boolean automaticallyApproveAndPromoteStaticAssets)
          If set to true, then this service will not use the SandBox concept and will instead automatically promote images to production as they are entered into the system.
 void setStaticAssetEnvironmentSecureUrlPrefix(String staticAssetEnvironmentSecureUrlPrefix)
           
 void setStaticAssetEnvironmentUrlPrefix(String staticAssetEnvironmentUrlPrefix)
          Sets the environment url prefix.
 void setStaticAssetUrlPrefix(String staticAssetUrlPrefix)
           
 StaticAsset updateStaticAsset(StaticAsset staticAsset, 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

staticAssetUrlPrefix

protected String staticAssetUrlPrefix

staticAssetEnvironmentUrlPrefix

protected String staticAssetEnvironmentUrlPrefix

staticAssetEnvironmentSecureUrlPrefix

protected String staticAssetEnvironmentSecureUrlPrefix

automaticallyApproveAndPromoteStaticAssets

protected boolean automaticallyApproveAndPromoteStaticAssets

staticAssetDao

protected StaticAssetDao staticAssetDao

sandBoxItemDao

protected SandBoxItemDao sandBoxItemDao

staticAssetStorageService

protected StaticAssetStorageService staticAssetStorageService
Constructor Detail

StaticAssetServiceImpl

public StaticAssetServiceImpl()
Method Detail

findStaticAssetById

public StaticAsset findStaticAssetById(Long id)
Specified by:
findStaticAssetById in interface StaticAssetService

findStaticAssetByFullUrl

public StaticAsset findStaticAssetByFullUrl(String fullUrl,
                                            SandBox targetSandBox)
Specified by:
findStaticAssetByFullUrl in interface StaticAssetService

addStaticAsset

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

Specified by:
addStaticAsset in interface StaticAssetService

updateStaticAsset

public StaticAsset updateStaticAsset(StaticAsset staticAsset,
                                     SandBox destSandbox)
Description copied from interface: StaticAssetService
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:
updateStaticAsset in interface StaticAssetService

deleteStaticAsset

public void deleteStaticAsset(StaticAsset staticAsset,
                              SandBox destinationSandbox)
Description copied from interface: StaticAssetService
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:
deleteStaticAsset in interface StaticAssetService

findAssets

public List<StaticAsset> findAssets(SandBox sandbox,
                                    org.hibernate.Criteria c)
Specified by:
findAssets in interface StaticAssetService

countAssets

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

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

getStaticAssetUrlPrefix

public String getStaticAssetUrlPrefix()
Description copied from interface: StaticAssetService
Returns the value configured to mark an item as a static URL. OOB BLC maintains this value in common.properties.

Specified by:
getStaticAssetUrlPrefix in interface StaticAssetService
Returns:

setStaticAssetUrlPrefix

public void setStaticAssetUrlPrefix(String staticAssetUrlPrefix)
Specified by:
setStaticAssetUrlPrefix in interface StaticAssetService

getStaticAssetEnvironmentUrlPrefix

public String getStaticAssetEnvironmentUrlPrefix()
Description copied from interface: StaticAssetService
Returns the value configured for the current environment for the static asset url prefix. If this is different than the common value, then the URLs will get rewritten by the FieldMapWrapper when called from the DisplayContentTag or ProcessURLFilter.

Specified by:
getStaticAssetEnvironmentUrlPrefix in interface StaticAssetService
Returns:

setStaticAssetEnvironmentUrlPrefix

public void setStaticAssetEnvironmentUrlPrefix(String staticAssetEnvironmentUrlPrefix)
Description copied from interface: StaticAssetService
Sets the environment url prefix.

Specified by:
setStaticAssetEnvironmentUrlPrefix in interface StaticAssetService

getStaticAssetEnvironmentSecureUrlPrefix

public String getStaticAssetEnvironmentSecureUrlPrefix()
Description copied from interface: StaticAssetService
Returns the secure value of the environment url prefix (e.g. prefixed with https if needed).

Specified by:
getStaticAssetEnvironmentSecureUrlPrefix in interface StaticAssetService
Returns:

setStaticAssetEnvironmentSecureUrlPrefix

public void setStaticAssetEnvironmentSecureUrlPrefix(String staticAssetEnvironmentSecureUrlPrefix)

getAutomaticallyApproveAndPromoteStaticAssets

public boolean getAutomaticallyApproveAndPromoteStaticAssets()
Description copied from interface: StaticAssetService
If set to true, then this service will not use the SandBox concept and will instead automatically promote images to production as they are entered into the system. This is recommended for the best workflow within the BLC-CMS and has been set as the default behavior.

Specified by:
getAutomaticallyApproveAndPromoteStaticAssets in interface StaticAssetService

setAutomaticallyApproveAndPromoteStaticAssets

public void setAutomaticallyApproveAndPromoteStaticAssets(boolean automaticallyApproveAndPromoteStaticAssets)
Description copied from interface: StaticAssetService
If set to true, then this service will not use the SandBox concept and will instead automatically promote images to production as they are entered into the system. This is recommended for the best workflow within the BLC-CMS and has been set as the default behavior.

Specified by:
setAutomaticallyApproveAndPromoteStaticAssets in interface StaticAssetService

convertAssetPath

public String convertAssetPath(String assetPath,
                               String contextPath,
                               boolean secureRequest)
This method will take in an assetPath (think image url) and prepend the staticAssetUrlPrefix if one exists. Will append any contextPath onto the request. If the incoming assetPath contains the internalStaticAssetPrefix and the image is being prepended, the prepend will be removed.

Specified by:
convertAssetPath in interface StaticAssetService
Parameters:
assetPath - - The path to rewrite if it is a cms managed asset
contextPath - - The context path of the web application (if applicable)
secureRequest - - True if the request is being served over https
Returns:
See Also:
StaticAssetService.getStaticAssetUrlPrefix(), StaticAssetService.getStaticAssetEnvironmentUrlPrefix()


Copyright © 2012. All Rights Reserved.