Interface CommentService


public interface CommentService
Since:
5.0
  • Method Details

    • addComment

      @Nonnull Comment addComment(@Nonnull AddCommentRequest request)
      Adds a general comment on a commentable.
      Parameters:
      request - describes the comment to create
      Returns:
      the created comment
      Throws:
      RepositoryArchivedException - if the repository is archived
    • addComment

      @Nonnull Comment addComment(@Nonnull AddFileCommentRequest request)
      Adds a comment on a file in a diff.
      Parameters:
      request - describes the comment to create
      Returns:
      the created comment
      Throws:
      RepositoryArchivedException - if the repository is archived
    • addComment

      @Nonnull Comment addComment(@Nonnull AddLineCommentRequest request)
      Adds a comment on a line on a file in a diff.
      Parameters:
      request - describes the comment to create
      Returns:
      the created comment
      Throws:
      RepositoryArchivedException - if the repository is archived
    • addReply

      @Nonnull Comment addReply(@Nonnull AddCommentReplyRequest request)
      Adds a comment reply to a tread.
      Parameters:
      request - a request describing the comment to be added
      Returns:
      the created comment
      Throws:
      NoSuchCommentException - if the parent comment cannot be found
      RepositoryArchivedException - if the repository is archived
    • countComments

      long countComments(@Nonnull CommentSearchRequest request)
      Count all the comments matching the provided request.

      If present, each one of the properties in the search request applies an extra filter to the search criteria. A null value (or an empty collection) means no filter will be applied for that property. Orphaned comments are not counted by this endpoint.

      Parameters:
      request - the request describing the search
      Returns:
      the number of comments matching the request
    • countCommentsByState

      Map<CommentState,Long> countCommentsByState(@Nonnull CommentSearchRequest request)
      Count all the comments matching the provided request, grouped by state.

      If present, each one of the properties in the search request applies an extra filter to the search criteria. A null value (or an empty collection) means no filter will be applied for that property.

      Parameters:
      request - the request describing the search
      Returns:
      the number of comments matching the request, grouped by state.
      Since:
      6.8
    • countThreads

      long countThreads(@Nonnull CommentSearchRequest request)
      Count all the threads matching the provided request.

      If present, each one of the properties in the search request applies an extra filter to the search criteria. A null value (or an empty collection) means no filter will be applied for that property. Orphaned comments are not counted by this endpoint.

      Parameters:
      request - the request describing the search
      Returns:
      the number of threads matching the request
    • deleteComment

      boolean deleteComment(long commentId, int version)
      Delete a comment.
      Parameters:
      commentId - the ID for the comment that should be deleted
      version - the expected version for the comment to delete
      Returns:
      true if the comment existed and was deleted, false otherwise
      Throws:
      CommentDeletionException - if the comment has replies
      CommentOutOfDateException - if the provided version doesn't match the comment's current version
      NoSuchCommentException - if the comment to delete cannot be found
      RepositoryArchivedException - if the repository is archived
    • getComment

      @Nonnull Optional<Comment> getComment(long commentId)
      Find a comment with the given ID.
      Parameters:
      commentId - the ID for the comment to look for
      Returns:
      the comment with the given ID
    • search

      @Nonnull Page<Comment> search(@Nonnull CommentSearchRequest request, @Nonnull PageRequest pageRequest)
      Search for all comments matching the provided request.

      If present, each one of the properties in the search request applies an extra filter to the search criteria. A null value (or an empty collection) means no filter will be applied for that property.

      Parameters:
      request - the request describing the search
      pageRequest - the request specifying the start and limit of the page
      Returns:
      the comments matching the request
      Since:
      6.7
    • searchThreads

      @Nonnull Page<CommentThread> searchThreads(@Nonnull CommentSearchRequest request, @Nonnull PageRequest pageRequest)
      Search for all threads matching the provided request.

      If present, each one of the properties in the search request applies an extra filter to the search criteria. A null value (or an empty collection) means no filter will be applied for that property. Orphaned comments are not returned by this endpoint.

      Parameters:
      request - the request describing the search
      pageRequest - the request specifying the start and limit of the page
      Returns:
      the threads matching the request
    • updateComment

      @Nonnull Comment updateComment(@Nonnull CommentUpdateRequest request)
      Updates a comment according to the provided request, with the following restrictions:
      • only the author of the comment may update the text of the comment
      • only the author of the comment, the author of the pull request (in the case of comments on pull requests) or repository admins and above may update the other fields of a comment
      Parameters:
      request - the request describing how the comment should be updated
      Returns:
      the updated comment
      Throws:
      CommentOutOfDateException - if the provided version doesn't match the comment's current version
      NoSuchCommentException - if the comment to update cannot be found
      RepositoryArchivedException - if the repository is archived