use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class TaskAttachmentResource method getAttachment.
@RequestMapping(value = "/runtime/tasks/{taskId}/attachments/{attachmentId}", method = RequestMethod.GET, produces = "application/json")
public AttachmentResponse getAttachment(@PathVariable("taskId") String taskId, @PathVariable("attachmentId") String attachmentId, HttpServletRequest request) {
HistoricTaskInstance task = getHistoricTaskFromRequest(taskId);
Attachment attachment = taskService.getAttachment(attachmentId);
if (attachment == null || !task.getId().equals(attachment.getTaskId())) {
throw new ActivitiObjectNotFoundException("Task '" + task.getId() + "' doesn't have an attachment with id '" + attachmentId + "'.", Comment.class);
}
return restResponseFactory.createAttachmentResponse(attachment);
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class TaskCommentResource method deleteComment.
@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());
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class TaskEventResource method getEvent.
@RequestMapping(value = "/runtime/tasks/{taskId}/events/{eventId}", method = RequestMethod.GET, produces = "application/json")
public EventResponse getEvent(@PathVariable("taskId") String taskId, @PathVariable("eventId") String eventId, HttpServletRequest request) {
HistoricTaskInstance task = getHistoricTaskFromRequest(taskId);
Event event = taskService.getEvent(eventId);
if (event == null || !task.getId().equals(event.getTaskId())) {
throw new ActivitiObjectNotFoundException("Task '" + task.getId() + "' doesn't have an event with id '" + eventId + "'.", Event.class);
}
return restResponseFactory.createEventResponse(event);
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class TaskEventResource method deleteEvent.
@RequestMapping(value = "/runtime/tasks/{taskId}/events/{eventId}", method = RequestMethod.DELETE)
public void deleteEvent(@PathVariable("taskId") String taskId, @PathVariable("eventId") String eventId, HttpServletResponse response) {
// Check if task exists
Task task = getTaskFromRequest(taskId);
Event event = taskService.getEvent(eventId);
if (event == null || event.getTaskId() == null || !event.getTaskId().equals(task.getId())) {
throw new ActivitiObjectNotFoundException("Task '" + task.getId() + "' doesn't have an event with id '" + event + "'.", Event.class);
}
taskService.deleteComment(eventId);
response.setStatus(HttpStatus.NO_CONTENT.value());
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class TaskServiceTest method testAddCandidateGroupUnexistingTask.
public void testAddCandidateGroupUnexistingTask() {
Group group = identityService.newGroup("group");
identityService.saveGroup(group);
try {
taskService.addCandidateGroup("unexistingTaskId", group.getId());
fail("ActivitiException expected");
} catch (ActivitiObjectNotFoundException ae) {
assertTextPresent("Cannot find task with id unexistingTaskId", ae.getMessage());
assertEquals(Task.class, ae.getObjectClass());
}
identityService.deleteGroup(group.getId());
}
Aggregations