Search in sources :

Example 1 with ListChangeComments

use of com.google.gerrit.server.restapi.change.ListChangeComments in project gerrit by GerritCodeReview.

the class ChangeApiImpl method commentsRequest.

@Override
public CommentsRequest commentsRequest() {
    return new CommentsRequest() {

        @Override
        public Map<String, List<CommentInfo>> get() throws RestApiException {
            try {
                ListChangeComments listComments = listCommentsProvider.get();
                listComments.setContext(this.getContext());
                listComments.setContextPadding(this.getContextPadding());
                return listComments.apply(change).value();
            } catch (Exception e) {
                throw asRestApiException("Cannot get comments", e);
            }
        }

        @Override
        public List<CommentInfo> getAsList() throws RestApiException {
            try {
                ListChangeComments listComments = listCommentsProvider.get();
                listComments.setContext(this.getContext());
                listComments.setContextPadding(this.getContextPadding());
                return listComments.getComments(change);
            } catch (Exception e) {
                throw asRestApiException("Cannot get comments", e);
            }
        }
    };
}
Also used : ListChangeComments(com.google.gerrit.server.restapi.change.ListChangeComments) List(java.util.List) IdString(com.google.gerrit.extensions.restapi.IdString) CommentInfo(com.google.gerrit.extensions.common.CommentInfo) RobotCommentInfo(com.google.gerrit.extensions.common.RobotCommentInfo) ApiUtil.asRestApiException(com.google.gerrit.server.api.ApiUtil.asRestApiException) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) IllegalLabelException(com.google.gerrit.server.StarredChangesUtil.IllegalLabelException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) StorageException(com.google.gerrit.exceptions.StorageException) CmdLineException(org.kohsuke.args4j.CmdLineException)

Aggregations

StorageException (com.google.gerrit.exceptions.StorageException)1 CommentInfo (com.google.gerrit.extensions.common.CommentInfo)1 RobotCommentInfo (com.google.gerrit.extensions.common.RobotCommentInfo)1 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)1 IdString (com.google.gerrit.extensions.restapi.IdString)1 RestApiException (com.google.gerrit.extensions.restapi.RestApiException)1 IllegalLabelException (com.google.gerrit.server.StarredChangesUtil.IllegalLabelException)1 ApiUtil.asRestApiException (com.google.gerrit.server.api.ApiUtil.asRestApiException)1 ListChangeComments (com.google.gerrit.server.restapi.change.ListChangeComments)1 List (java.util.List)1 CmdLineException (org.kohsuke.args4j.CmdLineException)1