org.broadleafcommerce.common.file.service
Class StaticAssetPathServiceImpl

java.lang.Object
  extended by org.broadleafcommerce.common.file.service.StaticAssetPathServiceImpl
All Implemented Interfaces:
StaticAssetPathService

@Service(value="blStaticAssetPathService")
public class StaticAssetPathServiceImpl
extends Object
implements StaticAssetPathService


Field Summary
protected  String staticAssetEnvironmentSecureUrlPrefix
           
protected  String staticAssetEnvironmentUrlPrefix
           
protected  String staticAssetUrlPrefix
           
 
Constructor Summary
StaticAssetPathServiceImpl()
           
 
Method Summary
 String convertAllAssetPathsInContent(String content, boolean secureRequest)
          This method will take in a content string (e.g.
 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.
 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 setStaticAssetEnvironmentSecureUrlPrefix(String staticAssetEnvironmentSecureUrlPrefix)
           
 void setStaticAssetEnvironmentUrlPrefix(String staticAssetEnvironmentUrlPrefix)
          Sets the environment url prefix.
 void setStaticAssetUrlPrefix(String staticAssetUrlPrefix)
          Sets the static asset url prefix
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

staticAssetUrlPrefix

@Value(value="${asset.server.url.prefix.internal}")
protected String staticAssetUrlPrefix

staticAssetEnvironmentUrlPrefix

@Value(value="${asset.server.url.prefix}")
protected String staticAssetEnvironmentUrlPrefix

staticAssetEnvironmentSecureUrlPrefix

@Value(value="${asset.server.url.prefix.secure}")
protected String staticAssetEnvironmentSecureUrlPrefix
Constructor Detail

StaticAssetPathServiceImpl

public StaticAssetPathServiceImpl()
Method Detail

convertAllAssetPathsInContent

public String convertAllAssetPathsInContent(String content,
                                            boolean secureRequest)
This method will take in a content string (e.g. StructuredContentDTO or PageDTO HTML/ASSET_LOOKUP/STRING field value) and replace any instances of "staticAssetUrlPrefix" in the string with the "staticAssetEnvironmentUrlPrefix" or the "staticAssetEnvironmentSecureUrlPrefix" depending on if the request was secure and if it was configured. Given asset.server.url.prefix.internal=cmsstatic Given asset.server.url.prefix=http://static.mydomain.com/cmsstatic Given asset.server.url.prefix.secure=https://static.mydomain.com/cmsstatic Example 1: Given content = "

" The result should yield: "

" Example 2: Given content = "

" The result should yield: "

"

Specified by:
convertAllAssetPathsInContent in interface StaticAssetPathService
Parameters:
content - - The content string to rewrite if it contains a cms managed asset
secureRequest - - True if the request is being served over https
Returns:
See Also:
org.broadleafcommerce.common.file.service.StaticAssetService#getStaticAssetUrlPrefix(), org.broadleafcommerce.common.file.service.StaticAssetService#getStaticAssetEnvironmentUrlPrefix()

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. Example 1: Given asset.server.url.prefix.internal=cmsstatic Given asset.server.url.prefix=http://static.mydomain.com/cmsstatic Given asset.server.url.prefix.secure=https://static.mydomain.com/cmsstatic Given assetPath = "/cmsstatic/my_image.jpg" The result should yield: "http://static.mydomain.com/cmsstatic/my_image.jpg" Example 2: Given asset.server.url.prefix.internal=cmsstatic Given asset.server.url.prefix= Given asset.server.url.prefix.secure= Given assetPath = "/cmsstatic/my_image.jpg" Given contextPath = "myApp" The result should yield: "/myApp/cmsstatic/my_image.jpg"

Specified by:
convertAssetPath in interface StaticAssetPathService
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:
org.broadleafcommerce.common.file.service.StaticAssetService#getStaticAssetUrlPrefix(), org.broadleafcommerce.common.file.service.StaticAssetService#getStaticAssetEnvironmentUrlPrefix()

getStaticAssetUrlPrefix

public String getStaticAssetUrlPrefix()
Description copied from interface: StaticAssetPathService
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 StaticAssetPathService

setStaticAssetUrlPrefix

public void setStaticAssetUrlPrefix(String staticAssetUrlPrefix)
Description copied from interface: StaticAssetPathService
Sets the static asset url prefix

Specified by:
setStaticAssetUrlPrefix in interface StaticAssetPathService

getStaticAssetEnvironmentUrlPrefix

public String getStaticAssetEnvironmentUrlPrefix()
Description copied from interface: StaticAssetPathService
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 StaticAssetPathService

setStaticAssetEnvironmentUrlPrefix

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

Specified by:
setStaticAssetEnvironmentUrlPrefix in interface StaticAssetPathService

getStaticAssetEnvironmentSecureUrlPrefix

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

Specified by:
getStaticAssetEnvironmentSecureUrlPrefix in interface StaticAssetPathService

setStaticAssetEnvironmentSecureUrlPrefix

public void setStaticAssetEnvironmentSecureUrlPrefix(String staticAssetEnvironmentSecureUrlPrefix)


Copyright © 2013. All Rights Reserved.