class MergeRequestRest {

    @POST
    @Path("{requestId}/comments")
    @Consumes(MediaType.TEXT_PLAIN)
    @Produces(MediaType.TEXT_PLAIN)
    @RolesAllowed("user")
    @ApiOperation("Creates a new Comment on the MergeRequest in the application with the provided information")
    public Response createComment(@Context ContainerRequestContext context,
                           @PathParam("requestId") String requestId,
                           @QueryParam("commentId") String commentId,
                           String commentStr) {
        checkStringParam(commentStr, "Comment string is required");
        User activeUser = getActiveUser(context, engineManager);

        try {
            Comment comment = null;
            if (StringUtils.isEmpty(commentId)) {
                comment = manager.createComment(createIRI(requestId, vf), activeUser, commentStr);
            } else {
                comment = manager.createComment(createIRI(requestId, vf), activeUser, commentStr,
                        createIRI(commentId, vf));
            }
            return Response.status(201).entity(comment.getResource().stringValue()).build();
        } catch (IllegalArgumentException ex) {
            throw ErrorUtils.sendError(ex, ex.getMessage(), Response.Status.BAD_REQUEST);
        } catch (IllegalStateException | MobiException ex) {
            throw ErrorUtils.sendError(ex, ex.getMessage(), Response.Status.INTERNAL_SERVER_ERROR);
        }
    }

}