use of org.alfresco.service.cmr.repository.InvalidNodeRefException 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