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) {
}
}
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) {
}
}
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;
}
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;
}
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() + "'.");
}
}
Aggregations