Search in sources :

Example 91 with ActivitiIllegalArgumentException

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

the class SaveProcessDefinitionInfoCmd method execute.

public Void execute(CommandContext commandContext) {
    if (processDefinitionId == null) {
        throw new ActivitiIllegalArgumentException("process definition id is null");
    }
    if (infoNode == null) {
        throw new ActivitiIllegalArgumentException("process definition info node is null");
    }
    ProcessDefinitionInfoEntityManager definitionInfoEntityManager = commandContext.getProcessDefinitionInfoEntityManager();
    ProcessDefinitionInfoEntity definitionInfoEntity = definitionInfoEntityManager.findProcessDefinitionInfoByProcessDefinitionId(processDefinitionId);
    if (definitionInfoEntity == null) {
        definitionInfoEntity = new ProcessDefinitionInfoEntity();
        definitionInfoEntity.setProcessDefinitionId(processDefinitionId);
        commandContext.getProcessDefinitionInfoEntityManager().insertProcessDefinitionInfo(definitionInfoEntity);
    } else {
        commandContext.getProcessDefinitionInfoEntityManager().updateProcessDefinitionInfo(definitionInfoEntity);
    }
    if (infoNode != null) {
        try {
            ObjectWriter writer = commandContext.getProcessEngineConfiguration().getObjectMapper().writer();
            commandContext.getProcessDefinitionInfoEntityManager().updateInfoJson(definitionInfoEntity.getId(), writer.writeValueAsBytes(infoNode));
        } catch (Exception e) {
            throw new ActivitiException("Unable to serialize info node " + infoNode);
        }
    }
    return null;
}
Also used : ProcessDefinitionInfoEntityManager(org.activiti.engine.impl.persistence.entity.ProcessDefinitionInfoEntityManager) ActivitiException(org.activiti.engine.ActivitiException) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) ProcessDefinitionInfoEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionInfoEntity) ActivitiException(org.activiti.engine.ActivitiException) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException)

Example 92 with ActivitiIllegalArgumentException

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

the class SetDeploymentCategoryCmd method execute.

public Void execute(CommandContext commandContext) {
    if (deploymentId == null) {
        throw new ActivitiIllegalArgumentException("Deployment id is null");
    }
    DeploymentEntity deployment = commandContext.getDeploymentEntityManager().findDeploymentById(deploymentId);
    if (deployment == null) {
        throw new ActivitiObjectNotFoundException("No deployment found for id = '" + deploymentId + "'", Deployment.class);
    }
    // Update category
    deployment.setCategory(category);
    if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
        commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, deployment));
    }
    return null;
}
Also used : DeploymentEntity(org.activiti.engine.impl.persistence.entity.DeploymentEntity) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 93 with ActivitiIllegalArgumentException

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

the class SetProcessDefinitionVersionCmd method execute.

