Class DefaultDraftService
- java.lang.Object
-
- com.atlassian.confluence.content.service.DefaultDraftService
-
- All Implemented Interfaces:
DraftService
public class DefaultDraftService extends Object implements DraftService
Note that this implementation of the DraftService does not perform any permission checking. This has always been the case in Confluence - if you want to change this, be aware that UI for certain operations could break (used to be necessary for copy page but this is not the case anymore - see CONFDEV-227 for details).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.atlassian.confluence.content.service.DraftService
DraftService.DraftType
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DraftcreateNewContentDraft(String spaceKey, DraftService.DraftType type)DraftfindDraftForEditor(long contentId, DraftService.DraftType type, String spaceKey)Find and return a draft of the specified content Id and type for the current user.List<Draft>findDrafts(int limit, int offset)Finds the users drafts.DraftgetDraft(long draftId)gets the draft by id for the authenticated userbooleanisDraftContentChanged(Long draftId, String title, String content, Long contentId)Deprecated.LongremoveDraft(long draftId)Removes the draft with the specified ID if it is found, and returns the same ID passed.LongremoveDraft(long abstractPageId, long draftId)Removes the draft specified by the given page id or draft id for the current user.DraftsaveDraftFromEditor(Long draftId, Long parentPageId, String title, DraftService.DraftType type, String content, Long contentId, String spaceKey, int pageVersion)Create and store a draft for the current user with the supplied details.DraftsaveDraftFromEditor(Long draftId, String title, DraftService.DraftType type, String content, Long contentId, String spaceKey, int pageVersion)Deprecated.
-
-
-
Method Detail
-
saveDraftFromEditor
public Draft saveDraftFromEditor(Long draftId, Long parentPageId, String title, DraftService.DraftType type, String content, Long contentId, String spaceKey, int pageVersion) throws NotValidException
Description copied from interface:DraftServiceCreate and store a draft for the current user with the supplied details.- Specified by:
saveDraftFromEditorin interfaceDraftServicecontent- the editor formatted content (will be converted into storage format).contentId- as a String since NEW is taken to represent a new draft- Returns:
- The Draft model object that was created and saved. The content of this draft will be in storage format
- Throws:
NotValidException- if the data for the draft is incomplete or the content identified does not exist
-
saveDraftFromEditor
@Deprecated public Draft saveDraftFromEditor(Long draftId, String title, DraftService.DraftType type, String content, Long contentId, String spaceKey, int pageVersion) throws NotValidException
Deprecated.Description copied from interface:DraftServiceCreate and store a draft for the current user with the supplied details.- Specified by:
saveDraftFromEditorin interfaceDraftServicecontent- the editor formatted content (will be converted into storage format).contentId- as a String since NEW is taken to represent a new draft- Returns:
- The Draft model object that was created and saved. The content of this draft will be in storage format
- Throws:
NotValidException- if the data for the draft is incomplete or the content identified does not exist
-
findDraftForEditor
public Draft findDraftForEditor(long contentId, DraftService.DraftType type, String spaceKey)
Description copied from interface:DraftServiceFind and return a draft of the specified content Id and type for the current user. The draft will be returned in a format suitable for the Confluence editor- Specified by:
findDraftForEditorin interfaceDraftService- Returns:
- the draft is found, otherwise null.
-
createNewContentDraft
public Draft createNewContentDraft(String spaceKey, DraftService.DraftType type)
- Specified by:
createNewContentDraftin interfaceDraftService
-
removeDraft
public Long removeDraft(long abstractPageId, long draftId)
Description copied from interface:DraftServiceRemoves the draft specified by the given page id or draft id for the current user. Looks at the draftId by preference, and reverts to the abstractPageId if the draftId is 0. Throws IllegalStateException if the draftId is 0 and the abstract page cannot be found.- Specified by:
removeDraftin interfaceDraftService- Parameters:
abstractPageId- the id of the abstract page the draft is an edit for.draftId- the draft of the id to remove, this is necessary if abstractPageId = 0.- Returns:
- the id of the removed draft or null if neither a matching page nor draft could be found.
-
removeDraft
public Long removeDraft(long draftId)
Description copied from interface:DraftServiceRemoves the draft with the specified ID if it is found, and returns the same ID passed.- Specified by:
removeDraftin interfaceDraftService- Parameters:
draftId- a draft to remove- Returns:
- draftId removed or null.
-
findDrafts
public List<Draft> findDrafts(int limit, int offset) throws NotValidException
Description copied from interface:DraftServiceFinds the users drafts.- Specified by:
findDraftsin interfaceDraftService- Parameters:
limit- - the maximum number of drafts to returnoffset- - the offset of results- Returns:
- Throws:
NotValidException
-
getDraft
public Draft getDraft(long draftId) throws NotAuthorizedException, NotValidException
Description copied from interface:DraftServicegets the draft by id for the authenticated user- Specified by:
getDraftin interfaceDraftService- Returns:
- the draft with id draftId if it is owned by the authenticated user
- Throws:
NotAuthorizedException- - if the owner of the draft is not the authenticated userNotValidException- - if no draft exists with this id
-
isDraftContentChanged
@Deprecated public boolean isDraftContentChanged(Long draftId, String title, String content, Long contentId) throws NotAuthorizedException, NotValidException
Deprecated.Description copied from interface:DraftServiceCompares the content of a draft to an existing page. If the draft is for a new page returns true whenDraft.isBlank()returns false and the draft has no attachments- Specified by:
isDraftContentChangedin interfaceDraftService- Returns:
- true if the draft content is different to it's pages content, or not blank when a new draft.
- Throws:
NotAuthorizedExceptionNotValidException
-
-