Search in sources :

Example 76 with ActivitiObjectNotFoundException

use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.

the class GetRenderedTaskFormCmd method execute.

public Object execute(CommandContext commandContext) {
    TaskEntity task = commandContext.getTaskEntityManager().findTaskById(taskId);
    if (task == null) {
        throw new ActivitiObjectNotFoundException("Task '" + taskId + "' not found", Task.class);
    }
    if (task.getTaskDefinition() == null) {
        throw new ActivitiException("Task form definition for '" + taskId + "' not found");
    }
    TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();
    if (taskFormHandler == null) {
        return null;
    }
    FormEngine formEngine = commandContext.getProcessEngineConfiguration().getFormEngines().get(formEngineName);
    if (formEngine == null) {
        throw new ActivitiException("No formEngine '" + formEngineName + "' defined process engine configuration");
    }
    TaskFormData taskForm = taskFormHandler.createTaskForm(task);
    return formEngine.renderTaskForm(taskForm);
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) TaskEntity(org.activiti.engine.impl.persistence.entity.TaskEntity) TaskFormHandler(org.activiti.engine.impl.form.TaskFormHandler) TaskFormData(org.activiti.engine.form.TaskFormData) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) FormEngine(org.activiti.engine.impl.form.FormEngine)

Example 77 with ActivitiObjectNotFoundException

use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.

the class GetStartFormCmd method execute.

public StartFormData execute(CommandContext commandContext) {
    ProcessDefinitionEntity processDefinition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(processDefinitionId);
    if (processDefinition == null) {
        throw new ActivitiObjectNotFoundException("No process definition found for id '" + processDefinitionId + "'", ProcessDefinition.class);
    }
    StartFormHandler startFormHandler = processDefinition.getStartFormHandler();
    if (startFormHandler == null) {
        throw new ActivitiException("No startFormHandler defined in process '" + processDefinitionId + "'");
    }
    return startFormHandler.createStartFormData(processDefinition);
}
Also used : StartFormHandler(org.activiti.engine.impl.form.StartFormHandler) ActivitiException(org.activiti.engine.ActivitiException) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 78 with ActivitiObjectNotFoundException

use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.

the class HistoricTaskInstanceTest method testHistoricIdentityLinksOnTask.

@Deployment
public void testHistoricIdentityLinksOnTask() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("historicIdentityLinks");
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(task);
    // Set additional identity-link not coming from process
    taskService.addUserIdentityLink(task.getId(), "gonzo", "customUseridentityLink");
    assertEquals(4, taskService.getIdentityLinksForTask(task.getId()).size());
    // Check historic identity-links when task is still active
    List<HistoricIdentityLink> historicIdentityLinks = historyService.getHistoricIdentityLinksForTask(task.getId());
    assertEquals(4, historicIdentityLinks.size());
    // Validate all links
    boolean foundCandidateUser = false, foundCandidateGroup = false, foundAssignee = false, foundCustom = false;
    for (HistoricIdentityLink link : historicIdentityLinks) {
        assertEquals(task.getId(), link.getTaskId());
        if (link.getGroupId() != null) {
            assertEquals("sales", link.getGroupId());
            foundCandidateGroup = true;
        } else {
            if (link.getType().equals("candidate")) {
                assertEquals("fozzie", link.getUserId());
                foundCandidateUser = true;
            } else if (link.getType().equals("assignee")) {
                assertEquals("kermit", link.getUserId());
                foundAssignee = true;
            } else if (link.getType().equals("customUseridentityLink")) {
                assertEquals("gonzo", link.getUserId());
                foundCustom = true;
            }
        }
    }
    assertTrue(foundAssignee);
    assertTrue(foundCandidateGroup);
    assertTrue(foundCandidateUser);
    assertTrue(foundCustom);
    // Now complete the task and check if links are still there
    taskService.complete(task.getId());
    assertEquals(4, historyService.getHistoricIdentityLinksForTask(task.getId()).size());
    // After deleting historic task, exception should be thrown when trying to get links
    historyService.deleteHistoricTaskInstance(task.getId());
    try {
        historyService.getHistoricIdentityLinksForTask(task.getId()).size();
        fail("Exception expected");
    } catch (ActivitiObjectNotFoundException aonfe) {
        assertEquals(HistoricTaskInstance.class, aonfe.getObjectClass());
    }
}
Also used : Task(org.activiti.engine.task.Task) HistoricIdentityLink(org.activiti.engine.history.HistoricIdentityLink) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) Deployment(org.activiti.engine.test.Deployment)

Example 79 with ActivitiObjectNotFoundException

use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.

the class ProcessInstanceMigrationTest method testSetProcessDefinitionVersionNonExistingPD.

@Deployment(resources = { TEST_PROCESS })
public void testSetProcessDefinitionVersionNonExistingPD() {
    // start process instance
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("receiveTask");
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
    try {
        commandExecutor.execute(new SetProcessDefinitionVersionCmd(pi.getId(), 23));
        fail("ActivitiException expected");
    } catch (ActivitiObjectNotFoundException ae) {
        assertTextPresent("no processes deployed with key = 'receiveTask' and version = '23'", ae.getMessage());
        assertEquals(ProcessDefinition.class, ae.getObjectClass());
    }
}
Also used : CommandExecutor(org.activiti.engine.impl.interceptor.CommandExecutor) SetProcessDefinitionVersionCmd(org.activiti.engine.impl.cmd.SetProcessDefinitionVersionCmd) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) Deployment(org.activiti.engine.test.Deployment)

Example 80 with ActivitiObjectNotFoundException

use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.

the class TaskServiceTest method testClaimUnexistingTaskId.

public void testClaimUnexistingTaskId() {
    User user = identityService.newUser("user");
    identityService.saveUser(user);
    try {
        taskService.claim("unexistingtaskid", user.getId());
        fail("ActivitiException expected");
    } catch (ActivitiObjectNotFoundException ae) {
        assertTextPresent("Cannot find task with id unexistingtaskid", ae.getMessage());
        assertEquals(Task.class, ae.getObjectClass());
    }
    identityService.deleteUser(user.getId());
}
Also used : Task(org.activiti.engine.task.Task) User(org.activiti.engine.identity.User) 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