Search in sources :

Example 1 with CommentDto

use of org.camunda.bpm.engine.rest.dto.task.CommentDto in project camunda-bpm-platform by camunda.

the class TaskCommentResourceImpl method createComment.

public CommentDto createComment(UriInfo uriInfo, CommentDto commentDto) {
    ensureHistoryEnabled(Status.FORBIDDEN);
    ensureTaskExists(Status.BAD_REQUEST);
    Comment comment;
    try {
        comment = engine.getTaskService().createComment(taskId, null, commentDto.getMessage());
    } catch (ProcessEngineException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e, "Not enough parameters submitted");
    }
    URI uri = uriInfo.getBaseUriBuilder().path(rootResourcePath).path(TaskRestService.PATH).path(taskId + "/comment/" + comment.getId()).build();
    CommentDto resultDto = CommentDto.fromComment(comment);
    // GET /
    resultDto.addReflexiveLink(uri, HttpMethod.GET, "self");
    return resultDto;
}
Also used : Comment(org.camunda.bpm.engine.task.Comment) CommentDto(org.camunda.bpm.engine.rest.dto.task.CommentDto) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) URI(java.net.URI) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 2 with CommentDto

use of org.camunda.bpm.engine.rest.dto.task.CommentDto in project camunda-bpm-platform by camunda.

the class TaskCommentResourceImpl method getComments.

public List<CommentDto> getComments() {
    if (!isHistoryEnabled()) {
        return Collections.emptyList();
    }
    ensureTaskExists(Status.NOT_FOUND);
    List<Comment> taskComments = engine.getTaskService().getTaskComments(taskId);
    List<CommentDto> comments = new ArrayList<CommentDto>();
    for (Comment comment : taskComments) {
        comments.add(CommentDto.fromComment(comment));
    }
    return comments;
}
Also used : Comment(org.camunda.bpm.engine.task.Comment) ArrayList(java.util.ArrayList) CommentDto(org.camunda.bpm.engine.rest.dto.task.CommentDto)

Aggregations

CommentDto (org.camunda.bpm.engine.rest.dto.task.CommentDto)2 Comment (org.camunda.bpm.engine.task.Comment)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1