public class ContentResource extends Object
Constructor and Description |
---|
ContentResource(ContentService contentService,
SpaceService spaceService,
ContentMacroService contentMacroService,
ContentTrashService contentTrashService,
CQLSearchService searchService) |
Modifier and Type | Method and Description |
---|---|
Content |
createContent(Content newContent)
Creates a new piece of Content.
|
javax.ws.rs.core.Response |
delete(ContentId contentId,
ContentStatus status)
Trashes or purges a piece of Content, based on its
ContentType and ContentStatus . |
PageResponse<Content> |
getContent(String type,
String spaceKey,
String title,
List<ContentStatus> statuses,
String postingDay,
String expand,
int start,
int limit,
javax.ws.rs.core.UriInfo uriInfo)
Returns a paginated list of Content.
|
Content |
getContentById(ContentId id,
List<ContentStatus> statuses,
Integer version,
String expand)
Returns a piece of Content.
|
History |
getHistory(ContentId contentId,
String expand)
Returns the history of a particular piece of content
|
MacroInstance |
getMacroBodyByHash(ContentId contentId,
int versionId,
String hash)
Returns the body of a macro (in storage format) with the given hash.
|
PageResponse<Content> |
search(String cql,
String cqlcontext,
String expand,
int start,
int limit,
javax.ws.rs.core.UriInfo uriInfo)
Fetch a list of content using the Confluence Query Language (CQL).
|
Content |
update(ContentId contentId,
Content content)
Updates a piece of Content, or restores if it is trashed.
|
public ContentResource(ContentService contentService, SpaceService spaceService, ContentMacroService contentMacroService, ContentTrashService contentTrashService, CQLSearchService searchService)
@PublicApi public Content getContentById(ContentId id, List<ContentStatus> statuses, Integer version, String expand) throws ServiceException
Returns a piece of Content.
Example request URI(s):
http://example.com/rest/api/content/1234?expand=space,body.view,version,container
http://example.com/rest/api/content/1234?status=any
id
- the id of the contentstatuses
- list of Content statuses to filter results on. Default value: [current]
expand
- A comma separated list of properties to expand on the content. Default value: history,space,version
We can also specify some extensions such as extensions.inlineProperties
(for getting inline comment-specific properties)
or extensions.resolution
for the resolution status of each comment in the resultsServiceException
@PublicApi public Content createContent(Content newContent) throws ServiceException
Creates a new piece of Content.
newContent
- content to be createdServiceException
@PublicApi public PageResponse<Content> getContent(String type, String spaceKey, String title, List<ContentStatus> statuses, String postingDay, String expand, int start, int limit, @Context javax.ws.rs.core.UriInfo uriInfo) throws ServiceException
Returns a paginated list of Content.
Example request URI(s):
http://example.com/rest/api/content?spaceKey=TST&Title=Cheese&expand=space,body.view,version,container
http://example.com/rest/api/content?type=blogpost&spaceKey=TST&title=Bacon&postingDay=2014-02-13&expand=space,body.view,version,container
type
- the content type to return. Default value: page
. Valid values: page, blogpost
.spaceKey
- the space key to find content under.title
- the title of the page to find. Required for page
type.statuses
- list of statuses the content to be found is in. Defaults to current is not specified.
If set to 'any', content in 'current' and 'trashed' status will be fetched.
Does not support 'historical' status for now.postingDay
- the posting day of the blog post. Required for blogpost
type. Format: yyyy-mm-dd
. Example: 2013-02-13
expand
- a comma separated list of properties to expand on the content. Default value: history,space,version
.start
- the start point of the collection to returnlimit
- the limit of the number of items to return, this may be restricted by fixed system limitsuriInfo
- (injected) information about the request URIServiceException
public PageResponse<Content> search(String cql, String cqlcontext, String expand, int start, int limit, @Context javax.ws.rs.core.UriInfo uriInfo)
Fetch a list of content using the Confluence Query Language (CQL). See : Advanced searching using CQL
For example :
Example request URI(s):
http://localhost:8080/confluence/rest/api/content/search?cql=creator=currentUser()&cqlcontext={%22spaceKey%22:%22TST%22, %22contentId%22:%2255%22}
http://localhost:8080/confluence/rest/api/content/search?cql=space=DEV%20AND%20label=docs&expand=space,metadata.labels&limit=10
cql
- a cql query string to use to locate contentcqlcontext
- the context to execute a cql search in, this is the json serialized form of SearchContextexpand
- a comma separated list of properties to expand on the content.start
- the start point of the collection to returnlimit
- the limit of the number of items to return, this may be restricted by fixed system limitsuriInfo
- (injected) information about the request URIServiceException
@PublicApi public History getHistory(ContentId contentId, String expand) throws ServiceException
Returns the history of a particular piece of content
Example request URI(s):
http://example.com/rest/api/content/1234/history
contentId
- the id of the contentexpand
- the properties on content history to expandServiceException
@PublicApi public MacroInstance getMacroBodyByHash(ContentId contentId, int versionId, String hash) throws ServiceException
Returns the body of a macro (in storage format) with the given hash. This resource is primarily used by connect applications that require the body of macro to perform their work.
The hash is generated by connect during render time of the local macro holder and is usually only relevant during the scope of one request. For optimisation purposes, this hash will usually live for multiple requests.
contentId
- a string containing the id of the contentversionId
- the version of the content which the hash belongshash
- the hash of the macro bodyServiceException
@PublicApi public Content update(ContentId contentId, Content content) throws ServiceException
Updates a piece of Content, or restores if it is trashed.
The body contains the representation of the content. Must include the new version number.
To restore a piece of content that has the status of trashed the content must have it's version incremented, and status set to current. No other field modifications will be performed when restoring a piece of content from the trash.
{"id": "557059","status": "current","version": {"number": 2}}
contentId
- the id of the contentcontent
- the content being updatedServiceException
@PublicApi public javax.ws.rs.core.Response delete(ContentId contentId, ContentStatus status) throws ServiceException
ContentType
and ContentStatus
.
There are three cases:
ContentStatus.CURRENT
, it will be trashed.
ContentStatus.TRASHED
and the "status" query parameter in the request is "trashed",
the content will be purged from the trash and deleted permanently.
contentId
- the id of the contentServiceException
Copyright © 2003–2016 Atlassian. All rights reserved.