Interface ContentRepository
- All Known Subinterfaces:
StudioBlobStore
,StudioBlobStoreAdapter
- All Known Implementing Classes:
BlobAwareContentRepository
,GitContentRepository
,StudioAwsS3BlobStore
public interface ContentRepository
This interface represents the repository layer of Crafter Studio. All interaction with the backend
Store must go through this interface.
- Author:
- russdanner
-
Method Summary
Modifier and TypeMethodDescriptionboolean
addRemote
(String siteId, String remoteName, String remoteUrl, String authenticationType, String remoteUsername, String remotePassword, String remoteToken, String remotePrivateKey) Add remote repository for site content repositoryvoid
cleanupRepositories
(String siteId) Performs a cleanup all repositories for the given siteboolean
contentExists
(String site, String path) Determine if content exists in the repository at a given pathcopyContent
(String site, String fromPath, String toPath) copy content from PathA to pathBcreateFolder
(String site, String path, String name) create a foldercreateVersion
(String site, String path, boolean majorVersion) create a versioncreateVersion
(String site, String path, String comment, boolean majorVersion) create a versiondeleteContent
(String site, String path, String approver) delete contentvoid
deleteGitLogForSite
(String siteId) Delete Git log for siteboolean
deleteSite
(String siteId) Deletes an existing site.default InputStream
getContent
(String site, String path) get document from wcm contentgetContent
(String site, String path, boolean shallow) Get content from the repositorygetContentChildren
(String site, String path) get immediate children for pathgetContentVersionHistory
(String site, String path) get the version history for an itemgetEditCommitIds
(String site, String path, String commitIdFrom, String commitIdTo) Get a list of commits for updates on a contentgetRepoFirstCommitId
(String site) Get first id from repository for given sitegetRepoLastCommitId
(String site) Get last commit id from repository for given site.void
initialPublish
(String site, String sandboxBranch, String environment, String author, String comment) Initial publish to specified environment.void
insertFullGitLog
(String siteId, int processed) Insert Full Git Logboolean
Check if content at given path is folderlistRemote
(String siteId, String sandboxBranch) List remote repositories for given sitevoid
lockItemForPublishing
(String site, String path) lock an item NOTE: site will be removed from this interfacemoveContent
(String site, String fromPath, String toPath) move content from PathA to pathBmoveContent
(String site, String fromPath, String toPath, String newName) move content from PathA to pathBboolean
pullFromRemote
(String siteId, String remoteName, String remoteBranch) Pull from remote repositoryboolean
pushToRemote
(String siteId, String remoteName, String remoteBranch) Push content to remote repositoryvoid
Remove all remotes for given sitevoid
resetStagingRepository
(String siteId) Reset staging repository to live for given siterevertContent
(String site, String path, String version, boolean major, String comment) revert a version (create a new version based on an old version)boolean
shallowContentExists
(String site, String path) This is a faster, but less accurate, version of contentExists.void
unLockItem
(String site, String path) unlock an item for publishing NOTE: site will be removed from this interfacevoid
unLockItemForPublishing
(String site, String path) unlock an item for publishing NOTE: site will be removed from this interfacewriteContent
(String site, String path, InputStream content) write content
-
Method Details
-
contentExists
Determine if content exists in the repository at a given path- Parameters:
site
- site id where the operation will be executedpath
- path to check if content exists- Returns:
- true if site has content object at path
-
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
-
getContent
get document from wcm content- Parameters:
site
- site id where the operation will be executedpath
- path of the content- Returns:
- document
- Throws:
ContentNotFoundException
- content not found at given path
-
getContent
Get content from the repository- Parameters:
site
- the site idpath
- the path of the contentshallow
- if true, it will load the file from disk directly, instead of retrieving it from git repository- Returns:
- InputStream to read the content
- Throws:
ContentNotFoundException
- if the content is not found
-
writeContent
write content- Parameters:
site
- site id where the operation will be executedpath
- path to contentcontent
- stream of content to write- Returns:
- Commit Id if successful, null otherwise
- Throws:
ServiceLayerException
- if error happens during write
-
createFolder
create a folder- Parameters:
site
- site id where the operation will be executedpath
- path to create a folder inname
- a folder name to create- Returns:
- Commit Id if successful, null otherwise
- Throws:
ServiceLayerException
-
deleteContent
delete content- Parameters:
site
- site id where the operation will be executedpath
- path to contentapprover
- user that approves delete content- Returns:
- Commit ID if successful, null otherwise
- Throws:
ServiceLayerException
-
moveContent
default Map<String,String> moveContent(String site, String fromPath, String toPath) throws ServiceLayerException move content from PathA to pathB- Parameters:
site
- site id where the operation will be executedfromPath
- source contenttoPath
- target path- Returns:
- Commit ID if successful, null otherwise
- Throws:
ServiceLayerException
-
moveContent
Map<String,String> moveContent(String site, String fromPath, String toPath, String newName) throws ServiceLayerException move content from PathA to pathB- Parameters:
site
- site id where the operation will be executedfromPath
- source contenttoPath
- target pathnewName
- new file name for rename- Returns:
- Commit ID if successful, empty string otherwise
- Throws:
ServiceLayerException
-
copyContent
copy content from PathA to pathB- Parameters:
site
- site id where the operation will be executedfromPath
- paths to contenttoPath
- target path- Returns:
- Commit ID if successful, empty string otherwise
- Throws:
ServiceLayerException
-
getContentChildren
get immediate children for path- Parameters:
site
- site id where the operation will be executedpath
- path to content- Returns:
- a list of children
-
getContentVersionHistory
get the version history for an item- Parameters:
site
- - the project IDpath
- - the path of the item- Returns:
- a list of versions
-
createVersion
create a version- Parameters:
site
- site id where the operation will be executedpath
- location of contentmajorVersion
- true if major- Returns:
- the created version ID or null on failure
-
createVersion
create a version- Parameters:
site
- site id where the operation will be executedpath
- location of contentcomment
- version history commentmajorVersion
- true if major- Returns:
- the created version ID or null on failure
-
revertContent
revert a version (create a new version based on an old version)- Parameters:
site
- site id where the operation will be executedpath
- - the path of the item to "revert"version
- - old version ID to base to version onmajor
- flag if it is major versioncomment
- add comment when committing content- Returns:
- Commit ID if successful, empty string otherwise
-
lockItemForPublishing
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
-
unLockItem
unlock an item for publishing NOTE: site will be removed from this interface- Parameters:
site
- site id where the operation will be executedpath
- path of the item
-
unLockItemForPublishing
unlock an item for publishing NOTE: site will be removed from this interface- Parameters:
site
- site id where the operation will be executedpath
- path of the item
-
deleteSite
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 identifiersandboxBranch
- sandbox branch nameenvironment
- environment to publishauthor
- authorcomment
- comment- Throws:
DeploymentException
- deployment error
-
getRepoLastCommitId
Get last commit id from repository for given site.- Parameters:
site
- site id- Returns:
- last commit id (current HEAD)
-
getRepoFirstCommitId
Get first id from repository for given site- Parameters:
site
- site id- Returns:
- first commit id
-
getEditCommitIds
Get a list of commits for updates on a content- Parameters:
site
- site idpath
- pathcommitIdFrom
- range from commit id (inclusive)commitIdTo
- range to commit id (inclusive)- Returns:
- list of edit commit ids
-
insertFullGitLog
Insert Full Git Log- Parameters:
siteId
- siteprocessed
- processed
-
deleteGitLogForSite
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 identifierremoteName
- remote nameremoteUrl
- remote urlauthenticationType
- authentication typeremoteUsername
- remote usernameremotePassword
- remote passwordremoteToken
- remote tokenremotePrivateKey
- remote private key- Returns:
- true if operation was successful
- Throws:
InvalidRemoteUrlException
- invalid url for remote repositoryServiceLayerException
- general service error
-
removeRemoteRepositoriesForSite
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 identifiersandboxBranch
- sandbox branch name- Returns:
- list of names of remote repositories
- Throws:
ServiceLayerException
- general service errororg.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 identifierremoteName
- remote nameremoteBranch
- remote branch- Returns:
- true if operation was successful
- Throws:
ServiceLayerException
- general service errorInvalidRemoteUrlException
- invalid url for remote repositoryorg.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 identifierremoteName
- remote nameremoteBranch
- remote branch- Returns:
- true if operation was successful
- Throws:
ServiceLayerException
- general service errorInvalidRemoteUrlException
- invalid url for remote repositoryorg.craftercms.commons.crypto.CryptoException
- git repository helper error
-
isFolder
Check if content at given path is folder- Parameters:
siteId
- site identifierpath
- content path- Returns:
- true if path is folder, otherwise false
-
resetStagingRepository
Reset staging repository to live for given site- Parameters:
siteId
- site identifier to use for resetting- Throws:
ServiceLayerException
- general service error
-
cleanupRepositories
Performs a cleanup all repositories for the given site- Parameters:
siteId
- site identifier
-