Interface ContentRepository
-
- All Known Subinterfaces:
StudioBlobStore
,StudioBlobStoreAdapter
- All Known Implementing Classes:
BlobAwareContentRepository
,GitContentRepository
,StudioAwsS3BlobStore
public interface ContentRepository
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
cancelPublishAll(String siteId, String publishingTarget)
Performs the cleanup after a failed publish all operation for the given site & targetvoid
checkContentExists(String site, String path)
Checks if a content exists at a given path and throw an exception if it does not.boolean
commitIdExists(String site, String commitId)
Check if given commit id existsboolean
commitIdExists(String site, GitRepositories repoType, String commitId)
Check if given commit id existsvoid
completePublishAll(String siteId, String publishingTarget, RepositoryChanges changes, String comment)
Performs the actual publish of all changes for the given site & targetboolean
contentExists(String site, String path)
Determine if content exists in the repository at a given pathint
countUnprocessedCommits(String siteId, long marker)
Count unprocessed commits from databaseboolean
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)
Create new site as a clone from remote repositoryboolean
createSiteFromBlueprint(String blueprintLocation, String siteId, String sandboxBranch, Map<String,String> params, String creator)
Create a new site based on a blueprintMap<String,String>
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 contentlong
getContentSize(String site, String path)
get file sizeGitLog
getGitLog(String siteId, String commitId)
Get git log object from databaseorg.craftercms.core.service.Item
getItem(String siteId, String path, boolean flatten)
DetailedItem.Environment
getItemEnvironmentProperties(String siteId, GitRepositories repo, String environment, String path)
Get environment properties for itemString
getLastEditCommitId(String siteId, String path)
List<RepoOperation>
getOperations(String site, String commitIdFrom, String commitIdTo)
Get a list of operations since the commit ID provided (compare that commit to HEAD)List<RepoOperation>
getOperationsFromDelta(String site, String commitIdFrom, String commitIdTo)
Get a list of operations since the commit ID provided (compare that commit to HEAD)String
getPreviousCommitId(String siteId, String commitId)
Get the previous commit id from repository for given a site id and a commit idList<PublishingHistoryItem>
getPublishingHistory(String siteId, String environment, String path, String publisher, ZonedDateTime fromDate, ZonedDateTime toDate, int limit)
Get publishing historyString
getRepoFirstCommitId(String site)
Get first id from repository for given siteString
getRepoLastCommitId(String site)
Get last commit id from repository for given site.List<String>
getSubtreeItems(String site, String path)
List subtree items for give site and pathList<GitLog>
getUnauditedCommits(String siteId, int batchSize)
Get unaudited commits from databaseList<GitLog>
getUnprocessedCommits(String siteId, long marker)
Get unprocessed commits from databasevoid
initialPublish(String siteId)
Execute initial publish for given sitevoid
insertGitLog(String siteId, String commitId, int processed)
Insert Git Logvoid
insertGitLog(String siteId, String commitId, int processed, int audited)
Insert Git Logvoid
itemUnlock(String site, String path)
unlock an itemvoid
lockItem(String site, String path)
lock an item NOTE: site will be removed from this interfacevoid
markGitLogAudited(String siteId, String commitId)
Mark Git log as auditedvoid
markGitLogProcessedBeforeMarker(String siteId, long marker, int processed)
Mark all git logs as processed if they are inserted before markervoid
markGitLogVerifiedProcessed(String siteId, String commitId)
Mark Git log as verifiedvoid
markGitLogVerifiedProcessedBulk(String siteId, List<String> commitIds)
Mark Git logs as verifiedvoid
populateGitLog(String siteId)
Populates the full git log of the sandbox repository into the databaseRepositoryChanges
preparePublishAll(String siteId, String publishingTarget)
Prepares the repository to publish all changes for the given site & targetvoid
publish(String siteId, String sandboxBranch, List<DeploymentItemTO> deploymentItems, String environment, String author, String comment)
Publish content to specified environment.RepositoryChanges
publishAll(String siteId, String publishingTarget, String comment)
Publishes all changes for the given site & targetboolean
publishedRepositoryExists(String siteId)
Check if published repository exists for given site.boolean
removeRemote(String siteId, String remoteName)
Remove remote with given name for siteboolean
repositoryExists(String site)
Check if repository exists for given sitevoid
updateGitlog(String siteId, String lastProcessedCommitId, int batchSize)
Update gitlog table with commit ids from repositoryvoid
upsertGitLogList(String siteId, List<String> commitIds, boolean processed, boolean audited)
Upsert git logs as processed and audited
-
-
-
Method Detail
-
getSubtreeItems
List<String> getSubtreeItems(String site, String path)
List subtree items for give site and path- Parameters:
site
- site identifierpath
- 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 usecommitIdFrom
- commit ID to start atcommitIdTo
- 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 usecommitIdFrom
- commit ID to start atcommitIdTo
- 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 idcommitId
- commit ID- Returns:
- git log object
-
markGitLogVerifiedProcessed
void markGitLogVerifiedProcessed(String siteId, String commitId)
Mark Git log as verified- Parameters:
siteId
- site identifiercommitId
- commit id
-
markGitLogVerifiedProcessedBulk
void markGitLogVerifiedProcessedBulk(String siteId, List<String> commitIds)
Mark Git logs as verified- Parameters:
siteId
- site identifiercommitIds
- list of commit ids
-
insertGitLog
void insertGitLog(String siteId, String commitId, int processed)
Insert Git Log- Parameters:
siteId
- sitecommitId
- commit IDprocessed
- processed
-
insertGitLog
void insertGitLog(String siteId, String commitId, int processed, int audited)
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
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 idcommitId
- 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 idrepoType
- repository typecommitId
- commit id 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, InvalidRemoteUrlException, ServiceLayerException
Create 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 foundInvalidRemoteUrlException
- invalid url for remote repositoryServiceLayerException
- general service error
-
removeRemote
boolean removeRemote(String siteId, String remoteName)
Remove remote with given name for site- Parameters:
siteId
- site identifierremoteName
- 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 executedpath
-- 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)
-
getContentSize
long getContentSize(String site, String path)
get file size- Parameters:
site
- site id where the operation will be executedpath
- 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 usecommitIdFrom
- commit ID to start atcommitIdTo
- 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 identifiercommitId
- commit id
-
updateGitlog
void updateGitlog(String siteId, String lastProcessedCommitId, int batchSize) throws SiteNotFoundException
Update gitlog table with commit ids from repository- Parameters:
siteId
- site identifierlastProcessedCommitId
- last processed commit idbatchSize
- size of a batch to update- Throws:
SiteNotFoundException
-
getUnauditedCommits
List<GitLog> getUnauditedCommits(String siteId, int batchSize)
Get unaudited commits from database- Parameters:
siteId
- site identifierbatchSize
- 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 identifiermarker
- 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 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
void markGitLogProcessedBeforeMarker(String siteId, long marker, int processed)
Mark all git logs as processed if they are inserted before marker- Parameters:
siteId
- site identifiermarker
- marker git commitprocessed
- 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 identifiercommitId
- 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 executedpath
- path of the item
-
itemUnlock
void itemUnlock(String site, String path)
unlock an item- Parameters:
site
- site id where the operation will be executedpath
- 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 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) throws ContentNotFoundException
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
- 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
-
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 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
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 sitepublishingTarget
- 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 logIOException
- 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 sitepath
- the content path- Throws:
ServiceLayerException
- if no content is found at the given path
-
-