Class TreeCommentManager

  • All Implemented Interfaces:
    CommentManager

    public class TreeCommentManager
    extends AbstractCommentManager
    Comment service implementation. The comments are linked together as a tree under a folder related to the root document that we comment.
    Since:
    11.1
    • Constructor Detail

      • TreeCommentManager

        public TreeCommentManager()
    • Method Detail

      • getComment

        public Comment getComment​(CoreSession session,
                                  String commentId)
        Description copied from interface: CommentManager
        Gets a comment.
        Parameters:
        session - the core session
        commentId - the comment id
        Returns:
        the comment
      • getComments

        public PartialList<Comment> getComments​(CoreSession session,
                                                String documentId,
                                                Long pageSize,
                                                Long currentPageIndex,
                                                boolean sortAscending)
        Description copied from interface: CommentManager
        Gets all comments for a document.
        Parameters:
        session - the core session
        documentId - the document id
        pageSize - the page size to query, give null or 0 to disable pagination
        currentPageIndex - the page index to query, give null or 0 to disable pagination
        sortAscending - whether to sort ascending or descending
        Returns:
        the list of comments, ordered by comment's creation date and according to sortAscending parameter, or an empty list if no comment is found.
      • getComments

        public List<Comment> getComments​(CoreSession session,
                                         Collection<String> documentIds)
        Description copied from interface: CommentManager
        Gets all comments for a collection of documents.
        Parameters:
        session - the core session
        documentIds - the document ids
        Returns:
        the list of comments
      • getDocumentsForComment

        public List<DocumentModel> getDocumentsForComment​(DocumentModel comment)
        Description copied from interface: CommentManager
        Gets documents in relation with a particular comment.
        Parameters:
        comment - the comment
        Returns:
        the list of documents
      • getThreadForComment

        public DocumentModel getThreadForComment​(DocumentModel comment)
        Description copied from interface: CommentManager
        Gets thread in relation with a given comment (post or comment).
        Parameters:
        comment - the comment
        Returns:
        the thread
      • getExternalComment

        public Comment getExternalComment​(CoreSession session,
                                          String documentId,
                                          String entityId)
        Description copied from interface: CommentManager
        Gets an external comment by its entityId under the document with documentId.
        Returns:
        the comment with given entityId under the document with given documentId
      • createComment

        public Comment createComment​(CoreSession session,
                                     Comment comment)
        Description copied from interface: CommentManager
        Creates a comment.
        Parameters:
        session - the core session
        Returns:
        the created comment
      • createComment

        public DocumentModel createComment​(DocumentModel commentedDoc,
                                           DocumentModel commentDoc)
        Description copied from interface: CommentManager
        Creates a comment document model, filling its properties with given info and linking it to given document.
        Parameters:
        commentedDoc - the document to comment
        commentDoc - the comment document model
        Returns:
        the created comment document model.
      • createLocatedComment

        public DocumentModel createLocatedComment​(DocumentModel doc,
                                                  DocumentModel comment,
                                                  String path)
        Description copied from interface: CommentManager
        Creates a comment document model. It gives opportunity to save the comments in a specified location.
        Parameters:
        doc - the document to comment
        comment - the comment content
        path - the location path
        Returns:
        the comment document model.
      • createComment

        public DocumentModel createComment​(DocumentModel doc,
                                           String text,
                                           String author)
        Description copied from interface: CommentManager
        Creates a comment document model, filling its properties with given info and linking it to given document.
        Parameters:
        doc - the document to comment
        text - the comment content
        author - the comment author
        Returns:
        the comment document model.
      • createComment

        public DocumentModel createComment​(DocumentModel doc,
                                           DocumentModel parent,
                                           DocumentModel child)
        Description copied from interface: CommentManager
        Creates a comment document model, filling its properties with given info and linking it to given document.
        Parameters:
        doc - the document to comment
        parent - the comment parent document model
        child - the comment child document model
        Returns:
        the created comment document model.
      • updateComment

        public Comment updateComment​(CoreSession session,
                                     String commentId,
                                     Comment comment)
        Description copied from interface: CommentManager
        Updates a comment.
        Parameters:
        session - the core session
        commentId - the comment id
        comment - the updated comment
        Returns:
        the updated comment
      • updateExternalComment

        public Comment updateExternalComment​(CoreSession session,
                                             String documentId,
                                             String entityId,
                                             Comment comment)
        Description copied from interface: CommentManager
        Updates an external comment by its entityId under the document with documentId.
        Returns:
        the updated comment with given entityId under the document with given documentId
      • update

        protected Comment update​(CoreSession session,
                                 Comment comment,
                                 DocumentModel commentDoc)
        Parameters:
        session - the user session, in order to check permissions
        comment - the comment holding new data
        commentDoc - the DocumentModel just retrieved from DB
      • deleteExternalComment

        public void deleteExternalComment​(CoreSession session,
                                          String documentId,
                                          String entityId)
        Description copied from interface: CommentManager
        Deletes an external comment by its {code entityId} under the document with documentId.
      • deleteComment

        public void deleteComment​(CoreSession s,
                                  String commentId)
        Description copied from interface: CommentManager
        Deletes a comment.
        Parameters:
        s - the core session
        commentId - the comment id
      • deleteComment

        public void deleteComment​(DocumentModel doc,
                                  DocumentModel comment)
        Description copied from interface: CommentManager
        Deletes a comment.
        Parameters:
        doc - the comment document model
        comment - the comment
      • getLocationRefOfCommentCreation

        protected DocumentRef getLocationRefOfCommentCreation​(CoreSession session,
                                                              DocumentModel commentedDoc)
        Returns the DocumentRef of the comments location in repository for the given commented document model.
        Parameters:
        session - the session needs to be privileged
        Returns:
        the document model container of the comments of the given commentedDoc
        Since:
        11.1
      • checkCreateCommentPermissions

        protected void checkCreateCommentPermissions​(CoreSession session,
                                                     DocumentRef documentRef)
        Checks if the user related to the session can comments the document linked to the documentRef.
      • getExternalCommentModel

        protected DocumentModel getExternalCommentModel​(CoreSession session,
                                                        String documentId,
                                                        String entityId)
        Parameters:
        session - the user session, in order to implicitly check permissions
        Returns:
        the external document model for the given entityId, if it exists, otherwise throws a CommentNotFoundException
      • removeComment

        protected void removeComment​(CoreSession session,
                                     DocumentRef documentRef)
        Remove the comment of the given documentRef
        Parameters:
        session - the user session, in order to check permissions
        documentRef - the documentRef of the comment document model to delete
      • getCommentDocumentModel

        protected DocumentModel getCommentDocumentModel​(CoreSession session,
                                                        String id)
        Parameters:
        session - the user session, in order to implicitly check permissions
        Returns:
        the comment document model of the given documentRef if it exists, otherwise throws a CommentNotFoundException
      • manageRelatedTextOfTopLevelDocument

        protected void manageRelatedTextOfTopLevelDocument​(CoreSession session,
                                                           DocumentModel topLevelDoc,
                                                           String commentId,
                                                           String commentText)
        Manages (Add, Update or Remove) the related text FacetNames.HAS_RELATED_TEXT of the top level document ancestor AbstractCommentManager.getTopLevelDocumentRef(CoreSession, DocumentRef) for the given comment / annotation. Each action of adding, updating or removing the comment / annotation text will call this method, which allow us to make the right action on the related text of the top level document.
        • Add a new Comment / Annotation will create a separate entry
        • Update a text Comment / Annotation will update this specific entry
        • Remove a Comment / Annotation will remove this specific entry
        Since:
        11.1
      • hasComments

        protected boolean hasComments​(CoreSession session,
                                      DocumentModel document)
        Returns true if the document has comments.
        Since:
        11.1
      • hasComments

        protected boolean hasComments​(CoreSession session,
                                      DocumentModel document,
                                      String user)
        Returns true if the documents has comments from the given user.
        Since:
        11.1
      • subscribeToNotifications

        protected void subscribeToNotifications​(DocumentModel document,
                                                NuxeoPrincipal user)
        Subscribes a user to notifications on the document.
        Since:
        11.1