Class GitContentRepository

    • Constructor Detail

      • GitContentRepository

        public GitContentRepository()
    • Method Detail

      • getSubtreeItems

        public List<String> getSubtreeItems​(String site,
                                            String path)
        Description copied from interface: ContentRepository
        List subtree items for give site and path
        Specified by:
        getSubtreeItems in interface ContentRepository
        Parameters:
        site - site identifier
        path - path for subtree root
        Returns:
        list of item paths contained in the subtree
      • getOperations

        public List<RepoOperation> getOperations​(String site,
                                                 String commitIdFrom,
                                                 String commitIdTo)
        Description copied from interface: ContentRepository
        Get a list of operations since the commit ID provided (compare that commit to HEAD)
        Specified by:
        getOperations in interface ContentRepository
        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

        public List<RepoOperation> getOperationsFromDelta​(String site,
                                                          String commitIdFrom,
                                                          String commitIdTo)
        Description copied from interface: ContentRepository
        Get a list of operations since the commit ID provided (compare that commit to HEAD)
        Specified by:
        getOperationsFromDelta in interface ContentRepository
        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
      • insertGitLog

        public void insertGitLog​(String siteId,
                                 String commitId,
                                 int processed)
        Description copied from interface: ContentRepository
        Insert Git Log
        Specified by:
        insertGitLog in interface ContentRepository
        Parameters:
        siteId - site
        commitId - commit ID
        processed - processed
      • insertGitLog

        public void insertGitLog​(String siteId,
                                 String commitId,
                                 int processed,
                                 int audited)
        Description copied from interface: ContentRepository
        Insert Git Log
        Specified by:
        insertGitLog in interface ContentRepository
        Parameters:
        siteId - site
        commitId - commit ID
        processed - processed
        audited - audited
      • getPublishingHistory

        public List<PublishingHistoryItem> getPublishingHistory​(String siteId,
                                                                String environment,
                                                                String pathRegex,
                                                                String publisher,
                                                                ZonedDateTime fromDate,
                                                                ZonedDateTime toDate,
                                                                int limit)
        Description copied from interface: ContentRepository
        Get publishing history
        Specified by:
        getPublishingHistory in interface ContentRepository
        Parameters:
        siteId - site identifier
        environment - environment
        pathRegex - 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

        public boolean createSiteFromBlueprint​(String blueprintLocation,
                                               String site,
                                               String sandboxBranch,
                                               Map<String,​String> params,
                                               String creator)
        Description copied from interface: ContentRepository
        Create a new site based on a blueprint
        Specified by:
        createSiteFromBlueprint in interface ContentRepository
        Parameters:
        blueprintLocation - blueprint location
        site - site identifier
        sandboxBranch - sandbox branch name
        params - site parameters
        creator - site creator
        Returns:
        true if successful, false otherwise
      • resetIfNeeded

        protected void resetIfNeeded​(org.eclipse.jgit.lib.Repository repo,
                                     org.eclipse.jgit.api.Git git)
                              throws IOException,
                                     org.eclipse.jgit.api.errors.GitAPIException
        Throws:
        IOException
        org.eclipse.jgit.api.errors.GitAPIException
      • checkoutBranch

        protected void checkoutBranch​(org.eclipse.jgit.api.Git git,
                                      String name,
                                      boolean create)
                               throws org.eclipse.jgit.api.errors.GitAPIException
        Throws:
        org.eclipse.jgit.api.errors.GitAPIException
      • checkoutBranch

        protected void checkoutBranch​(org.eclipse.jgit.api.Git git,
                                      String name)
                               throws org.eclipse.jgit.api.errors.GitAPIException
        Throws:
        org.eclipse.jgit.api.errors.GitAPIException
      • deleteBranches

        protected void deleteBranches​(org.eclipse.jgit.api.Git git,
                                      String... names)
                               throws org.eclipse.jgit.api.errors.GitAPIException
        Throws:
        org.eclipse.jgit.api.errors.GitAPIException
      • branchExists

        protected boolean branchExists​(org.eclipse.jgit.lib.Repository repo,
                                       String branch)
                                throws IOException
        Throws:
        IOException
      • repositoryExists

        public boolean repositoryExists​(String siteId)
        Description copied from interface: ContentRepository
        Check if repository exists for given site
        Specified by:
        repositoryExists in interface ContentRepository
        Parameters:
        siteId - site id
        Returns:
        true if repository exists, otherwise false
      • commitIdExists

        public boolean commitIdExists​(String site,
                                      String commitId)
        Description copied from interface: ContentRepository
        Check if given commit id exists
        Specified by:
        commitIdExists in interface ContentRepository
        Parameters:
        site - site id
        commitId - commit id to check
        Returns:
        true if it exists in site repository, otherwise false
      • commitIdExists

        public boolean commitIdExists​(String site,
                                      GitRepositories repoType,
                                      String commitId)
        Description copied from interface: ContentRepository
        Check if given commit id exists
        Specified by:
        commitIdExists in interface ContentRepository
        Parameters:
        site - site id
        repoType - repository type
        commitId - commit id to check
        Returns:
        true if it exists in site repository, otherwise false
      • removeRemote

        public boolean removeRemote​(String siteId,
                                    String remoteName)
        Description copied from interface: ContentRepository
        Remove remote with given name for site
        Specified by:
        removeRemote in interface ContentRepository
        Parameters:
        siteId - site identifier
        remoteName - remote name
        Returns:
        true if operation was successful
      • 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
        Parameters:
        site - site id where the operation will be executed
        Returns:
        true if site has content object at path
      • 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
      • getChangeSetPathsFromDelta

        public Map<String,​String> getChangeSetPathsFromDelta​(String site,
                                                                   String commitIdFrom,
                                                                   String commitIdTo)
        Description copied from interface: ContentRepository
        Get a list of paths that changed since the commit ID provided to commit ID provided
        Specified by:
        getChangeSetPathsFromDelta in interface ContentRepository
        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
      • updateGitlog

        public void updateGitlog​(String siteId,
                                 String lastProcessedCommitId,
                                 int batchSize)
        Description copied from interface: ContentRepository
        Update gitlog table with commit ids from repository
        Specified by:
        updateGitlog in interface ContentRepository
        Parameters:
        siteId - site identifier
        lastProcessedCommitId - last processed commit id
        batchSize - size of a batch to update
      • getUnauditedCommits

        public List<GitLog> getUnauditedCommits​(String siteId,
                                                int batchSize)
        Description copied from interface: ContentRepository
        Get unaudited commits from database
        Specified by:
        getUnauditedCommits in interface ContentRepository
        Parameters:
        siteId - site identifier
        batchSize - size of a batch to retrieve
        Returns:
        list of gitlog records
      • getUnprocessedCommits

        public List<GitLog> getUnprocessedCommits​(String siteId,
                                                  long marker)
        Description copied from interface: ContentRepository
        Get unprocessed commits from database
        Specified by:
        getUnprocessedCommits in interface ContentRepository
        Parameters:
        siteId - site identifier
        marker - id of last verified commit Id
        Returns:
        list of gitlog records
      • countUnprocessedCommits

        public int countUnprocessedCommits​(String siteId,
                                           long marker)
        Description copied from interface: ContentRepository
        Count unprocessed commits from database
        Specified by:
        countUnprocessedCommits in interface ContentRepository
        Parameters:
        siteId - site identifier
        marker - id of last verified commit Id
        Returns:
        number of unprocessed gitlog records
      • markGitLogProcessedBeforeMarker

        public void markGitLogProcessedBeforeMarker​(String siteId,
                                                    long marker,
                                                    int processed)
        Description copied from interface: ContentRepository
        Mark all git logs as processed if they are inserted before marker
        Specified by:
        markGitLogProcessedBeforeMarker in interface ContentRepository
        Parameters:
        siteId - site identifier
        marker - marker git commit
        processed - value for processed
      • getPreviousCommitId

        public String getPreviousCommitId​(String siteId,
                                          String commitId)
        Description copied from interface: ContentRepository
        Get the previous commit id from repository for given a site id and a commit id
        Specified by:
        getPreviousCommitId in interface ContentRepository
        Parameters:
        siteId - site identifier
        commitId - commit Id
        Returns:
      • lockItem

        public void lockItem​(String site,
                             String path)
        Description copied from interface: ContentRepository
        lock an item NOTE: site will be removed from this interface
        Specified by:
        lockItem in interface ContentRepository
        Parameters:
        site - site id where the operation will be executed
        path - path of the item
      • itemUnlock

        public void itemUnlock​(String site,
                               String path)
        Description copied from interface: ContentRepository
        unlock an item
        Specified by:
        itemUnlock in interface ContentRepository
        Parameters:
        site - site id where the operation will be executed
        path - path of the item
      • upsertGitLogList

        public void upsertGitLogList​(String siteId,
                                     List<String> commitIds,
                                     boolean processed,
                                     boolean audited)
        Description copied from interface: ContentRepository
        Upsert git logs as processed and audited
        Specified by:
        upsertGitLogList in interface ContentRepository
        Parameters:
        siteId - site identifier
        commitIds - commit ids
        processed - true if already processed
        audited - true if already audited
      • getContentByCommitId

        public Optional<org.springframework.core.io.Resource> getContentByCommitId​(String site,
                                                                                   String path,
                                                                                   String commitId)
        Description copied from interface: ContentRepository
        return a specific version of the content
        Specified by:
        getContentByCommitId in interface ContentRepository
        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

        public boolean publishedRepositoryExists​(String siteId)
        Description copied from interface: ContentRepository
        Check if published repository exists for given site.
        Specified by:
        publishedRepositoryExists in interface ContentRepository
        Parameters:
        siteId - site identifier
        Returns:
        true if PUBLISHED repository exists, otherwise false
      • populateGitLog

        public void populateGitLog​(String siteId)
                            throws org.eclipse.jgit.api.errors.GitAPIException,
                                   IOException
        Description copied from interface: ContentRepository
        Populates the full git log of the sandbox repository into the database
        Specified by:
        populateGitLog in interface ContentRepository
        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
      • setStudioConfiguration

        public void setStudioConfiguration​(StudioConfiguration studioConfiguration)
      • setGitLogDao

        public void setGitLogDao​(GitLogDAO gitLogDao)
      • setUserServiceInternal

        public void setUserServiceInternal​(UserServiceInternal userServiceInternal)
      • setRemoteRepositoryDAO

        public void setRemoteRepositoryDAO​(RemoteRepositoryDAO remoteRepositoryDAO)
      • setEncryptor

        public void setEncryptor​(org.craftercms.commons.crypto.TextEncryptor encryptor)
      • setContextManager

        public void setContextManager​(ContextManager contextManager)
      • setContentStoreService

        public void setContentStoreService​(org.craftercms.core.service.ContentStoreService contentStoreService)
      • setGeneralLockService

        public void setGeneralLockService​(GeneralLockService generalLockService)
      • setSiteService

        public void setSiteService​(SiteService siteService)
      • setPublishRequestDao

        public void setPublishRequestDao​(PublishRequestDAO publishRequestDao)
      • setItemServiceInternal

        public void setItemServiceInternal​(ItemServiceInternal itemServiceInternal)
      • setStudioUtils

        public void setStudioUtils​(StudioUtils studioUtils)
      • setSiteFeedMapper

        public void setSiteFeedMapper​(SiteFeedMapper siteFeedMapper)
      • setServicesConfig

        public void setServicesConfig​(ServicesConfig servicesConfig)