Interface CommentService
- Since:
- 5.0
-
Method Summary
Modifier and TypeMethodDescriptionaddComment(AddCommentRequest request) Adds a general comment on a commentable.addComment(AddFileCommentRequest request) Adds a comment on a file in a diff.addComment(AddLineCommentRequest request) Adds a comment on a line on a file in a diff.addReply(AddCommentReplyRequest request) Adds a comment reply to atread.longcountComments(CommentSearchRequest request) Count all thecommentsmatching the provided request.countCommentsByState(CommentSearchRequest request) longcountThreads(CommentSearchRequest request) Count all thethreadsmatching the provided request.booleandeleteComment(long commentId, int version) Delete a comment.getComment(long commentId) Find a comment with the given ID.search(CommentSearchRequest request, PageRequest pageRequest) Search for allcommentsmatching the provided request.searchThreads(CommentSearchRequest request, PageRequest pageRequest) Search for allthreadsmatching the provided request.updateComment(CommentUpdateRequest request) Updates acommentaccording to the providedrequest, 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
-
Method Details
-
addComment
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
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
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
Adds a comment reply to atread.- Parameters:
request- a request describing the comment to be added- Returns:
- the created comment
- Throws:
NoSuchCommentException- if the parent comment cannot be foundRepositoryArchivedException- if the repository is archived
-
countComments
Count all thecommentsmatching the provided request.If present, each one of the properties in the search request applies an extra filter to the search criteria. A
nullvalue (or an empty collection) means no filter will be applied for that property.Orphanedcomments are not counted by this endpoint.Any pending comments in the result will be limited to the ones created by the currently authenticated user.
- Parameters:
request- the request describing the search- Returns:
- the number of comments matching the request
-
countCommentsByState
Count all thecommentsmatching the provided request, grouped bystate.If present, each one of the properties in the search request applies an extra filter to the search criteria. A
nullvalue (or an empty collection) means no filter will be applied for that property.Any pending comments in the result will be limited to the ones created by the currently authenticated user.
- Parameters:
request- the request describing the search- Returns:
- the number of comments matching the request, grouped by state.
- Since:
- 6.8
-
countThreads
Count all thethreadsmatching the provided request.If present, each one of the properties in the search request applies an extra filter to the search criteria. A
nullvalue (or an empty collection) means no filter will be applied for that property.Orphanedcomments are not counted by this endpoint.Any pending comments in the result will be limited to the ones created by the currently authenticated user.
- 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 deletedversion- the expected version for the comment to delete- Returns:
trueif the comment existed and was deleted,falseotherwise- Throws:
CommentDeletionException- if the comment has repliesCommentOutOfDateException- if the providedversiondoesn't match the comment's current versionNoSuchCommentException- if the comment to delete cannot be foundRepositoryArchivedException- if the repository is archived
-
getComment
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 allcommentsmatching the provided request.If present, each one of the properties in the search request applies an extra filter to the search criteria. A
nullvalue (or an empty collection) means no filter will be applied for that property.Any pending comments in the result will be limited to the ones created by the currently authenticated user.
- Parameters:
request- the request describing the searchpageRequest- 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 allthreadsmatching the provided request.If present, each one of the properties in the search request applies an extra filter to the search criteria. A
nullvalue (or an empty collection) means no filter will be applied for that property.Orphanedcomments are not returned by this endpoint.Any pending comments in the result will be limited to the ones created by the currently authenticated user.
- Parameters:
request- the request describing the searchpageRequest- the request specifying the start and limit of the page- Returns:
- the threads matching the request
-
updateComment
Updates acommentaccording to the providedrequest, 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 providedversiondoesn't match the comment's current versionNoSuchCommentException- if the comment to update cannot be foundRepositoryArchivedException- if the repository is archived
-