public class ContentResource extends Object
Constructor and Description |
---|
ContentResource(ContentService contentService,
SpaceService spaceService,
ContentMacroService contentMacroService,
ContentTrashService contentTrashService,
CQLSearchService searchService,
ContentDraftService contentDraftService) |
Modifier and Type | Method and Description |
---|---|
Content |
createContent(Content content,
ContentStatus status,
String expand)
Creates a new piece of Content or publishes the draft if the content id is present.
|
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)
Deprecated.
|
MacroInstance |
getMacroBodyByMacroId(ContentId contentId,
int versionId,
String macroId)
Returns the body of a macro (in storage format) with the given id.
|
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,
ContentStatus status,
ContentDraftService.ConflictPolicy conflictPolicy)
Updates a piece of Content, including changes to content status
|
public ContentResource(ContentService contentService, SpaceService spaceService, ContentMacroService contentMacroService, ContentTrashService contentTrashService, CQLSearchService searchService, ContentDraftService contentDraftService)
@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 content, ContentStatus status, String expand) throws ServiceException
Creates a new piece of Content or publishes the draft if the content id is present.
For the case publishing draft, a new piece of content will be created and all metadata from the draft will be transferred into the newly created content.
content:
- new content to be createdexpand:
- A comma separated list of properties to expand on the content. Default value: history,space,version
ServiceException
@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
@PublicApi 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
@Deprecated @PublicApi public MacroInstance getMacroBodyByHash(ContentId contentId, int versionId, String hash) throws ServiceException
getMacroBodyByMacroId(com.atlassian.confluence.api.model.content.id.ContentId, int, java.lang.String)
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.
Collecting a macro by its hash should now be considered deprecated and will be replaced, transparently with
macroIds. This resource is currently only called from connect addons which will eventually all use the
getContentById(com.atlassian.confluence.api.model.content.id.ContentId, java.util.List, Integer, String)
resource.
To make the migration as seamless as possible, this resource will match macros against a generated hash or a stored macroId. This will allow add ons to work during the migration period.
contentId
- a string containing the id of the contentversionId
- the version of the content which the hash belongshash
- the macroId to find the correct macroServiceException
@PublicApi public MacroInstance getMacroBodyByMacroId(ContentId contentId, int versionId, String macroId) throws ServiceException
Returns the body of a macro (in storage format) with the given id. This resource is primarily used by connect applications that require the body of macro to perform their work.
When content is created, if no macroId is specified, then Confluence will generate a random id. The id is persisted as the content is saved and only modified by Confluence if there are conflicting IDs.
To preserve backwards compatibility this resource will also match on the hash of the macro body, even if a macroId is found. This check will become redundant as pages get macroId's generated for them and transparently propagate out to all instances.
contentId
- a string containing the id of the contentversionId
- the version of the content to searchmacroId
- the macroId to find the correct macroServiceException
@PublicApi public Content update(ContentId contentId, Content content, ContentStatus status, ContentDraftService.ConflictPolicy conflictPolicy) throws ServiceException
Updates a piece of Content, including changes to content status
To update a piece of content you must increment the version.number, supplying the number of the version you are creating. The title property can be updated on all content, body can be updated on all content that has a body (not attachments). For instance to update the content of a blogpost that currently has version 1:
PUT /rest/api/content/456 { "version":{ "number": 2 }, "title":"My new title", "type":"page", "body":{ "storage":{ "value":"<p>New page data.</p>", "representation":"storage" } } }
To update a page and change its parent page, supply the ancestors property with the request with the parent as the first ancestor i.e. to move a page to be a child of page with ID 789
PUT /rest/api/content/456 { "version":{ "number": 2 }, "ancestors": [{"id":789}], "type":"page", "body":{ "storage":{ "value":"<p>New page data.</p>", "representation":"storage" } } }
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.
Request example to restore from trash: {"id": "557059","status": "current","version": {"number": 2}}
If the content you're updating has a draft, specifying status=draft will delete that draft and the body of the content will be replaced with the body specified in the request.
Request example to delete a draft: PUT: http://localhost:9096/confluence/rest/api/content/2149384202?status=draft
{ "id":"2149384202", "status":"current", "version":{ "number":4 }, "space":{ "key":"TST" }, "type":"page", "title":"page title", "body":{ "storage":{ "value":"<p>New page data.</p>", "representation":"storage" } } }
Updating a draft is not currently supported.
contentId
- the ID of the content to be updatedcontent
- the new contentstatus
- the existing status of the content to be updated.ServiceException
@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.