org.broadleafcommerce.cms.file.service
Interface StaticAssetStorageService

All Known Implementing Classes:
StaticAssetStorageServiceImpl

public interface StaticAssetStorageService

Author:
Jeff Fischer

Method Summary
 StaticAssetStorage create()
          Deprecated. Use createStaticAssetStorageFromFile instead.
 Blob createBlob(org.springframework.web.multipart.MultipartFile uploadedFile)
          Deprecated. Use createStaticAssetStorageFromFile instead.
 void createStaticAssetStorageFromFile(org.springframework.web.multipart.MultipartFile file, StaticAsset staticAsset)
          Persists the file being based in according to the staticAsset's StorageType.
 void delete(StaticAssetStorage assetStorage)
           
 StaticAssetStorage findStaticAssetStorageById(Long id)
           
 String generateStorageFileName(StaticAsset staticAsset, boolean useSharedPath)
          By default, delegates a call to #generateStorageFileName(String) using staticAsset.getFullUrl() as the passed in argument.
 String generateStorageFileName(String fullUrl, boolean useSharedPath)
          Stores the file on the filesystem by performing an MD5 hash of the the staticAsset.fullUrl.
 Map<String,String> getCacheFileModel(String fullUrl, SandBox sandBox, Map<String,String> parameterMap)
           
 StaticAssetStorage readStaticAssetStorageByStaticAssetId(Long id)
           
 StaticAssetStorage save(StaticAssetStorage assetStorage)
           
 

Method Detail

findStaticAssetStorageById

StaticAssetStorage findStaticAssetStorageById(Long id)

create

StaticAssetStorage create()
Deprecated. Use createStaticAssetStorageFromFile instead.

Returns:

readStaticAssetStorageByStaticAssetId

StaticAssetStorage readStaticAssetStorageByStaticAssetId(Long id)

save

StaticAssetStorage save(StaticAssetStorage assetStorage)

delete

void delete(StaticAssetStorage assetStorage)

createBlob

Blob createBlob(org.springframework.web.multipart.MultipartFile uploadedFile)
                throws IOException
Deprecated. Use createStaticAssetStorageFromFile instead.

Parameters:
uploadedFile -
Returns:
Throws:
IOException

generateStorageFileName

String generateStorageFileName(String fullUrl,
                               boolean useSharedPath)
Stores the file on the filesystem by performing an MD5 hash of the the staticAsset.fullUrl. To ensure that files can be stored and accessed in an efficient manner, the system creates directories based on the characters in the hash. For example, if the URL is /product/myproductimage.jpg, then the MD5 would be 35ec52a8dbd8cf3e2c650495001fe55f resulting in the following file on the filesystem {assetFileSystemPath}/35/ec/myproductimage.jpg. If there is a "siteId" in the BroadleafRequestContext then the site is also distributed using a similar algorithm but the system attempts to keep images for sites in their own directory resulting in an extra two folders required to reach any given product. So, for site with id 125, the system will MD5 "/site-125" in order to build the URL string. "/site-125" has an md5 string of "7fde295edac6ca7f85d0368ea741b241". So, in this case with the above product URL in site125, the full URL on the filesystem will be: {assetFileSystemPath}/7f/site-125/35/ec/myproductimage.jpg. This algorithm has the following benefits: - Efficient file-system storage with - Balanced tree of files that supports 10 million files If support for more files is needed, implementors should consider one of the following approaches: 1. Overriding the maxGeneratedFileSystemDirectories property from its default of 2 to 3 2. Overriding this method to introduce an alternate approach

Parameters:
fullUrl - The URL used to represent an asset for which a name on the fileSystem is desired.
useSharedPath - If false, the system will generate a path using Site information if available.
Returns:

generateStorageFileName

String generateStorageFileName(StaticAsset staticAsset,
                               boolean useSharedPath)
By default, delegates a call to #generateStorageFileName(String) using staticAsset.getFullUrl() as the passed in argument.

Parameters:
staticAsset - StaticAsset for which a filename is desired.
useSharedPath - If false, the system will generate a path using Site information if available.
Returns:

getCacheFileModel

Map<String,String> getCacheFileModel(String fullUrl,
                                     SandBox sandBox,
                                     Map<String,String> parameterMap)
                                     throws Exception
Throws:
Exception

createStaticAssetStorageFromFile

void createStaticAssetStorageFromFile(org.springframework.web.multipart.MultipartFile file,
                                      StaticAsset staticAsset)
                                      throws IOException
Persists the file being based in according to the staticAsset's StorageType.

Parameters:
file -
id -
Throws:
IOException


Copyright © 2013. All Rights Reserved.