@Service(value="blStaticAssetService") public class StaticAssetServiceImpl extends AbstractContentService implements StaticAssetService
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
automaticallyApproveAndPromoteStaticAssets |
protected ImageArtifactProcessor |
imageArtifactProcessor |
protected SandBoxItemDao |
sandBoxItemDao |
protected StaticAssetDao |
staticAssetDao |
protected String |
staticAssetEnvironmentSecureUrlPrefix |
protected String |
staticAssetEnvironmentUrlPrefix |
protected StaticAssetStorageService |
staticAssetStorageService |
protected String |
staticAssetUrlPrefix |
protected boolean |
storeAssetsOnFileSystem |
| Constructor and Description |
|---|
StaticAssetServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
StaticAsset |
addStaticAsset(StaticAsset staticAsset,
org.broadleafcommerce.common.sandbox.domain.SandBox destinationSandbox)
This method is intended to be called from within the CMS
admin only.
|
protected String |
buildAssetURL(Map<String,String> assetProperties,
String originalFilename)
Will assemble the url from the passed in properties as
/{entityType}/{fileName}
/product/7001-ab12
If the properties above are not set, it will generate the fileName randomly.
|
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(org.broadleafcommerce.common.sandbox.domain.SandBox sandbox,
org.hibernate.Criteria c) |
StaticAsset |
createStaticAssetFromFile(org.springframework.web.multipart.MultipartFile file,
Map<String,String> properties)
Used when uploading a file to Broadleaf.
|
void |
deleteStaticAsset(StaticAsset staticAsset,
org.broadleafcommerce.common.sandbox.domain.SandBox destinationSandbox)
If deleting and item where page.originalPageId != null
then the item is deleted from the database.
|
List<StaticAsset> |
findAssets(org.broadleafcommerce.common.sandbox.domain.SandBox sandbox,
org.hibernate.Criteria c) |
StaticAsset |
findStaticAssetByFullUrl(String fullUrl,
org.broadleafcommerce.common.sandbox.domain.SandBox targetSandBox) |
StaticAsset |
findStaticAssetById(Long id) |
protected String |
generateFileName(int size)
Generates a filename as a set of Hex digits.
|
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.
|
protected String |
getFileExtension(String fileName) |
protected void |
getMimeType(org.springframework.web.multipart.MultipartFile file,
StaticAsset newAsset) |
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,
org.broadleafcommerce.common.sandbox.domain.SandBox destinationSandBox) |
void |
itemRejected(SandBoxItem sandBoxItem,
org.broadleafcommerce.common.sandbox.domain.SandBox destinationSandBox) |
void |
itemReverted(SandBoxItem sandBoxItem) |
List<StaticAsset> |
readAllStaticAssets() |
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,
org.broadleafcommerce.common.sandbox.domain.SandBox destSandbox)
This method is intended to be called from within the CMS
admin only.
|
countItems, findItems@Value(value="${asset.server.url.prefix.internal}")
protected String staticAssetUrlPrefix
@Value(value="${asset.server.url.prefix}")
protected String staticAssetEnvironmentUrlPrefix
protected ImageArtifactProcessor imageArtifactProcessor
@Value(value="${asset.use.filesystem.storage}")
protected boolean storeAssetsOnFileSystem
@Value(value="${asset.server.url.prefix.secure}")
protected String staticAssetEnvironmentSecureUrlPrefix
@Value(value="${automatically.approve.static.assets}")
protected boolean automaticallyApproveAndPromoteStaticAssets
protected StaticAssetDao staticAssetDao
protected SandBoxItemDao sandBoxItemDao
protected StaticAssetStorageService staticAssetStorageService
public StaticAsset findStaticAssetById(Long id)
findStaticAssetById in interface StaticAssetServicepublic List<StaticAsset> readAllStaticAssets()
readAllStaticAssets in interface StaticAssetServiceprotected String generateFileName(int size)
size - protected String buildAssetURL(Map<String,String> assetProperties, String originalFilename)
url - asset - assetProperties - @Transactional(value="blTransactionManager") public StaticAsset createStaticAssetFromFile(org.springframework.web.multipart.MultipartFile file, Map<String,String> properties)
StaticAssetServiceStaticAssetServiceImpl has a
environment properties that determine this behavior asset.use.filesystem.storage, and
asset.server.file.system.path.
The properties allows for implementors to update other Asset properties at the
same time they are uploading a file. The default implementation uses this for an optional URL to
be specified.createStaticAssetFromFile in interface StaticAssetServicefile - - the file being uploadedproperties - - additional meta-data propertiesStaticAssetServiceImplprotected void getMimeType(org.springframework.web.multipart.MultipartFile file,
StaticAsset newAsset)
public StaticAsset findStaticAssetByFullUrl(String fullUrl, org.broadleafcommerce.common.sandbox.domain.SandBox targetSandBox)
findStaticAssetByFullUrl in interface StaticAssetServicepublic StaticAsset addStaticAsset(StaticAsset staticAsset, org.broadleafcommerce.common.sandbox.domain.SandBox destinationSandbox)
StaticAssetServiceaddStaticAsset in interface StaticAssetServicepublic StaticAsset updateStaticAsset(StaticAsset staticAsset, org.broadleafcommerce.common.sandbox.domain.SandBox destSandbox)
StaticAssetServiceupdateStaticAsset in interface StaticAssetServicepublic void deleteStaticAsset(StaticAsset staticAsset, org.broadleafcommerce.common.sandbox.domain.SandBox destinationSandbox)
StaticAssetServicedeleteStaticAsset in interface StaticAssetServicepublic List<StaticAsset> findAssets(org.broadleafcommerce.common.sandbox.domain.SandBox sandbox, org.hibernate.Criteria c)
findAssets in interface StaticAssetServicepublic Long countAssets(org.broadleafcommerce.common.sandbox.domain.SandBox sandbox, org.hibernate.Criteria c)
countAssets in interface StaticAssetServicepublic void itemPromoted(SandBoxItem sandBoxItem, org.broadleafcommerce.common.sandbox.domain.SandBox destinationSandBox)
itemPromoted in interface SandBoxItemListenerpublic void itemRejected(SandBoxItem sandBoxItem, org.broadleafcommerce.common.sandbox.domain.SandBox destinationSandBox)
itemRejected in interface SandBoxItemListenerpublic void itemReverted(SandBoxItem sandBoxItem)
itemReverted in interface SandBoxItemListenerpublic String getStaticAssetUrlPrefix()
StaticAssetServicegetStaticAssetUrlPrefix in interface StaticAssetServicepublic void setStaticAssetUrlPrefix(String staticAssetUrlPrefix)
setStaticAssetUrlPrefix in interface StaticAssetServicepublic String getStaticAssetEnvironmentUrlPrefix()
StaticAssetServicegetStaticAssetEnvironmentUrlPrefix in interface StaticAssetServicepublic void setStaticAssetEnvironmentUrlPrefix(String staticAssetEnvironmentUrlPrefix)
StaticAssetServicesetStaticAssetEnvironmentUrlPrefix in interface StaticAssetServicepublic String getStaticAssetEnvironmentSecureUrlPrefix()
StaticAssetServicegetStaticAssetEnvironmentSecureUrlPrefix in interface StaticAssetServicepublic void setStaticAssetEnvironmentSecureUrlPrefix(String staticAssetEnvironmentSecureUrlPrefix)
public boolean getAutomaticallyApproveAndPromoteStaticAssets()
StaticAssetServicegetAutomaticallyApproveAndPromoteStaticAssets in interface StaticAssetServicepublic void setAutomaticallyApproveAndPromoteStaticAssets(boolean automaticallyApproveAndPromoteStaticAssets)
StaticAssetServicesetAutomaticallyApproveAndPromoteStaticAssets in interface StaticAssetServicepublic String convertAssetPath(String assetPath, String contextPath, boolean secureRequest)
convertAssetPath in interface StaticAssetServiceassetPath - - 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 httpsStaticAssetService.getStaticAssetUrlPrefix(),
StaticAssetService.getStaticAssetEnvironmentUrlPrefix()Copyright © 2019. All rights reserved.