Interface ContentRepository
- All Known Subinterfaces:
StudioBlobAwareContentRepository,StudioBlobStore,StudioBlobStoreAdapter
- All Known Implementing Classes:
BlobAwareContentRepository,GitContentRepository,StudioAwsS3BlobStore
public interface ContentRepository
-
Method Summary
Modifier and TypeMethodDescriptionvoidcancelPublishAll(String siteId, String publishingTarget) Performs the cleanup after a failed publish all operation for the given site & targetvoidcheckContentExists(String site, String path) Checks if a content exists at a given path and throw an exception if it does not.booleancommitIdExists(String site, String commitId) Check if given commit id existsbooleancommitIdExists(String site, GitRepositories repoType, String commitId) Check if given commit id (or revision string) existsvoidcompletePublishAll(String siteId, String publishingTarget, RepositoryChanges changes, String comment) Performs the actual publish of all changes for the given site & targetbooleancontentExists(String site, String path) Determine if content exists in the repository at a given pathintcountUnprocessedCommits(String siteId, long marker) Count unprocessed commits from databasebooleancreateSiteCloneRemote(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) Create new site as a clone from remote repositorybooleancreateSiteFromBlueprint(String blueprintLocation, String siteId, String sandboxBranch, Map<String, String> params, String creator) Create a new site based on a blueprintvoidduplicateSite(String sourceSiteId, String siteId, String sourceSandboxBranch, String sandboxBranch) Create copies of the source site's repositories.getChangeSetPathsFromDelta(String site, String commitIdFrom, String commitIdTo) Get a list of paths that changed since the commit ID provided to commit ID providedOptional<org.springframework.core.io.Resource> getContentByCommitId(String site, String path, String commitId) return a specific version of the contentgetContentItemHistory(String site, String path) Get the history of a content item.longgetContentSize(String site, String path) get file sizeGet git log object from databaseorg.craftercms.core.service.ItemgetItemEnvironmentProperties(String siteId, GitRepositories repo, String environment, String path) Get environment properties for itemgetItemPaths(String site, GitRepositories repoType, String revstr) Get the site content item list for the given sitegetLastEditCommitId(String siteId, String path) getOperations(String site, String commitIdFrom, String commitIdTo) Get a list of operations since the commit ID provided (compare that commit to HEAD)getOperationsFromDelta(String site, String commitIdFrom, String commitIdTo) Get a list of operations since the commit ID provided (compare that commit to HEAD)getPreviousCommitId(String siteId, String commitId) Get the previous commit id from repository for given a site id and a commit idgetPublishingHistory(String siteId, String environment, String path, String publisher, ZonedDateTime fromDate, ZonedDateTime toDate, int limit) Get publishing historygetRepoFirstCommitId(String site) Get first id from repository for given sitegetRepoLastCommitId(String site) Get last commit id from repository for given site.getSubtreeItems(String site, String path) List sandbox subtree items for give site and pathgetSubtreeItems(String site, String path, GitRepositories repoType, String revstr) List subtree items for give site and pathgetUnauditedCommits(String siteId, int batchSize) Get unaudited commits from databasegetUnprocessedCommits(String siteId, long marker) Get unprocessed commits from databasevoidinitialPublish(String siteId) Execute initial publish for given sitevoidinsertGitLog(String siteId, String commitId, int processed) Insert Git LogvoidinsertGitLog(String siteId, String commitId, int processed, int audited) Insert Git LogvoiditemUnlock(String site, String path) unlock an itemvoidlock an item NOTE: site will be removed from this interfacevoidmarkGitLogAudited(String siteId, String commitId) Mark Git log as auditedvoidmarkGitLogProcessedBeforeMarker(String siteId, long marker, int processed) Mark all git logs as processed if they are inserted before markervoidmarkGitLogVerifiedProcessed(String siteId, String commitId) Mark Git log as verifiedvoidmarkGitLogVerifiedProcessedBulk(String siteId, List<String> commitIds) Mark Git logs as verifiedvoidpopulateGitLog(String siteId) Populates the full git log of the sandbox repository into the databasepreparePublishAll(String siteId, String publishingTarget) Prepares the repository to publish all changes for the given site & targetvoidpublish(String siteId, String sandboxBranch, List<DeploymentItemTO> deploymentItems, String environment, String author, String comment) Publish content to specified environment.publishAll(String siteId, String publishingTarget, String comment) Publishes all changes for the given site & targetbooleanpublishedRepositoryExists(String siteId) Check if published repository exists for given site.booleanremoveRemote(String siteId, String remoteName) Remove remote with given name for sitebooleanrepositoryExists(String site) Check if repository exists for given sitebooleanshallowContentExists(String site, String path) This is a faster, but less accurate, version of contentExists.voidupdateGitlog(String siteId, String lastProcessedCommitId, int batchSize) Update gitlog table with commit ids from repositoryvoidupsertGitLogList(String siteId, List<String> commitIds, boolean processed, boolean audited) Upsert git logs as processed and audited
-
Method Details
-
getItemPaths
Get the site content item list for the given site- Parameters:
site- site idrepoType- repository typerevstr- A git object references expression (e.g.: HEAD, branch name, commit id)- Returns:
- list of site content items paths
-
getSubtreeItems
List sandbox subtree items for give site and path- Parameters:
site- site identifierpath- path for subtree root- Returns:
- list of item paths contained in the subtree
-
getSubtreeItems
List subtree items for give site and path- Parameters:
site- site identifierpath- path for subtree rootrepoType- repository typerevstr- A git object references expression (e.g.: HEAD, branch name, commit id)- Returns:
- list of item paths contained in the subtree
-
getOperations
Get a list of operations since the commit ID provided (compare that commit to HEAD)- Parameters:
site- site to usecommitIdFrom- commit ID to start atcommitIdTo- commit ID to end at- Returns:
- commit ID of current HEAD, updated operationsSinceCommit
-
getOperationsFromDelta
Get a list of operations since the commit ID provided (compare that commit to HEAD)- Parameters:
site- site to usecommitIdFrom- commit ID to start atcommitIdTo- commit ID to end at- Returns:
- commit ID of current HEAD, updated operationsSinceCommit
-
getRepoFirstCommitId
Get first id from repository for given site- Parameters:
site- site id- Returns:
- first commit id
-
getGitLog
Get git log object from database- Parameters:
siteId- site idcommitId- commit ID- Returns:
- git log object
-
markGitLogVerifiedProcessed
Mark Git log as verified- Parameters:
siteId- site identifiercommitId- commit id
-
markGitLogVerifiedProcessedBulk
Mark Git logs as verified- Parameters:
siteId- site identifiercommitIds- list of commit ids
-
insertGitLog
Insert Git Log- Parameters:
siteId- sitecommitId- commit IDprocessed- processed
-
insertGitLog
Insert Git Log- Parameters:
siteId- sitecommitId- commit IDprocessed- processedaudited- 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 identifierenvironment- environmentpath- path regular expression to use as filterpublisher- user to filter byfromDate- lower boundary for published datetoDate- upper boundary for published datelimit- 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 locationsiteId- site identifiersandboxBranch- sandbox branch nameparams- site parameterscreator- 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 identifiersandboxBranch- sandbox branch namedeploymentItems- items to be publishedenvironment- environment to publish toauthor- authorcomment- submission comment- Throws:
DeploymentException- deployment error
-
repositoryExists
Check if repository exists for given site- Parameters:
site- site id- Returns:
- true if repository exists, otherwise false
-
commitIdExists
Check if given commit id exists- Parameters:
site- site idcommitId- commit id to check- Returns:
- true if it exists in site repository, otherwise false
-
commitIdExists
Check if given commit id (or revision string) exists- Parameters:
site- site idrepoType- repository typecommitId- 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, ServiceLayerExceptionCreate new site as a clone from remote repository- Parameters:
siteId- site identifiersandboxBranch- sandbox branch nameremoteName- remote nameremoteUrl- remote repository urlremoteBranch- remote branch namesingleBranch- flag to signal if clone single branch or full repositoryauthenticationType- type of authentication to use to connect remote repositoryremoteUsername- remote usernameremotePassword- remote passwordremoteToken- remote tokenremotePrivateKey- remote private keyparams- site parameterscreateAsOrphan- create as orphancreator- site creator- Returns:
- true if success
- Throws:
InvalidRemoteRepositoryException- invalid remote repositoryInvalidRemoteRepositoryCredentialsException- invalid credentials for remote repositoryRemoteRepositoryNotFoundException- remote repository not foundServiceLayerException- general service error
-
removeRemote
Remove remote with given name for site- Parameters:
siteId- site identifierremoteName- remote name- Returns:
- true if operation was successful
-
contentExists
Determine if content exists in the repository at a given path- Parameters:
site- site id where the operation will be executedpath-- Returns:
- true if site has content object at path
-
getRepoLastCommitId
Get last commit id from repository for given site.- Parameters:
site- site id- Returns:
- last commit id (current HEAD)
-
getItem
-
getContentSize
get file size- Parameters:
site- site id where the operation will be executedpath- path to content- Returns:
- Size in bytes
-
getLastEditCommitId
-
getChangeSetPathsFromDelta
Get a list of paths that changed since the commit ID provided to commit ID provided- Parameters:
site- site to usecommitIdFrom- commit ID to start atcommitIdTo- commit ID to end at- Returns:
- list of paths of files that changed between two commits
-
markGitLogAudited
Mark Git log as audited- Parameters:
siteId- site identifiercommitId- commit id
-
updateGitlog
Update gitlog table with commit ids from repository- Parameters:
siteId- site identifierlastProcessedCommitId- last processed commit idbatchSize- size of a batch to update
-
getUnauditedCommits
Get unaudited commits from database- Parameters:
siteId- site identifierbatchSize- size of a batch to retrieve- Returns:
- list of gitlog records
-
getUnprocessedCommits
Get unprocessed commits from database- Parameters:
siteId- site identifiermarker- id of last verified commit Id- Returns:
- list of gitlog records
-
countUnprocessedCommits
Count unprocessed commits from database- Parameters:
siteId- site identifiermarker- 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 identifierrepo- repository typeenvironment- branchpath- path of the item- Returns:
- environment properties
-
markGitLogProcessedBeforeMarker
Mark all git logs as processed if they are inserted before marker- Parameters:
siteId- site identifiermarker- marker git commitprocessed- value for processed
-
getPreviousCommitId
Get the previous commit id from repository for given a site id and a commit id- Parameters:
siteId- site identifiercommitId- commit Id- Returns:
-
lockItem
lock an item NOTE: site will be removed from this interface- Parameters:
site- site id where the operation will be executedpath- path of the item
-
itemUnlock
unlock an item- Parameters:
site- site id where the operation will be executedpath- path of the item
-
upsertGitLogList
Upsert git logs as processed and audited- Parameters:
siteId- site identifiercommitIds- commit idsprocessed- true if already processedaudited- 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 executedpath- path of the contentcommitId- version to return- Returns:
- the resource if available
-
publishedRepositoryExists
Check if published repository exists for given site.- Parameters:
siteId- site identifier- Returns:
- true if PUBLISHED repository exists, otherwise false
-
initialPublish
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 sitepublishingTarget- the publishing targetcomment- 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 sitepublishingTarget- 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 sitepublishingTarget- the publishing targetchanges- the set of changed filescomment- submission comment- Throws:
ServiceLayerException- if there is any error during publishing
-
cancelPublishAll
Performs the cleanup after a failed publish all operation for the given site & target- Parameters:
siteId- the id of the sitepublishingTarget- the publishing target- Throws:
ServiceLayerException- if there is any error during cleanup
-
populateGitLog
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 logIOException- if there is any error executing the db script
-
checkContentExists
Checks if a content exists at a given path and throw an exception if it does not.- Parameters:
site- id of the sitepath- 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 idpath- 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 commitsorg.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 idsiteId- new site idsandboxBranch- sandbox branch name- Throws:
IOException- if there is any error while copying the directoriesServiceLayerException
-
shallowContentExists
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
-