+ NetconfMessageTransformUtil.writeNormalizedRpc((ContainerNode) payload, result, rpcInput, ctx);
+ } catch (final XMLStreamException | IOException | IllegalStateException e) {
+ throw new IllegalStateException("Unable to serialize " + rpcInput, e);
+ }
+
+ final Document node = result.getNode().getOwnerDocument();
+
+ return new NetconfMessage(node);
+ }
+
+ @Override
+ public NetconfMessage toActionRequest(SchemaPath action, final DOMDataTreeIdentifier domDataTreeIdentifier,
+ final NormalizedNode<?, ?> payload) {
+ ActionDefinition actionDefinition = null;
+ SchemaPath schemaPath = action;
+ for (ActionDefinition actionDef : actions) {
+ if (actionDef.getPath().getLastComponent().equals(action.getLastComponent())) {
+ actionDefinition = actionDef;
+ schemaPath = actionDef.getPath();
+ }
+ }
+ Preconditions.checkNotNull(actionDefinition, "Action does not exist: %s", action.getLastComponent());
+
+ if (actionDefinition.getInput().getChildNodes().isEmpty()) {
+ return new NetconfMessage(NetconfMessageTransformUtil.prepareDomResultForActionRequest(
+ DataSchemaContextTree.from(schemaContext), domDataTreeIdentifier, action, counter,
+ actionDefinition.getQName().getLocalName())
+ .getNode().getOwnerDocument());
+ }
+
+ Preconditions.checkNotNull(payload, "Transforming an action with input: %s, payload cannot be null",
+ action.getLastComponent());
+ Preconditions.checkArgument(payload instanceof ContainerNode,
+ "Transforming an rpc with input: %s, payload has to be a container, but was: %s",
+ action.getLastComponent(), payload);
+ // Set the path to the input of rpc for the node stream writer
+ action = action.createChild(QName.create(action.getLastComponent(), "input").intern());
+ final DOMResult result = NetconfMessageTransformUtil.prepareDomResultForActionRequest(
+ DataSchemaContextTree.from(schemaContext), domDataTreeIdentifier, action, counter,
+ actionDefinition.getQName().getLocalName());
+
+ try {
+ NetconfMessageTransformUtil.writeNormalizedRpc((ContainerNode) payload, result,
+ schemaPath.createChild(QName.create(action.getLastComponent(), "input").intern()), schemaContext);