com.atlassian.confluence.pages
Class DefaultDraftManager

java.lang.Object
  extended by com.atlassian.confluence.pages.DefaultDraftManager
All Implemented Interfaces:
DraftManager

public class DefaultDraftManager
extends Object
implements DraftManager

This implementation supports anonymous drafts using session-based storage.


Field Summary
protected  org.apache.log4j.Logger log
          Deprecated. 
 
Constructor Summary
DefaultDraftManager()
           
 
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 the MergeResult 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)
          Merges the draft with the original version compared to the latest version of the page.
 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 setAttachmentManager(AttachmentManager attachmentManager)
           
 void setDraftDao(DraftDao draftDao)
           
 void setHttpContext(HttpContext httpContext)
           
 void setMergerManager(MergerManager mergerManager)
           
 void setPageManager(PageManager pageManager)
           
 void setSettingsManager(SettingsManager settingsManager)
           
 void updateSpaceKey(String newSpaceKey, String oldSpaceKey)
          Updates all drafts with oldSpaceKey as their space key to have newSpaceKey instead.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

@Deprecated
protected final transient org.apache.log4j.Logger log
Deprecated. 
Constructor Detail

DefaultDraftManager

public DefaultDraftManager()
Method Detail

saveDraft

public void saveDraft(Draft draft)
Description copied from interface: DraftManager
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.

Specified by:
saveDraft in interface DraftManager

findDraft

public Draft findDraft(String pageId,
                       String owner,
                       String type,
                       String spaceKey)
Description copied from interface: DraftManager
Finds the draft with the given page ID, owner and type. Returns null if a matching draft cannot be found.

Specified by:
findDraft in interface DraftManager
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

public Draft getDraft(long draftId)
Description copied from interface: DraftManager
Finds the draft given a specific draft id. Returns null if no draft is found.

Specified by:
getDraft in interface DraftManager
Returns:
the matching draft or null if a draft cannot be found

getDraftsForSpace

public List<Draft> getDraftsForSpace(String spaceKey)
Specified by:
getDraftsForSpace in interface DraftManager
Returns:
all the Drafts for the identified space key. An empty list will be returned if there are none.

removeDraft

public void removeDraft(String pageId,
                        String owner,
                        String type,
                        String spaceKey)
Description copied from interface: DraftManager
Removes the draft specified by the given page ID, owner and type. Does nothing if the draft cannot be found.

Specified by:
removeDraft in interface DraftManager
See Also:
for an explanation of the arguments, for a faster way to remove a draft if you have its ID

removeDraftById

public void removeDraftById(long id)
Description copied from interface: DraftManager
Removes a draft by ID. Does nothing if the draft cannot be found.

Specified by:
removeDraftById in interface DraftManager
Parameters:
id - the ID of the draft to remove

getDraftSaveInterval

public int getDraftSaveInterval()
Description copied from interface: DraftManager
Returns the time in milliseconds between saving drafts in the editor. It is configurable in the application.

Specified by:
getDraftSaveInterval in interface DraftManager

findDraftsForUser

public List<Draft> findDraftsForUser(com.atlassian.user.User user)
Description copied from interface: DraftManager
Returns the drafts for the user provided or an empty list if the user has no drafts.

Specified by:
findDraftsForUser in interface DraftManager

isMergeRequired

public boolean isMergeRequired(Draft draft)
Description copied from interface: DraftManager
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.

Specified by:
isMergeRequired in interface DraftManager

getMergedContent

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

Merges the draft with the original version compared to the latest version of the page.

Specified by:
getMergedContent in interface DraftManager
Parameters:
draft - the draft whose changes to merge with the latest version of the content
Returns:
merged content, or null if the merge failed.

mergeContent

public MergeResult mergeContent(Draft draft)
Merges the draft with the original version compared to the latest version of the page.

Specified by:
mergeContent in interface DraftManager
Parameters:
draft - the draft whose changes to merge with the latest version of the content
Returns:
result of the merge which contains additional information about the merge.

updateSpaceKey

public void updateSpaceKey(String newSpaceKey,
                           String oldSpaceKey)
Description copied from interface: DraftManager
Updates all drafts with oldSpaceKey as their space key to have newSpaceKey instead. Used when converting a global space into a personal space.

Specified by:
updateSpaceKey in interface DraftManager
Parameters:
newSpaceKey - the new space key
oldSpaceKey - the old space key

getOrCreate

public Draft getOrCreate(String username,
                         String draftType,
                         String spaceKey)
Description copied from interface: DraftManager
Gets a new draft object. If such a draft does not exist one is created.

Specified by:
getOrCreate in interface DraftManager
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

public Draft createDraftForPage(AbstractPage page,
                                String username)
Description copied from interface: DraftManager
Gets a new draft object. If such a draft does not exist one is created.

Specified by:
createDraftForPage in interface DraftManager
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

public void removeAll()
Description copied from interface: DraftManager
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.

Specified by:
removeAll in interface DraftManager

removeDraftsForUser

public void removeDraftsForUser(String username)
Description copied from interface: DraftManager
Removes all drafts in the data store associated with the specified user.

Specified by:
removeDraftsForUser in interface DraftManager

setSettingsManager

public void setSettingsManager(SettingsManager settingsManager)

setDraftDao

public void setDraftDao(DraftDao draftDao)

setPageManager

public void setPageManager(PageManager pageManager)

setAttachmentManager

public void setAttachmentManager(AttachmentManager attachmentManager)

setHttpContext

public void setHttpContext(HttpContext httpContext)

setMergerManager

public void setMergerManager(MergerManager mergerManager)


Copyright © 2003-2012 Atlassian. All Rights Reserved.