@Service(value="noteService") public class NoteService extends Object
NoteManagement
.Constructor and Description |
---|
NoteService() |
Modifier and Type | Method and Description |
---|---|
NoteModificationResult |
createNote(NoteStoringTO noteStoringTO,
Set<String> additionalBlogNameIds)
Creates a note from the supplied transfer object.
|
void |
deleteAutosave(Long noteId)
Deletes an autosave identified by the passed ID.
|
void |
deleteNote(Long noteId,
boolean deleteSystemPosts,
boolean clientManagerCanDelete)
Deletes a user tagged post and all its comments.
|
void |
deleteNotesOfUser(Long userId)
Delete all notes and drafts of a user.
|
AutosaveNoteData |
getAutosave(Long noteId,
Long parentNoteId,
Collection<StringPropertyTO> properties,
Locale locale)
Return an autosave of the current user.
|
List<SimpleNoteListItem> |
getCommentsOfDiscussion(Long noteId)
Returns all the notes of a discussion excluding the root note.
|
Long |
getDiscussionId(Long noteId)
Returns the ID of the discussion the note is part of.
|
<T> T |
getNote(Long noteId,
Converter<Note,T> converter)
Method to get a specific note.
|
NoteData |
getNote(long noteId,
NoteRenderContext renderContext) |
long |
getNoteCount()
Returns the number of notes created within the current client.
|
DiscussionNoteData |
getNoteWithComments(Long noteId,
QueryResultConverter<SimpleNoteListItem,DiscussionNoteData> converter)
Returns a note with its comments which are ordered according to the provided converter.
|
int |
getNumberOfNotesInDiscussion(Long noteId)
Returns the number of notes in a discussion.
|
int |
getNumberOfReplies(Long noteId)
Returns the number of replies to a note.
|
boolean |
noteExists(Long noteId)
Method to check if a note exists.
|
NoteModificationResult |
updateNote(NoteStoringTO noteStoringTO,
Long noteId,
Set<String> additionalBlogNameIds)
Updates an existing note with the data of the supplied transfer object.
|
public NoteModificationResult createNote(NoteStoringTO noteStoringTO, Set<String> additionalBlogNameIds) throws BlogNotFoundException, NoteManagementAuthorizationException, NoteStoringPreProcessorException
noteStoringTO
- The note to create.additionalBlogNameIds
- set of blog aliases for creating crossposts. These aliases will be ignore, if the
note is a comment to another note.BlogNotFoundException
- in case the target blog does not existNoteManagementAuthorizationException
- in case the user is not authorized to create the note, for instance if he has no
write access to the target blogNoteStoringPreProcessorException
- in case one of the pre processors failedpublic void deleteAutosave(Long noteId) throws NoteManagementAuthorizationException
noteId
- Id of the autosave to delete.NoteManagementAuthorizationException
- Thrown, when the user is not allowed to access the note.public void deleteNote(Long noteId, boolean deleteSystemPosts, boolean clientManagerCanDelete) throws NoteManagementAuthorizationException
noteId
- Id of the note to delete.deleteSystemPosts
- If true system notes will also be deleted.clientManagerCanDelete
- If true notes will also be deleted, if the current user is a client manager.NoteManagementAuthorizationException
- Thrown, when the user is not allowed to access the note.public void deleteNotesOfUser(Long userId) throws AuthorizationException
userId
- ID of the user whose notes should be deletedAuthorizationException
- in case the current user is not the internal system user, the client manager or
the creator of the notespublic AutosaveNoteData getAutosave(Long noteId, Long parentNoteId, Collection<StringPropertyTO> properties, Locale locale)
noteId
- the ID of a note to get the autosave of the edit operation of this note. Can be
null.parentNoteId
- the ID of a parent note to get the autosave of a comment to this note. Can be
null.properties
- properties which should be used to get filters for finding an autosave. The
filters are resolved with the help of the registered
AutosavePropertyFilterProvider
the re
Can be null.locale
- the locale to use when filling localizable content of the note like tagspublic List<SimpleNoteListItem> getCommentsOfDiscussion(Long noteId) throws NoteNotFoundException
noteId
- the ID of the note whose discussion will be evaluatedNoteNotFoundException
- in case the note does not existpublic Long getDiscussionId(Long noteId) throws NoteNotFoundException
noteId
- the ID of the note for which the discussion ID should be returnedNoteNotFoundException
- in case the note does not existpublic NoteData getNote(long noteId, NoteRenderContext renderContext) throws NoteNotFoundException, AuthorizationException
noteId
- The note id.renderContext
- The rendering context. If the render mode of the context is null, no
NoteRenderingPreProcessors will be called.NoteNotFoundException
- Thrown, when there is no note for this id.AuthorizationException
- Thrown, when the user is not allowed to access the note.public <T> T getNote(Long noteId, Converter<Note,T> converter)
T
- Type of the return value.noteId
- The notes id.converter
- The converter to convert the note.public long getNoteCount()
public DiscussionNoteData getNoteWithComments(Long noteId, QueryResultConverter<SimpleNoteListItem,DiscussionNoteData> converter) throws NoteNotFoundException, AuthorizationException
noteId
- the id of the note to retrieveconverter
- the converter to use for filling the commentsNoteNotFoundException
- if the requested note does not existAuthorizationException
- if the current user has no read access to the notepublic int getNumberOfNotesInDiscussion(Long noteId) throws NoteNotFoundException
noteId
- the ID of the note whose discussion will be evaluatedNoteNotFoundException
- in case the note does not existpublic int getNumberOfReplies(Long noteId) throws NoteNotFoundException
noteId
- the ID of the noteNoteNotFoundException
- Thrown, when the note doesn't exist anymore.public boolean noteExists(Long noteId)
noteId
- Id of the note to ask for.True
, if the note exits.public NoteModificationResult updateNote(NoteStoringTO noteStoringTO, Long noteId, Set<String> additionalBlogNameIds) throws BlogNotFoundException, NoteNotFoundException, NoteManagementAuthorizationException, NoteStoringPreProcessorException, MovingOfNonRootNotesNotAllowedException
noteStoringTO
- The note to create.noteId
- the ID of the note to updateadditionalBlogNameIds
- set of blog aliases for creating crossposts. These aliases will be ignore, if the
note is a comment to another note.BlogNotFoundException
- in case the target blog does not existNoteNotFoundException
- in case the note to update does not existNoteManagementAuthorizationException
- in case the user is not authorized to update the note, for instance if he has no
write access to the blog or is not the author of the noteNoteStoringPreProcessorException
- in case one of the pre processors failedMovingOfNonRootNotesNotAllowedException
- Thrown, when the user tries to move a note, which is not a parent root.Copyright © 2019 Communote team. All rights reserved.