@Service(value="blStaticAssetStorageService") public class StaticAssetStorageServiceImpl extends Object implements StaticAssetStorageService
Modifier and Type | Field and Description |
---|---|
protected ArtifactService |
artifactService |
protected BroadleafFileService |
broadleafFileService |
protected String |
cacheDirectory |
protected ConcurrentFileOutputStream |
concurrentFileOutputStream |
protected static String |
DEFAULT_ADMIN_IMAGE_EXTENSIONS |
static long |
DEFAULT_ASSET_UPLOAD_SIZE |
protected static int |
DEFAULT_BUFFER_SIZE |
protected org.springframework.boot.autoconfigure.web.servlet.MultipartProperties |
defaultMultipartSettings |
protected org.springframework.core.env.Environment |
env |
protected StaticAssetServiceExtensionManager |
extensionManager |
protected NamedOperationManager |
namedOperationManager |
protected String |
recompressFormats |
protected StaticAssetService |
staticAssetService |
protected StaticAssetStorageDao |
staticAssetStorageDao |
protected StreamingTransactionCapableUtil |
transUtil |
Constructor and Description |
---|
StaticAssetStorageServiceImpl() |
Modifier and Type | Method and Description |
---|---|
protected Map<String,String> |
buildModel(String returnFilePath,
String mimeType) |
protected String |
constructCacheFileName(StaticAsset staticAsset,
Map<String,String> parameterMap)
Builds a file system path for the passed in static asset and paramaterMap.
|
StaticAssetStorage |
create() |
Blob |
createBlob(InputStream uploadedFileInputStream,
long fileSize)
Creates a blob from an input stream with a given filesize.
|
Blob |
createBlob(org.springframework.web.multipart.MultipartFile uploadedFile) |
protected void |
createLocalFileFromClassPathResource(StaticAsset staticAsset,
File baseLocalFile) |
protected void |
createLocalFileFromInputStream(InputStream is,
File baseLocalFile) |
void |
createStaticAssetStorage(InputStream fileInputStream,
StaticAsset staticAsset)
Similar to
StaticAssetStorageService.createStaticAssetStorageFromFile(MultipartFile, StaticAsset) except that this does not depend on
an uploaded file and can support more generic use cases |
void |
createStaticAssetStorageFromFile(org.springframework.web.multipart.MultipartFile file,
StaticAsset staticAsset)
Persists the file to the DB or FileSystem according to the staticAsset's StorageType.
|
void |
delete(StaticAssetStorage assetStorage)
Removes a static asset from the database.
|
protected StaticAsset |
findStaticAsset(String fullUrl) |
StaticAssetStorage |
findStaticAssetStorageById(Long id)
Returns a StaticAssetStorage object.
|
protected List<String> |
getAdminImageFileExtensions() |
Map<String,String> |
getCacheFileModel(String fullUrl,
Map<String,String> parameterMap) |
protected int |
getFileBufferSize() |
protected String |
getFileExtension(String assetPath) |
protected File |
getFileFromLocalRepository(String cachedFileName) |
protected long |
getMaxUploadableFileSize() |
protected long |
getMaxUploadableImageSize() |
protected long |
getMaxUploadSizeForFile(String fileName) |
protected boolean |
isImageFile(String fileName) |
protected File |
lookupAssetAndCreateLocalFile(StaticAsset staticAsset,
File baseLocalFile) |
protected String |
pad(String s,
int length,
char pad) |
StaticAssetStorage |
readStaticAssetStorageByStaticAssetId(Long id)
Returns a StaticAssetStorage object using the id of a related StaticAsset.
|
StaticAssetStorage |
save(StaticAssetStorage assetStorage)
Persists a static asset to the database.
|
protected boolean |
shouldRecompress(String mimeType) |
protected boolean |
shouldUseSharedFile(InputStream is) |
void |
validateFileSize(org.springframework.web.multipart.MultipartFile file)
Validates given file with the maximum upload file size value
|
protected static final String DEFAULT_ADMIN_IMAGE_EXTENSIONS
public static final long DEFAULT_ASSET_UPLOAD_SIZE
protected static final int DEFAULT_BUFFER_SIZE
protected String cacheDirectory
@Autowired protected org.springframework.core.env.Environment env
protected StaticAssetService staticAssetService
protected BroadleafFileService broadleafFileService
protected ArtifactService artifactService
protected StaticAssetStorageDao staticAssetStorageDao
protected NamedOperationManager namedOperationManager
protected StaticAssetServiceExtensionManager extensionManager
protected StreamingTransactionCapableUtil transUtil
@Value(value="${image.artifact.recompress.formats:png}") protected String recompressFormats
@Autowired(required=false) protected org.springframework.boot.autoconfigure.web.servlet.MultipartProperties defaultMultipartSettings
protected ConcurrentFileOutputStream concurrentFileOutputStream
protected StaticAsset findStaticAsset(String fullUrl)
protected boolean shouldUseSharedFile(InputStream is)
protected File lookupAssetAndCreateLocalFile(StaticAsset staticAsset, File baseLocalFile) throws IOException, SQLException
IOException
SQLException
protected void createLocalFileFromClassPathResource(StaticAsset staticAsset, File baseLocalFile) throws IOException
IOException
protected void createLocalFileFromInputStream(InputStream is, File baseLocalFile) throws IOException
IOException
public Map<String,String> getCacheFileModel(String fullUrl, Map<String,String> parameterMap) throws Exception
getCacheFileModel
in interface StaticAssetStorageService
Exception
protected boolean shouldRecompress(String mimeType)
public StaticAssetStorage findStaticAssetStorageById(Long id)
StaticAssetStorageService
findStaticAssetStorageById
in interface StaticAssetStorageService
public StaticAssetStorage create()
create
in interface StaticAssetStorageService
public StaticAssetStorage readStaticAssetStorageByStaticAssetId(Long id)
StaticAssetStorageService
readStaticAssetStorageByStaticAssetId
in interface StaticAssetStorageService
public StaticAssetStorage save(StaticAssetStorage assetStorage)
StaticAssetStorageService
save
in interface StaticAssetStorageService
public void delete(StaticAssetStorage assetStorage)
StaticAssetStorageService
delete
in interface StaticAssetStorageService
public Blob createBlob(org.springframework.web.multipart.MultipartFile uploadedFile) throws IOException
createBlob
in interface StaticAssetStorageService
IOException
public Blob createBlob(InputStream uploadedFileInputStream, long fileSize) throws IOException
StaticAssetStorageService
createBlob
in interface StaticAssetStorageService
IOException
protected String constructCacheFileName(StaticAsset staticAsset, Map<String,String> parameterMap)
staticAsset
- parameterMap
- useSharedFile
- @Transactional(value="blTransactionManagerAssetStorageInfo") public void createStaticAssetStorageFromFile(org.springframework.web.multipart.MultipartFile file, StaticAsset staticAsset) throws IOException
StaticAssetStorageService
createStaticAssetStorageFromFile
in interface StaticAssetStorageService
file
- the uploaded file from the Spring controllerstaticAsset
- the StaticAsset
entity to obtain storage information from like file size and the file name,
usually created from StaticAssetService.createStaticAssetFromFile(MultipartFile, Map)
IOException
StaticAssetService#createStaticAssetFromFile(MultipartFile, Map)}
@Transactional(value="blTransactionManagerAssetStorageInfo") public void createStaticAssetStorage(InputStream fileInputStream, StaticAsset staticAsset) throws IOException
StaticAssetStorageService
StaticAssetStorageService.createStaticAssetStorageFromFile(MultipartFile, StaticAsset)
except that this does not depend on
an uploaded file and can support more generic use casescreateStaticAssetStorage
in interface StaticAssetStorageService
fileInputStream
- the input stream of the uploaded filestaticAsset
- the StaticAsset
entity to obtain storage information from like file size and the file name,
usually created from StaticAssetService.createStaticAsset(InputStream, String, long, Map)
IOException
StaticAssetService#createStaticAsset(InputStream, String, long, Map)}
protected long getMaxUploadSizeForFile(String fileName)
protected boolean isImageFile(String fileName)
protected long getMaxUploadableFileSize()
protected long getMaxUploadableImageSize()
protected int getFileBufferSize()
public void validateFileSize(org.springframework.web.multipart.MultipartFile file) throws IOException
StaticAssetStorageService
validateFileSize
in interface StaticAssetStorageService
IOException
Copyright © 2022. All rights reserved.