Remove DocumentedException.ErrorSeverity
[netconf.git] / netconf / sal-netconf-connector / src / main / java / org / opendaylight / netconf / sal / connect / netconf / util / NetconfMessageTransformUtil.java
index 8b31af657c8b074991e7872d5264a08382b10cfe..a3d53d268f188825a5bce0d6c49d53d13e55f430 100644 (file)
@@ -31,6 +31,7 @@ import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.dom.DOMSource;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
 import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.api.FailedNetconfMessage;
@@ -42,7 +43,6 @@ import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.notifications.NetconfNotification;
 import org.opendaylight.netconf.sal.connect.util.MessageCounter;
 import org.opendaylight.netconf.util.NetconfUtil;
-import org.opendaylight.netconf.util.NodeContainerProxy;
 import org.opendaylight.netconf.util.messages.NetconfMessageUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.edit.config.input.EditContent;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionInput;
@@ -51,18 +51,21 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.not
 import org.opendaylight.yangtools.rfc7952.data.api.NormalizedMetadata;
 import org.opendaylight.yangtools.rfc7952.data.util.ImmutableNormalizedMetadata;
 import org.opendaylight.yangtools.rfc7952.data.util.ImmutableNormalizedMetadata.Builder;
+import org.opendaylight.yangtools.yang.common.ErrorSeverity;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.XMLNamespace;
+import org.opendaylight.yangtools.yang.common.YangConstants;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode;
+import org.opendaylight.yangtools.yang.data.api.schema.AnyxmlNode;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
@@ -72,10 +75,9 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.SchemaOrderedNormalizedNodeWriter;
 import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode;
 import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree;
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -88,7 +90,7 @@ public final class NetconfMessageTransformUtil {
     public static final String MESSAGE_ID_PREFIX = "m";
     public static final String MESSAGE_ID_ATTR = "message-id";
 
-    public static final QName CREATE_SUBSCRIPTION_RPC_QNAME =
+    public static final @NonNull QName CREATE_SUBSCRIPTION_RPC_QNAME =
             QName.create(CreateSubscriptionInput.QNAME, "create-subscription").intern();
     private static final String SUBTREE = "subtree";
 
@@ -96,74 +98,83 @@ public final class NetconfMessageTransformUtil {
     private static final Document BLANK_DOCUMENT = XmlUtil.newDocument();
     public static final String EVENT_TIME = "eventTime";
 
-    private NetconfMessageTransformUtil() {}
+    private NetconfMessageTransformUtil() {
 
-    public static final QName IETF_NETCONF_MONITORING =
+    }
+
+    public static final @NonNull QName IETF_NETCONF_MONITORING =
             QName.create(NetconfState.QNAME, "ietf-netconf-monitoring").intern();
-    public static final QName GET_DATA_QNAME = QName.create(IETF_NETCONF_MONITORING, "data").intern();
-    public static final QName GET_SCHEMA_QNAME = QName.create(IETF_NETCONF_MONITORING, "get-schema").intern();
-    public static final QName IETF_NETCONF_MONITORING_SCHEMA_FORMAT =
+    public static final @NonNull QName GET_DATA_QNAME = QName.create(IETF_NETCONF_MONITORING, "data").intern();
+    public static final @NonNull QName GET_SCHEMA_QNAME = QName.create(IETF_NETCONF_MONITORING, "get-schema").intern();
+    public static final @NonNull QName IETF_NETCONF_MONITORING_SCHEMA_FORMAT =
             QName.create(IETF_NETCONF_MONITORING, "format").intern();
-    public static final QName IETF_NETCONF_MONITORING_SCHEMA_LOCATION =
+    public static final @NonNull QName IETF_NETCONF_MONITORING_SCHEMA_LOCATION =
             QName.create(IETF_NETCONF_MONITORING, "location").intern();
-    public static final QName IETF_NETCONF_MONITORING_SCHEMA_IDENTIFIER =
+    public static final @NonNull QName IETF_NETCONF_MONITORING_SCHEMA_IDENTIFIER =
             QName.create(IETF_NETCONF_MONITORING, "identifier").intern();
-    public static final QName IETF_NETCONF_MONITORING_SCHEMA_VERSION =
+    public static final @NonNull QName IETF_NETCONF_MONITORING_SCHEMA_VERSION =
             QName.create(IETF_NETCONF_MONITORING, "version").intern();
-    public static final QName IETF_NETCONF_MONITORING_SCHEMA_NAMESPACE =
+    public static final @NonNull QName IETF_NETCONF_MONITORING_SCHEMA_NAMESPACE =
             QName.create(IETF_NETCONF_MONITORING, "namespace").intern();
 
-    public static final QName IETF_NETCONF_NOTIFICATIONS =
+    public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS =
             QName.create(NetconfCapabilityChange.QNAME, "ietf-netconf-notifications").intern();
 
-    public static final URI NETCONF_URI = NETCONF_QNAME.getNamespace();
-
-    public static final NodeIdentifier NETCONF_DATA_NODEID = NodeIdentifier.create(NETCONF_DATA_QNAME);
-
-    public static final QName NETCONF_RPC_REPLY_QNAME = QName.create(NETCONF_QNAME, "rpc-reply").intern();
-    public static final NodeIdentifier NETCONF_RPC_REPLY_NODEID = NodeIdentifier.create(NETCONF_RPC_REPLY_QNAME);
-
-    public static final QName NETCONF_OK_QNAME = QName.create(NETCONF_QNAME, "ok").intern();
-    public static final QName NETCONF_ERROR_OPTION_QNAME = QName.create(NETCONF_QNAME, "error-option").intern();
-    public static final NodeIdentifier NETCONF_ERROR_OPTION_NODEID = NodeIdentifier.create(NETCONF_ERROR_OPTION_QNAME);
-    public static final QName NETCONF_RUNNING_QNAME = QName.create(NETCONF_QNAME, "running").intern();
-    public static final QName NETCONF_SOURCE_QNAME = QName.create(NETCONF_QNAME, "source").intern();
-    public static final NodeIdentifier NETCONF_SOURCE_NODEID = NodeIdentifier.create(NETCONF_SOURCE_QNAME);
-    public static final QName NETCONF_CANDIDATE_QNAME = QName.create(NETCONF_QNAME, "candidate").intern();
-    public static final QName NETCONF_TARGET_QNAME = QName.create(NETCONF_QNAME, "target").intern();
-    public static final NodeIdentifier NETCONF_TARGET_NODEID = NodeIdentifier.create(NETCONF_TARGET_QNAME);
-    public static final QName NETCONF_CONFIG_QNAME = QName.create(NETCONF_QNAME, "config").intern();
-    public static final NodeIdentifier NETCONF_CONFIG_NODEID = NodeIdentifier.create(NETCONF_CONFIG_QNAME);
-
-    public static final QName NETCONF_COMMIT_QNAME = QName.create(NETCONF_QNAME, "commit").intern();
-    public static final SchemaPath NETCONF_COMMIT_PATH = toPath(NETCONF_COMMIT_QNAME);
-    public static final QName NETCONF_VALIDATE_QNAME = QName.create(NETCONF_QNAME, "validate").intern();
-    public static final NodeIdentifier NETCONF_VALIDATE_NODEID = NodeIdentifier.create(NETCONF_VALIDATE_QNAME);
-    public static final SchemaPath NETCONF_VALIDATE_PATH = toPath(NETCONF_VALIDATE_QNAME);
-    public static final QName NETCONF_COPY_CONFIG_QNAME = QName.create(NETCONF_QNAME, "copy-config").intern();
-    public static final NodeIdentifier NETCONF_COPY_CONFIG_NODEID = NodeIdentifier.create(NETCONF_COPY_CONFIG_QNAME);
-    public static final SchemaPath NETCONF_COPY_CONFIG_PATH = toPath(NETCONF_COPY_CONFIG_QNAME);
-
-    public static final QName NETCONF_OPERATION_QNAME = QName.create(NETCONF_QNAME, "operation").intern();
-    private static final QName NETCONF_OPERATION_QNAME_LEGACY = NETCONF_OPERATION_QNAME.withoutRevision().intern();
-    public static final QName NETCONF_DEFAULT_OPERATION_QNAME =
+    public static final XMLNamespace NETCONF_URI = NETCONF_QNAME.getNamespace();
+
+    public static final @NonNull NodeIdentifier NETCONF_DATA_NODEID = NodeIdentifier.create(NETCONF_DATA_QNAME);
+
+    public static final @NonNull QName NETCONF_RPC_REPLY_QNAME = QName.create(NETCONF_QNAME, "rpc-reply").intern();
+    public static final @NonNull NodeIdentifier NETCONF_RPC_REPLY_NODEID =
+        NodeIdentifier.create(NETCONF_RPC_REPLY_QNAME);
+
+    public static final @NonNull QName NETCONF_OK_QNAME = QName.create(NETCONF_QNAME, "ok").intern();
+    public static final @NonNull QName NETCONF_ERROR_OPTION_QNAME =
+        QName.create(NETCONF_QNAME, "error-option").intern();
+    public static final @NonNull NodeIdentifier NETCONF_ERROR_OPTION_NODEID =
+        NodeIdentifier.create(NETCONF_ERROR_OPTION_QNAME);
+    public static final @NonNull QName NETCONF_RUNNING_QNAME = QName.create(NETCONF_QNAME, "running").intern();
+    public static final @NonNull QName NETCONF_SOURCE_QNAME = QName.create(NETCONF_QNAME, "source").intern();
+    public static final @NonNull NodeIdentifier NETCONF_SOURCE_NODEID = NodeIdentifier.create(NETCONF_SOURCE_QNAME);
+    public static final @NonNull QName NETCONF_CANDIDATE_QNAME = QName.create(NETCONF_QNAME, "candidate").intern();
+    public static final @NonNull QName NETCONF_TARGET_QNAME = QName.create(NETCONF_QNAME, "target").intern();
+    public static final @NonNull NodeIdentifier NETCONF_TARGET_NODEID = NodeIdentifier.create(NETCONF_TARGET_QNAME);
+    public static final @NonNull QName NETCONF_CONFIG_QNAME = QName.create(NETCONF_QNAME, "config").intern();
+    public static final @NonNull NodeIdentifier NETCONF_CONFIG_NODEID = NodeIdentifier.create(NETCONF_CONFIG_QNAME);
+
+    public static final @NonNull QName NETCONF_COMMIT_QNAME = QName.create(NETCONF_QNAME, "commit").intern();
+    public static final @NonNull SchemaPath NETCONF_COMMIT_PATH = toPath(NETCONF_COMMIT_QNAME);
+    public static final @NonNull QName NETCONF_VALIDATE_QNAME = QName.create(NETCONF_QNAME, "validate").intern();
+    public static final @NonNull NodeIdentifier NETCONF_VALIDATE_NODEID = NodeIdentifier.create(NETCONF_VALIDATE_QNAME);
+    public static final @NonNull SchemaPath NETCONF_VALIDATE_PATH = toPath(NETCONF_VALIDATE_QNAME);
+    public static final @NonNull QName NETCONF_COPY_CONFIG_QNAME = QName.create(NETCONF_QNAME, "copy-config").intern();
+    public static final @NonNull NodeIdentifier NETCONF_COPY_CONFIG_NODEID =
+        NodeIdentifier.create(NETCONF_COPY_CONFIG_QNAME);
+    public static final @NonNull SchemaPath NETCONF_COPY_CONFIG_PATH = toPath(NETCONF_COPY_CONFIG_QNAME);
+
+    public static final @NonNull QName NETCONF_OPERATION_QNAME = QName.create(NETCONF_QNAME, "operation").intern();
+    private static final @NonNull QName NETCONF_OPERATION_QNAME_LEGACY =
+        NETCONF_OPERATION_QNAME.withoutRevision().intern();
+    public static final @NonNull QName NETCONF_DEFAULT_OPERATION_QNAME =
             QName.create(NETCONF_OPERATION_QNAME, "default-operation").intern();
-    public static final NodeIdentifier NETCONF_DEFAULT_OPERATION_NODEID =
+    public static final @NonNull NodeIdentifier NETCONF_DEFAULT_OPERATION_NODEID =
             NodeIdentifier.create(NETCONF_DEFAULT_OPERATION_QNAME);
-    public static final QName NETCONF_EDIT_CONFIG_QNAME = QName.create(NETCONF_QNAME, "edit-config").intern();
-    public static final NodeIdentifier NETCONF_EDIT_CONFIG_NODEID = NodeIdentifier.create(NETCONF_EDIT_CONFIG_QNAME);
-    public static final SchemaPath NETCONF_EDIT_CONFIG_PATH = toPath(NETCONF_EDIT_CONFIG_QNAME);
-    public static final QName NETCONF_GET_CONFIG_QNAME = QName.create(NETCONF_QNAME, "get-config");
-    public static final NodeIdentifier NETCONF_GET_CONFIG_NODEID = NodeIdentifier.create(NETCONF_GET_CONFIG_QNAME);
-    public static final SchemaPath NETCONF_GET_CONFIG_PATH = toPath(NETCONF_GET_CONFIG_QNAME);
-    public static final QName NETCONF_DISCARD_CHANGES_QNAME = QName.create(NETCONF_QNAME, "discard-changes");
-    public static final SchemaPath NETCONF_DISCARD_CHANGES_PATH = toPath(NETCONF_DISCARD_CHANGES_QNAME);
-    public static final QName NETCONF_TYPE_QNAME = QName.create(NETCONF_QNAME, "type").intern();
-    public static final QName NETCONF_FILTER_QNAME = QName.create(NETCONF_QNAME, "filter").intern();
-    public static final QName NETCONF_GET_QNAME = QName.create(NETCONF_QNAME, "get").intern();
-    public static final NodeIdentifier NETCONF_GET_NODEID = NodeIdentifier.create(NETCONF_GET_QNAME);
-    public static final SchemaPath NETCONF_GET_PATH = toPath(NETCONF_GET_QNAME);
-    public static final QName NETCONF_RPC_QNAME = QName.create(NETCONF_QNAME, "rpc").intern();
+    public static final @NonNull QName NETCONF_EDIT_CONFIG_QNAME = QName.create(NETCONF_QNAME, "edit-config").intern();
+    public static final @NonNull NodeIdentifier NETCONF_EDIT_CONFIG_NODEID =
+        NodeIdentifier.create(NETCONF_EDIT_CONFIG_QNAME);
+    public static final @NonNull SchemaPath NETCONF_EDIT_CONFIG_PATH = toPath(NETCONF_EDIT_CONFIG_QNAME);
+    public static final @NonNull QName NETCONF_GET_CONFIG_QNAME = QName.create(NETCONF_QNAME, "get-config");
+    public static final @NonNull NodeIdentifier NETCONF_GET_CONFIG_NODEID =
+        NodeIdentifier.create(NETCONF_GET_CONFIG_QNAME);
+    public static final @NonNull SchemaPath NETCONF_GET_CONFIG_PATH = toPath(NETCONF_GET_CONFIG_QNAME);
+    public static final @NonNull QName NETCONF_DISCARD_CHANGES_QNAME = QName.create(NETCONF_QNAME, "discard-changes");
+    public static final @NonNull SchemaPath NETCONF_DISCARD_CHANGES_PATH = toPath(NETCONF_DISCARD_CHANGES_QNAME);
+    public static final @NonNull QName NETCONF_TYPE_QNAME = QName.create(NETCONF_QNAME, "type").intern();
+    public static final @NonNull QName NETCONF_FILTER_QNAME = QName.create(NETCONF_QNAME, "filter").intern();
+    public static final @NonNull QName NETCONF_GET_QNAME = QName.create(NETCONF_QNAME, "get").intern();
+    public static final @NonNull NodeIdentifier NETCONF_GET_NODEID = NodeIdentifier.create(NETCONF_GET_QNAME);
+    public static final @NonNull SchemaPath NETCONF_GET_PATH = toPath(NETCONF_GET_QNAME);
+    public static final @NonNull QName NETCONF_RPC_QNAME = QName.create(NETCONF_QNAME, "rpc").intern();
     public static final QName YANG_QNAME = null;
     public static final URI NETCONF_ACTION_NAMESPACE = URI.create("urn:ietf:params:xml:ns:yang:1");
     public static final String NETCONF_ACTION = "action";
@@ -181,61 +192,92 @@ public final class NetconfMessageTransformUtil {
     public static final URI NETCONF_RUNNING_WRITABLE_URI = URI
             .create("urn:ietf:params:netconf:capability:writable-running:1.0");
 
-    public static final QName NETCONF_LOCK_QNAME = QName.create(NETCONF_QNAME, "lock").intern();
-    public static final NodeIdentifier NETCONF_LOCK_NODEID = NodeIdentifier.create(NETCONF_LOCK_QNAME);
-    public static final SchemaPath NETCONF_LOCK_PATH = toPath(NETCONF_LOCK_QNAME);
-    public static final QName NETCONF_UNLOCK_QNAME = QName.create(NETCONF_QNAME, "unlock").intern();
-    public static final NodeIdentifier NETCONF_UNLOCK_NODEID = NodeIdentifier.create(NETCONF_UNLOCK_QNAME);
-    public static final SchemaPath NETCONF_UNLOCK_PATH = toPath(NETCONF_UNLOCK_QNAME);
+    public static final @NonNull QName NETCONF_LOCK_QNAME = QName.create(NETCONF_QNAME, "lock").intern();
+    public static final @NonNull NodeIdentifier NETCONF_LOCK_NODEID = NodeIdentifier.create(NETCONF_LOCK_QNAME);
+    public static final @NonNull SchemaPath NETCONF_LOCK_PATH = toPath(NETCONF_LOCK_QNAME);
+    public static final @NonNull QName NETCONF_UNLOCK_QNAME = QName.create(NETCONF_QNAME, "unlock").intern();
+    public static final @NonNull NodeIdentifier NETCONF_UNLOCK_NODEID = NodeIdentifier.create(NETCONF_UNLOCK_QNAME);
+    public static final @NonNull SchemaPath NETCONF_UNLOCK_PATH = toPath(NETCONF_UNLOCK_QNAME);
 
-    public static final NodeIdentifier EDIT_CONTENT_NODEID = NodeIdentifier.create(EditContent.QNAME);
+    public static final @NonNull NodeIdentifier EDIT_CONTENT_NODEID = NodeIdentifier.create(EditContent.QNAME);
 
     // Discard changes message
-    public static final ContainerNode DISCARD_CHANGES_RPC_CONTENT = Builders.containerBuilder()
+    public static final @NonNull ContainerNode DISCARD_CHANGES_RPC_CONTENT = Builders.containerBuilder()
             .withNodeIdentifier(NodeIdentifier.create(NETCONF_DISCARD_CHANGES_QNAME)).build();
 
     // Commit changes message
-    public static final ContainerNode COMMIT_RPC_CONTENT = Builders.containerBuilder()
+    public static final @NonNull ContainerNode COMMIT_RPC_CONTENT = Builders.containerBuilder()
             .withNodeIdentifier(NodeIdentifier.create(NETCONF_COMMIT_QNAME)).build();
 
     // Get message
-    public static final ContainerNode GET_RPC_CONTENT = Builders.containerBuilder()
+    public static final @NonNull ContainerNode GET_RPC_CONTENT = Builders.containerBuilder()
             .withNodeIdentifier(NETCONF_GET_NODEID).build();
 
     // Create-subscription changes message
-    public static final ContainerNode CREATE_SUBSCRIPTION_RPC_CONTENT = Builders.containerBuilder()
+    public static final @NonNull ContainerNode CREATE_SUBSCRIPTION_RPC_CONTENT = Builders.containerBuilder()
             .withNodeIdentifier(NodeIdentifier.create(CREATE_SUBSCRIPTION_RPC_QNAME)).build();
 
-    public static final SchemaPath CREATE_SUBSCRIPTION_RPC_PATH = toPath(CREATE_SUBSCRIPTION_RPC_QNAME);
+    public static final @NonNull SchemaPath CREATE_SUBSCRIPTION_RPC_PATH = toPath(CREATE_SUBSCRIPTION_RPC_QNAME);
 
-    public static final NodeIdentifier NETCONF_FILTER_NODEID = NodeIdentifier.create(NETCONF_FILTER_QNAME);
+    public static final @NonNull NodeIdentifier NETCONF_FILTER_NODEID = NodeIdentifier.create(NETCONF_FILTER_QNAME);
 
-    public static final DataContainerChild<?, ?> EMPTY_FILTER;
+    public static final @NonNull AnyxmlNode<?> EMPTY_FILTER = buildFilterStructure(getNetconfFilterElement());
 
-    static {
-        final Element element = XmlUtil.createElement(BLANK_DOCUMENT, NETCONF_FILTER_QNAME.getLocalName(),
-                Optional.of(NETCONF_FILTER_QNAME.getNamespace().toString()));
-        element.setAttributeNS(NETCONF_FILTER_QNAME.getNamespace().toString(),
-                NETCONF_TYPE_QNAME.getLocalName(), SUBTREE);
+    /**
+     * Creation of the subtree filter structure using {@link YangInstanceIdentifier} path.
+     *
+     * @param identifier parent path / query
+     * @param ctx        mountpoint schema context
+     * @return created DOM structure with subtree filter
+     */
+    public static AnyxmlNode<?> toFilterStructure(final YangInstanceIdentifier identifier,
+                                                       final EffectiveModelContext ctx) {
+        final Element element = getNetconfFilterElement();
+        try {
+            NetconfUtil.writeFilter(identifier, new DOMResult(element), SchemaPath.ROOT, ctx);
+        } catch (IOException | XMLStreamException e) {
+            throw new IllegalStateException("Unable to serialize filter element for path " + identifier, e);
+        }
+        return buildFilterStructure(element);
+    }
 
-        EMPTY_FILTER = Builders.anyXmlBuilder().withNodeIdentifier(NETCONF_FILTER_NODEID)
-                .withValue(new DOMSource(element)).build();
+    /**
+     * Creation of the subtree filter structure using list of parent {@link YangInstanceIdentifier}
+     * and specific selection fields. Field paths are relative to parent query path.
+     *
+     * @param fieldsFilters list of: parent path and selection fields
+     * @param ctx           mountpoint schema context
+     * @return created DOM structure with subtree filter
+     */
+    public static AnyxmlNode<?> toFilterStructure(final List<FieldsFilter> fieldsFilters,
+                                                  final EffectiveModelContext ctx) {
+        Preconditions.checkState(!fieldsFilters.isEmpty(), "An empty list of subtree filters is not allowed");
+        final Element element = getNetconfFilterElement();
+
+        for (final FieldsFilter filter : fieldsFilters) {
+            try {
+                NetconfUtil.writeFilter(filter.path(), new DOMResult(element), SchemaPath.ROOT, ctx, filter.fields());
+            } catch (IOException | XMLStreamException e) {
+                throw new IllegalStateException(String.format(
+                        "Unable to serialize filter element for path %s with fields: %s",
+                        filter.path(), filter.fields()), e);
+            }
+        }
+        return buildFilterStructure(element);
     }
 
-    public static DataContainerChild<?, ?> toFilterStructure(final YangInstanceIdentifier identifier,
-                                                             final SchemaContext ctx) {
+    private static Element getNetconfFilterElement() {
         final Element element = XmlUtil.createElement(BLANK_DOCUMENT, NETCONF_FILTER_QNAME.getLocalName(),
                 Optional.of(NETCONF_FILTER_QNAME.getNamespace().toString()));
         element.setAttributeNS(NETCONF_FILTER_QNAME.getNamespace().toString(), NETCONF_TYPE_QNAME.getLocalName(),
                 SUBTREE);
+        return element;
+    }
 
-        try {
-            NetconfUtil.writeFilter(identifier, new DOMResult(element), SchemaPath.ROOT, ctx);
-        } catch (IOException | XMLStreamException e) {
-            throw new IllegalStateException("Unable to serialize filter element for path " + identifier, e);
-        }
-
-        return Builders.anyXmlBuilder().withNodeIdentifier(NETCONF_FILTER_NODEID).withValue(new DOMSource(element))
+    private static AnyxmlNode<?> buildFilterStructure(final Element element) {
+        return Builders.anyXmlBuilder()
+                .withNodeIdentifier(NETCONF_FILTER_NODEID)
+                .withValue(new DOMSource(element))
                 .build();
     }
 
@@ -253,7 +295,7 @@ public final class NetconfMessageTransformUtil {
             throw new NetconfDocumentedException("Response message contained unknown \"message-id\"",
                     null, NetconfDocumentedException.ErrorType.PROTOCOL,
                     NetconfDocumentedException.ErrorTag.BAD_ATTRIBUTE,
-                    NetconfDocumentedException.ErrorSeverity.ERROR, errorInfo);
+                    ErrorSeverity.ERROR, errorInfo);
         }
     }
 
@@ -274,8 +316,7 @@ public final class NetconfMessageTransformUtil {
             }
         }
 
-        final ErrorSeverity severity = toRpcErrorSeverity(ex.getErrorSeverity());
-        return severity == ErrorSeverity.ERROR
+        return ex.getErrorSeverity() == ErrorSeverity.ERROR
                 ? RpcResultBuilder.newError(toRpcErrorType(ex.getErrorType()), ex.getErrorTag().getTagValue(),
                         ex.getLocalizedMessage(), null, infoBuilder.toString(), ex.getCause())
                 : RpcResultBuilder.newWarning(
@@ -283,15 +324,6 @@ public final class NetconfMessageTransformUtil {
                         ex.getLocalizedMessage(), null, infoBuilder.toString(), ex.getCause());
     }
 
-    private static ErrorSeverity toRpcErrorSeverity(final NetconfDocumentedException.ErrorSeverity severity) {
-        switch (severity) {
-            case WARNING:
-                return RpcError.ErrorSeverity.WARNING;
-            default:
-                return RpcError.ErrorSeverity.ERROR;
-        }
-    }
-
     private static RpcError.ErrorType toRpcErrorType(final NetconfDocumentedException.ErrorType type) {
         switch (type) {
             case PROTOCOL:
@@ -323,33 +355,24 @@ public final class NetconfMessageTransformUtil {
                 || NETCONF_GET_QNAME.getLocalName().equals(rpc.getLocalName()));
     }
 
-    public static ContainerSchemaNode createSchemaForDataRead(final SchemaContext schemaContext) {
-        return new NodeContainerProxy(NETCONF_DATA_QNAME, schemaContext.getChildNodes());
-    }
-
-    public static ContainerSchemaNode createSchemaForNotification(final NotificationDefinition next) {
-        return new NodeContainerProxy(next.getQName(), next.getChildNodes(), next.getAvailableAugmentations());
-    }
-
     @Deprecated
-    public static ContainerNode wrap(final QName name, final DataContainerChild<?, ?>... node) {
+    public static @NonNull ContainerNode wrap(final QName name, final DataContainerChild... node) {
         return wrap(toId(name), node);
     }
 
-    public static ContainerNode wrap(final NodeIdentifier name, final DataContainerChild<?, ?>... node) {
+    public static @NonNull ContainerNode wrap(final NodeIdentifier name, final DataContainerChild... node) {
         return Builders.containerBuilder().withNodeIdentifier(name).withValue(ImmutableList.copyOf(node)).build();
     }
 
-    public static AnyXmlNode createEditConfigAnyxml(
-            final SchemaContext ctx, final YangInstanceIdentifier dataPath,
-            final Optional<ModifyAction> operation,
-            final Optional<NormalizedNode<?, ?>> lastChildOverride) {
-        final NormalizedNode<?, ?> configContent;
+    public static DOMSourceAnyxmlNode createEditConfigAnyxml(
+            final EffectiveModelContext ctx, final YangInstanceIdentifier dataPath,
+            final Optional<ModifyAction> operation, final Optional<NormalizedNode> lastChildOverride) {
+        final NormalizedNode configContent;
         final NormalizedMetadata metadata;
         if (dataPath.isEmpty()) {
             Preconditions.checkArgument(lastChildOverride.isPresent(),
                     "Data has to be present when creating structure for top level element");
-            Preconditions.checkArgument(lastChildOverride.get() instanceof DataContainerChild<?, ?>,
+            Preconditions.checkArgument(lastChildOverride.get() instanceof DataContainerChild,
                     "Data has to be either container or a list node when creating structure for top level element, "
                             + "but was: %s", lastChildOverride.get());
             configContent = lastChildOverride.get();
@@ -396,14 +419,14 @@ public final class NetconfMessageTransformUtil {
         }
     }
 
-    public static DataContainerChild<?, ?> createEditConfigStructure(final SchemaContext ctx,
+    public static DataContainerChild createEditConfigStructure(final EffectiveModelContext ctx,
             final YangInstanceIdentifier dataPath, final Optional<ModifyAction> operation,
-            final Optional<NormalizedNode<?, ?>> lastChildOverride) {
+            final Optional<NormalizedNode> lastChildOverride) {
         return Builders.choiceBuilder().withNodeIdentifier(EDIT_CONTENT_NODEID)
                 .withChild(createEditConfigAnyxml(ctx, dataPath, operation, lastChildOverride)).build();
     }
 
-    public static SchemaPath toPath(final QName rpc) {
+    public static @NonNull SchemaPath toPath(final QName rpc) {
         return SchemaPath.ROOT.createChild(rpc);
     }
 
@@ -454,8 +477,7 @@ public final class NetconfMessageTransformUtil {
     }
 
     public static DOMResult prepareDomResultForActionRequest(final DataSchemaContextTree dataSchemaContextTree,
-            final DOMDataTreeIdentifier domDataTreeIdentifier, final SchemaPath actionSchemaPath,
-            final MessageCounter counter, final String action) {
+            final DOMDataTreeIdentifier domDataTreeIdentifier, final MessageCounter counter, final QName action) {
         final Document document = XmlUtil.newDocument();
         final Element rpcNS =
                 document.createElementNS(NETCONF_RPC_QNAME.getNamespace().toString(), NETCONF_RPC_QNAME.getLocalName());
@@ -467,7 +489,8 @@ public final class NetconfMessageTransformUtil {
         final Element actionData = prepareActionData(rootSchemaContextNode, actionNS,
                 domDataTreeIdentifier.getRootIdentifier().getPathArguments().iterator(), document);
 
-        final Element specificActionElement = document.createElement(action);
+        final Element specificActionElement =
+                document.createElementNS(action.getNamespace().toString(), action.getLocalName());
         actionData.appendChild(specificActionElement);
         rpcNS.appendChild(actionNS);
         document.appendChild(rpcNS);
@@ -490,7 +513,7 @@ public final class NetconfMessageTransformUtil {
             final Element actualElement = document.createElementNS(actualNS.getNamespace().toString(),
                     actualNS.getLocalName());
             if (next instanceof NodeWithValue) {
-                actualElement.setNodeValue(((NodeWithValue) next).getValue().toString());
+                actualElement.setNodeValue(((NodeWithValue<?>) next).getValue().toString());
             } else if (next instanceof NodeIdentifierWithPredicates) {
                 for (Entry<QName, Object> entry : ((NodeIdentifierWithPredicates) next).entrySet()) {
                     final Element entryElement = document.createElementNS(entry.getKey().getNamespace().toString(),
@@ -508,16 +531,20 @@ public final class NetconfMessageTransformUtil {
     }
 
     @SuppressWarnings("checkstyle:IllegalCatch")
-    public static void writeNormalizedRpc(final ContainerNode normalized, final DOMResult result,
-                                          final SchemaPath schemaPath,
-                                          final SchemaContext baseNetconfCtx) throws IOException, XMLStreamException {
+    public static void writeNormalizedOperationInput(final ContainerNode normalized, final DOMResult result,
+            final Absolute operationPath, final EffectiveModelContext baseNetconfCtx)
+                throws IOException, XMLStreamException {
+        final QName inputQName = YangConstants.operationInputQName(operationPath.lastNodeIdentifier().getModule());
+        // FIXME: eliminate this conversion
+        final SchemaPath inputPath = operationPath.asSchemaPath().createChild(inputQName);
+
         final XMLStreamWriter writer = NetconfUtil.XML_FACTORY.createXMLStreamWriter(result);
         try {
             try (NormalizedNodeStreamWriter normalizedNodeStreamWriter =
-                    XMLStreamNormalizedNodeStreamWriter.create(writer, baseNetconfCtx, schemaPath)) {
+                    XMLStreamNormalizedNodeStreamWriter.create(writer, baseNetconfCtx, inputPath)) {
                 try (SchemaOrderedNormalizedNodeWriter normalizedNodeWriter =
-                        new SchemaOrderedNormalizedNodeWriter(normalizedNodeStreamWriter, baseNetconfCtx, schemaPath)) {
-                    final Collection<DataContainerChild<?, ?>> value = normalized.getValue();
+                        new SchemaOrderedNormalizedNodeWriter(normalizedNodeStreamWriter, baseNetconfCtx, inputPath)) {
+                    final Collection<DataContainerChild> value = normalized.body();
                     normalizedNodeWriter.write(value);
                     normalizedNodeWriter.flush();
                 }
@@ -533,13 +560,10 @@ public final class NetconfMessageTransformUtil {
 
     public static RpcResult<NetconfMessage> toRpcResult(final FailedNetconfMessage message) {
         return RpcResultBuilder.<NetconfMessage>failed()
-                .withRpcError(
-                        toRpcError(
-                                new NetconfDocumentedException(
-                                        message.getException().getMessage(),
-                                        DocumentedException.ErrorType.APPLICATION,
-                                        DocumentedException.ErrorTag.MALFORMED_MESSAGE,
-                                        DocumentedException.ErrorSeverity.ERROR)))
+                .withRpcError(toRpcError(new NetconfDocumentedException(message.getException().getMessage(),
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.MALFORMED_MESSAGE,
+                    ErrorSeverity.ERROR)))
                 .build();
     }
 }