com.atlassian.confluence.pages
Interface DraftManager

All Known Implementing Classes:
DefaultDraftManager

public interface DraftManager

Saves, retrieves and merges drafts of Confluence content. Currently supports drafts for blog posts and pages.


Method Summary
 Draft createDraftForPage(AbstractPage page, String username)
          Gets a new draft object.
 Draft findDraft(String pageId, String owner, String type, String spaceKey)
          Finds the draft with the given page ID, owner and type.
 List<Draft> findDraftsForUser(com.atlassian.user.User user)
          Returns the drafts for the user provided or an empty list if the user has no drafts.
 Draft getDraft(long draftId)
          Finds the draft given a specific draft id.
 int getDraftSaveInterval()
          Returns the time in milliseconds between saving drafts in the editor.
 List<Draft> getDraftsForSpace(String spaceKey)
           
 String getMergedContent(Draft draft)
          Deprecated. since 4.0 use mergeContent(Draft draft) instead.
 Draft getOrCreate(String username, String draftType, String spaceKey)
          Gets a new draft object.
 boolean isMergeRequired(Draft draft)
          Returns true if the draft version of a page is different to the current version of a page, otherwise false.
 MergeResult mergeContent(Draft draft)
          Attempts the merge the changes done by this draft with the latest version of the content.
 void removeAll()
          Removes all drafts in the data store associated with the current user.
 void removeDraft(String pageId, String owner, String type, String spaceKey)
          Removes the draft specified by the given page ID, owner and type.
 void removeDraftById(long id)
          Removes a draft by ID.
 void removeDraftsForUser(String username)
          Removes all drafts in the data store associated with the specified user.
 void saveDraft(Draft draft)
          Saves the provided draft to the data store.
 void updateSpaceKey(String newSpaceKey, String oldSpaceKey)
          Updates all drafts with oldSpaceKey as their space key to have newSpaceKey instead.
 

Method Detail

saveDraft

void saveDraft(Draft draft)
Saves the provided draft to the data store. Anonymous drafts will be persisted to the web session.

The draft must have a page ID of "0" for drafts of new content, or the ID of an existing page or blog post.

Throws:
IllegalArgumentException - if the provided draft is null, has a null page ID, or no content with the draft's page ID can be found.

findDraft

Draft findDraft(String pageId,
                String owner,
                String type,
                String spaceKey)
Finds the draft with the given page ID, owner and type. Returns null if a matching draft cannot be found.

Parameters:
pageId - the ID of the content which the draft is for
owner - the user name of the user who created the draft
type - the type of draft, which is usually the result of calling ContentEntityObject.getType()
spaceKey - Space that the draft lives in.
Returns:
the matching draft or null if a draft cannot be found

getDraft

Draft getDraft(long draftId)
Finds the draft given a specific draft id. Returns null if no draft is found.

Returns:
the matching draft or null if a draft cannot be found

getDraftsForSpace

List<Draft> getDraftsForSpace(String spaceKey)
Parameters:
spaceKey -
Returns:
all the Drafts for the identified space key. An empty list will be returned if there are none.

removeDraft

void removeDraft(String pageId,
                 String owner,
                 String type,
                 String spaceKey)
Removes the draft specified by the given page ID, owner and type. Does nothing if the draft cannot be found.

See Also:
for an explanation of the arguments, for a faster way to remove a draft if you have its ID

removeDraftById

void removeDraftById(long id)
Removes a draft by ID. Does nothing if the draft cannot be found.

Parameters:
id - the ID of the draft to remove

getDraftSaveInterval

int getDraftSaveInterval()
Returns the time in milliseconds between saving drafts in the editor. It is configurable in the application.


findDraftsForUser

List<Draft> findDraftsForUser(com.atlassian.user.User user)
Returns the drafts for the user provided or an empty list if the user has no drafts.


isMergeRequired

boolean isMergeRequired(Draft draft)
Returns true if the draft version of a page is different to the current version of a page, otherwise false. Always returns false for new content.


getMergedContent

@Deprecated
String getMergedContent(Draft draft)
Deprecated. since 4.0 use mergeContent(Draft draft) instead.

Attempts the merge the changes done by this draft with the latest version of the content. Returns the result of the merge.

Parameters:
draft - the draft whose changes to merge with the latest version of the content
Returns:
the merged content

mergeContent

MergeResult mergeContent(Draft draft)
Attempts the merge the changes done by this draft with the latest version of the content. Returns the result of the merge.

Parameters:
draft - the draft whose changes to merge with the latest version of the content
Returns:
the result of the merge.

updateSpaceKey

void updateSpaceKey(String newSpaceKey,
                    String oldSpaceKey)
Updates all drafts with oldSpaceKey as their space key to have newSpaceKey instead. Used when converting a global space into a personal space.

Parameters:
newSpaceKey - the new space key
oldSpaceKey - the old space key

getOrCreate

Draft getOrCreate(String username,
                  String draftType,
                  String spaceKey)
Gets a new draft object. If such a draft does not exist one is created.

Parameters:
username - name of user or null for anonymous users
draftType - the content type of the draft, e.g. Page.CONTENT_TYPE
spaceKey - the space key of the content
Returns:
the existing draft for the given content and user, or a new draft object if that does not exist.

createDraftForPage

Draft createDraftForPage(AbstractPage page,
                         String username)
Gets a new draft object. If such a draft does not exist one is created.

Parameters:
page - the existing content to create the draft for
username - name of user or null for anonymous users
Returns:
the existing draft for the given content and user, or a new draft object if that does not exist.

removeAll

void removeAll()
Removes all drafts in the data store associated with the current user. If the current user is anonymous, removes all drafts in that user's session, otherwise removes all drafts stored in the database.


removeDraftsForUser

void removeDraftsForUser(String username)
Removes all drafts in the data store associated with the specified user.



Copyright © 2003-2012 Atlassian. All Rights Reserved.