Package com.atlassian.confluence.pages
Class DefaultDraftManager
- java.lang.Object
-
- 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.
-
-
Constructor Summary
Constructors Constructor Description DefaultDraftManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description int
countDrafts(String owner)
Draft
create(String username, DraftService.DraftType draftType, String spaceKey)
Creates a new persistent draft of the specified draft type in the space for the user.Draft
create(String username, DraftService.DraftType draftType, String spaceKey, long parentPageId)
Creates a new persistent draft of the specified draft type in the space for the user.Draft
findDraft(Long 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.Draft
getOrCreate(String username, String draftType, String spaceKey)
Deprecated.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
removeAllDrafts()
Removes all drafts stored in the databasevoid
removeDraft(Draft draft)
Removes the draft specified.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
setConfluenceUserDao(ConfluenceUserDao confluenceUserDao)
void
setDraftDao(DraftDao draftDao)
void
setHttpContext(HttpContext httpContext)
void
setLabelManager(LabelManager labelManager)
void
setMergerManager(MergerManager mergerManager)
void
setPageManager(PageManager pageManager)
-
-
-
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 interfaceDraftManager
-
findDraft
public Draft findDraft(Long 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 interfaceDraftManager
- Parameters:
pageId
- the ID of the content which the draft is forowner
- the user name of the user who created the drafttype
- the type of draft, which is usually the result of callingContentEntityObject.getType()
spaceKey
- Space that the draft lives in.- Returns:
- the matching draft or null if a draft cannot be found
-
countDrafts
public int countDrafts(String owner)
- Specified by:
countDrafts
in interfaceDraftManager
- Returns:
- A count of drafts with content for the given owner
-
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 interfaceDraftManager
- Returns:
- the matching draft or null if a draft cannot be found
-
removeDraft
public void removeDraft(Draft draft)
Description copied from interface:DraftManager
Removes the draft specified. Does nothing if the draft cannot be found.- Specified by:
removeDraft
in interfaceDraftManager
-
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 interfaceDraftManager
-
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 interfaceDraftManager
-
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 interfaceDraftManager
- 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.
-
create
public Draft create(String username, DraftService.DraftType draftType, String spaceKey)
Description copied from interface:DraftManager
Creates a new persistent draft of the specified draft type in the space for the user.- Specified by:
create
in interfaceDraftManager
- Parameters:
username
- - the owner of the draft, may be null for anonymousdraftType
- - the type of draft, (either blogpost or page)spaceKey
- - the space in which to create the draft- Returns:
- a newly created persistent draft
-
create
public Draft create(String username, DraftService.DraftType draftType, String spaceKey, long parentPageId)
Description copied from interface:DraftManager
Creates a new persistent draft of the specified draft type in the space for the user.- Specified by:
create
in interfaceDraftManager
- Parameters:
username
- - the owner of the draft, may be null for anonymousdraftType
- - the type of draft, (either blogpost or page)spaceKey
- - the space in which to create the draftparentPageId
- - the parentPageId of a page- Returns:
- a newly created persistent draft
-
getOrCreate
@Deprecated public Draft getOrCreate(String username, String draftType, String spaceKey)
Deprecated.Description copied from interface:DraftManager
Gets a new draft object. If such a draft does not exist one is created.- Specified by:
getOrCreate
in interfaceDraftManager
- Parameters:
username
- name of user or null for anonymous usersdraftType
- 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.
-
removeAllDrafts
public void removeAllDrafts()
Description copied from interface:DraftManager
Removes all drafts stored in the database- Specified by:
removeAllDrafts
in interfaceDraftManager
-
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 interfaceDraftManager
-
setDraftDao
public void setDraftDao(DraftDao draftDao)
-
setPageManager
public void setPageManager(PageManager pageManager)
-
setAttachmentManager
public void setAttachmentManager(AttachmentManager attachmentManager)
-
setLabelManager
public void setLabelManager(LabelManager labelManager)
-
setHttpContext
public void setHttpContext(HttpContext httpContext)
-
setMergerManager
public void setMergerManager(MergerManager mergerManager)
-
setConfluenceUserDao
public void setConfluenceUserDao(ConfluenceUserDao confluenceUserDao)
-
-