Interface ContentRepository

    • Method Detail

      • getSubtreeItems

        List<String> getSubtreeItems​(String site,
                                     String path)
        List 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
      • 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 exists
        Parameters:
        site - site id
        repoType - repository type
        commitId - commit id to check
        Returns:
        true if it exists in site repository, otherwise false
      • 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
      • 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)
                   throws SiteNotFoundException
        Update gitlog table with commit ids from repository
        Parameters:
        siteId - site identifier
        lastProcessedCommitId - last processed commit id
        batchSize - size of a batch to update
        Throws:
        SiteNotFoundException
      • 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)
                                                                     throws ContentNotFoundException
        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
        Throws:
        ContentNotFoundException - content not found for given path and version
      • 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
      • 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