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
  • Field Details

  • 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 class org.craftercms.commons.file.blob.impl.s3.AwsS3BlobStore
      Throws:
      org.craftercms.commons.config.ConfigurationException
    • checkReadWriteMode

      protected void checkReadWriteMode() throws ServiceLayerException
      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 mode
      ServiceLayerException
    • isFolder

      protected boolean isFolder(String path)
    • getFullKey

      protected String getFullKey(org.craftercms.commons.file.blob.impl.AbstractBlobStore.Mapping mapping, String path)
    • getReference

      public org.craftercms.commons.file.blob.Blob getReference(String path)
      Description copied from interface: StudioBlobStore
      Return a reference to a file in the store
      Specified by:
      getReference in interface StudioBlobStore
      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 interface StudioBlobStore
      Returns:
      true if the store is read only
    • contentExists

      public boolean contentExists(String site, String path)
      Description copied from interface: ContentRepository
      Determine if content exists in the repository at a given path
      Specified by:
      contentExists in interface ContentRepository
      Specified by:
      contentExists in interface ContentRepository
      Parameters:
      site - site id where the operation will be executed
      path - path to check if content exists
      Returns:
      true if site has content object at path
    • checkContentExists

      public void checkContentExists(String site, String path) throws ServiceLayerException
      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 interface ContentRepository
      Parameters:
      site - id of the site
      path - the content path
      Throws:
      ServiceLayerException - if no content is found at the given path
    • shallowContentExists

      public boolean shallowContentExists(String site, String path)
      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 interface ContentRepository
      Specified by:
      shallowContentExists in interface ContentRepository
      Returns:
      true if site has content object at path
    • getContent

      public InputStream getContent(String site, String path, boolean shallow)
      Description copied from interface: ContentRepository
      Get content from the repository
      Specified by:
      getContent in interface ContentRepository
      Parameters:
      site - the site id
      path - the path of the content
      shallow - if true, it will load the file from disk directly, instead of retrieving it from git repository
      Returns:
      InputStream to read the content
    • getContentSize

      public long getContentSize(String site, String path)
      Description copied from interface: ContentRepository
      get file size
      Specified by:
      getContentSize in interface ContentRepository
      Parameters:
      site - site id where the operation will be executed
      path - 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 interface ContentRepository
      Parameters:
      site - site id where the operation will be executed
      path - path to content
      content - stream of content to write
      Returns:
      Commit Id if successful, null otherwise
      Throws:
      ServiceLayerException - if error happens during write
    • createFolder

      public String createFolder(String site, String path, String name) throws ServiceLayerException
      Description copied from interface: ContentRepository
      create a folder
      Specified by:
      createFolder in interface ContentRepository
      Parameters:
      site - site id where the operation will be executed
      path - path to create a folder in
      name - a folder name to create
      Returns:
      Commit Id if successful, null otherwise
      Throws:
      ServiceLayerException
    • deleteContent

      public String deleteContent(String site, String path, String approver) throws ServiceLayerException
      Description copied from interface: ContentRepository
      delete content
      Specified by:
      deleteContent in interface ContentRepository
      Parameters:
      site - site id where the operation will be executed
      path - path to content
      approver - 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 interface ContentRepository
      Parameters:
      site - site id where the operation will be executed
      fromPath - source content
      toPath - target path
      newName - new file name for rename
      Returns:
      Commit ID if successful, empty string otherwise
      Throws:
      ServiceLayerException
    • copyContent

      public String copyContent(String site, String fromPath, String toPath) throws ServiceLayerException
      Description copied from interface: ContentRepository
      copy content from PathA to pathB
      Specified by:
      copyContent in interface ContentRepository
      Parameters:
      site - site id where the operation will be executed
      fromPath - paths to content
      toPath - 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 interface ContentRepository
      Parameters:
      site - site identifier
      sandboxBranch - sandbox branch name
      deploymentItems - items to be published
      environment - environment to publish to
      author - author
      comment - submission comment
    • initialPublish

      public void initialPublish(String siteId)
      Description copied from interface: ContentRepository
      Execute initial publish for given site
      Specified by:
      initialPublish in interface ContentRepository
      Parameters:
      siteId - site identifier
    • publishAll

      public RepositoryChanges publishAll(String siteId, String publishingTarget, String comment)
      Description copied from interface: ContentRepository
      Publishes all changes for the given site & target
      Specified by:
      publishAll in interface ContentRepository
      Parameters:
      siteId - the id of the site
      publishingTarget - the publishing target
      comment - submission comment
    • preparePublishAll

      public RepositoryChanges preparePublishAll(String siteId, String publishingTarget)
      Description copied from interface: ContentRepository
      Prepares the repository to publish all changes for the given site & target
      Specified by:
      preparePublishAll in interface ContentRepository
      Parameters:
      siteId - the id of the site
      publishingTarget - 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 interface ContentRepository
      Parameters:
      siteId - the id of the site
      publishingTarget - the publishing target
      changes - the set of changed files
      comment - submission comment
    • cancelPublishAll

      public void cancelPublishAll(String siteId, String publishingTarget)
      Description copied from interface: ContentRepository
      Performs the cleanup after a failed publish all operation for the given site & target
      Specified by:
      cancelPublishAll in interface ContentRepository
      Parameters:
      siteId - the id of the site
      publishingTarget - 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 interface ContentRepository
      Parameters:
      sourceSiteId - source site id
      siteId - new site id
      sandboxBranch - sandbox branch name
    • copyBlobs

      public void copyBlobs(StudioBlobStore source, String environment, List<String> items)
      Description copied from interface: StudioBlobStore
      Copy the blob items from the source store
      Specified by:
      copyBlobs in interface StudioBlobStore
      Parameters:
      source - the source store
      environment - the environment (publishing target)
      items - the items to copy