Interface ContentRepository

All Known Subinterfaces:
StudioBlobAwareContentRepository, StudioBlobStore, StudioBlobStoreAdapter
All Known Implementing Classes:
BlobAwareContentRepository, GitContentRepository, StudioAwsS3BlobStore

public interface ContentRepository
  • Method Details

    • getItemPaths

      default List<String> getItemPaths(String site, GitRepositories repoType, String revstr)
      Get the site content item list for the given site
      Parameters:
      site - site id
      repoType - repository type
      revstr - A git object references expression (e.g.: HEAD, branch name, commit id)
      Returns:
      list of site content items paths
    • getSubtreeItems

      default List<String> getSubtreeItems(String site, String path)
      List sandbox subtree items for give site and path
      Parameters:
      site - site identifier
      path - path for subtree root
      Returns:
      list of item paths contained in the subtree
    • getSubtreeItems

      List<String> getSubtreeItems(String site, String path, GitRepositories repoType, String revstr)
      List subtree items for give site and path
      Parameters:
      site - site identifier
      path - path for subtree root
      repoType - repository type
      revstr - A git object references expression (e.g.: HEAD, branch name, commit id)
      Returns:
      list of item paths contained in the subtree
    • getOperations

      List<RepoOperation> getOperations(String site, String commitIdFrom, String commitIdTo)
      Get a list of operations since the commit ID provided (compare that commit to HEAD)
      Parameters:
      site - site to use
      commitIdFrom - commit ID to start at
      commitIdTo - commit ID to end at
      Returns:
      commit ID of current HEAD, updated operationsSinceCommit
    • getOperationsFromDelta

      List<RepoOperation> getOperationsFromDelta(String site, String commitIdFrom, String commitIdTo)
      Get a list of operations since the commit ID provided (compare that commit to HEAD)
      Parameters:
      site - site to use
      commitIdFrom - commit ID to start at
      commitIdTo - commit ID to end at
      Returns:
      commit ID of current HEAD, updated operationsSinceCommit
    • getRepoFirstCommitId

      String getRepoFirstCommitId(String site)
      Get first id from repository for given site
      Parameters:
      site - site id
      Returns:
      first commit id
    • getGitLog

      GitLog getGitLog(String siteId, String commitId)
      Get git log object from database
      Parameters:
      siteId - site id
      commitId - commit ID
      Returns:
      git log object
    • markGitLogVerifiedProcessed

      void markGitLogVerifiedProcessed(String siteId, String commitId)
      Mark Git log as verified
      Parameters:
      siteId - site identifier
      commitId - commit id
    • markGitLogVerifiedProcessedBulk

      void markGitLogVerifiedProcessedBulk(String siteId, List<String> commitIds)
      Mark Git logs as verified
      Parameters:
      siteId - site identifier
      commitIds - list of commit ids
    • insertGitLog

      void insertGitLog(String siteId, String commitId, int processed)
      Insert Git Log
      Parameters:
      siteId - site
      commitId - commit ID
      processed - processed
    • insertGitLog

      void insertGitLog(String siteId, String commitId, int processed, int audited)
      Insert Git Log
      Parameters:
      siteId - site
      commitId - commit ID
      processed - processed
      audited - audited
    • getPublishingHistory

      List<PublishingHistoryItem> getPublishingHistory(String siteId, String environment, String path, String publisher, ZonedDateTime fromDate, ZonedDateTime toDate, int limit)
      Get publishing history
      Parameters:
      siteId - site identifier
      environment - environment
      path - path regular expression to use as filter
      publisher - user to filter by
      fromDate - lower boundary for published date
      toDate - upper boundary for published date
      limit - number of records to return
      Returns:
      publishing history
    • createSiteFromBlueprint

      boolean createSiteFromBlueprint(String blueprintLocation, String siteId, String sandboxBranch, Map<String,String> params, String creator)
      Create a new site based on a blueprint
      Parameters:
      blueprintLocation - blueprint location
      siteId - site identifier
      sandboxBranch - sandbox branch name
      params - site parameters
      creator - site creator
      Returns:
      true if successful, false otherwise
    • publish

      void publish(String siteId, String sandboxBranch, List<DeploymentItemTO> deploymentItems, String environment, String author, String comment) throws DeploymentException
      Publish content to specified environment.
      Parameters:
      siteId - site identifier
      sandboxBranch - sandbox branch name
      deploymentItems - items to be published
      environment - environment to publish to
      author - author
      comment - submission comment
      Throws:
      DeploymentException - deployment error
    • repositoryExists

      boolean repositoryExists(String site)
      Check if repository exists for given site
      Parameters:
      site - site id
      Returns:
      true if repository exists, otherwise false
    • commitIdExists

      boolean commitIdExists(String site, String commitId)
      Check if given commit id exists
      Parameters:
      site - site id
      commitId - commit id to check
      Returns:
      true if it exists in site repository, otherwise false
    • commitIdExists

      boolean commitIdExists(String site, GitRepositories repoType, String commitId)
      Check if given commit id (or revision string) exists
      Parameters:
      site - site id
      repoType - repository type
      commitId - commit id or revision to check
      Returns:
      true if it exists in site repository, otherwise false
    • createSiteCloneRemote

      boolean createSiteCloneRemote(String siteId, String sandboxBranch, String remoteName, String remoteUrl, String remoteBranch, boolean singleBranch, String authenticationType, String remoteUsername, String remotePassword, String remoteToken, String remotePrivateKey, Map<String,String> params, boolean createAsOrphan, String creator) throws InvalidRemoteRepositoryException, InvalidRemoteRepositoryCredentialsException, RemoteRepositoryNotFoundException, ServiceLayerException
      Create new site as a clone from remote repository
      Parameters:
      siteId - site identifier
      sandboxBranch - sandbox branch name
      remoteName - remote name
      remoteUrl - remote repository url
      remoteBranch - remote branch name
      singleBranch - flag to signal if clone single branch or full repository
      authenticationType - type of authentication to use to connect remote repository
      remoteUsername - remote username
      remotePassword - remote password
      remoteToken - remote token
      remotePrivateKey - remote private key
      params - site parameters
      createAsOrphan - create as orphan
      creator - site creator
      Returns:
      true if success
      Throws:
      InvalidRemoteRepositoryException - invalid remote repository
      InvalidRemoteRepositoryCredentialsException - invalid credentials for remote repository
      RemoteRepositoryNotFoundException - remote repository not found
      ServiceLayerException - general service error
    • removeRemote

      boolean removeRemote(String siteId, String remoteName)
      Remove remote with given name for site
      Parameters:
      siteId - site identifier
      remoteName - remote name
      Returns:
      true if operation was successful
    • contentExists

      boolean contentExists(String site, String path)
      Determine if content exists in the repository at a given path
      Parameters:
      site - site id where the operation will be executed
      path -
      Returns:
      true if site has content object at path
    • getRepoLastCommitId

      String getRepoLastCommitId(String site)
      Get last commit id from repository for given site.
      Parameters:
      site - site id
      Returns:
      last commit id (current HEAD)
    • getItem

      org.craftercms.core.service.Item getItem(String siteId, String path, boolean flatten)
    • getContentSize

      long getContentSize(String site, String path)
      get file size
      Parameters:
      site - site id where the operation will be executed
      path - path to content
      Returns:
      Size in bytes
    • getLastEditCommitId

      String getLastEditCommitId(String siteId, String path)
    • getChangeSetPathsFromDelta

      Map<String,String> getChangeSetPathsFromDelta(String site, String commitIdFrom, String commitIdTo)
      Get a list of paths that changed since the commit ID provided to commit ID provided
      Parameters:
      site - site to use
      commitIdFrom - commit ID to start at
      commitIdTo - commit ID to end at
      Returns:
      list of paths of files that changed between two commits
    • markGitLogAudited

      void markGitLogAudited(String siteId, String commitId)
      Mark Git log as audited
      Parameters:
      siteId - site identifier
      commitId - commit id
    • updateGitlog

      void updateGitlog(String siteId, String lastProcessedCommitId, int batchSize)
      Update gitlog table with commit ids from repository
      Parameters:
      siteId - site identifier
      lastProcessedCommitId - last processed commit id
      batchSize - size of a batch to update
    • getUnauditedCommits

      List<GitLog> getUnauditedCommits(String siteId, int batchSize)
      Get unaudited commits from database
      Parameters:
      siteId - site identifier
      batchSize - size of a batch to retrieve
      Returns:
      list of gitlog records
    • getUnprocessedCommits

      List<GitLog> getUnprocessedCommits(String siteId, long marker)
      Get unprocessed commits from database
      Parameters:
      siteId - site identifier
      marker - id of last verified commit Id
      Returns:
      list of gitlog records
    • countUnprocessedCommits

      int countUnprocessedCommits(String siteId, long marker)
      Count unprocessed commits from database
      Parameters:
      siteId - site identifier
      marker - id of last verified commit Id
      Returns:
      number of unprocessed gitlog records
    • getItemEnvironmentProperties

      DetailedItem.Environment getItemEnvironmentProperties(String siteId, GitRepositories repo, String environment, String path)
      Get environment properties for item
      Parameters:
      siteId - site identifier
      repo - repository type
      environment - branch
      path - path of the item
      Returns:
      environment properties
    • markGitLogProcessedBeforeMarker

      void markGitLogProcessedBeforeMarker(String siteId, long marker, int processed)
      Mark all git logs as processed if they are inserted before marker
      Parameters:
      siteId - site identifier
      marker - marker git commit
      processed - value for processed
    • getPreviousCommitId

      String getPreviousCommitId(String siteId, String commitId)
      Get the previous commit id from repository for given a site id and a commit id
      Parameters:
      siteId - site identifier
      commitId - commit Id
      Returns:
    • lockItem

      void lockItem(String site, String path)
      lock an item NOTE: site will be removed from this interface
      Parameters:
      site - site id where the operation will be executed
      path - path of the item
    • itemUnlock

      void itemUnlock(String site, String path)
      unlock an item
      Parameters:
      site - site id where the operation will be executed
      path - path of the item
    • upsertGitLogList

      void upsertGitLogList(String siteId, List<String> commitIds, boolean processed, boolean audited)
      Upsert git logs as processed and audited
      Parameters:
      siteId - site identifier
      commitIds - commit ids
      processed - true if already processed
      audited - true if already audited
    • getContentByCommitId

      Optional<org.springframework.core.io.Resource> getContentByCommitId(String site, String path, String commitId)
      return a specific version of the content
      Parameters:
      site - site id where the operation will be executed
      path - path of the content
      commitId - version to return
      Returns:
      the resource if available
    • publishedRepositoryExists

      boolean publishedRepositoryExists(String siteId)
      Check if published repository exists for given site.
      Parameters:
      siteId - site identifier
      Returns:
      true if PUBLISHED repository exists, otherwise false
    • initialPublish

      void initialPublish(String siteId) throws SiteNotFoundException
      Execute initial publish for given site
      Parameters:
      siteId - site identifier
      Throws:
      SiteNotFoundException
    • publishAll

      RepositoryChanges publishAll(String siteId, String publishingTarget, String comment) throws ServiceLayerException
      Publishes all changes for the given site & target
      Parameters:
      siteId - the id of the site
      publishingTarget - the publishing target
      comment - submission comment
      Throws:
      ServiceLayerException
    • preparePublishAll

      RepositoryChanges preparePublishAll(String siteId, String publishingTarget) throws ServiceLayerException
      Prepares the repository to publish all changes for the given site & target
      Parameters:
      siteId - the id of the site
      publishingTarget - the publishing target
      Returns:
      the set of changed files
      Throws:
      ServiceLayerException - if there is any error during the preparation
    • completePublishAll

      void completePublishAll(String siteId, String publishingTarget, RepositoryChanges changes, String comment) throws ServiceLayerException
      Performs the actual publish of all changes for the given site & target
      Parameters:
      siteId - the id of the site
      publishingTarget - the publishing target
      changes - the set of changed files
      comment - submission comment
      Throws:
      ServiceLayerException - if there is any error during publishing
    • cancelPublishAll

      void cancelPublishAll(String siteId, String publishingTarget) throws ServiceLayerException
      Performs the cleanup after a failed publish all operation for the given site & target
      Parameters:
      siteId - the id of the site
      publishingTarget - the publishing target
      Throws:
      ServiceLayerException - if there is any error during cleanup
    • populateGitLog

      void populateGitLog(String siteId) throws org.eclipse.jgit.api.errors.GitAPIException, IOException
      Populates the full git log of the sandbox repository into the database
      Parameters:
      siteId - the id of the site
      Throws:
      org.eclipse.jgit.api.errors.GitAPIException - if there is any error reading the git log
      IOException - if there is any error executing the db script
    • checkContentExists

      void checkContentExists(String site, String path) throws ServiceLayerException
      Checks if a content exists at a given path and throw an exception if it does not.
      Parameters:
      site - id of the site
      path - the content path
      Throws:
      ServiceLayerException - if no content is found at the given path
    • getContentItemHistory

      List<ItemVersion> getContentItemHistory(String site, String path) throws IOException, org.eclipse.jgit.api.errors.GitAPIException
      Get the history of a content item.
      Note: the results of this method are not guaranteed when the path does not currently exist in the repository.
      Parameters:
      site - site id
      path - path of the content item
      Returns:
      list of item versions
      Throws:
      IOException - if there is any error reading the git log or getting diffs between commits
      org.eclipse.jgit.api.errors.GitAPIException - if there is any error while executing git commands
    • duplicateSite

      void duplicateSite(String sourceSiteId, String siteId, String sourceSandboxBranch, String sandboxBranch) throws IOException, ServiceLayerException
      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.
      Parameters:
      sourceSiteId - source site id
      siteId - new site id
      sandboxBranch - sandbox branch name
      Throws:
      IOException - if there is any error while copying the directories
      ServiceLayerException
    • shallowContentExists

      boolean shallowContentExists(String site, String path)
      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.
      Returns:
      true if site has content object at path