public Void execute(CommandContext commandContext) {
    // check that the new process definition is just another version of the same
    // process definition that the process instance is using
    ExecutionEntityManager executionManager = commandContext.getExecutionEntityManager();
    ExecutionEntity processInstance = executionManager.findExecutionById(processInstanceId);
    if (processInstance == null) {
        throw new ActivitiObjectNotFoundException("No process instance found for id = '" + processInstanceId + "'.", ProcessInstance.class);
    } else if (!processInstance.isProcessInstanceType()) {
        throw new ActivitiIllegalArgumentException("A process instance id is required, but the provided id " + "'" + processInstanceId + "' " + "points to a child execution of process instance " + "'" + processInstance.getProcessInstanceId() + "'. " + "Please invoke the " + getClass().getSimpleName() + " with a root execution id.");
    }
    ProcessDefinitionImpl currentProcessDefinitionImpl = processInstance.getProcessDefinition();
    DeploymentManager deploymentCache = commandContext.getProcessEngineConfiguration().getDeploymentManager();
    ProcessDefinitionEntity currentProcessDefinition;
    if (currentProcessDefinitionImpl instanceof ProcessDefinitionEntity) {
        currentProcessDefinition = (ProcessDefinitionEntity) currentProcessDefinitionImpl;
    } else {
        currentProcessDefinition = deploymentCache.findDeployedProcessDefinitionById(currentProcessDefinitionImpl.getId());
    }
    ProcessDefinitionEntity newProcessDefinition = deploymentCache.findDeployedProcessDefinitionByKeyAndVersion(currentProcessDefinition.getKey(), processDefinitionVersion);
    validateAndSwitchVersionOfExecution(commandContext, processInstance, newProcessDefinition);
    // switch the historic process instance to the new process definition version
    commandContext.getHistoryManager().recordProcessDefinitionChange(processInstanceId, newProcessDefinition.getId());
    // switch all sub-executions of the process instance to the new process definition version
    List<ExecutionEntity> childExecutions = executionManager.findChildExecutionsByProcessInstanceId(processInstanceId);
    for (ExecutionEntity executionEntity : childExecutions) {
        validateAndSwitchVersionOfExecution(commandContext, executionEntity, newProcessDefinition);
    }
    return null;
}
Also used : ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ProcessDefinitionImpl(org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl) DeploymentManager(org.activiti.engine.impl.persistence.deploy.DeploymentManager) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) ExecutionEntityManager(org.activiti.engine.impl.persistence.entity.ExecutionEntityManager)

Example 94 with ActivitiIllegalArgumentException

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

the class SetProcessInstanceBusinessKeyCmd method execute.

public Void execute(CommandContext commandContext) {
    ExecutionEntityManager executionManager = commandContext.getExecutionEntityManager();
    ExecutionEntity processInstance = executionManager.findExecutionById(processInstanceId);
    if (processInstance == null) {
        throw new ActivitiObjectNotFoundException("No process instance found for id = '" + processInstanceId + "'.", ProcessInstance.class);
    } else if (!processInstance.isProcessInstanceType()) {
        throw new ActivitiIllegalArgumentException("A process instance id is required, but the provided id " + "'" + processInstanceId + "' " + "points to a child execution of process instance " + "'" + processInstance.getProcessInstanceId() + "'. " + "Please invoke the " + getClass().getSimpleName() + " with a root execution id.");
    }
    processInstance.updateProcessBusinessKey(businessKey);
    return null;
}
Also used : ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) ExecutionEntityManager(org.activiti.engine.impl.persistence.entity.ExecutionEntityManager)

Example 95 with ActivitiIllegalArgumentException

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

the class SetUserPictureCmd method execute.

public Object execute(CommandContext commandContext) {
    if (userId == null) {
        throw new ActivitiIllegalArgumentException("userId is null");
    }
    User user = commandContext.getUserIdentityManager().findUserById(userId);
    if (user == null) {
        throw new ActivitiObjectNotFoundException("user " + userId + " doesn't exist", User.class);
    }
    commandContext.getUserIdentityManager().setUserPicture(userId, picture);
    return null;
}
Also used : User(org.activiti.engine.identity.User) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Aggregations

ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)153 ActivitiException (org.activiti.engine.ActivitiException)31 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)30 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)27 HashMap (java.util.HashMap)24 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)20 Deployment (org.activiti.engine.test.Deployment)16 TaskQuery (org.activiti.engine.task.TaskQuery)12 ArrayList (java.util.ArrayList)11 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)11 MultipartHttpServletRequest (org.springframework.web.multipart.MultipartHttpServletRequest)10 RestVariable (org.activiti.rest.service.api.engine.variable.RestVariable)9 UserQuery (org.activiti.engine.identity.UserQuery)8 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)8 Execution (org.activiti.engine.runtime.Execution)8 QueryVariable (org.activiti.rest.service.api.engine.variable.QueryVariable)8 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)7 Task (org.activiti.engine.task.Task)6 RestVariableScope (org.activiti.rest.service.api.engine.variable.RestVariable.RestVariableScope)6 MultipartFile (org.springframework.web.multipart.MultipartFile)6