com.atlassian.confluence.rest.resources
Class ContentResource

java.lang.Object
  extended by com.atlassian.confluence.rest.resources.ContentResource

public class ContentResource
extends java.lang.Object

REST wrapper for the ContentService.


Constructor Summary
ContentResource(ContentService contentService, SpaceService spaceService, ContentMacroService contentMacroService)
           
 
Method Summary
 Content createContent(Content newContent)
          Creates a new piece of Content.
 void delete(ContentId contentId)
          Deletes a piece of Content.
 Content getContent(ContentId contentId, java.lang.String expand)
          Returns a piece of Content.
 PageResponse<Content> getContent(java.lang.String type, java.lang.String spaceKey, java.lang.String title, java.lang.String postingDay, java.lang.String expand, int start, int limit, javax.ws.rs.core.UriInfo uriInfo)
          Returns a piece of Content.
 History getHistory(ContentId contentId, java.lang.String expand)
          Returns the history of a particular piece of content
 MacroInstance getMacroBodyByHash(ContentId contentId, int versionId, java.lang.String hash)
          Returns the body of a macro (in storage format) with the given hash.
 Content update(ContentId contentId, Content content)
          Updates a piece of Content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentResource

public ContentResource(ContentService contentService,
                       SpaceService spaceService,
                       ContentMacroService contentMacroService)
Method Detail

getContent

@PublicApi
public Content getContent(ContentId contentId,
                                    java.lang.String expand)
                   throws ServiceException

Returns a piece of Content.

Example request: http://example.com/rest/api/content/1234?expand=space,body.view,version,container

Parameters:
contentId - the id of the content
expand - A comma separated list of properties to expand on the content. Default value: history,space,version
Returns:
a JSON representation of the content, or a 404 NOT FOUND if there is no content with the given id or if the user is not permitted.
Throws:
ServiceException

createContent

@PublicApi
public Content createContent(Content newContent)
                      throws ServiceException

Creates a new piece of Content.

Parameters:
newContent - content to be created
Returns:
content created
Throws:
ServiceException

getContent

@PublicApi
public PageResponse<Content> getContent(java.lang.String type,
                                                  java.lang.String spaceKey,
                                                  java.lang.String title,
                                                  java.lang.String postingDay,
                                                  java.lang.String expand,
                                                  int start,
                                                  int limit,
                                                  @Context
                                                  javax.ws.rs.core.UriInfo uriInfo)
                                 throws ServiceException

Returns a piece of Content. EXPERIMENTAL: only implemented for pages and blogposts

Example requests:

  1. http://example.com/rest/api/content?spaceKey=TST&Title=Cheese&expand=space,body.view,version,container
  2. http://example.com/rest/api/content?type=blogpost&spaceKey=TST&title=Bacon&postingDay=2014-02-13&expand=space,body.view,version,container

Parameters:
type - the content type to return. Default value: page. Valid values: page, blogpost.
spaceKey - the space key to find content under. Required.
title - the title of the page to find. Required for page type.
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.
Returns:
a JSON representation of the content, or a 404 NOT FOUND if there is no content with the given id or if the user is not permitted.
Throws:
ServiceException

getHistory

@PublicApi
public History getHistory(ContentId contentId,
                                    java.lang.String expand)
                   throws ServiceException

Returns the history of a particular piece of content

Parameters:
contentId - the id of the content
expand - the properties on content history to expand
Returns:
a JSON representation of the content history
Throws:
ServiceException

getMacroBodyByHash

@PublicApi
public MacroInstance getMacroBodyByHash(ContentId contentId,
                                                  int versionId,
                                                  java.lang.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.

Parameters:
contentId - a string containing the id of the content
versionId - the version of the content which the hash belongs
hash - the hash of the macro body
Returns:
the raw macro body in storage format
Throws:
ServiceException

update

@PublicApi
public Content update(ContentId contentId,
                                Content content)
               throws ServiceException

Updates a piece of Content.

The body contains the representation of the content.

Parameters:
contentId - the id of the content
content - the content being updated
Returns:
a JSON representation of the content, or a 404 NOT FOUND if there is no content with the given id or if the user is not permitted.
Throws:
ServiceException

delete

@PublicApi
public void delete(ContentId contentId)
            throws ServiceException

Deletes a piece of Content.

Parameters:
contentId - the id of the content
Throws:
ServiceException


Copyright © 2003-2014 Atlassian. All Rights Reserved.