@Service(value="blS3FileServiceProvider") public class S3FileServiceProvider extends Object implements org.broadleafcommerce.common.file.service.FileServiceProvider
| Modifier and Type | Field and Description |
|---|---|
protected org.broadleafcommerce.common.file.service.BroadleafFileService |
blFileService |
protected static String |
BUCKET_PREFIX |
protected org.broadleafcommerce.common.io.ConcurrentFileOutputStream |
concurrentFileOutputStream |
protected Map<S3Configuration,com.amazonaws.services.s3.AmazonS3> |
configClientMap |
protected static String |
MULTITENANT_SITE_CLASSNAME |
protected static String |
MULTITENANTSITE_GETPARENTID_METHODNAME |
protected S3ConfigurationService |
s3ConfigurationService |
protected static String |
SITE_PREFIX |
| Constructor and Description |
|---|
S3FileServiceProvider() |
| Modifier and Type | Method and Description |
|---|---|
void |
addOrUpdateResources(org.broadleafcommerce.common.file.domain.FileWorkArea workArea,
List<File> files,
boolean removeFilesFromWorkArea) |
List<String> |
addOrUpdateResourcesForPaths(org.broadleafcommerce.common.file.domain.FileWorkArea workArea,
List<File> files,
boolean removeFilesFromWorkArea)
Writes the resource to S3.
|
protected List<String> |
addOrUpdateResourcesInternal(S3Configuration s3config,
com.amazonaws.services.s3.AmazonS3 s3,
org.broadleafcommerce.common.file.domain.FileWorkArea workArea,
List<File> files,
boolean removeFilesFromWorkArea) |
protected String |
buildResourceName(String name)
hook for overriding name used for resource in S3
|
protected String |
buildResourceParentName(String name)
Builds the resourceName for it's parent.
|
protected void |
ensureFileCreation(File returnFile,
String name)
Ensures the file creation
|
protected com.amazonaws.services.s3.AmazonS3 |
getAmazonS3Client(S3Configuration s3config) |
protected com.amazonaws.services.s3.AmazonS3 |
getAmazonS3ClientFromConfiguration(S3Configuration s3config)
Creates an instance of the S3 Client based on the 'use instance profile' property.
|
protected com.amazonaws.auth.AWSCredentials |
getAWSCredentials(S3Configuration s3configParam) |
protected String |
getBucketName(String name,
String defaultBucketName)
Returns the bucket name or the default one.
|
protected Class<?> |
getMultiTenantClass()
Get MultiTenantSite Class by Reflection
|
protected Method |
getMultiTenantGetParentSiteIdMethod()
Gets getParentId method by reflection
|
protected String |
getMultiTenantSiteSpecificResourceNameParent(String resourceName)
Get the parent from a MultiTentantSite.
|
File |
getResource(String name)
Entry point to retrieve resources from this module.
|
File |
getResource(String name,
org.broadleafcommerce.common.file.service.type.FileApplicationType fileApplicationType)
Handles the resource gathering, starts as regular retrieval, if it fails (and the conditions allow it) it will try to retrieve the image from the parent site
|
File |
getResource(String rawName,
org.broadleafcommerce.common.file.service.type.FileApplicationType fileApplicationType,
boolean isParent)
Handles the logic for resource retrieval it accepts if is a child resource or parent, only differs in
in tha name generation.
|
protected String |
getResourceName(S3Configuration s3config,
String bucketName,
String rawName)
Retrieves the resourceName from its rawname.
|
protected String |
getSiteDirectory(Long id) |
protected String |
getSiteDirectory(org.broadleafcommerce.common.site.domain.Site site) |
protected String |
getSiteSpecificResourceName(String resourceName) |
protected Long |
invokeMultiTenantGetParentSiteIdMethod(Object site)
Reflection getParentSiteId Invocation
|
protected boolean |
isMultiTenantEnvironment()
Check if the module is call with MultiTenant module
|
boolean |
removeResource(String name) |
void |
setBroadleafFileService(org.broadleafcommerce.common.file.service.BroadleafFileService bfs) |
void |
setConcurrentFileOutputStream(org.broadleafcommerce.common.io.ConcurrentFileOutputStream concurrentFileOutputStream) |
protected S3ConfigurationService s3ConfigurationService
protected org.broadleafcommerce.common.file.service.BroadleafFileService blFileService
protected Map<S3Configuration,com.amazonaws.services.s3.AmazonS3> configClientMap
protected org.broadleafcommerce.common.io.ConcurrentFileOutputStream concurrentFileOutputStream
protected static String BUCKET_PREFIX
protected static String SITE_PREFIX
protected static String MULTITENANT_SITE_CLASSNAME
protected static String MULTITENANTSITE_GETPARENTID_METHODNAME
public File getResource(String name)
getResource in interface org.broadleafcommerce.common.file.service.FileServiceProviderprotected String getBucketName(String name, String defaultBucketName)
name - defaultBucketName - protected String getResourceName(S3Configuration s3config, String bucketName, String rawName)
s3config - bucketName - rawName - protected void ensureFileCreation(File returnFile, String name) throws RuntimeException
returnFile - name - RuntimeExceptionpublic File getResource(String rawName, org.broadleafcommerce.common.file.service.type.FileApplicationType fileApplicationType, boolean isParent)
rawName - fileApplicationType - isParent - public void addOrUpdateResources(org.broadleafcommerce.common.file.domain.FileWorkArea workArea,
List<File> files,
boolean removeFilesFromWorkArea)
addOrUpdateResources in interface org.broadleafcommerce.common.file.service.FileServiceProviderpublic List<String> addOrUpdateResourcesForPaths(org.broadleafcommerce.common.file.domain.FileWorkArea workArea, List<File> files, boolean removeFilesFromWorkArea)
addOrUpdateResourcesForPaths in interface org.broadleafcommerce.common.file.service.FileServiceProviderprotected List<String> addOrUpdateResourcesInternal(S3Configuration s3config, com.amazonaws.services.s3.AmazonS3 s3, org.broadleafcommerce.common.file.domain.FileWorkArea workArea, List<File> files, boolean removeFilesFromWorkArea)
public boolean removeResource(String name)
removeResource in interface org.broadleafcommerce.common.file.service.FileServiceProviderprotected String buildResourceName(String name)
name - protected String getSiteDirectory(org.broadleafcommerce.common.site.domain.Site site)
protected com.amazonaws.services.s3.AmazonS3 getAmazonS3Client(S3Configuration s3config)
protected com.amazonaws.services.s3.AmazonS3 getAmazonS3ClientFromConfiguration(S3Configuration s3config)
s3config - Configuration objectprotected com.amazonaws.auth.AWSCredentials getAWSCredentials(S3Configuration s3configParam)
public void setBroadleafFileService(org.broadleafcommerce.common.file.service.BroadleafFileService bfs)
public void setConcurrentFileOutputStream(org.broadleafcommerce.common.io.ConcurrentFileOutputStream concurrentFileOutputStream)
public File getResource(String name, org.broadleafcommerce.common.file.service.type.FileApplicationType fileApplicationType)
getResource in interface org.broadleafcommerce.common.file.service.FileServiceProviderprotected String buildResourceParentName(String name)
name - protected boolean isMultiTenantEnvironment()
protected Class<?> getMultiTenantClass() throws ClassNotFoundException, LinkageError
ThrowableClassNotFoundExceptionLinkageErrorprotected Method getMultiTenantGetParentSiteIdMethod() throws NoSuchMethodException, SecurityException, ClassNotFoundException, LinkageError
NoSuchMethodException, - SecurityException,ClassNotFoundException, LinkageErrorNoSuchMethodExceptionSecurityExceptionClassNotFoundExceptionLinkageErrorprotected Long invokeMultiTenantGetParentSiteIdMethod(Object site)
site - Copyright © 2021. All rights reserved.