Class StudioAwsS3BlobStore
java.lang.Object
org.craftercms.commons.file.blob.impl.AbstractBlobStore<org.craftercms.commons.config.profiles.aws.S3Profile>
org.craftercms.commons.file.blob.impl.s3.AwsS3BlobStore
org.craftercms.studio.impl.v2.repository.blob.s3.StudioAwsS3BlobStore
- All Implemented Interfaces:
org.craftercms.commons.file.blob.BlobStore
,ContentRepository
,StudioBlobStore
,StudioBlobStoreAdapter
,ContentRepository
public class StudioAwsS3BlobStore
extends org.craftercms.commons.file.blob.impl.s3.AwsS3BlobStore
implements StudioBlobStoreAdapter
Implementation of
StudioBlobStore
for AWS S3- Since:
- 3.1.6
- Author:
- joseross
-
Nested Class Summary
Nested classes/interfaces inherited from class org.craftercms.commons.file.blob.impl.AbstractBlobStore
org.craftercms.commons.file.blob.impl.AbstractBlobStore.Mapping
-
Field Summary
FieldsFields inherited from class org.craftercms.commons.file.blob.impl.s3.AwsS3BlobStore
asyncClientFactory, clientFactory
Fields inherited from class org.craftercms.commons.file.blob.impl.AbstractBlobStore
id, mappings, pattern, profile, profileMapper, publishingTargetResolver
Fields inherited from interface org.craftercms.commons.file.blob.BlobStore
CONFIG_KEY_CONFIGURATION, CONFIG_KEY_ID, CONFIG_KEY_MAPPING, CONFIG_KEY_MAPPING_PREFIX, CONFIG_KEY_MAPPING_PUBLISHING_TARGET, CONFIG_KEY_MAPPING_STORE_TARGET, CONFIG_KEY_PATTERN, CONFIG_KEY_READ_ONLY, CONFIG_KEY_STORE, CONFIG_KEY_TYPE
-
Constructor Summary
ConstructorsConstructorDescriptionStudioAwsS3BlobStore
(ServicesConfig servicesConfig, org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor taskExecutor) -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancelPublishAll
(String siteId, String publishingTarget) Performs the cleanup after a failed publish all operation for the given site & targetvoid
checkContentExists
(String site, String path) Checks if a content exists at a given path and throw an exception if it does not.protected void
Checks that the blob store is in writable mode (readOnly = false) and throws an exception if it is not.void
completePublishAll
(String siteId, String publishingTarget, RepositoryChanges changes, String comment) Performs the actual publish of all changes for the given site & targetboolean
contentExists
(String site, String path) Determine if content exists in the repository at a given pathvoid
copyBlobs
(StudioBlobStore source, String environment, List<String> items) Copy the blob items from the source storecopyContent
(String site, String fromPath, String toPath) copy content from PathA to pathBcreateFolder
(String site, String path, String name) create a folderdeleteContent
(String site, String path, String approver) delete contentvoid
doInit
(org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> config) void
duplicateSite
(String sourceSiteId, String siteId, String sourceSandboxBranch, String sandboxBranch) Create copies of the source site's repositories.getContent
(String site, String path, boolean shallow) Get content from the repositorylong
getContentSize
(String site, String path) get file sizeprotected String
getFullKey
(org.craftercms.commons.file.blob.impl.AbstractBlobStore.Mapping mapping, String path) org.craftercms.commons.file.blob.Blob
getReference
(String path) Return a reference to a file in the storevoid
initialPublish
(String siteId) Execute initial publish for given siteprotected boolean
boolean
Indicate if the store is read onlymoveContent
(String site, String fromPath, String toPath, String newName) move content from PathA to pathBpreparePublishAll
(String siteId, String publishingTarget) Prepares the repository to publish all changes for the given site & targetvoid
publish
(String site, String sandboxBranch, List<DeploymentItemTO> deploymentItems, String environment, String author, String comment) Publish content to specified environment.publishAll
(String siteId, String publishingTarget, String comment) Publishes all changes for the given site & targetboolean
shallowContentExists
(String site, String path) This is a faster, but less accurate, version of contentExists.writeContent
(String site, String path, InputStream content) write contentMethods inherited from class org.craftercms.commons.file.blob.impl.s3.AwsS3BlobStore
doGetContent, getAsyncClient, getClient, getKey, setAsyncClientFactory, setClientFactory
Methods inherited from class org.craftercms.commons.file.blob.impl.AbstractBlobStore
getId, getMapping, getResource, init, isCompatible, setId, setPattern, setProfileMapper, setPublishingTargetResolver
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.craftercms.commons.file.blob.BlobStore
getId, getResource, init, isCompatible
Methods inherited from interface org.craftercms.studio.api.v1.repository.ContentRepository
getContent, moveContent
Methods inherited from interface org.craftercms.studio.api.v2.repository.ContentRepository
getGlobalRepoLastCommitId, getItemPaths, getSubtreeItems
Methods inherited from interface org.craftercms.studio.api.v2.repository.blob.StudioBlobStoreAdapter
addRemote, commitIdExists, commitIdExists, createSiteCloneRemote, createSiteFromBlueprint, createVersion, createVersion, deleteSite, forAllSitePaths, getCommitIdsBetween, getContentByCommitId, getContentChildren, getContentItemHistory, getContentVersionHistory, getIntroducedCommits, getItem, getItemEnvironmentProperties, getLastEditCommitId, getOperationsFromDelta, getPreviousCommitId, getPublishingHistory, getRepoFirstCommitId, getRepoLastCommitId, getSubtreeItems, gitGCRepositories, initialPublish, isFolder, itemUnlock, listRemote, lockItem, lockItemForPublishing, publishedRepositoryExists, pullFromRemote, pushToRemote, removeRemote, removeRemoteRepositoriesForSite, repositoryExists, resetStagingRepository, revertContent, unLockItem, unLockItemForPublishing
-
Field Details
-
OK
- See Also:
-
servicesConfig
-
readOnly
protected boolean readOnly
-
-
Constructor Details
-
StudioAwsS3BlobStore
@ConstructorProperties({"servicesConfig","taskExecutor"}) public StudioAwsS3BlobStore(ServicesConfig servicesConfig, org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor taskExecutor)
-
-
Method Details
-
doInit
public void doInit(org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> config) throws org.craftercms.commons.config.ConfigurationException - Overrides:
doInit
in classorg.craftercms.commons.file.blob.impl.s3.AwsS3BlobStore
- Throws:
org.craftercms.commons.config.ConfigurationException
-
checkReadWriteMode
Checks that the blob store is in writable mode (readOnly = false) and throws an exception if it is not.- Throws:
BlobStoreNotWritableModeException
- is the blob store is in read-only modeServiceLayerException
-
isFolder
-
getFullKey
-
getReference
Description copied from interface:StudioBlobStore
Return a reference to a file in the store- Specified by:
getReference
in interfaceStudioBlobStore
- Parameters:
path
- the path of the file- Returns:
- the blob object
-
isReadOnly
public boolean isReadOnly()Description copied from interface:StudioBlobStore
Indicate if the store is read only- Specified by:
isReadOnly
in interfaceStudioBlobStore
- Returns:
- true if the store is read only
-
contentExists
Description copied from interface:ContentRepository
Determine if content exists in the repository at a given path- Specified by:
contentExists
in interfaceContentRepository
- Specified by:
contentExists
in interfaceContentRepository
- Parameters:
site
- site id where the operation will be executedpath
- path to check if content exists- Returns:
- true if site has content object at path
-
checkContentExists
Description copied from interface:ContentRepository
Checks if a content exists at a given path and throw an exception if it does not.- Specified by:
checkContentExists
in interfaceContentRepository
- Parameters:
site
- id of the sitepath
- the content path- Throws:
ServiceLayerException
- if no content is found at the given path
-
shallowContentExists
Description copied from interface:ContentRepository
This is a faster, but less accurate, version of contentExists. This prioritizes performance over checking the actual underlying repository if the content is actually in the store or we simply hold a reference to the object in the actual store.- Specified by:
shallowContentExists
in interfaceContentRepository
- Specified by:
shallowContentExists
in interfaceContentRepository
- Returns:
- true if site has content object at path
-
getContent
Description copied from interface:ContentRepository
Get content from the repository- Specified by:
getContent
in interfaceContentRepository
- Parameters:
site
- the site idpath
- the path of the contentshallow
- if true, it will load the file from disk directly, instead of retrieving it from git repository- Returns:
- InputStream to read the content
-
getContentSize
Description copied from interface:ContentRepository
get file size- Specified by:
getContentSize
in interfaceContentRepository
- Parameters:
site
- site id where the operation will be executedpath
- path to content- Returns:
- Size in bytes
-
writeContent
public String writeContent(String site, String path, InputStream content) throws ServiceLayerException Description copied from interface:ContentRepository
write content- Specified by:
writeContent
in interfaceContentRepository
- Parameters:
site
- site id where the operation will be executedpath
- path to contentcontent
- stream of content to write- Returns:
- Commit Id if successful, null otherwise
- Throws:
ServiceLayerException
- if error happens during write
-
createFolder
Description copied from interface:ContentRepository
create a folder- Specified by:
createFolder
in interfaceContentRepository
- Parameters:
site
- site id where the operation will be executedpath
- path to create a folder inname
- a folder name to create- Returns:
- Commit Id if successful, null otherwise
- Throws:
ServiceLayerException
-
deleteContent
Description copied from interface:ContentRepository
delete content- Specified by:
deleteContent
in interfaceContentRepository
- Parameters:
site
- site id where the operation will be executedpath
- path to contentapprover
- user that approves delete content- Returns:
- Commit ID if successful, null otherwise
- Throws:
ServiceLayerException
-
moveContent
public String moveContent(String site, String fromPath, String toPath, String newName) throws ServiceLayerException Description copied from interface:ContentRepository
move content from PathA to pathB- Specified by:
moveContent
in interfaceContentRepository
- Parameters:
site
- site id where the operation will be executedfromPath
- source contenttoPath
- target pathnewName
- new file name for rename- Returns:
- Commit ID if successful, empty string otherwise
- Throws:
ServiceLayerException
-
copyContent
Description copied from interface:ContentRepository
copy content from PathA to pathB- Specified by:
copyContent
in interfaceContentRepository
- Parameters:
site
- site id where the operation will be executedfromPath
- paths to contenttoPath
- target path- Returns:
- Commit ID if successful, empty string otherwise
- Throws:
ServiceLayerException
-
publish
public void publish(String site, String sandboxBranch, List<DeploymentItemTO> deploymentItems, String environment, String author, String comment) Description copied from interface:ContentRepository
Publish content to specified environment.- Specified by:
publish
in interfaceContentRepository
- Parameters:
site
- site identifiersandboxBranch
- sandbox branch namedeploymentItems
- items to be publishedenvironment
- environment to publish toauthor
- authorcomment
- submission comment
-
initialPublish
Description copied from interface:ContentRepository
Execute initial publish for given site- Specified by:
initialPublish
in interfaceContentRepository
- Parameters:
siteId
- site identifier
-
publishAll
Description copied from interface:ContentRepository
Publishes all changes for the given site & target- Specified by:
publishAll
in interfaceContentRepository
- Parameters:
siteId
- the id of the sitepublishingTarget
- the publishing targetcomment
- submission comment
-
preparePublishAll
Description copied from interface:ContentRepository
Prepares the repository to publish all changes for the given site & target- Specified by:
preparePublishAll
in interfaceContentRepository
- Parameters:
siteId
- the id of the sitepublishingTarget
- the publishing target- Returns:
- the set of changed files
-
completePublishAll
public void completePublishAll(String siteId, String publishingTarget, RepositoryChanges changes, String comment) Description copied from interface:ContentRepository
Performs the actual publish of all changes for the given site & target- Specified by:
completePublishAll
in interfaceContentRepository
- Parameters:
siteId
- the id of the sitepublishingTarget
- the publishing targetchanges
- the set of changed filescomment
- submission comment
-
cancelPublishAll
Description copied from interface:ContentRepository
Performs the cleanup after a failed publish all operation for the given site & target- Specified by:
cancelPublishAll
in interfaceContentRepository
- Parameters:
siteId
- the id of the sitepublishingTarget
- the publishing target
-
duplicateSite
public void duplicateSite(String sourceSiteId, String siteId, String sourceSandboxBranch, String sandboxBranch) Description copied from interface:ContentRepository
Create copies of the source site's repositories. This method will copy sandbox and published (if exists) repositories under a new directory with the new site id. For sandbox repository, a new branch will be created (from the currently checked-out branch) with the given sandbox branch name if it does not exist.- Specified by:
duplicateSite
in interfaceContentRepository
- Parameters:
sourceSiteId
- source site idsiteId
- new site idsandboxBranch
- sandbox branch name
-
copyBlobs
Description copied from interface:StudioBlobStore
Copy the blob items from the source store- Specified by:
copyBlobs
in interfaceStudioBlobStore
- Parameters:
source
- the source storeenvironment
- the environment (publishing target)items
- the items to copy
-