public interface

DraftService

com.atlassian.confluence.content.service.DraftService
Known Indirect Subclasses

Class Overview

A Service responsible for Draft related operations during editing in Confluence.

Summary

Nested Classes
enum DraftService.DraftType  
Public Methods
Draft createDraftForEditor(AbstractPage page)
Create and store a draft for the supplied AbstractPage for the current user.
Draft findDraftForEditor(long contentId, DraftService.DraftType type, String spaceKey)
Find and return a draft of the specified content Id and type for the current user.
Draft findOrCreateDraftForEditor(String spaceKey, DraftService.DraftType type)
Find the draft within the identified space for the current user.
void removeDraft(long contentId, DraftService.DraftType type, String spaceKey)
Removes the draft specified by the given content id and type for the current user.
Draft saveDraftFromEditor(String title, DraftService.DraftType type, String content, String contentId, String spaceKey, int pageVersion)
Create and store a draft for the current user with the supplied details.

Public Methods

public Draft createDraftForEditor (AbstractPage page)

Create and store a draft for the supplied AbstractPage for the current user. The draft will be created in storage format but the return object will contain editor format content.

Parameters
page the page to create a Draft from
Returns
  • the Draft that was created. The content of this Draft will be in a format suitable for the editor.
Throws
NotAuthorizedException if the current user is not able to save a draft (doesn't have edit permission)
NotValidException if the data for the draft is incomplete or the content identified does not exist

public Draft findDraftForEditor (long contentId, DraftService.DraftType type, String spaceKey)

Find and return a draft of the specified content Id and type for the current user. The draft will be returned in a format suitable for the Confluence editor

Returns
  • the draft is found, otherwise null.
Throws
NotAuthorizedException if the current user is not permitted to view drafts for the identified content
NotValidException if the content identified does not exist
IllegalArgumentException if there are any problems with the supplied parameters

public Draft findOrCreateDraftForEditor (String spaceKey, DraftService.DraftType type)

Find the draft within the identified space for the current user. If none is found then a new empty Draft is created, saved and returned. Any content within the draft will be suitable for use in the Confluence editor.@return

Throws
NotAuthorizedException if the current user is not permitted to view or create drafts in the space
NotValidException if the space identified does not exist.
IllegalArgumentException if the required parameters are not provided.

public void removeDraft (long contentId, DraftService.DraftType type, String spaceKey)

Removes the draft specified by the given content id and type for the current user. Does nothing if no draft is found.

Parameters
spaceKey since a new page draft is unique per space the spaceKey must be provided if the contentId is 0
Throws
NotAuthorizedException if the current user does not have permission.
NotValidException

public Draft saveDraftFromEditor (String title, DraftService.DraftType type, String content, String contentId, String spaceKey, int pageVersion)

Create and store a draft for the current user with the supplied details.

Parameters
content the editor formatted content (will be converted into storage format).
contentId as a String since NEW is taken to represent a new draft
Returns
  • The Draft model object that was created and saved. The content of this draft will be in storage format
Throws
NotAuthorizedException if the current user is not able to save a draft (doesn't have edit permission)
NotValidException if the data for the draft is incomplete or the content identified does not exist
IllegalArgumentException if there is a problem with the arguments supplied