Package 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
Modifier and TypeMethodDescriptiondefault int
countDrafts
(ConfluenceUser owner) int
countDrafts
(String owner) Deprecated, for removal: This API element is subject to removal in a future version.default Draft
create
(ConfluenceUser user, DraftService.DraftType draftType, String spaceKey) Creates a new persistent draft of the specified draft type in the space for the user.default Draft
create
(ConfluenceUser user, DraftService.DraftType draftType, String spaceKey, long parentPageId) Creates a new persistent draft of the specified draft type in the space for the user.create
(String username, DraftService.DraftType draftType, String spaceKey) Deprecated, for removal: This API element is subject to removal in a future version.since 9.5 usecreate(ConfluenceUser, DraftType, String)
default Draft
create
(String username, DraftService.DraftType draftType, String spaceKey, long parentPageId) Deprecated, for removal: This API element is subject to removal in a future version.since 9.5 usecreate(ConfluenceUser, DraftType, String, long)
default Draft
findDraft
(Long pageId, ConfluenceUser owner, String type, String spaceKey) Finds the draft with the given page ID, owner and type.Deprecated, for removal: This API element is subject to removal in a future version.since 9.5 usefindDraft(Long, ConfluenceUser, String, String)
Returns the drafts for the user provided or an empty list if the user has no drafts.findDraftsForUser
(com.atlassian.user.User user) Deprecated, for removal: This API element is subject to removal in a future version.since 9.5 usefindDraft(Long, ConfluenceUser, String, String)
getDraft
(long draftId) Finds the draft given a specific draft id.getOrCreate
(String username, String draftType, String spaceKey) Deprecated.since 5.7.boolean
isMergeRequired
(Draft draft) Returns true if the draft version of a page is different to the current version of a page, otherwise false.mergeContent
(Draft draft) Attempts the merge the changes done by this draft with the latest version of the content.void
Removes all drafts stored in the databasevoid
removeDraft
(Draft draft) Removes the draft specified.default void
Removes all drafts in the data store associated with the specified user.void
removeDraftsForUser
(String username) Deprecated, for removal: This API element is subject to removal in a future version.since 9.5 useremoveDraftsForUser(ConfluenceUser)
void
Saves the provided draft to the data store.
-
Method Details
-
saveDraft
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
@Deprecated(since="9.5", forRemoval=true) @Transactional(readOnly=true) Draft findDraft(Long pageId, String owner, String type, String spaceKey) Deprecated, for removal: This API element is subject to removal in a future version.since 9.5 usefindDraft(Long, ConfluenceUser, String, String)
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 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
-
findDraft
@Transactional(readOnly=true) default Draft findDraft(Long pageId, ConfluenceUser 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 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
- Since:
- 9.5
-
countDrafts
Deprecated, for removal: This API element is subject to removal in a future version.since 9.5 usecountDrafts(ConfluenceUser)
- Parameters:
owner
-- Returns:
- A count of drafts with content for the given owner
-
countDrafts
- Parameters:
owner
-- Returns:
- A count of drafts with content for the given owner
- Since:
- 9.5
-
getDraft
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
-
removeDraft
Removes the draft specified. Does nothing if the draft cannot be found. -
findDraftsForUser
@Transactional(readOnly=true) @Deprecated(since="9.5", forRemoval=true) List<Draft> findDraftsForUser(com.atlassian.user.User user) Deprecated, for removal: This API element is subject to removal in a future version.since 9.5 usefindDraft(Long, ConfluenceUser, String, String)
Returns the drafts for the user provided or an empty list if the user has no drafts. -
findDraftsForUser
Returns the drafts for the user provided or an empty list if the user has no drafts.- Since:
- 9.5
-
isMergeRequired
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.
-
mergeContent
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.
-
getOrCreate
Deprecated.since 5.7. No replacement.Gets a new draft object. If such a draft does not exist one is created.- 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
@Transactional void removeAllDrafts()Removes all drafts stored in the database- Since:
- 5.8
-
removeDraftsForUser
Deprecated, for removal: This API element is subject to removal in a future version.since 9.5 useremoveDraftsForUser(ConfluenceUser)
Removes all drafts in the data store associated with the specified user. -
removeDraftsForUser
Removes all drafts in the data store associated with the specified user.- Since:
- 9.5
-
create
@Transactional @Deprecated(since="9.5", forRemoval=true) Draft create(String username, DraftService.DraftType draftType, String spaceKey) Deprecated, for removal: This API element is subject to removal in a future version.since 9.5 usecreate(ConfluenceUser, DraftType, String)
Creates a new persistent draft of the specified draft type in the space for the user.- 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
@Transactional default Draft create(ConfluenceUser user, DraftService.DraftType draftType, String spaceKey) Creates a new persistent draft of the specified draft type in the space for the user.- Parameters:
user
- - 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
- Since:
- 9.5
-
create
@Transactional @Deprecated(since="9.5", forRemoval=true) default Draft create(String username, DraftService.DraftType draftType, String spaceKey, long parentPageId) Deprecated, for removal: This API element is subject to removal in a future version.since 9.5 usecreate(ConfluenceUser, DraftType, String, long)
Creates a new persistent draft of the specified draft type in the space for the user.- 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
- Since:
- 6.11.0
-
create
@Transactional default Draft create(ConfluenceUser user, DraftService.DraftType draftType, String spaceKey, long parentPageId) Creates a new persistent draft of the specified draft type in the space for the user.- Parameters:
user
- - 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
- Since:
- 9.5
-
countDrafts(ConfluenceUser)