Class CommentManager
java.lang.Object
io.goobi.viewer.model.annotation.comments.CommentManager
- All Implemented Interfaces:
AnnotationLister<Comment>
Class to create comments from a text input for a given PI and page order and to save them using a given
AnnotationSaver.- Author:
- Florian Alpers
-
Constructor Summary
ConstructorsConstructorDescriptionCommentManager(AnnotationSaver saver, AnnotationDeleter deleter, AnnotationLister<Comment> lister, ChangeNotificator... notificators) -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcheckAndCleanScripts(String text, User editor, String pi, Integer page) voidcreateComment(String text, User creator, String pi, Integer pageOrder, String license, PublicationStatus publicationStatus) voiddeleteComment(Comment comment) voideditComment(Comment comment, String text, User editor, PublicationStatus publicationStatus) getAnnotation(Long id) longgetAnnotationCount(String textQuery, List<String> motivations, List<Long> generators, List<Long> creators, String targetPi, Integer targetPage) getAnnotations(int firstIndex, int items, String textQuery, List<String> motivations, List<Long> generators, List<Long> creators, String targetPi, Integer targetPage, String sortField, boolean sortDescending) static Set<CommentGroup> longstatic booleanChecks whether the given user has access to any comment groups, whether via being admin or owner or member of any linked user group.static booleanqueryCommentGroupIdentifiers(CommentGroup commentGroup) static voidshutdown()Shuts down the background e-mail notification executor.
-
Constructor Details
-
CommentManager
public CommentManager(AnnotationSaver saver, AnnotationDeleter deleter, AnnotationLister<Comment> lister, ChangeNotificator... notificators) - Parameters:
saver- strategy used to persist new or edited commentsdeleter- strategy used to remove commentslister- strategy used to retrieve commentsnotificators- zero or more notificators for comment change events
-
-
Method Details
-
shutdown
public static void shutdown()Shuts down the background e-mail notification executor. Called byContextListenerduring application shutdown. Waits up to 5 seconds for in-flight notifications to finish. -
createComment
public void createComment(String text, User creator, String pi, Integer pageOrder, String license, PublicationStatus publicationStatus) - Parameters:
text- raw comment text entered by the usercreator- user creating the commentpi- persistent identifier of the target recordpageOrder- page number the comment is attached tolicense- license string to apply to the commentpublicationStatus- initial publication status of the comment
-
editComment
public void editComment(Comment comment, String text, User editor, PublicationStatus publicationStatus) - Parameters:
comment- the original comment being editedtext- new comment text provided by the editoreditor- user performing the editpublicationStatus- updated publication status for the comment
-
deleteComment
- Parameters:
comment- the comment to delete
-
getAllAnnotations
- Specified by:
getAllAnnotationsin interfaceAnnotationLister<Comment>
-
getTotalAnnotationCount
public long getTotalAnnotationCount()- Specified by:
getTotalAnnotationCountin interfaceAnnotationLister<Comment>
-
getAnnotations
public List<Comment> getAnnotations(int firstIndex, int items, String textQuery, List<String> motivations, List<Long> generators, List<Long> creators, String targetPi, Integer targetPage, String sortField, boolean sortDescending) - Specified by:
getAnnotationsin interfaceAnnotationLister<Comment>
-
getAnnotationCount
public long getAnnotationCount(String textQuery, List<String> motivations, List<Long> generators, List<Long> creators, String targetPi, Integer targetPage) - Specified by:
getAnnotationCountin interfaceAnnotationLister<Comment>
-
checkAndCleanScripts
- Parameters:
text- raw comment text to sanitizeeditor- user who submitted the textpi- persistent identifier of the target recordpage- page number the comment is attached to- Returns:
- text stripped of any JS
-
getAnnotation
- Specified by:
getAnnotationin interfaceAnnotationLister<Comment>
-
getRelevantCommentGroupsForRecord
public static Set<CommentGroup> getRelevantCommentGroupsForRecord(String pi) throws DAOException, PresentationException, IndexUnreachableException - Parameters:
pi- persistent identifier of the record to match against comment group queries- Returns:
- Set
- Throws:
DAOExceptionPresentationExceptionIndexUnreachableException
-
queryCommentGroupIdentifiers
public static boolean queryCommentGroupIdentifiers(CommentGroup commentGroup) throws PresentationException, IndexUnreachableException - Parameters:
commentGroup- comment group whose Solr query should be executed- Returns:
- true if commentGroup query has matching identifiers in the index; false otherwise
- Throws:
PresentationExceptionIndexUnreachableException
-
isUserHasAccessToCommentGroups
Checks whether the given user has access to any comment groups, whether via being admin or owner or member of any linked user group.- Parameters:
user- user to check access for- Returns:
- true if user has access; false otherwise
- Throws:
DAOException
-