@Service(value="blStaticAssetStorageService") public class StaticAssetStorageServiceImpl extends Object implements StaticAssetStorageService
Modifier and Type | Field and Description |
---|---|
protected ArtifactService |
artifactService |
protected String |
assetFileClasspathDirectory |
protected String |
assetFileSystemPath |
protected int |
assetServerMaxGeneratedDirectories |
protected String |
cacheDirectory |
protected int |
fileBufferSize |
protected long |
maxUploadableFileSize |
protected NamedOperationManager |
namedOperationManager |
protected StaticAssetService |
staticAssetService |
protected StaticAssetStorageDao |
staticAssetStorageDao |
Constructor and Description |
---|
StaticAssetStorageServiceImpl() |
Modifier and Type | Method and Description |
---|---|
protected String |
constructCacheFileName(StaticAsset staticAsset,
Map<String,String> parameterMap,
boolean useSharedFile)
Builds a file system path for the passed in static asset and paramaterMap.
|
StaticAssetStorage |
create() |
Blob |
createBlob(org.springframework.web.multipart.MultipartFile uploadedFile) |
protected void |
createCacheFile(InputStream is,
File cacheFile) |
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) |
protected InputStream |
findInputStreamForStaticAsset(StaticAsset staticAsset) |
protected StaticAsset |
findStaticAsset(String fullUrl,
SandBox sandBox) |
StaticAssetStorage |
findStaticAssetStorageById(Long id) |
protected String |
fixPath(String path)
Removes trailing "/" and ensures that there is a beginning "/"
|
String |
generateStorageFileName(StaticAsset staticAsset,
boolean useSharedFile)
By default, delegates a call to
#generateStorageFileName(String) using staticAsset.getFullUrl()
as the passed in argument. |
String |
generateStorageFileName(String fullUrl,
boolean useSharedFile)
Stores the file on the filesystem by performing an MD5 hash of the
the staticAsset.fullUrl.
|
protected String |
getBaseDirectory()
Returns the baseDirectory for writing and reading files as the property assetFileSystemPath if it
exists or java.tmp.io if that property has not been set.
|
Map<String,String> |
getCacheFileModel(String fullUrl,
SandBox sandBox,
Map<String,String> parameterMap) |
protected InputStream |
getResourceFromClasspath(StaticAsset staticAsset) |
protected String |
pad(String s,
int length,
char pad) |
StaticAssetStorage |
readStaticAssetStorageByStaticAssetId(Long id) |
StaticAssetStorage |
save(StaticAssetStorage assetStorage) |
protected boolean |
shouldUseSharedFile(InputStream is) |
@Value(value="${asset.server.file.system.path}") protected String assetFileSystemPath
@Value(value="${asset.server.file.classpath.directory}") protected String assetFileClasspathDirectory
@Value(value="${asset.server.max.generated.file.system.directories}") protected int assetServerMaxGeneratedDirectories
@Value(value="${asset.server.max.uploadable.file.size}") protected long maxUploadableFileSize
@Value(value="${asset.server.file.buffer.size}") protected int fileBufferSize
protected String cacheDirectory
protected StaticAssetService staticAssetService
protected ArtifactService artifactService
protected StaticAssetStorageDao staticAssetStorageDao
protected NamedOperationManager namedOperationManager
protected StaticAsset findStaticAsset(String fullUrl, SandBox sandBox)
protected String fixPath(String path)
path
- public String generateStorageFileName(StaticAsset staticAsset, boolean useSharedFile)
StaticAssetStorageService
#generateStorageFileName(String)
using staticAsset.getFullUrl()
as the passed in argument.generateStorageFileName
in interface StaticAssetStorageService
staticAsset
- StaticAsset for which a filename is desired.useSharedFile
- If false, the system will generate a path using Site
information if available.protected String getBaseDirectory()
public String generateStorageFileName(String fullUrl, boolean useSharedFile)
StaticAssetStorageService
generateStorageFileName
in interface StaticAssetStorageService
fullUrl
- The URL used to represent an asset for which a name on the fileSystem is desired.useSharedFile
- If false, the system will generate a path using Site
information if available.protected boolean shouldUseSharedFile(InputStream is)
@Transactional(value="blTransactionManagerAssetStorageInfo") public Map<String,String> getCacheFileModel(String fullUrl, SandBox sandBox, Map<String,String> parameterMap) throws Exception
getCacheFileModel
in interface StaticAssetStorageService
Exception
protected InputStream findInputStreamForStaticAsset(StaticAsset staticAsset) throws SQLException, IOException
SQLException
IOException
protected InputStream getResourceFromClasspath(StaticAsset staticAsset)
@Transactional(value="blTransactionManagerAssetStorageInfo") public StaticAssetStorage findStaticAssetStorageById(Long id)
findStaticAssetStorageById
in interface StaticAssetStorageService
@Transactional(value="blTransactionManagerAssetStorageInfo") public StaticAssetStorage create()
create
in interface StaticAssetStorageService
@Transactional(value="blTransactionManagerAssetStorageInfo") public StaticAssetStorage readStaticAssetStorageByStaticAssetId(Long id)
readStaticAssetStorageByStaticAssetId
in interface StaticAssetStorageService
@Transactional(value="blTransactionManagerAssetStorageInfo") public StaticAssetStorage save(StaticAssetStorage assetStorage)
save
in interface StaticAssetStorageService
@Transactional(value="blTransactionManagerAssetStorageInfo") public void delete(StaticAssetStorage assetStorage)
delete
in interface StaticAssetStorageService
@Transactional(value="blTransactionManagerAssetStorageInfo") public Blob createBlob(org.springframework.web.multipart.MultipartFile uploadedFile) throws IOException
createBlob
in interface StaticAssetStorageService
IOException
protected void createCacheFile(InputStream is, File cacheFile) throws SQLException, IOException
SQLException
IOException
protected String constructCacheFileName(StaticAsset staticAsset, Map<String,String> parameterMap, boolean useSharedFile)
staticAsset
- parameterMap
- useSharedFile
- @Transactional(value="blTransactionManagerAssetStorageInfo") public void createStaticAssetStorageFromFile(org.springframework.web.multipart.MultipartFile file, StaticAsset staticAsset) throws IOException
StaticAssetStorageService
createStaticAssetStorageFromFile
in interface StaticAssetStorageService
IOException
Copyright © 2014. All rights reserved.