Search in sources :

Example 51 with ActivitiIllegalArgumentException

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

the class ProcessDefinitionQueryTest method testQueryByInvalidKeyLike.

public void testQueryByInvalidKeyLike() {
    ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery().processDefinitionKeyLike("%invalid%");
    verifyQueryResults(query, 0);
    try {
        repositoryService.createProcessDefinitionQuery().processDefinitionKeyLike(null);
        fail();
    } catch (ActivitiIllegalArgumentException e) {
    }
}
Also used : ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery)

Example 52 with ActivitiIllegalArgumentException

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

the class ProcessDefinitionQueryTest method testQueryByInvalidVersion.

public void testQueryByInvalidVersion() {
    ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery().processDefinitionVersion(3);
    verifyQueryResults(query, 0);
    try {
        repositoryService.createProcessDefinitionQuery().processDefinitionVersion(-1).list();
        fail();
    } catch (ActivitiIllegalArgumentException e) {
    }
    try {
        repositoryService.createProcessDefinitionQuery().processDefinitionVersion(null).list();
        fail();
    } catch (ActivitiIllegalArgumentException e) {
    }
}
Also used : ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery)

Example 53 with ActivitiIllegalArgumentException

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

the class DeploymentManager method getBpmnModelById.

public BpmnModel getBpmnModelById(String processDefinitionId) {
    if (processDefinitionId == null) {
        throw new ActivitiIllegalArgumentException("Invalid process definition id : null");
    }
    // first try the cache
    BpmnModel bpmnModel = bpmnModelCache.get(processDefinitionId);
    if (bpmnModel == null) {
        ProcessDefinitionEntity processDefinition = findDeployedProcessDefinitionById(processDefinitionId);
        if (processDefinition == null) {
            throw new ActivitiObjectNotFoundException("no deployed process definition found with id '" + processDefinitionId + "'", ProcessDefinition.class);
        }
        // Fetch the resource
        String resourceName = processDefinition.getResourceName();
        ResourceEntity resource = Context.getCommandContext().getResourceEntityManager().findResourceByDeploymentIdAndResourceName(processDefinition.getDeploymentId(), resourceName);
        if (resource == null) {
            if (Context.getCommandContext().getDeploymentEntityManager().findDeploymentById(processDefinition.getDeploymentId()) == null) {
                throw new ActivitiObjectNotFoundException("deployment for process definition does not exist: " + processDefinition.getDeploymentId(), Deployment.class);
            } else {
                throw new ActivitiObjectNotFoundException("no resource found with name '" + resourceName + "' in deployment '" + processDefinition.getDeploymentId() + "'", InputStream.class);
            }
        }
        // Convert the bpmn 2.0 xml to a bpmn model
        BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
        bpmnModel = bpmnXMLConverter.convertToBpmnModel(new BytesStreamSource(resource.getBytes()), false, false);
        bpmnModelCache.add(processDefinition.getId(), bpmnModel);
    }
    return bpmnModel;
}
Also used : BytesStreamSource(org.activiti.engine.impl.util.io.BytesStreamSource) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ResourceEntity(org.activiti.engine.impl.persistence.entity.ResourceEntity) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) BpmnModel(org.activiti.bpmn.model.BpmnModel) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter)

Example 54 with ActivitiIllegalArgumentException

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

the class DeploymentManager method findDeployedProcessDefinitionById.

public ProcessDefinitionEntity findDeployedProcessDefinitionById(String processDefinitionId) {
    if (processDefinitionId == null) {
        throw new ActivitiIllegalArgumentException("Invalid process definition id : null");
    }
    // first try the cache
    ProcessDefinitionEntity processDefinition = processDefinitionCache.get(processDefinitionId);
    if (processDefinition == null) {
        processDefinition = Context.getCommandContext().getProcessDefinitionEntityManager().findProcessDefinitionById(processDefinitionId);
        if (processDefinition == null) {
            throw new ActivitiObjectNotFoundException("no deployed process definition found with id '" + processDefinitionId + "'", ProcessDefinition.class);
        }
        processDefinition = resolveProcessDefinition(processDefinition);
    }
    return processDefinition;
}
Also used : ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 55 with ActivitiIllegalArgumentException

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

the class ProcessDefinitionResource method executeProcessDefinitionAction.

@RequestMapping(value = "/repository/process-definitions/{processDefinitionId}", method = RequestMethod.PUT, produces = "application/json")
public ProcessDefinitionResponse executeProcessDefinitionAction(@PathVariable String processDefinitionId, @RequestBody ProcessDefinitionActionRequest actionRequest, HttpServletRequest request) {
    if (actionRequest == null) {
        throw new ActivitiIllegalArgumentException("No action found in request body.");
    }
    ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId);
    if (actionRequest.getCategory() != null) {
        // Update of category required
        repositoryService.setProcessDefinitionCategory(processDefinition.getId(), actionRequest.getCategory());
        // No need to re-fetch the ProcessDefinition entity, just update category in response
        ProcessDefinitionResponse response = restResponseFactory.createProcessDefinitionResponse(processDefinition);
        response.setCategory(actionRequest.getCategory());
        return response;
    } else {
        // Actual action
        if (actionRequest.getAction() != null) {
            if (ProcessDefinitionActionRequest.ACTION_SUSPEND.equals(actionRequest.getAction())) {
                return suspendProcessDefinition(processDefinition, actionRequest.isIncludeProcessInstances(), actionRequest.getDate());
            } else if (ProcessDefinitionActionRequest.ACTION_ACTIVATE.equals(actionRequest.getAction())) {
                return activateProcessDefinition(processDefinition, actionRequest.isIncludeProcessInstances(), actionRequest.getDate());
            }
        }
        throw new ActivitiIllegalArgumentException("Invalid action: '" + actionRequest.getAction() + "'.");
    }
}
Also used : ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)154 ActivitiException (org.activiti.engine.ActivitiException)32 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)31 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 ArrayList (java.util.ArrayList)12 TaskQuery (org.activiti.engine.task.TaskQuery)12 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)11 MultipartHttpServletRequest (org.springframework.web.multipart.MultipartHttpServletRequest)10 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)9 RestVariable (org.activiti.rest.service.api.engine.variable.RestVariable)9 UserQuery (org.activiti.engine.identity.UserQuery)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 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)6 RestVariableScope (org.activiti.rest.service.api.engine.variable.RestVariable.RestVariableScope)6 MultipartFile (org.springframework.web.multipart.MultipartFile)6