Class StaticAssetPathServiceImpl
- All Implemented Interfaces:
StaticAssetPathService
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String
addThemeContextIfNeeded
(String assetURL) convertAllAssetPathsInContent
(String content, boolean secureRequest) This method will take in a content string (e.g.convertAssetPath
(String assetPath, String contextPath, boolean secureRequest) This method will take in an assetPath (think image url) and prepend the staticAssetUrlPrefix if one exists.Returns the secure value of the environment url prefix (e.g. prefixed with https if needed).Returns the value configured for the current environment for the static asset url prefix.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
-
Field Details
-
staticAssetUrlPrefix
-
staticAssetEnvironmentUrlPrefix
-
staticAssetEnvironmentSecureUrlPrefix
-
-
Constructor Details
-
StaticAssetPathServiceImpl
public StaticAssetPathServiceImpl()
-
-
Method Details
-
convertAllAssetPathsInContent
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 interfaceStaticAssetPathService
- Parameters:
content
- - The content string to rewrite if it contains a cms managed assetsecureRequest
- - 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
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"
Also, since all paths are intended to be URLs, there should be no system-specific separator characters like '\' for Windows. All paths should be unix file paths as URLs.
- Specified by:
convertAssetPath
in interfaceStaticAssetPathService
- Parameters:
assetPath
- - The path to rewrite if it is a cms managed assetcontextPath
- - 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
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 interfaceStaticAssetPathService
-
setStaticAssetUrlPrefix
Description copied from interface:StaticAssetPathService
Sets the static asset url prefix- Specified by:
setStaticAssetUrlPrefix
in interfaceStaticAssetPathService
-
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 interfaceStaticAssetPathService
-
setStaticAssetEnvironmentUrlPrefix
Description copied from interface:StaticAssetPathService
Sets the environment url prefix.- Specified by:
setStaticAssetEnvironmentUrlPrefix
in interfaceStaticAssetPathService
-
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 interfaceStaticAssetPathService
-
setStaticAssetEnvironmentSecureUrlPrefix
-
addThemeContextIfNeeded
-