Search in sources :

Example 41 with ActivitiObjectNotFoundException

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);
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) Attachment(org.activiti.engine.task.Attachment) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 42 with ActivitiObjectNotFoundException

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());
}
Also used : Comment(org.activiti.engine.task.Comment) Task(org.activiti.engine.task.Task) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 43 with ActivitiObjectNotFoundException

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);
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) Event(org.activiti.engine.task.Event) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 44 with ActivitiObjectNotFoundException

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());
}
Also used : Task(org.activiti.engine.task.Task) Event(org.activiti.engine.task.Event) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 45 with ActivitiObjectNotFoundException

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());
}
Also used : Group(org.activiti.engine.identity.Group) Task(org.activiti.engine.task.Task) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Aggregations

ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)88 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)27 ActivitiException (org.activiti.engine.ActivitiException)26 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)26 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)17 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)15 Task (org.activiti.engine.task.Task)12 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)8 User (org.activiti.engine.identity.User)8 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)8 RestVariable (org.activiti.rest.service.api.engine.variable.RestVariable)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 IOException (java.io.IOException)7 ObjectOutputStream (java.io.ObjectOutputStream)7 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)7 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)6 RestVariableScope (org.activiti.rest.service.api.engine.variable.RestVariable.RestVariableScope)6 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)6 Comment (org.activiti.engine.task.Comment)5 DeploymentEntity (org.activiti.engine.impl.persistence.entity.DeploymentEntity)4