コード例 #1
0
  @RequestMapping(
      value = "/runtime/tasks/{taskId}/comments/{commentId}",
      method = RequestMethod.DELETE)
  public void deleteComment(
      @PathVariable("taskId") String taskId,
      @PathVariable("commentId") String commentId,
      HttpServletResponse response) {

    // Check if task exists
    Task task = getTaskFromRequest(taskId);

    Comment comment = taskService.getComment(commentId);
    if (comment == null
        || comment.getTaskId() == null
        || !comment.getTaskId().equals(task.getId())) {
      throw new ActivitiObjectNotFoundException(
          "Task '" + task.getId() + "' doesn't have a comment with id '" + commentId + "'.",
          Comment.class);
    }

    taskService.deleteComment(commentId);
    response.setStatus(HttpStatus.NO_CONTENT.value());
  }
コード例 #2
0
  @RequestMapping(
      value = "/runtime/tasks/{taskId}/comments/{commentId}",
      method = RequestMethod.GET,
      produces = "application/json")
  public CommentResponse getComment(
      @PathVariable("taskId") String taskId,
      @PathVariable("commentId") String commentId,
      HttpServletRequest request) {

    HistoricTaskInstance task = getHistoricTaskFromRequest(taskId);

    Comment comment = taskService.getComment(commentId);
    if (comment == null || !task.getId().equals(comment.getTaskId())) {
      throw new ActivitiObjectNotFoundException(
          "Task '" + task.getId() + "' doesn't have a comment with id '" + commentId + "'.",
          Comment.class);
    }

    String serverRootUrl = request.getRequestURL().toString();
    serverRootUrl = serverRootUrl.substring(0, serverRootUrl.indexOf("/runtime/tasks/"));

    return restResponseFactory.createRestComment(comment, serverRootUrl);
  }