Interface CommentManager

    • Method Detail

      • getComments

        List<DocumentModel> getComments​(DocumentModel docModel)
        Gets comments of a document.
        Parameters:
        docModel - the document model
        Returns:
        the list of comments
      • getComments

        List<DocumentModel> getComments​(CoreSession session,
                                        DocumentModel docModel)
        Gets comments of a document.
        Parameters:
        session - the core session
        docModel - the document model
        Returns:
        the list of comments
        Throws:
        CommentSecurityException - if the current user does not have the right permissions on the commented document
        Since:
        10.3
      • createComment

        @Deprecated(since="10.3",
                    forRemoval=true)
        DocumentModel createComment​(DocumentModel docModel,
                                    String comment,
                                    String author)
        Deprecated, for removal: This API element is subject to removal in a future version.
        since 10.3, use createComment(CoreSession, Comment) instead.
        Creates a comment document model, filling its properties with given info and linking it to given document.
        Parameters:
        docModel - the document to comment
        comment - the comment content
        author - the comment author
        Returns:
        the comment document model.
      • createComment

        DocumentModel createComment​(DocumentModel docModel,
                                    DocumentModel comment)
        Creates a comment document model, filling its properties with given info and linking it to given document.
        Parameters:
        docModel - the document to comment
        comment - the comment document model
        Returns:
        the created comment document model.
        Throws:
        CommentSecurityException - if the current user does not have the right permissions on the document to comment.
      • createComment

        @Deprecated(since="10.3",
                    forRemoval=true)
        DocumentModel createComment​(DocumentModel docModel,
                                    DocumentModel parent,
                                    DocumentModel child)
        Deprecated, for removal: This API element is subject to removal in a future version.
        since 10.3, use createComment(CoreSession, Comment) instead.
        Creates a comment document model, filling its properties with given info and linking it to given document.
        Parameters:
        docModel - the document to comment
        parent - the comment parent document model
        child - the comment child document model
        Returns:
        the created comment document model.
      • getDocumentsForComment

        @Deprecated(since="10.3",
                    forRemoval=true)
        List<DocumentModel> getDocumentsForComment​(DocumentModel comment)
        Deprecated, for removal: This API element is subject to removal in a future version.
        since 10.3, only used with deprecated implementation, no replacement.
        Gets documents in relation with a particular comment.
        Parameters:
        comment - the comment
        Returns:
        the list of documents
      • getThreadForComment

        @Deprecated(since="11.1")
        DocumentModel getThreadForComment​(DocumentModel comment)
        Deprecated.
        since 11.1, unused
        Gets thread in relation with a given comment (post or comment).
        Parameters:
        comment - the comment
        Returns:
        the thread
        Throws:
        CommentSecurityException - if the current user does not have the right permissions on the commented document.
        Since:
        5.5
      • createLocatedComment

        DocumentModel createLocatedComment​(DocumentModel docModel,
                                           DocumentModel comment,
                                           String path)
        Creates a comment document model. It gives opportunity to save the comments in a specified location.
        Parameters:
        docModel - the document to comment
        comment - the comment content
        path - the location path
        Returns:
        the comment document model.
        Throws:
        CommentSecurityException - if the current user does not have the right permissions on the document to comment.
      • createComment

        Comment createComment​(CoreSession session,
                              Comment comment)
        Creates a comment.
        Parameters:
        session - the core session
        Returns:
        the created comment
        Throws:
        CommentNotFoundException - if the document to comment, i.e. comment's parent, does not exist.
        CommentSecurityException - if the current user does not have the right permissions on the document to comment.
        Since:
        10.3
      • getComment

        Comment getComment​(CoreSession session,
                           String commentId)
        Gets a comment.
        Parameters:
        session - the core session
        commentId - the comment id
        Returns:
        the comment
        Throws:
        CommentNotFoundException - if the comment does not exist
        CommentSecurityException - if the current user does not have the right permissions on the commented document.
        Since:
        10.3
      • getComments

        List<Comment> getComments​(CoreSession session,
                                  String documentId)
        Gets all comments for a document.
        Parameters:
        session - the core session
        documentId - the document id
        Returns:
        the list of comments, ordered ascending by comment's creation date, or an empty list if no comment is found.
        Since:
        10.3
      • getComments

        List<Comment> getComments​(CoreSession session,
                                  String documentId,
                                  boolean sortAscending)
        Gets all comments for a document.
        Parameters:
        session - the core session
        documentId - the document id
        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.
        Since:
        10.3
      • getComments

        PartialList<Comment> getComments​(CoreSession session,
                                         String documentId,
                                         Long pageSize,
                                         Long currentPageIndex)
        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
        Returns:
        the list of comments, ordered ascending by comment's creation date, or an empty list if no comment is found.
        Since:
        10.3
      • getComments

        PartialList<Comment> getComments​(CoreSession session,
                                         String documentId,
                                         Long pageSize,
                                         Long currentPageIndex,
                                         boolean sortAscending)
        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.
        Throws:
        CommentSecurityException - if the current user does not have the right permissions on the commented document.
        Since:
        10.3
      • getComments

        List<Comment> getComments​(CoreSession session,
                                  Collection<String> documentIds)
        Gets all comments for a collection of documents.
        Parameters:
        session - the core session
        documentIds - the document ids
        Returns:
        the list of comments
        Since:
        11.3
      • updateComment

        Comment updateComment​(CoreSession session,
                              String commentId,
                              Comment comment)
        Updates a comment.
        Parameters:
        session - the core session
        commentId - the comment id
        comment - the updated comment
        Returns:
        the updated comment
        Throws:
        CommentNotFoundException - if no comment was found with the given id.
        CommentSecurityException - if the current user does not have the right permissions on the commented document.
        Since:
        10.3
      • deleteComment

        void deleteComment​(CoreSession session,
                           String commentId)
        Deletes a comment.
        Parameters:
        session - the core session
        commentId - the comment id
        Throws:
        CommentNotFoundException - if no comment was found with the given id.
        CommentSecurityException - if the current user does not have the right permissions on the commented document.
        Since:
        10.3
      • getExternalComment

        Comment getExternalComment​(CoreSession session,
                                   String documentId,
                                   String entityId)
        Gets an external comment by its entityId under the document with documentId.
        Returns:
        the comment with given entityId under the document with given documentId
        Throws:
        CommentNotFoundException - if no comment was found with the given external entity id
        CommentSecurityException - if the current user does have the right permissions on the commented document.
        Since:
        11.1
      • updateExternalComment

        Comment updateExternalComment​(CoreSession session,
                                      String documentId,
                                      String entityId,
                                      Comment comment)
        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
        Throws:
        CommentNotFoundException - if no comment was found with the given external entity id
        CommentSecurityException - if the current user does have the right permissions on the commented document.
        Since:
        11.1
      • deleteExternalComment

        void deleteExternalComment​(CoreSession session,
                                   String documentId,
                                   String entityId)
        Deletes an external comment by its {code entityId} under the document with documentId.
        Throws:
        CommentNotFoundException - if no comment was found with the given external entity id
        CommentSecurityException - if the current user does have the right permissions on the commented document.
        Since:
        11.1
      • hasFeature

        boolean hasFeature​(CommentManager.Feature feature)
        Checks if a feature is available.
        Since:
        10.3
      • getTopLevelDocumentRef

        DocumentRef getTopLevelDocumentRef​(CoreSession session,
                                           DocumentRef commentRef)
        Gets the top level ancestor document ref for the given document model comment ref. No matter how many levels of comments there is.

        Given a document fileOne, that we comment with commentOne which we reply on with replyOne

        This method will return:

        • CommentManager#getAncestorRef(session, commentOne) = fileOne
        • CommentManager#getAncestorRef(session, replyOne) = fileOne
        Parameters:
        session - the CoreSession
        commentRef - the comment document model ref
        Returns:
        the top level ancestor document ref
        Since:
        11.1