com.atlassian.confluence.content.service
Interface DraftService

All Known Implementing Classes:
DefaultDraftService

public interface DraftService

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


Nested Class Summary
static class DraftService.DraftType
           
 
Method Summary
 int countDrafts()
          Deprecated. since 5.7. Not used, so no replacement.
 Draft createDraftForEditor(AbstractPage page)
          Deprecated. since 5.7. Not used, so no replacement.
 Draft createNewContentDraft(String spaceKey, DraftService.DraftType type)
           
 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.
 List<Draft> findDrafts(int limit, int offset)
          Finds the users drafts.
 Draft findOrCreateDraftForEditor(String spaceKey, DraftService.DraftType type)
          Deprecated. since 4.2 use findDraftForEditor(long, com.atlassian.confluence.content.service.DraftService.DraftType, java.lang.String) or createNewContentDraft(java.lang.String, com.atlassian.confluence.content.service.DraftService.DraftType) or getDraft(long)instead.
 Draft getDraft(long draftId)
          gets the draft by id for the authenticated user
 boolean isDraftContentChanged(Long draftId, String title, String content, Long contentId)
          Deprecated. since 5.7. No replacement (should stop being used).
 Long removeDraft(long draftId)
          Removes the draft with the specified ID if it is found, and returns the same ID passed.
 void removeDraft(long contentId, DraftService.DraftType type, String spaceKey)
          Deprecated. since 4.3 use removeDraft(long)
 Long removeDraft(long abstractPageId, long draftId)
          Removes the draft specified by the given page id or draft id for the current user.
 Draft saveDraftFromEditor(Long draftId, String title, DraftService.DraftType type, String content, Long contentId, String spaceKey, int pageVersion)
          Create and store a draft for the current user with the supplied details.
 Draft saveDraftFromEditor(String title, DraftService.DraftType type, String content, String contentId, String spaceKey, int pageVersion)
          Deprecated. since 4.3 use saveDraftFromEditor(Long, String, DraftType, String, Long, String, int)
 

Method Detail

saveDraftFromEditor

Draft saveDraftFromEditor(Long draftId,
                          String title,
                          DraftService.DraftType type,
                          String content,
                          Long contentId,
                          String spaceKey,
                          int pageVersion)
                          throws NotValidException
Create and store a draft for the current user with the supplied details.

Parameters:
draftId -
title -
type -
content - the editor formatted content (will be converted into storage format).
contentId - as a String since NEW is taken to represent a new draft
spaceKey -
pageVersion -
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

saveDraftFromEditor

@Deprecated
Draft saveDraftFromEditor(String title,
                                     DraftService.DraftType type,
                                     String content,
                                     String contentId,
                                     String spaceKey,
                                     int pageVersion)
                          throws NotValidException
Deprecated. since 4.3 use saveDraftFromEditor(Long, String, DraftType, String, Long, String, int)

Throws:
NotValidException

createDraftForEditor

@Deprecated
Draft createDraftForEditor(AbstractPage page)
                           throws NotValidException
Deprecated. since 5.7. Not used, so no replacement.

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

isDraftContentChanged

@Deprecated
boolean isDraftContentChanged(Long draftId,
                                         String title,
                                         String content,
                                         Long contentId)
Deprecated. since 5.7. No replacement (should stop being used).

Compares the content of a draft to an existing page. If the draft is for a new page returns true when Draft.isBlank() returns false and the draft has no attachments

Returns:
true if the draft content is different to it's pages content, or not blank when a new draft.

findDraftForEditor

Draft findDraftForEditor(long contentId,
                         DraftService.DraftType type,
                         String spaceKey)
                         throws NotAuthorizedException,
                                NotValidException
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

Parameters:
contentId -
type -
spaceKey -
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

findOrCreateDraftForEditor

Draft findOrCreateDraftForEditor(String spaceKey,
                                 DraftService.DraftType type)
Deprecated. since 4.2 use findDraftForEditor(long, com.atlassian.confluence.content.service.DraftService.DraftType, java.lang.String) or createNewContentDraft(java.lang.String, com.atlassian.confluence.content.service.DraftService.DraftType) or getDraft(long)instead.

Create 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.

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.

createNewContentDraft

Draft createNewContentDraft(String spaceKey,
                            DraftService.DraftType type)

removeDraft

Long removeDraft(long abstractPageId,
                 long draftId)
Removes the draft specified by the given page id or draft id for the current user. Looks at the draftId by preference, and reverts to the abstractPageId if the draftId is 0. Throws IllegalStateException if the draftId is 0 and the abstract page cannot be found.

Parameters:
abstractPageId - the id of the abstract page the draft is an edit for.
draftId - the draft of the id to remove, this is necessary if abstractPageId = 0.
Returns:
the id of the removed draft or null if neither a matching page nor draft could be found.
Throws:
NotAuthorizedException - if the current user does not have permission.

removeDraft

@Deprecated
void removeDraft(long contentId,
                            DraftService.DraftType type,
                            String spaceKey)
Deprecated. since 4.3 use removeDraft(long)

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

Parameters:
contentId -
type -
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

removeDraft

Long removeDraft(long draftId)
Removes the draft with the specified ID if it is found, and returns the same ID passed.

Parameters:
draftId - a draft to remove
Returns:
draftId removed or null.

findDrafts

List<Draft> findDrafts(int limit,
                       int offset)
                       throws NotValidException
Finds the users drafts.

Parameters:
limit - - the maximum number of drafts to return
offset - - the offset of results
Returns:
Throws:
NotAuthorizedException
NotValidException

countDrafts

@Deprecated
int countDrafts()
Deprecated. since 5.7. Not used, so no replacement.

Returns:
A count of the drafts for the authenticated user

getDraft

Draft getDraft(long draftId)
               throws NotAuthorizedException,
                      NotValidException
gets the draft by id for the authenticated user

Parameters:
draftId -
Returns:
the draft with id draftId if it is owned by the authenticated user
Throws:
NotAuthorizedException - - if the owner of the draft is not the authenticated user
NotValidException - - if no draft exists with this id


Copyright © 2003–2015 Atlassian. All rights reserved.