Interface ContentService
-
- All Known Implementing Classes:
ContentServiceImpl
public interface ContentService
Content Services that other services may use- Author:
- russdanner
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
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 existsString
copyContent(String site, String fromPath, String toPath)
copy content fromPath to toPathContentItemTO
createDummyDmContentItemForDeletedNode(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 pathInputStream
getContent(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
instanceString
getContentAsString(String site, String path)
get content as string from repositoryString
getContentAsString(String site, String path, String encoding)
get content as string from repositoryContentItemTO
getContentItem(String site, String path)
get the content item (metadata) at a specific pathContentItemTO
getContentItem(String site, String path, int depth)
get the content item (metadata) at a specific pathContentItemTO
getContentItemTree(String site, String path, int depth)
get the tree of content items (metadata) beginning at a rootVersionTO[]
getContentItemVersionHistory(String site, String path)
get the version history for an itemlong
getContentSize(String site, String path)
get file sizeString
getContentTypeClass(String site, String uri)
Optional<org.springframework.core.io.Resource>
getContentVersion(String site, String path, String version)
return the content for a given versionString
getContentVersionAsString(String site, String path, String version)
return the content for a given versionGoLiveDeleteCandidates
getDeleteCandidates(String site, String uri)
String
getItemContentType(String site, String path)
Retrieves the content type for a given pathList<DmOrderTO>
getItemOrders(String site, String path)
String
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)
String
moveContent(String site, String fromPath, String toPath)
move content fromPath to toPathvoid
notifyContentEvent(String site, String path)
Notify when there is a content updateResultTO
processContent(String id, InputStream input, boolean isXml, Map<String,String> params, String contentChainForm)
boolean
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
reorderItems(String site, String relativePath, String before, String after, String orderName)
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.boolean
writeContent(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 contentvoid
writeContentAndRename(String site, String path, String targetPath, String fileName, String contentType, InputStream input, String createFolders, String edit, String unlock, boolean createFolder)
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)
-
-
-
Method Detail
-
contentExists
boolean contentExists(String site, String path)
Check if content exists- Parameters:
site
- site identifierpath
- path of the content- Returns:
- true if site has content object at path
-
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
-
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 identifierpath
- path of the content- Returns:
- document
- Throws:
ContentNotFoundException
-
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
-
getContentAsString
String getContentAsString(String site, String path)
get content as string from repository- Parameters:
site
- site identifierpath
- path of the content- Returns:
- document
-
checkWriteAssetPath
void checkWriteAssetPath(String path) throws ServiceLayerException
Check if path is a correct location to write asset content- Parameters:
path
- to write asset- Throws:
ServiceLayerException
- if path is not permitted
-
getContentAsString
String getContentAsString(String site, String path, String encoding)
get content as string from repository- Parameters:
site
- site identifierpath
- path of the contentencoding
- file encoding- Returns:
- document
-
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
boolean writeContent(String site, String path, InputStream content) throws ServiceLayerException
write content- Parameters:
site
- - the project IDpath
- path to contentcontent
- stream of content to write- Returns:
- return true if successful
- Throws:
ServiceLayerException
- general service error
-
notifyContentEvent
void notifyContentEvent(String site, String path)
Notify when there is a content update- Parameters:
site
- site namepath
- path name
-
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
String moveContent(String site, String fromPath, String toPath)
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
ContentItemTO getContentItemTree(String site, String path, int depth)
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
ContentItemTO getContentItem(String site, String path)
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
ContentItemTO getContentItem(String site, String path, int depth)
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
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)
-
getContentItemVersionHistory
VersionTO[] getContentItemVersionHistory(String site, String path)
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
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
-
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
- Throws:
ServiceLayerException
-
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
String getNextAvailableName(String site, String path)
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
ContentItemTO createDummyDmContentItemForDeletedNode(String site, String relativePath)
-
processContent
ResultTO processContent(String id, InputStream input, boolean isXml, Map<String,String> params, String contentChainForm) throws ServiceLayerException, UserNotFoundException
-
getDeleteCandidates
GoLiveDeleteCandidates getDeleteCandidates(String site, String uri) throws ServiceLayerException
- Throws:
ServiceLayerException
-
lockContent
void lockContent(String site, String path) throws UserNotFoundException, ServiceLayerException
-
getItemOrders
List<DmOrderTO> getItemOrders(String site, String path) throws ContentNotFoundException
- 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
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
-
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
-
-