Search in sources :

Example 6 with ActivitiObjectNotFoundException

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

the class GetIdentityLinksForProcessDefinitionCmd method execute.

@SuppressWarnings({ "unchecked", "rawtypes" })
public List<IdentityLink> execute(CommandContext commandContext) {
    ProcessDefinitionEntity processDefinition = commandContext.getProcessDefinitionEntityManager().findProcessDefinitionById(processDefinitionId);
    if (processDefinition == null) {
        throw new ActivitiObjectNotFoundException("Cannot find process definition with id " + processDefinitionId, ProcessDefinition.class);
    }
    List<IdentityLink> identityLinks = (List) processDefinition.getIdentityLinks();
    return identityLinks;
}
Also used : List(java.util.List) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) IdentityLink(org.activiti.engine.task.IdentityLink)

Example 7 with ActivitiObjectNotFoundException

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

the class GetRenderedStartFormCmd method execute.

public Object execute(CommandContext commandContext) {
    ProcessDefinitionEntity processDefinition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(processDefinitionId);
    if (processDefinition == null) {
        throw new ActivitiObjectNotFoundException("Process Definition '" + processDefinitionId + "' not found", ProcessDefinition.class);
    }
    StartFormHandler startFormHandler = processDefinition.getStartFormHandler();
    if (startFormHandler == null) {
        return null;
    }
    FormEngine formEngine = commandContext.getProcessEngineConfiguration().getFormEngines().get(formEngineName);
    if (formEngine == null) {
        throw new ActivitiException("No formEngine '" + formEngineName + "' defined process engine configuration");
    }
    StartFormData startForm = startFormHandler.createStartFormData(processDefinition);
    return formEngine.renderStartForm(startForm);
}
Also used : StartFormHandler(org.activiti.engine.impl.form.StartFormHandler) ActivitiException(org.activiti.engine.ActivitiException) StartFormData(org.activiti.engine.form.StartFormData) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) FormEngine(org.activiti.engine.impl.form.FormEngine)

Example 8 with ActivitiObjectNotFoundException

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

the class DeleteCommentCmd method execute.

public Void execute(CommandContext commandContext) {
    CommentEntityManager commentManager = commandContext.getCommentEntityManager();
    if (commentId != null) {
        // Delete for an individual comment
        Comment comment = commentManager.findComment(commentId);
        if (comment == null) {
            throw new ActivitiObjectNotFoundException("Comment with id '" + commentId + "' doesn't exists.", Comment.class);
        }
        commentManager.delete((CommentEntity) comment);
    } else {
        // Delete all comments on a task of process
        ArrayList<Comment> comments = new ArrayList<Comment>();
        if (processInstanceId != null) {
            comments.addAll(commentManager.findCommentsByProcessInstanceId(processInstanceId));
        }
        if (taskId != null) {
            comments.addAll(commentManager.findCommentsByTaskId(taskId));
        }
        for (Comment comment : comments) {
            commentManager.delete((CommentEntity) comment);
        }
    }
    return null;
}
Also used : Comment(org.activiti.engine.task.Comment) CommentEntityManager(org.activiti.engine.impl.persistence.entity.CommentEntityManager) ArrayList(java.util.ArrayList) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 9 with ActivitiObjectNotFoundException

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

the class DeleteHistoricProcessInstanceCmd method execute.

public Object execute(CommandContext commandContext) {
    if (processInstanceId == null) {
        throw new ActivitiIllegalArgumentException("processInstanceId is null");
    }
    // Check if process instance is still running
    HistoricProcessInstance instance = commandContext.getHistoricProcessInstanceEntityManager().findHistoricProcessInstance(processInstanceId);
    if (instance == null) {
        throw new ActivitiObjectNotFoundException("No historic process instance found with id: " + processInstanceId, HistoricProcessInstance.class);
    }
    if (instance.getEndTime() == null) {
        throw new ActivitiException("Process instance is still running, cannot delete historic process instance: " + processInstanceId);
    }
    commandContext.getHistoricProcessInstanceEntityManager().deleteHistoricProcessInstanceById(processInstanceId);
    return null;
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 10 with ActivitiObjectNotFoundException

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

the class AbstractSetProcessInstanceStateCmd method execute.

public Void execute(CommandContext commandContext) {
    if (executionId == null) {
        throw new ActivitiIllegalArgumentException("ProcessInstanceId cannot be null.");
    }
    ExecutionEntity executionEntity = commandContext.getExecutionEntityManager().findExecutionById(executionId);
    if (executionEntity == null) {
        throw new ActivitiObjectNotFoundException("Cannot find processInstance for id '" + executionId + "'.", Execution.class);
    }
    if (!executionEntity.isProcessInstanceType()) {
        throw new ActivitiException("Cannot set suspension state for execution '" + executionId + "': not a process instance.");
    }
    SuspensionStateUtil.setSuspensionState(executionEntity, getNewState());
    // All child executions are suspended
    List<ExecutionEntity> childExecutions = commandContext.getExecutionEntityManager().findChildExecutionsByProcessInstanceId(executionId);
    for (ExecutionEntity childExecution : childExecutions) {
        if (!childExecution.getId().equals(executionId)) {
            SuspensionStateUtil.setSuspensionState(childExecution, getNewState());
        }
    }
    // All tasks are suspended
    List<TaskEntity> tasks = commandContext.getTaskEntityManager().findTasksByProcessInstanceId(executionId);
    for (TaskEntity taskEntity : tasks) {
        SuspensionStateUtil.setSuspensionState(taskEntity, getNewState());
    }
    return null;
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) TaskEntity(org.activiti.engine.impl.persistence.entity.TaskEntity) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Aggregations

ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)87 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)27 ActivitiException (org.activiti.engine.ActivitiException)25 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)25 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)16 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)15 Task (org.activiti.engine.task.Task)12 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 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)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