Interface ContentService
- All Known Implementing Classes:
ContentServiceImpl
public interface ContentService
Content Services that other services may use
- Author:
- russdanner
-
Method Summary
Modifier and TypeMethodDescriptionvoid
checkContentExists
(String site, String path) Checks if a content exists at a given path and throw an exception if it does not.void
checkWriteAssetPath
(String path) Check if path is a correct location to write asset contentboolean
contentExists
(String site, String path) Check if content existscopyContent
(String site, String fromPath, String toPath) copy content fromPath to toPathcreateDummyDmContentItemForDeletedNode
(String site, String relativePath) boolean
createFolder
(String site, String path, String name) create a folderboolean
deleteContent
(String site, String path, boolean generateActivity, String approver) boolean
deleteContent
(String site, String path, String approver) delete content at the pathgetContent
(String site, String path) get document from wcm contentorg.dom4j.Document
getContentAsDocument
(String site, String path) get document from wcm contentorg.springframework.core.io.Resource
getContentAsResource
(String site, String path) Returns content wrapped as aResource
instancegetContentAsString
(String site, String path) get content as string from repositorygetContentAsString
(String site, String path, String encoding) get content as string from repositorygetContentItem
(String site, String path) get the content item (metadata) at a specific pathgetContentItem
(String site, String path, int depth) get the content item (metadata) at a specific pathgetContentItemTree
(String site, String path, int depth) get the tree of content items (metadata) beginning at a rootgetContentItemVersionHistory
(String site, String path) get the version history for an itemlong
getContentSize
(String site, String path) get file sizegetContentTypeClass
(String site, String uri) Optional
<org.springframework.core.io.Resource> getContentVersion
(String site, String path, String version) return the content for a given versiongetContentVersionAsString
(String site, String path, String version) return the content for a given versiongetDeleteCandidates
(String site, String uri) getItemContentType
(String site, String path) Retrieves the content type for a given pathgetItemOrders
(String site, String path) getNextAvailableName
(String site, String path) get the next available of the given content name at the given path (used for paste/duplicate)void
lockContent
(String site, String path) moveContent
(String site, String fromPath, String toPath) move content fromPath to toPathvoid
notifyContentEvent
(String site, String path) Notify when there is a content updateboolean
pullFromRemote
(String siteId, String remoteName, String remoteBranch) Pull from remote repositoryboolean
pushToRemote
(String siteId, String remoteName, String remoteBranch) Push content to remote repositoryboolean
renameContent
(String site, String path, String name) rename a content itemdouble
boolean
revertContentItem
(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.shallowGetContentAsString
(String siteId, String path) Get content from the repository.boolean
validateAndCreateFolder
(String site, String path, String name) Validate the input and create a folderwriteContent
(String site, String path, InputStream content) write contentvoid
writeContent
(String site, String path, String fileName, String contentType, InputStream input, String createFolders, String edit, String unlock) write contentvoid
writeContent
(String site, String path, String fileName, String contentType, InputStream input, String createFolders, String edit, String unlock, boolean skipAuditLogInsert) write contentboolean
writeContentAndNotify
(String site, String path, InputStream content) write content from an input stream and notify the subscribers.void
writeContentAndRename
(String site, String path, String targetPath, String fileName, String contentType, InputStream input, String createFolders, String edit, String unlock, boolean createFolder) writeContentAsset
(String site, String path, String assetName, InputStream in, String isImage, String allowedWidth, String allowedHeight, String allowLessSize, String draft, String unlock, String systemAsset)
-
Method Details
-
contentExists
Check if content exists- Parameters:
site
- site identifierpath
- path of the content- Returns:
- true if site has content object at path
-
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
-
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 identifierpath
- path of the content- Returns:
- document
- Throws:
ContentNotFoundException
-
getContentSize
get file size- Parameters:
site
- site id where the operation will be executedpath
- path to content- Returns:
- Size in bytes
-
getContentAsString
get content as string from repository- Parameters:
site
- site identifierpath
- path of the content- Returns:
- document
-
checkWriteAssetPath
Check if path is a correct location to write asset content- Parameters:
path
- to write asset- Throws:
ServiceLayerException
- if path is not permitted
-
getContentAsString
get content as string from repository- Parameters:
site
- site identifierpath
- path of the contentencoding
- file encoding- Returns:
- document
-
shallowGetContentAsString
Get content from the repository. This "shallow" version of the method will retrieve the content from disk instead of the git repository.- Parameters:
siteId
- the site idpath
- the path of the content- Returns:
- the content as a string
-
getContentAsDocument
org.dom4j.Document getContentAsDocument(String site, String path) throws org.dom4j.DocumentException get document from wcm content- Parameters:
site
- site identifierpath
- content path- Returns:
- document
- Throws:
org.dom4j.DocumentException
- XML document error
-
getContentAsResource
org.springframework.core.io.Resource getContentAsResource(String site, String path) throws ContentNotFoundException Returns content wrapped as aResource
instance- Parameters:
site
- the site idpath
- the path of the content- Returns:
- the resource object
- Throws:
ContentNotFoundException
- if there is no content at the given path- Since:
- 3.1.1
-
writeContent
write content- Parameters:
site
- - the project IDpath
- path to contentcontent
- stream of content to write- Returns:
- return new commit id
- Throws:
ServiceLayerException
- general service error
-
writeContentAndNotify
boolean writeContentAndNotify(String site, String path, InputStream content) throws ServiceLayerException write content from an input stream and notify the subscribers.- Parameters:
site
- - the project IDpath
- path to contentcontent
- stream of content to write- Returns:
- return true if successful
- Throws:
ServiceLayerException
- general service error
-
notifyContentEvent
Notify when there is a content update- Parameters:
site
- site namepath
- path name
-
validateAndCreateFolder
boolean validateAndCreateFolder(String site, String path, String name) throws ServiceLayerException, UserNotFoundException, org.craftercms.commons.validation.ValidationException Validate the input and create a folder- Parameters:
site
- - the project IDpath
- path to create a folder inname
- a folder name to create- Returns:
- return the reference to the folder created
- Throws:
ServiceLayerException
UserNotFoundException
org.craftercms.commons.validation.ValidationException
-
createFolder
boolean createFolder(String site, String path, String name) throws ServiceLayerException, UserNotFoundException create a folder- Parameters:
site
- - the project IDpath
- path to create a folder inname
- a folder name to create- Returns:
- return the reference to the folder created
- Throws:
SiteNotFoundException
- site not foundServiceLayerException
UserNotFoundException
-
deleteContent
boolean deleteContent(String site, String path, String approver) throws ServiceLayerException, UserNotFoundException delete content at the path- Parameters:
site
- - the project IDpath
- path to content- Returns:
- return true if successful
- Throws:
SiteNotFoundException
- site not foundServiceLayerException
UserNotFoundException
-
deleteContent
boolean deleteContent(String site, String path, boolean generateActivity, String approver) throws ServiceLayerException, UserNotFoundException -
copyContent
String copyContent(String site, String fromPath, String toPath) throws ServiceLayerException, UserNotFoundException copy content fromPath to toPath- Parameters:
site
- - the project IDfromPath
- the source pathtoPath
- the target path to copy content to- Returns:
- final path if successful, null otherwise
- Throws:
ServiceLayerException
UserNotFoundException
-
moveContent
move content fromPath to toPath- Parameters:
site
- - the project IDfromPath
- the source pathtoPath
- the target path to copy content to- Returns:
- final path if successful, null otherwise
-
getContentItemTree
get the tree of content items (metadata) beginning at a root- Parameters:
site
- - the project IDpath
- - the path to root at- Returns:
- content item with children tree
-
getContentItem
get the content item (metadata) at a specific path- Parameters:
site
- - the project IDpath
- - the path of the content item- Returns:
- content item representation
-
getContentItem
get the content item (metadata) at a specific path- Parameters:
site
- - the project IDpath
- - the path of the content itemdepth
- - depth to get desendents- Returns:
- content item representation
-
getItemContentType
String getItemContentType(String site, String path) throws org.dom4j.DocumentException, SiteNotFoundException Retrieves the content type for a given path- Parameters:
site
- the site idpath
- the content path- Returns:
- content type
- Throws:
org.dom4j.DocumentException
- on failure to retrieve the content type from xml (when applicable)SiteNotFoundException
-
getContentItemVersionHistory
get the version history for an item- Parameters:
site
- - the project IDpath
- - the path of the item- Returns:
- version history
-
revertContentItem
boolean revertContentItem(String site, String path, String version, boolean major, String comment) throws ServiceLayerException, UserNotFoundException revert a version (create a new version based on an old version)- Parameters:
site
- - the project IDpath
- - the path of the item to "revert"version
- - old version ID to base to version onmajor
- major versioncomment
- comment for revert action- Returns:
- true if success otherwise false
- Throws:
SiteNotFoundException
- site not foundServiceLayerException
UserNotFoundException
-
getContentVersion
Optional<org.springframework.core.io.Resource> getContentVersion(String site, String path, String version) throws ContentNotFoundException return the content for a given version- Parameters:
site
- - the project IDpath
- - the path itemversion
- - version- Returns:
- content
- Throws:
ContentNotFoundException
- content not found
-
getContentVersionAsString
String getContentVersionAsString(String site, String path, String version) throws ContentNotFoundException return the content for a given version- Parameters:
site
- - the project IDpath
- - the path itemversion
- - version- Returns:
- version number
- Throws:
ContentNotFoundException
- content not found
-
writeContent
void writeContent(String site, String path, String fileName, String contentType, InputStream input, String createFolders, String edit, String unlock) throws ServiceLayerException, UserNotFoundException, org.craftercms.commons.validation.ValidationException write content- Parameters:
site
- site identifierpath
- pathfileName
- file namecontentType
- content typeinput
- contentcreateFolders
- create missing folders in path?edit
- editunlock
- unlock the content upon edit?- Throws:
ServiceLayerException
- general service errorUserNotFoundException
org.craftercms.commons.validation.ValidationException
-
writeContent
void writeContent(String site, String path, String fileName, String contentType, InputStream input, String createFolders, String edit, String unlock, boolean skipAuditLogInsert) throws ServiceLayerException, UserNotFoundException write content- Parameters:
site
- site identifierpath
- pathfileName
- file namecontentType
- content typeinput
- contentcreateFolders
- create missing folders in path?edit
- editunlock
- unlock the content upon edit?skipAuditLogInsert
- if true do not insert audit log row, otherwise false- Throws:
ServiceLayerException
- general service errorUserNotFoundException
-
writeContentAndRename
void writeContentAndRename(String site, String path, String targetPath, String fileName, String contentType, InputStream input, String createFolders, String edit, String unlock, boolean createFolder) throws ServiceLayerException, org.craftercms.commons.validation.ValidationException - Throws:
ServiceLayerException
org.craftercms.commons.validation.ValidationException
-
writeContentAsset
Map<String,Object> writeContentAsset(String site, String path, String assetName, InputStream in, String isImage, String allowedWidth, String allowedHeight, String allowLessSize, String draft, String unlock, String systemAsset) throws ServiceLayerException - Throws:
ServiceLayerException
-
getNextAvailableName
get the next available of the given content name at the given path (used for paste/duplicate)- Parameters:
site
- site identifierpath
- path of the item- Returns:
- next available name that avoids a name conflict
-
createDummyDmContentItemForDeletedNode
-
getContentTypeClass
-
getDeleteCandidates
- Throws:
ServiceLayerException
-
lockContent
-
getItemOrders
- Throws:
ContentNotFoundException
-
reorderItems
double reorderItems(String site, String relativePath, String before, String after, String orderName) throws ServiceLayerException - Throws:
ServiceLayerException
-
renameContent
boolean renameContent(String site, String path, String name) throws ServiceLayerException, UserNotFoundException, org.craftercms.commons.validation.ValidationException rename a content item- Parameters:
site
- - the project IDpath
- path to a folder to renamename
- a new folder name- Returns:
- return the reference to the folder renamed
- Throws:
ServiceLayerException
- general service errorUserNotFoundException
- user not foundorg.craftercms.commons.validation.ValidationException
- validation exception
-
pushToRemote
boolean pushToRemote(String siteId, String remoteName, String remoteBranch) throws ServiceLayerException, InvalidRemoteUrlException, AuthenticationException, 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 remote urlAuthenticationException
- authentication errororg.craftercms.commons.crypto.CryptoException
- git repository helper error
-
pullFromRemote
boolean pullFromRemote(String siteId, String remoteName, String remoteBranch) throws ServiceLayerException, InvalidRemoteUrlException, AuthenticationException, 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 remote urlAuthenticationException
- authentication errororg.craftercms.commons.crypto.CryptoException
- git repository helper error
-