Interface ContentRepository

    • Method Detail

      • 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 - path to check if content exists
        Returns:
        true if site has content object at path
      • 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
      • writeContent

        String writeContent​(String site,
                            String path,
                            InputStream content)
                     throws ServiceLayerException
        write content
        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

        String createFolder​(String site,
                            String path,
                            String name)
        create a folder
        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
      • deleteContent

        String deleteContent​(String site,
                             String path,
                             String approver)
        delete content
        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
      • moveContent

        default Map<String,​String> moveContent​(String site,
                                                     String fromPath,
                                                     String toPath)
        move content from PathA to pathB
        Parameters:
        site - site id where the operation will be executed
        fromPath - source content
        toPath - target path
        Returns:
        Commit ID if successful, null otherwise
      • moveContent

        Map<String,​String> moveContent​(String site,
                                             String fromPath,
                                             String toPath,
                                             String newName)
        move content from PathA to pathB
        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
      • copyContent

        String copyContent​(String site,
                           String fromPath,
                           String toPath)
        copy content from PathA to pathB
        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
      • getContentChildren

        RepositoryItem[] getContentChildren​(String site,
                                            String path)
        get immediate children for path
        Parameters:
        site - site id where the operation will be executed
        path - path to content
        Returns:
        a list of children
      • getContentVersionHistory

        VersionTO[] getContentVersionHistory​(String site,
                                             String path)
        get the version history for an item
        Parameters:
        site - - the project ID
        path - - the path of the item
        Returns:
        a list of versions
      • createVersion

        String createVersion​(String site,
                             String path,
                             boolean majorVersion)
        create a version
        Parameters:
        site - site id where the operation will be executed
        path - location of content
        majorVersion - true if major
        Returns:
        the created version ID or null on failure
      • createVersion

        String createVersion​(String site,
                             String path,
                             String comment,
                             boolean majorVersion)
        create a version
        Parameters:
        site - site id where the operation will be executed
        path - location of content
        comment - version history comment
        majorVersion - true if major
        Returns:
        the created version ID or null on failure
      • revertContent

        String revertContent​(String site,
                             String path,
                             String version,
                             boolean major,
                             String comment)
        revert a version (create a new version based on an old version)
        Parameters:
        site - site id where the operation will be executed
        path - - the path of the item to "revert"
        version - - old version ID to base to version on
        major - flag if it is major version
        comment - add comment when committing content
        Returns:
        Commit ID if successful, empty string otherwise
      • lockItemForPublishing

        void lockItemForPublishing​(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
      • unLockItem

        void unLockItem​(String site,
                        String path)
        unlock an item for publishing NOTE: site will be removed from this interface
        Parameters:
        site - site id where the operation will be executed
        path - path of the item
      • unLockItemForPublishing

        void unLockItemForPublishing​(String site,
                                     String path)
        unlock an item for publishing NOTE: site will be removed from this interface
        Parameters:
        site - site id where the operation will be executed
        path - path of the item
      • deleteSite

        boolean deleteSite​(String siteId)
        Deletes an existing site.
        Parameters:
        siteId - site to delete
        Returns:
        true if successful, false otherwise
      • initialPublish

        void initialPublish​(String site,
                            String sandboxBranch,
                            String environment,
                            String author,
                            String comment)
                     throws DeploymentException
        Initial publish to specified environment.
        Parameters:
        site - site identifier
        sandboxBranch - sandbox branch name
        environment - environment to publish
        author - author
        comment - comment
        Throws:
        DeploymentException - deployment error
      • getRepoLastCommitId

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

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

        List<String> getEditCommitIds​(String site,
                                      String path,
                                      String commitIdFrom,
                                      String commitIdTo)
        Get a list of commits for updates on a content
        Parameters:
        site - site id
        path - path
        commitIdFrom - range from commit id (inclusive)
        commitIdTo - range to commit id (inclusive)
        Returns:
        list of edit commit ids
      • insertFullGitLog

        void insertFullGitLog​(String siteId,
                              int processed)
        Insert Full Git Log
        Parameters:
        siteId - site
        processed - processed
      • deleteGitLogForSite

        void deleteGitLogForSite​(String siteId)
        Delete Git log for site
        Parameters:
        siteId - site identifier
      • addRemote

        boolean addRemote​(String siteId,
                          String remoteName,
                          String remoteUrl,
                          String authenticationType,
                          String remoteUsername,
                          String remotePassword,
                          String remoteToken,
                          String remotePrivateKey)
                   throws InvalidRemoteUrlException,
                          ServiceLayerException
        Add remote repository for site content repository
        Parameters:
        siteId - site identifier
        remoteName - remote name
        remoteUrl - remote url
        authenticationType - authentication type
        remoteUsername - remote username
        remotePassword - remote password
        remoteToken - remote token
        remotePrivateKey - remote private key
        Returns:
        true if operation was successful
        Throws:
        InvalidRemoteUrlException - invalid url for remote repository
        ServiceLayerException - general service error
      • removeRemoteRepositoriesForSite

        void removeRemoteRepositoriesForSite​(String siteId)
        Remove all remotes for given site
        Parameters:
        siteId - site identifier
      • listRemote

        List<RemoteRepositoryInfoTO> listRemote​(String siteId,
                                                String sandboxBranch)
                                         throws ServiceLayerException,
                                                org.craftercms.commons.crypto.CryptoException
        List remote repositories for given site
        Parameters:
        siteId - site identifier
        sandboxBranch - sandbox branch name
        Returns:
        list of names of remote repositories
        Throws:
        ServiceLayerException - general service error
        org.craftercms.commons.crypto.CryptoException - git repository helper error
      • pushToRemote

        boolean pushToRemote​(String siteId,
                             String remoteName,
                             String remoteBranch)
                      throws ServiceLayerException,
                             InvalidRemoteUrlException,
                             org.craftercms.commons.crypto.CryptoException
        Push content to remote repository
        Parameters:
        siteId - site identifier
        remoteName - remote name
        remoteBranch - remote branch
        Returns:
        true if operation was successful
        Throws:
        ServiceLayerException - general service error
        InvalidRemoteUrlException - invalid url for remote repository
        org.craftercms.commons.crypto.CryptoException - git repository helper error
      • pullFromRemote

        boolean pullFromRemote​(String siteId,
                               String remoteName,
                               String remoteBranch)
                        throws ServiceLayerException,
                               InvalidRemoteUrlException,
                               org.craftercms.commons.crypto.CryptoException
        Pull from remote repository
        Parameters:
        siteId - site identifier
        remoteName - remote name
        remoteBranch - remote branch
        Returns:
        true if operation was successful
        Throws:
        ServiceLayerException - general service error
        InvalidRemoteUrlException - invalid url for remote repository
        org.craftercms.commons.crypto.CryptoException - git repository helper error
      • isFolder

        boolean isFolder​(String siteId,
                         String path)
        Check if content at given path is folder
        Parameters:
        siteId - site identifier
        path - content path
        Returns:
        true if path is folder, otherwise false
      • resetStagingRepository

        void resetStagingRepository​(String siteId)
                             throws ServiceLayerException
        Reset staging repository to live for given site
        Parameters:
        siteId - site identifier to use for resetting
        Throws:
        ServiceLayerException - general service error
      • reloadRepository

        void reloadRepository​(String siteId)
        Reload repository for given site
        Parameters:
        siteId - site identifier
      • cleanupRepositories

        void cleanupRepositories​(String siteId)
        Performs a cleanup all repositories for the given site
        Parameters:
        siteId - site identifier