com.atlassian.confluence.pages
Class DefaultDraftManager

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

public class DefaultDraftManager
extends java.lang.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, java.lang.String username)
          Gets a new draft object.
 Draft findDraft(java.lang.String pageId, java.lang.String owner, java.lang.String type)
          Finds the draft with the given page ID, owner and type.
 java.util.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.
 java.lang.String getMergedContent(Draft draft)
          Attempts the merge the changes done by this draft with the latest version of the content.
 Draft getOrCreate(java.lang.String username, java.lang.String draftType, java.lang.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.
 void removeAll()
          Removes all drafts in the data store associated with the current user.
 void removeDraft(java.lang.String pageId, java.lang.String owner, java.lang.String type)
          Removes the draft specified by the given page ID, owner and type.
 void removeDraftById(long id)
          Removes a draft by ID.
 void removeDraftsForUser(java.lang.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 setPageManager(PageManager pageManager)
           
 void setSettingsManager(SettingsManager settingsManager)
           
 void updateSpaceKey(java.lang.String newSpaceKey, java.lang.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(java.lang.String pageId,
                       java.lang.String owner,
                       java.lang.String type)
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()
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

removeDraft

public void removeDraft(java.lang.String pageId,
                        java.lang.String owner,
                        java.lang.String type)
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 java.util.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

public java.lang.String getMergedContent(Draft draft)
Description copied from interface: DraftManager
Attempts the merge the changes done by this draft with the latest version of the content. Returns the result of the merge.

Specified by:
getMergedContent in interface DraftManager
Parameters:
draft - the draft whose changes to merge with the latest version of the content
Returns:
the merged content

updateSpaceKey

public void updateSpaceKey(java.lang.String newSpaceKey,
                           java.lang.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(java.lang.String username,
                         java.lang.String draftType,
                         java.lang.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,
                                java.lang.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(java.lang.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)


Copyright © 2003-2010 Atlassian. All Rights Reserved.