public PrismObject<NodeType> getNodeById(String nodeIdentifier, OperationResult result) throws ObjectNotFoundException { try { // QueryType q = QueryUtil.createNameQuery(nodeIdentifier); // TODO change // to query-by-node-id ObjectQuery q = ObjectQueryUtil.createNameQuery( NodeType.class, taskManager.getPrismContext(), nodeIdentifier); List<PrismObject<NodeType>> nodes = taskManager.getRepositoryService().searchObjects(NodeType.class, q, null, result); if (nodes.isEmpty()) { // result.recordFatalError("A node with identifier " + nodeIdentifier + " // does not exist."); throw new ObjectNotFoundException( "A node with identifier " + nodeIdentifier + " does not exist."); } else if (nodes.size() > 1) { throw new SystemException( "Multiple nodes with the same identifier '" + nodeIdentifier + "' in the repository."); } else { return nodes.get(0); } } catch (SchemaException e) { // should not occur throw new SystemException("Cannot get the list of nodes from the repository", e); } }