use of org.alfresco.rest.framework.core.exceptions.EntityNotFoundException in project alfresco-remote-api by Alfresco.
the class ProcessDefinitionsImpl method getStartFormModel.
@Override
public CollectionWithPagingInfo<FormModelElement> getStartFormModel(String definitionId, Paging paging) {
// first validate if user is allowed to access the process definition if workflows are deployed per tenant
if (tenantService.isEnabled() && deployWorkflowsInTenant) {
ProcessDefinitionQuery query = activitiProcessEngine.getRepositoryService().createProcessDefinitionQuery().processDefinitionId(definitionId);
query.processDefinitionKeyLike("@" + TenantUtil.getCurrentDomain() + "@%");
org.activiti.engine.repository.ProcessDefinition processDefinition = query.singleResult();
if (processDefinition == null) {
throw new EntityNotFoundException(definitionId);
}
}
StartFormData startFormData = activitiProcessEngine.getFormService().getStartFormData(definitionId);
if (startFormData == null) {
throw new EntityNotFoundException(definitionId);
}
if (qNameConverter == null) {
qNameConverter = new WorkflowQNameConverter(namespaceService);
}
if (workflowFactory == null) {
workflowFactory = new WorkflowObjectFactory(qNameConverter, tenantService, messageService, dictionaryService, engineId, defaultStartTaskType);
}
// Lookup type definition for the startTask
TypeDefinition startTaskType = workflowFactory.getTaskFullTypeDefinition(startFormData.getFormKey(), true);
return getFormModelElements(startTaskType, paging);
}
use of org.alfresco.rest.framework.core.exceptions.EntityNotFoundException in project alfresco-remote-api by Alfresco.
the class ProcessesImpl method getProcessImage.
@Override
public BinaryResource getProcessImage(String processId) {
validateIfUserAllowedToWorkWithProcess(processId);
ProcessInstance processInstance = activitiProcessEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processId).singleResult();
if (processInstance == null) {
throw new EntityNotFoundException(processId);
}
try {
BpmnModel model = activitiProcessEngine.getRepositoryService().getBpmnModel(processInstance.getProcessDefinitionId());
if (model != null && model.getLocationMap().size() > 0) {
List<String> activeActivities = activitiProcessEngine.getRuntimeService().getActiveActivityIds(processId);
ProcessDiagramGenerator generator = new DefaultProcessDiagramGenerator();
InputStream generateDiagram = generator.generateDiagram(model, "png", activeActivities);
File file = TempFileProvider.createTempFile(processId + UUID.randomUUID(), ".png");
FileOutputStream fos = new FileOutputStream(file);
IOUtils.copy(generateDiagram, fos);
fos.close();
return new FileBinaryResource(file);
} else {
throw new EntityNotFoundException(processId + "/image");
}
} catch (IOException error) {
throw new ApiException("Error while getting process image.");
}
}
use of org.alfresco.rest.framework.core.exceptions.EntityNotFoundException in project alfresco-remote-api by Alfresco.
the class ProcessesImpl method updateVariable.
@Override
public Variable updateVariable(String processId, Variable variable) {
validateIfUserAllowedToWorkWithProcess(processId);
ProcessInstance processInstance = activitiProcessEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processId).singleResult();
if (processInstance == null) {
throw new EntityNotFoundException(processId);
}
return updateVariableInProcess(processId, processInstance.getProcessDefinitionId(), variable);
}
use of org.alfresco.rest.framework.core.exceptions.EntityNotFoundException in project alfresco-remote-api by Alfresco.
the class ProcessesImpl method updateVariables.
@Override
public List<Variable> updateVariables(String processId, List<Variable> variables) {
validateIfUserAllowedToWorkWithProcess(processId);
ProcessInstance processInstance = activitiProcessEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processId).singleResult();
if (processInstance == null) {
throw new EntityNotFoundException(processId);
}
List<Variable> updatedVariables = new ArrayList<Variable>();
if (variables != null) {
for (Variable variable : variables) {
updatedVariables.add(updateVariableInProcess(processId, processInstance.getProcessDefinitionId(), variable));
}
}
return updatedVariables;
}
use of org.alfresco.rest.framework.core.exceptions.EntityNotFoundException in project alfresco-remote-api by Alfresco.
the class WorkflowRestImpl method deleteItemFromProcess.
/**
* Delete an item from the process package variable
*/
public void deleteItemFromProcess(String itemId, String processId) {
NodeRef nodeRef = getNodeRef(itemId);
ActivitiScriptNode packageScriptNode = null;
try {
packageScriptNode = (ActivitiScriptNode) activitiProcessEngine.getRuntimeService().getVariable(processId, BPM_PACKAGE);
} catch (ActivitiObjectNotFoundException e) {
throw new EntityNotFoundException(processId);
}
if (packageScriptNode == null) {
throw new InvalidArgumentException("process doesn't contain a workflow package variable");
}
boolean itemIdFoundInPackage = false;
List<ChildAssociationRef> documentList = nodeService.getChildAssocs(packageScriptNode.getNodeRef());
for (ChildAssociationRef childAssociationRef : documentList) {
if (childAssociationRef.getChildRef().equals(nodeRef)) {
itemIdFoundInPackage = true;
break;
}
}
if (itemIdFoundInPackage == false) {
throw new EntityNotFoundException("Item " + itemId + " not found in the process package variable");
}
try {
nodeService.removeChild(packageScriptNode.getNodeRef(), nodeRef);
activitiWorkflowEngine.dispatchPackageUpdatedEvent(packageScriptNode, null, null, processId, null);
} catch (InvalidNodeRefException e) {
throw new EntityNotFoundException("Item " + itemId + " not found");
}
}
Aggregations