Class ContentServiceImpl
java.lang.Object
org.craftercms.studio.impl.v2.service.content.ContentServiceImpl
- All Implemented Interfaces:
ContentService
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
public class ContentServiceImpl
extends Object
implements ContentService, org.springframework.context.ApplicationContextAware
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
contentExists
(String siteId, String path) Check the existent of a content pathboolean
deleteContent
(String siteId, String path, String submissionComment) Delete content for given path.boolean
deleteContent
(String siteId, List<String> paths, String submissionComment) Delete content for given paths.getChildItems
(String siteId, String path) Get child items for given path.getChildItems
(String siteId, List<String> paths) Get child items for given paths.getChildrenByPath
(String siteId, String path, String locale, String keyword, List<String> systemTypes, List<String> excludes, String sortStrategy, String order, int offset, int limit) Get list of children for given pathgetChildrenByPaths
(String siteId, List<String> paths, Map<String, GetChildrenBulkRequest.PathParams> pathParams) Get children for paths bulk.@Valid org.springframework.core.io.Resource
getContentAsResource
(String site, String path) Returns content wrapped as aResource
instanceOptional
<org.springframework.core.io.Resource> getContentByCommitId
(String siteId, String path, String commitId) Get content for commit idgetContentVersionHistory
(String siteId, String path) Get the version history for a given content item.org.craftercms.core.service.Item
getItemByPath
(String siteId, String path, boolean preferContent) Get detailed item for given pathorg.dom4j.Document
getItemDescriptor
(String siteId, String path, boolean flatten) getQuickCreatableContentTypes
(String siteId) Get list of content types marked as quick creatable for given sitegetSandboxItemsByPath
(String siteId, List<String> paths, boolean preferContent) Get sandbox items for given list of pathsvoid
lockContent
(String siteId, String path) Lock item by path for given siteboolean
renameContent
(String site, String path, String name) Rename content for given pathvoid
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) void
setAuditServiceInternal
(AuditServiceInternal auditServiceInternal) void
setContentServiceInternal
(ContentServiceInternal contentServiceInternal) void
setContentServiceV1
(ContentService contentService) void
setContentTypeServiceInternal
(ContentTypeServiceInternal contentTypeServiceInternal) void
setDependencyServiceInternal
(DependencyServiceInternal dependencyServiceInternal) void
setDeploymentService
(DeploymentService deploymentService) void
setGeneralLockService
(GeneralLockService generalLockService) void
setItemServiceInternal
(ItemServiceInternal itemServiceInternal) void
setSecurityService
(SecurityService securityService) void
setSiteService
(SiteService siteService) void
setUserServiceInternal
(UserServiceInternal userServiceInternal) boolean
shallowContentExists
(String site, String path) This is a faster, but less accurate, version of contentExists.void
unlockContent
(String siteId, String path) Unlock item by path for given site
-
Constructor Details
-
ContentServiceImpl
public ContentServiceImpl()
-
-
Method Details
-
contentExists
Description copied from interface:ContentService
Check the existent of a content path- Specified by:
contentExists
in interfaceContentService
- Parameters:
siteId
- site identifierpath
- content path- Returns:
- true if the content exists, false otherwise
- Throws:
SiteNotFoundException
- if site is not found
-
shallowContentExists
Description copied from interface:ContentService
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.- Specified by:
shallowContentExists
in interfaceContentService
- Returns:
- true if site has content object at path
- Throws:
SiteNotFoundException
-
getQuickCreatableContentTypes
public List<QuickCreateItem> getQuickCreatableContentTypes(String siteId) throws SiteNotFoundException Description copied from interface:ContentService
Get list of content types marked as quick creatable for given site- Specified by:
getQuickCreatableContentTypes
in interfaceContentService
- Parameters:
siteId
- site id to use- Returns:
- list of content types
- Throws:
SiteNotFoundException
-
getChildItems
Description copied from interface:ContentService
Get child items for given path. Child item is - belongs to item subtree - is item specific dependency- Specified by:
getChildItems
in interfaceContentService
- Parameters:
siteId
- site identifierpath
- path to get child items for- Returns:
- list of paths of child items
-
getChildItems
Description copied from interface:ContentService
Get child items for given paths. Child item is - belongs to item subtree - is item specific dependency- Specified by:
getChildItems
in interfaceContentService
- Parameters:
siteId
- site identifierpaths
- list of paths to get child items for- Returns:
- list of paths of child items
-
deleteContent
public boolean deleteContent(String siteId, String path, String submissionComment) throws ServiceLayerException, AuthenticationException, DeploymentException, UserNotFoundException Description copied from interface:ContentService
Delete content for given path. Following content will be deleted: - given path - child items for given path- Specified by:
deleteContent
in interfaceContentService
- Parameters:
siteId
- site identifierpath
- content to be deletedsubmissionComment
- submission comment- Returns:
- true if success, otherwise false
- Throws:
ServiceLayerException
- general service errorAuthenticationException
- authentication errorDeploymentException
- deployment error caused by deleteUserNotFoundException
-
deleteContent
public boolean deleteContent(String siteId, List<String> paths, String submissionComment) throws ServiceLayerException, AuthenticationException, DeploymentException, UserNotFoundException Description copied from interface:ContentService
Delete content for given paths. Following content will be deleted: - given paths - child items for given paths- Specified by:
deleteContent
in interfaceContentService
- Parameters:
siteId
- site identifierpaths
- content to be deletedsubmissionComment
- submission comment- Returns:
- true if success, otherwise false
- Throws:
ServiceLayerException
- general service errorAuthenticationException
- authentication errorDeploymentException
- deployment error caused by deleteUserNotFoundException
-
getChildrenByPath
public GetChildrenResult getChildrenByPath(String siteId, String path, String locale, String keyword, List<String> systemTypes, List<String> excludes, String sortStrategy, String order, int offset, int limit) throws ServiceLayerException, UserNotFoundException Description copied from interface:ContentService
Get list of children for given path- Specified by:
getChildrenByPath
in interfaceContentService
- Parameters:
siteId
- site identifierpath
- item path to children forlocale
- filter children by localekeyword
- filter children by keywordsystemTypes
- filter children by typeexcludes
- exclude items by pathsortStrategy
- sort orderorder
- ascending or descendingoffset
- offset of the first child in the resultlimit
- number of children to return- Returns:
- list of children
- Throws:
ServiceLayerException
UserNotFoundException
-
getChildrenByPaths
public GetChildrenByPathsBulkResult getChildrenByPaths(String siteId, List<String> paths, Map<String, GetChildrenBulkRequest.PathParams> pathParams) throws ServiceLayerException, UserNotFoundExceptionDescription copied from interface:ContentService
Get children for paths bulk. This method will return children for a list of paths. Result items will also include aSandboxItem
object for the item itself.- Specified by:
getChildrenByPaths
in interfaceContentService
- Parameters:
siteId
- the site idpaths
- paths to get children for. Notice that this parameter is redundant with the pathParams. This list of paths is used to validate permissions.pathParams
- Map of extra parameters for each path- Returns:
- object containing a list of
GetChildrenByPathsBulkResult.ChildrenByPathResult
- Throws:
ServiceLayerException
- general service errorUserNotFoundException
- user not found (when calculating available actions)
-
getItem
public org.craftercms.core.service.Item getItem(String siteId, String path, boolean flatten) throws SiteNotFoundException, ContentNotFoundException - Specified by:
getItem
in interfaceContentService
- Throws:
SiteNotFoundException
ContentNotFoundException
-
getItemDescriptor
public org.dom4j.Document getItemDescriptor(String siteId, String path, boolean flatten) throws SiteNotFoundException, ContentNotFoundException - Specified by:
getItemDescriptor
in interfaceContentService
- Throws:
SiteNotFoundException
ContentNotFoundException
-
getItemByPath
public DetailedItem getItemByPath(String siteId, String path, boolean preferContent) throws ServiceLayerException, UserNotFoundException Description copied from interface:ContentService
Get detailed item for given path- Specified by:
getItemByPath
in interfaceContentService
- Parameters:
siteId
- site identifierpath
- item pathpreferContent
- if true return content item if available- Returns:
- detailed item
- Throws:
ServiceLayerException
UserNotFoundException
-
getSandboxItemsByPath
public List<SandboxItem> getSandboxItemsByPath(String siteId, List<String> paths, boolean preferContent) throws ServiceLayerException, UserNotFoundException Description copied from interface:ContentService
Get sandbox items for given list of paths- Specified by:
getSandboxItemsByPath
in interfaceContentService
- Parameters:
siteId
- site identifierpaths
- list of paths to get sandbox itemspreferContent
- if true return content items if available- Returns:
- list of sandbox items
- Throws:
ServiceLayerException
UserNotFoundException
-
lockContent
public void lockContent(String siteId, String path) throws UserNotFoundException, ServiceLayerException Description copied from interface:ContentService
Lock item by path for given site- Specified by:
lockContent
in interfaceContentService
- Parameters:
siteId
- site identifierpath
- path to lock- Throws:
UserNotFoundException
ServiceLayerException
-
unlockContent
public void unlockContent(String siteId, String path) throws ContentNotFoundException, SiteNotFoundException Description copied from interface:ContentService
Unlock item by path for given site- Specified by:
unlockContent
in interfaceContentService
- Parameters:
siteId
- site identifierpath
- item path- Throws:
ContentNotFoundException
SiteNotFoundException
-
getContentByCommitId
public Optional<org.springframework.core.io.Resource> getContentByCommitId(String siteId, String path, String commitId) throws ContentNotFoundException Description copied from interface:ContentService
Get content for commit id- Specified by:
getContentByCommitId
in interfaceContentService
- Parameters:
siteId
- site identifierpath
- path of the contentcommitId
- commit id of the content version- Returns:
- the content if available
- Throws:
ContentNotFoundException
-
renameContent
public boolean renameContent(String site, String path, String name) throws ServiceLayerException, UserNotFoundException, org.craftercms.commons.validation.ValidationException Description copied from interface:ContentService
Rename content for given path- Specified by:
renameContent
in interfaceContentService
- Parameters:
site
- site identifierpath
- path of the contentname
- new name of the content- Returns:
- true if success, otherwise false
- Throws:
ServiceLayerException
- general service errorUserNotFoundException
- user not found errororg.craftercms.commons.validation.ValidationException
- validation exception
-
getContentAsResource
@Valid public @Valid org.springframework.core.io.Resource getContentAsResource(String site, String path) throws ContentNotFoundException Description copied from interface:ContentService
Returns content wrapped as aResource
instance- Specified by:
getContentAsResource
in interfaceContentService
- 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
-
getContentVersionHistory
public List<ItemVersion> getContentVersionHistory(String siteId, String path) throws ServiceLayerException Description copied from interface:ContentService
Get the version history for a given content item.- Specified by:
getContentVersionHistory
in interfaceContentService
- Parameters:
siteId
- the site idpath
- the content path- Returns:
- the list of versions
- Throws:
ServiceLayerException
- if an error occurs while create the list ofItemVersion
s
-
setApplicationContext
public void setApplicationContext(@NonNull org.springframework.context.ApplicationContext applicationContext) - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
-
setContentServiceInternal
-
setContentTypeServiceInternal
-
setDependencyServiceInternal
-
setDeploymentService
-
setUserServiceInternal
-
setSiteService
-
setAuditServiceInternal
-
setItemServiceInternal
-
setSecurityService
-
setGeneralLockService
-
setContentServiceV1
-