@Override public boolean apply(final NormalizedNode<?, ?> input) { if (input instanceof AugmentationNode) { return true; } if (!qnames.contains(input.getNodeType())) { return true; } LOG.debug("Skipping key child {}", input); return false; } }));
private QName resolveQName(final NormalizedNode<?, ?> node, final String prefix, final String localName) { final QNameModule module; if (prefix.isEmpty()) { module = node.getNodeType().getModule(); } else { module = namespaceContext.convert(prefix); } return QName.create(module, localName); }
private QName resolveQName(final NormalizedNode<?, ?> node, final String prefix, final String localName) { final QNameModule module; if (prefix.isEmpty()) { module = node.getNodeType().getModule(); } else { module = namespaceContext.convert(prefix); } return QName.create(module, localName); }
@Override public SchemaOrderedNormalizedNodeWriter write(final NormalizedNode<?, ?> node) throws IOException { if (Objects.equals(root, schemaContext)) { currentSchemaNode = schemaContext.getDataChildByName(node.getNodeType()); } else { currentSchemaNode = root; } return write(node, currentSchemaNode); }
@Override public SchemaOrderedNormalizedNodeWriter write(final NormalizedNode<?, ?> node) throws IOException { if (Objects.equals(root, schemaContext)) { currentSchemaNode = schemaContext.getDataChildByName(node.getNodeType()); } else { currentSchemaNode = root; } return write(node, currentSchemaNode); }
@Override public String getElementNamespaceUri(final Object element) { return contextNode(element).getNodeType().getNamespace().toString(); }
@Override public String getElementNamespaceUri(final Object element) { return contextNode(element).getNodeType().getNamespace().toString(); }
@Override public String getElementName(final Object element) { return contextNode(element).getNodeType().getLocalName(); }
@Override public String getElementQName(final Object element) { return namespaceContext.jaxenQName(contextNode(element).getNodeType()); }
@Override public String getElementQName(final Object element) { return namespaceContext.jaxenQName(contextNode(element).getNodeType()); }
@Override public String getElementName(final Object element) { return contextNode(element).getNodeType().getLocalName(); }
@Nonnull @Override public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull final SchemaPath schemaPath, @Nullable final NormalizedNode<?, ?> normalizedNode) { DataObject input = null; if (normalizedNode != null) { // RPC input is optional final SchemaPath nodePatch = schemaPath.createChild(normalizedNode.getNodeType()); input = serializer.fromNormalizedNodeRpcData(nodePatch, (ContainerNode) normalizedNode); } final CompletableFuture<DataObject> result = rpcRegistry.invoke(schemaPath, input).toCompletableFuture(); final ListenableFuture<DOMRpcResult> output = getDOMRpcResult(toListenableFuture(result)); return Futures.makeChecked(output, ANY_EX_TO_RPC_EXCEPTION_MAPPER); }
public OrderedNormalizedNodeWriter write(final NormalizedNode<?, ?> node) throws IOException { if (root == schemaContext) { return write(node, schemaContext.getDataChildByName(node.getNodeType())); } return write(node, root); }
private ArrayListMultimap<QName, NormalizedNode<?, ?>> resolveAugmentations(final NormalizedNode<?, ?> child) { final ArrayListMultimap<QName, NormalizedNode<?, ?>> resolvedAugs = ArrayListMultimap.create(); for (final NormalizedNode<?, ?> node : ((AugmentationNode) child).getValue()) { if (node instanceof AugmentationNode) { resolvedAugs.putAll(resolveAugmentations(node)); } else { resolvedAugs.put(node.getNodeType(), node); } } return resolvedAugs; }
private ArrayListMultimap<QName, NormalizedNode<?, ?>> resolveAugmentations(NormalizedNode<?, ?> child) { final ArrayListMultimap<QName, NormalizedNode<?, ?>> resolvedAugs = ArrayListMultimap.create(); for (NormalizedNode<?, ?> node : ((AugmentationNode) child).getValue()) { if (node instanceof AugmentationNode) { resolvedAugs.putAll(resolveAugmentations(node)); } else { resolvedAugs.put(node.getNodeType(), node); } } return resolvedAugs; }
private static NormalizedNode<?, ?> getNodeReferencedByInstanceIdentifier(final YangInstanceIdentifier path, final NormalizedNodeContext currentNodeContext) { final NormalizedNodeNavigator navigator = (NormalizedNodeNavigator) currentNodeContext.getNavigator(); final NormalizedNode<?, ?> rootNode = navigator.getDocument().getRootNode(); final List<PathArgument> pathArguments = path.getPathArguments(); if (pathArguments.get(0).getNodeType().equals(rootNode.getNodeType())) { final List<PathArgument> relPath = pathArguments.subList(1, pathArguments.size()); final Optional<NormalizedNode<?, ?>> possibleNode = NormalizedNodes.findNode(rootNode, relPath); if (possibleNode.isPresent()) { return possibleNode.get(); } } return null; }
private ArrayListMultimap<QName, NormalizedNode<?, ?>> resolveAugmentations(final NormalizedNode<?, ?> child) { final ArrayListMultimap<QName, NormalizedNode<?, ?>> resolvedAugs = ArrayListMultimap.create(); for (final NormalizedNode<?, ?> node : ((AugmentationNode) child).getValue()) { if (node instanceof AugmentationNode) { resolvedAugs.putAll(resolveAugmentations(node)); } else { resolvedAugs.put(node.getNodeType(), node); } } return resolvedAugs; }
private static NormalizedNode<?, ?> getNodeReferencedByInstanceIdentifier(final YangInstanceIdentifier path, final NormalizedNodeContext currentNodeContext) { final NormalizedNodeNavigator navigator = (NormalizedNodeNavigator) currentNodeContext.getNavigator(); final NormalizedNode<?, ?> rootNode = navigator.getDocument().getRootNode(); final List<PathArgument> pathArguments = path.getPathArguments(); if (pathArguments.get(0).getNodeType().equals(rootNode.getNodeType())) { final List<PathArgument> relPath = pathArguments.subList(1, pathArguments.size()); final Optional<NormalizedNode<?, ?>> possibleNode = NormalizedNodes.findNode(rootNode, relPath); if (possibleNode.isPresent()) { return possibleNode.get(); } } return null; }
private void validateLeafRefNodeData(final NormalizedNode<?, ?> leaf, final LeafRefContext referencingCtx, final ModificationType modificationType, final YangInstanceIdentifier current) { final Set<Object> values = computeValues(root, createPath(referencingCtx.getAbsoluteLeafRefTargetPath()), current); if (values.contains(leaf.getValue())) { LOG.debug("Operation [{}] validate data of LEAFREF node: name[{}] = value[{}] {}", modificationType, referencingCtx.getNodeName(), leaf.getValue(), SUCCESS); return; } LOG.debug("Operation [{}] validate data of LEAFREF node: name[{}] = value[{}] {}", modificationType, referencingCtx.getNodeName(), leaf.getValue(), FAILED); LOG.debug("Invalid leafref value [{}] allowed values {} of LEAFREF node: {} leafRef target path: {}", leaf.getValue(), values, leaf.getNodeType(), referencingCtx.getAbsoluteLeafRefTargetPath()); errorsMessages.add(String.format("Invalid leafref value [%s] allowed values %s of LEAFREF node: %s leafRef " + "target path: %s", leaf.getValue(), values, leaf.getNodeType(), referencingCtx.getAbsoluteLeafRefTargetPath())); }
private static NormalizedNode<?, ?> getNodeReferencedByAbsoluteLeafref(final RevisionAwareXPath xpath, final NormalizedNodeContext currentNodeContext, final SchemaContext schemaContext, final TypedDataSchemaNode correspondingSchemaNode) { final LeafrefXPathStringParsingPathArgumentBuilder builder = new LeafrefXPathStringParsingPathArgumentBuilder( xpath.toString(), schemaContext, correspondingSchemaNode, currentNodeContext); final List<PathArgument> pathArguments = builder.build(); final NormalizedNodeNavigator navigator = (NormalizedNodeNavigator) currentNodeContext.getNavigator(); final NormalizedNode<?, ?> rootNode = navigator.getDocument().getRootNode(); if (pathArguments.get(0).getNodeType().equals(rootNode.getNodeType())) { final List<PathArgument> relPath = pathArguments.subList(1, pathArguments.size()); final Optional<NormalizedNode<?, ?>> possibleNode = NormalizedNodes.findNode(rootNode, relPath); if (possibleNode.isPresent()) { return possibleNode.get(); } } return null; }