use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class AddIdentityLinkForProcessDefinitionCmd method execute.
public Void execute(CommandContext commandContext) {
ProcessDefinitionEntity processDefinition = commandContext.getProcessDefinitionEntityManager().findProcessDefinitionById(processDefinitionId);
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("Cannot find process definition with id " + processDefinitionId, ProcessDefinition.class);
}
processDefinition.addIdentityLink(userId, groupId);
return null;
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class SetProcessDefinitionCategoryCmd method execute.
public Void execute(CommandContext commandContext) {
if (processDefinitionId == null) {
throw new ActivitiIllegalArgumentException("Process definition id is null");
}
ProcessDefinitionEntity processDefinition = commandContext.getProcessDefinitionEntityManager().findProcessDefinitionById(processDefinitionId);
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("No process definition found for id = '" + processDefinitionId + "'", ProcessDefinition.class);
}
// Update category
processDefinition.setCategory(category);
// Remove process definition from cache, it will be refetched later
DeploymentCache<ProcessDefinitionEntity> processDefinitionCache = commandContext.getProcessEngineConfiguration().getProcessDefinitionCache();
if (processDefinitionCache != null) {
processDefinitionCache.remove(processDefinitionId);
}
if (commandContext.getEventDispatcher().isEnabled()) {
commandContext.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, processDefinition));
}
return null;
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class SetProcessInstanceNameCmd method execute.
@Override
public Void execute(CommandContext commandContext) {
if (processInstanceId == null) {
throw new ActivitiIllegalArgumentException("processInstanceId is null");
}
ExecutionEntity execution = commandContext.getExecutionEntityManager().findExecutionById(processInstanceId);
if (execution == null) {
throw new ActivitiObjectNotFoundException("process instance " + processInstanceId + " doesn't exist", ProcessInstance.class);
}
if (!execution.isProcessInstanceType()) {
throw new ActivitiObjectNotFoundException("process instance " + processInstanceId + " doesn't exist, the given ID references an execution, though", ProcessInstance.class);
}
if (execution.isSuspended()) {
throw new ActivitiException("process instance " + processInstanceId + " is suspended, cannot set name");
}
// Actually set the name
execution.setName(name);
// Record the change in history
commandContext.getHistoryManager().recordProcessInstanceNameChange(processInstanceId, name);
return null;
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class RuntimeServiceTest method testSetProcessInstanceName.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testSetProcessInstanceName() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
assertNotNull(processInstance);
assertNull(processInstance.getName());
// Set the name
runtimeService.setProcessInstanceName(processInstance.getId(), "New name");
processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(processInstance);
assertEquals("New name", processInstance.getName());
// Set the name to null
runtimeService.setProcessInstanceName(processInstance.getId(), null);
processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(processInstance);
assertNull(processInstance.getName());
// Set name for unexisting process instance, should fail
try {
runtimeService.setProcessInstanceName("unexisting", null);
fail("Exception excpected");
} catch (ActivitiObjectNotFoundException aonfe) {
assertEquals(ProcessInstance.class, aonfe.getObjectClass());
}
processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(processInstance);
assertNull(processInstance.getName());
// Set name for suspended process instance, should fail
runtimeService.suspendProcessInstanceById(processInstance.getId());
try {
runtimeService.setProcessInstanceName(processInstance.getId(), null);
fail("Exception excpected");
} catch (ActivitiException ae) {
assertEquals("process instance " + processInstance.getId() + " is suspended, cannot set name", ae.getMessage());
}
processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(processInstance);
assertNull(processInstance.getName());
}
use of org.activiti.engine.ActivitiObjectNotFoundException 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;
}
Aggregations