@Service(value="blStaticAssetStorageService") public class StaticAssetStorageServiceImpl extends java.lang.Object implements StaticAssetStorageService
| Modifier and Type | Field and Description |
|---|---|
protected ArtifactService |
artifactService |
protected java.lang.String |
assetFileClasspathDirectory |
protected java.lang.String |
assetFileSystemPath |
protected int |
assetServerMaxGeneratedDirectories |
protected java.lang.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 java.lang.String |
constructCacheFileName(StaticAsset staticAsset,
java.util.Map<java.lang.String,java.lang.String> parameterMap,
boolean useSharedFile)
Builds a file system path for the passed in static asset and paramaterMap.
|
StaticAssetStorage |
create() |
java.sql.Blob |
createBlob(org.springframework.web.multipart.MultipartFile uploadedFile) |
protected void |
createCacheFile(java.io.InputStream is,
java.io.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 java.io.InputStream |
findInputStreamForStaticAsset(StaticAsset staticAsset) |
protected StaticAsset |
findStaticAsset(java.lang.String fullUrl,
SandBox sandBox) |
StaticAssetStorage |
findStaticAssetStorageById(java.lang.Long id) |
protected java.lang.String |
fixPath(java.lang.String path)
Removes trailing "/" and ensures that there is a beginning "/"
|
java.lang.String |
generateStorageFileName(StaticAsset staticAsset,
boolean useSharedFile)
By default, delegates a call to
#generateStorageFileName(String) using staticAsset.getFullUrl()
as the passed in argument. |
java.lang.String |
generateStorageFileName(java.lang.String fullUrl,
boolean useSharedFile)
Stores the file on the filesystem by performing an MD5 hash of the
the staticAsset.fullUrl.
|
protected java.lang.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.
|
java.util.Map<java.lang.String,java.lang.String> |
getCacheFileModel(java.lang.String fullUrl,
SandBox sandBox,
java.util.Map<java.lang.String,java.lang.String> parameterMap) |
protected java.io.InputStream |
getResourceFromClasspath(StaticAsset staticAsset) |
static void |
main(java.lang.String[] args) |
protected java.lang.String |
pad(java.lang.String s,
int length,
char pad) |
StaticAssetStorage |
readStaticAssetStorageByStaticAssetId(java.lang.Long id) |
StaticAssetStorage |
save(StaticAssetStorage assetStorage) |
protected boolean |
shouldUseSharedFile(java.io.InputStream is) |
@Value(value="${asset.server.file.system.path}")
protected java.lang.String assetFileSystemPath
@Value(value="${asset.server.file.classpath.directory}")
protected java.lang.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 java.lang.String cacheDirectory
protected StaticAssetService staticAssetService
protected ArtifactService artifactService
protected StaticAssetStorageDao staticAssetStorageDao
protected NamedOperationManager namedOperationManager
protected StaticAsset findStaticAsset(java.lang.String fullUrl, SandBox sandBox)
protected java.lang.String fixPath(java.lang.String path)
path - public java.lang.String generateStorageFileName(StaticAsset staticAsset, boolean useSharedFile)
StaticAssetStorageService#generateStorageFileName(String) using staticAsset.getFullUrl()
as the passed in argument.generateStorageFileName in interface StaticAssetStorageServicestaticAsset - StaticAsset for which a filename is desired.useSharedFile - If false, the system will generate a path using Site information if available.protected java.lang.String getBaseDirectory()
public java.lang.String generateStorageFileName(java.lang.String fullUrl,
boolean useSharedFile)
StaticAssetStorageServicegenerateStorageFileName in interface StaticAssetStorageServicefullUrl - 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(java.io.InputStream is)
@Transactional(value="blTransactionManagerAssetStorageInfo")
public java.util.Map<java.lang.String,java.lang.String> getCacheFileModel(java.lang.String fullUrl,
SandBox sandBox,
java.util.Map<java.lang.String,java.lang.String> parameterMap)
throws java.lang.Exception
getCacheFileModel in interface StaticAssetStorageServicejava.lang.Exceptionprotected java.io.InputStream findInputStreamForStaticAsset(StaticAsset staticAsset) throws java.sql.SQLException, java.io.IOException
java.sql.SQLExceptionjava.io.IOExceptionprotected java.io.InputStream getResourceFromClasspath(StaticAsset staticAsset)
@Transactional(value="blTransactionManagerAssetStorageInfo") public StaticAssetStorage findStaticAssetStorageById(java.lang.Long id)
findStaticAssetStorageById in interface StaticAssetStorageService@Transactional(value="blTransactionManagerAssetStorageInfo") public StaticAssetStorage create()
create in interface StaticAssetStorageService@Transactional(value="blTransactionManagerAssetStorageInfo") public StaticAssetStorage readStaticAssetStorageByStaticAssetId(java.lang.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 java.sql.Blob createBlob(org.springframework.web.multipart.MultipartFile uploadedFile)
throws java.io.IOException
createBlob in interface StaticAssetStorageServicejava.io.IOExceptionprotected void createCacheFile(java.io.InputStream is,
java.io.File cacheFile)
throws java.sql.SQLException,
java.io.IOException
java.sql.SQLExceptionjava.io.IOExceptionprotected java.lang.String constructCacheFileName(StaticAsset staticAsset, java.util.Map<java.lang.String,java.lang.String> parameterMap, boolean useSharedFile)
staticAsset - parameterMap - useSharedFile - protected java.lang.String pad(java.lang.String s,
int length,
char pad)
public void createStaticAssetStorageFromFile(org.springframework.web.multipart.MultipartFile file,
StaticAsset staticAsset)
throws java.io.IOException
StaticAssetStorageServicecreateStaticAssetStorageFromFile in interface StaticAssetStorageServicejava.io.IOExceptionpublic static void main(java.lang.String[] args)
Copyright © 2018. All Rights Reserved.