+ public synchronized DOMRpcResult toRpcResult(final NetconfMessage message, final SchemaPath rpc) {
+ final NormalizedNode<?, ?> normalizedNode;
+ if (NetconfMessageTransformUtil.isDataRetrievalOperation(rpc.getLastComponent())) {
+ final Element xmlData = NetconfMessageTransformUtil.getDataSubtree(message.getDocument());
+ final ContainerSchemaNode schemaForDataRead = NetconfMessageTransformUtil.createSchemaForDataRead(schemaContext);
+ final ContainerNode dataNode = parserFactory.getContainerNodeParser().parse(Collections.singleton(xmlData), schemaForDataRead);
+
+ normalizedNode = Builders.containerBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(NetconfMessageTransformUtil.NETCONF_RPC_REPLY_QNAME))
+ .withChild(dataNode).build();
+ } else {
+ final Set<Element> documentElement = Collections.singleton(message.getDocument().getDocumentElement());
+ final RpcDefinition rpcDefinition = mappedRpcs.get(rpc.getLastComponent());
+ Preconditions.checkArgument(rpcDefinition != null, "Unable to parse response of %s, the rpc is unknown", rpc.getLastComponent());
+
+ // In case no input for rpc is defined, we can simply construct the payload here
+ if (rpcDefinition.getOutput() == null) {
+ Preconditions.checkArgument(XmlElement.fromDomDocument(message.getDocument()).getOnlyChildElementWithSameNamespaceOptionally("ok").isPresent(),
+ "Unexpected content in response of rpc: %s, %s", rpcDefinition.getQName(), message);
+ normalizedNode = null;
+ } else {
+ normalizedNode = parserFactory.getContainerNodeParser().parse(documentElement, rpcDefinition.getOutput());
+ }
+ }
+ return new DefaultDOMRpcResult(normalizedNode);