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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
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 pathString
copyContent(String site, String fromPath, String toPath)
copy content from PathA to pathBString
createFolder(String site, String path, String name)
create a folderString
createVersion(String site, String path, boolean majorVersion)
create a versionString
createVersion(String site, String path, String comment, boolean majorVersion)
create a versionString
deleteContent(String site, String path, String approver)
delete contentvoid
deleteGitLogForSite(String siteId)
Delete Git log for siteboolean
deleteSite(String siteId)
Deletes an existing site.InputStream
getContent(String site, String path)
get document from wcm contentRepositoryItem[]
getContentChildren(String site, String path)
get immediate children for pathVersionTO[]
getContentVersionHistory(String site, String path)
get the version history for an itemList<String>
getEditCommitIds(String site, String path, String commitIdFrom, String commitIdTo)
Get a list of commits for updates on a contentString
getRepoFirstCommitId(String site)
Get first id from repository for given siteString
getRepoLastCommitId(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
isFolder(String siteId, String path)
Check if content at given path is folderList<RemoteRepositoryInfoTO>
listRemote(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 interfacedefault Map<String,String>
moveContent(String site, String fromPath, String toPath)
move content from PathA to pathBMap<String,String>
moveContent(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
reloadRepository(String siteId)
Reload repository for given sitevoid
removeRemoteRepositoriesForSite(String siteId)
Remove all remotes for given sitevoid
resetStagingRepository(String siteId)
Reset staging repository to live for given siteString
revertContent(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 interfaceString
writeContent(String site, String path, InputStream content)
write content
-
-
-
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 executedpath
- 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
-
getContent
InputStream getContent(String site, String path) throws ContentNotFoundException
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
-
writeContent
String writeContent(String site, String path, InputStream content) throws ServiceLayerException
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
String createFolder(String site, String path, String name)
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
-
deleteContent
String deleteContent(String site, String path, String approver)
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
-
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 executedfromPath
- source contenttoPath
- 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 executedfromPath
- source contenttoPath
- target pathnewName
- 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 executedfromPath
- paths to contenttoPath
- 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 executedpath
- 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 IDpath
- - 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 executedpath
- location of contentmajorVersion
- 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 executedpath
- location of contentcomment
- version history commentmajorVersion
- 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 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
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 executedpath
- 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 executedpath
- 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 executedpath
- 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 identifiersandboxBranch
- sandbox branch nameenvironment
- environment to publishauthor
- authorcomment
- 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 idpath
- pathcommitIdFrom
- 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
- siteprocessed
- 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 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
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 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
boolean isFolder(String siteId, String path)
Check if content at given path is folder- Parameters:
siteId
- site identifierpath
- 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
-
-