Interface ContentService
-
- All Known Implementing Classes:
ContentServiceImpl
@ExperimentalApi public interface ContentServiceProvides methods for creating, reading, updating and deleting ConfluenceContentobjects such as Pages, BlogPosts and Comments.- Since:
- 5.5
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceContentService.ContentFetcherA content fetcher that also allows fetching many, this exists as a separate interface to allow the type system to only offer fetchMany methods when appropriate.static interfaceContentService.ContentFinderA finder for locating contentstatic interfaceContentService.ParameterContentFinderA content finder allowing various parameters to be set to restrict the fetched content.static interfaceContentService.SingleContentFetcherstatic interfaceContentService.ValidatorProvides methods for validating the create, update and delete methods.
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_EXPANSIONSDefault expansions for methods such ascreate(Content).
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Contentcreate(Content newContent)Create a piece of content.Contentcreate(Content newContent, Expansion... expansions)Create a piece of content.voiddelete(Content content)Removes a piece of Content from the system.ContentService.ContentFinderfind(Expansion... expansions)Create a ContentFinder for locating content, the expansions will be applied to each piece of content that matches the finder.Contentupdate(Content content)Updates a piece of content.ContentService.Validatorvalidator()Get the validator view of the ContentService.
-
-
-
Field Detail
-
DEFAULT_EXPANSIONS
static final String DEFAULT_EXPANSIONS
Default expansions for methods such ascreate(Content).- See Also:
- Constant Field Values
-
-
Method Detail
-
find
ContentService.ContentFinder find(Expansion... expansions)
Create a ContentFinder for locating content, the expansions will be applied to each piece of content that matches the finder. Content will be retrieved by using the fetch methods on the returned ContentFinder.For example, to fetch the first 50 blog posts in the DEV Space :
contentService.find() .withSpace("DEV") .withType(ContentType.BLOG_POST) .fetchMany(new SimplePageRequest(0,50);- Parameters:
expansions-- Returns:
-
create
Content create(Content newContent) throws ServiceException
Create a piece of content.Valid
ContentRepresentations for theContentBodycan be found in the documentation on theContentBodyConversionService.- Parameters:
newContent- the content to create- Returns:
- the content created
- Throws:
ServiceException- if the content cannot be created
-
create
Content create(Content newContent, Expansion... expansions) throws ServiceException
Create a piece of content.Valid
ContentRepresentations for theContentBodycan be found in the documentation on theContentBodyConversionService.- Parameters:
newContent- the content to createexpansions- the particular expansions will be applied to the new created content- Returns:
- the content created
- Throws:
ServiceException- if the content cannot be created
-
update
Content update(Content content) throws ServiceException
Updates a piece of content.Valid
ContentRepresentations for theContentBodycan be found in the documentation on theContentBodyConversionService.Content with an existing status of
ContentStatus.TRASHEDthat is updated to have statusContentStatus.CURRENTwill be restored from the trash, provided that the version in the supplied Content is correct and the user has permission to perform the restore.
Any other changes to the Content being restored will be discarded.- Parameters:
content- the updatedContent- Returns:
- the updated content after being persisted
- Throws:
ServiceException
-
delete
void delete(Content content) throws ServiceException
Removes a piece of Content from the system.The way that this method behaves depends on whether the Content being deleted supports trashing, and its current status:
-
Trashable content currently includes Pages and Blogpost, which can have two statuses relevant here:
current, in which case calling this method will trash the contenttrashed, in which case calling this method will fail. Clients should useContentTrashService.purge(Content)to permanently delete trashed content.
-
Non-trashable content (e.g. Comments, Attachments) will be immediately and permanently purged from the
system, without being updated to have
trashedstatus.
The methods
ContentTrashService.trash(Content)andContentTrashService.purge(Content)can be used for content that is known to support trashing.- Parameters:
content- the content to remove- Throws:
ServiceException- if the content cannot be found, or cannot be deleted
-
Trashable content currently includes Pages and Blogpost, which can have two statuses relevant here:
-
validator
ContentService.Validator validator()
Get the validator view of the ContentService.- Returns:
- a Validator that can be used to validate service requests.
-
-