Remove RestconfError.ErrorType
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / netconf / sal / restconf / impl / BrokerFacade.java
index 3a4c0ec1cf310555d8c64df1fad14f9574d2f46a..78ec0b719e8e57209d7f0323d2535a6950ab6471 100644 (file)
@@ -31,7 +31,6 @@ import javax.annotation.PreDestroy;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import javax.ws.rs.core.Response.Status;
-import org.apache.aries.blueprint.annotation.service.Reference;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
@@ -55,7 +54,6 @@ import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
-import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
 import org.opendaylight.restconf.common.patch.PatchContext;
 import org.opendaylight.restconf.common.patch.PatchEditOperation;
 import org.opendaylight.restconf.common.patch.PatchEntity;
@@ -63,6 +61,7 @@ import org.opendaylight.restconf.common.patch.PatchStatusContext;
 import org.opendaylight.restconf.common.patch.PatchStatusEntity;
 import org.opendaylight.restconf.common.util.DataChangeScope;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
@@ -76,13 +75,14 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.OrderedLeafSetNode;
-import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
+import org.opendaylight.yangtools.yang.data.api.schema.UserLeafSetNode;
+import org.opendaylight.yangtools.yang.data.api.schema.UserMapNode;
+import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder;
+import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
+import org.opendaylight.yangtools.yang.data.api.schema.builder.NormalizedNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.SchemaAwareBuilders;
 import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode;
 import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
@@ -98,21 +98,19 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @Singleton
-@SuppressWarnings("checkstyle:FinalClass")
 public class BrokerFacade implements Closeable {
     private static final Logger LOG = LoggerFactory.getLogger(BrokerFacade.class);
 
-    private volatile DOMRpcService rpcService;
-
-    private final DOMDataBroker domDataBroker;
+    private final ThreadLocal<Boolean> isMounted = new ThreadLocal<>();
     private final DOMNotificationService domNotification;
     private final ControllerContext controllerContext;
+    private final DOMDataBroker domDataBroker;
 
-    private final ThreadLocal<Boolean> isMounted = new ThreadLocal<>();
+    private volatile DOMRpcService rpcService;
 
     @Inject
-    public BrokerFacade(final @Reference DOMRpcService rpcService, final DOMDataBroker domDataBroker,
-            final @Reference DOMNotificationService domNotification, final ControllerContext controllerContext) {
+    public BrokerFacade(final DOMRpcService rpcService, final DOMDataBroker domDataBroker,
+            final DOMNotificationService domNotification, final ControllerContext controllerContext) {
         this.rpcService = requireNonNull(rpcService);
         this.domDataBroker = requireNonNull(domDataBroker);
         this.domNotification = requireNonNull(domNotification);
@@ -144,7 +142,7 @@ public class BrokerFacade implements Closeable {
      *            path of data
      * @return read date
      */
-    public NormalizedNode<?, ?> readConfigurationData(final YangInstanceIdentifier path) {
+    public NormalizedNode readConfigurationData(final YangInstanceIdentifier path) {
         return readConfigurationData(path, null);
     }
 
@@ -157,7 +155,7 @@ public class BrokerFacade implements Closeable {
      *            value of with-defaults parameter
      * @return read date
      */
-    public NormalizedNode<?, ?> readConfigurationData(final YangInstanceIdentifier path, final String withDefa) {
+    public NormalizedNode readConfigurationData(final YangInstanceIdentifier path, final String withDefa) {
         try (DOMDataTreeReadTransaction tx = this.domDataBroker.newReadOnlyTransaction()) {
             return readDataViaTransaction(tx, CONFIGURATION, path, withDefa);
         }
@@ -172,8 +170,7 @@ public class BrokerFacade implements Closeable {
      *            path of data
      * @return read data
      */
-    public NormalizedNode<?, ?> readConfigurationData(final DOMMountPoint mountPoint,
-            final YangInstanceIdentifier path) {
+    public NormalizedNode readConfigurationData(final DOMMountPoint mountPoint, final YangInstanceIdentifier path) {
         return readConfigurationData(mountPoint, path, null);
     }
 
@@ -188,7 +185,7 @@ public class BrokerFacade implements Closeable {
      *            value of with-defaults parameter
      * @return read data
      */
-    public NormalizedNode<?, ?> readConfigurationData(final DOMMountPoint mountPoint, final YangInstanceIdentifier path,
+    public NormalizedNode readConfigurationData(final DOMMountPoint mountPoint, final YangInstanceIdentifier path,
             final String withDefa) {
         final Optional<DOMDataBroker> domDataBrokerService = mountPoint.getService(DOMDataBroker.class);
         if (domDataBrokerService.isPresent()) {
@@ -206,7 +203,7 @@ public class BrokerFacade implements Closeable {
      *            path of data
      * @return read data
      */
-    public NormalizedNode<?, ?> readOperationalData(final YangInstanceIdentifier path) {
+    public NormalizedNode readOperationalData(final YangInstanceIdentifier path) {
         try (DOMDataTreeReadTransaction tx = this.domDataBroker.newReadOnlyTransaction()) {
             return readDataViaTransaction(tx, OPERATIONAL, path);
         }
@@ -221,7 +218,7 @@ public class BrokerFacade implements Closeable {
      *            path of data
      * @return read data
      */
-    public NormalizedNode<?, ?> readOperationalData(final DOMMountPoint mountPoint, final YangInstanceIdentifier path) {
+    public NormalizedNode readOperationalData(final DOMMountPoint mountPoint, final YangInstanceIdentifier path) {
         final Optional<DOMDataBroker> domDataBrokerService = mountPoint.getService(DOMDataBroker.class);
         if (domDataBrokerService.isPresent()) {
             try (DOMDataTreeReadTransaction tx = domDataBrokerService.get().newReadOnlyTransaction()) {
@@ -250,9 +247,8 @@ public class BrokerFacade implements Closeable {
      *            insert
      * @return wrapper of status and future of PUT
      */
-    public PutResult commitConfigurationDataPut(
-            final EffectiveModelContext globalSchema, final YangInstanceIdentifier path,
-            final NormalizedNode<?, ?> payload, final String insert, final String point) {
+    public PutResult commitConfigurationDataPut(final EffectiveModelContext globalSchema,
+            final YangInstanceIdentifier path, final NormalizedNode payload, final String insert, final String point) {
         requireNonNull(globalSchema);
         requireNonNull(path);
         requireNonNull(payload);
@@ -287,9 +283,8 @@ public class BrokerFacade implements Closeable {
      *            insert
      * @return wrapper of status and future of PUT
      */
-    public PutResult commitMountPointDataPut(
-            final DOMMountPoint mountPoint, final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload,
-            final String insert, final String point) {
+    public PutResult commitMountPointDataPut(final DOMMountPoint mountPoint, final YangInstanceIdentifier path,
+            final NormalizedNode payload, final String insert, final String point) {
         requireNonNull(mountPoint);
         requireNonNull(path);
         requireNonNull(payload);
@@ -335,11 +330,8 @@ public class BrokerFacade implements Closeable {
                         patchContext.getPatchId(),
                         null,
                         false,
-                        ImmutableList.of(new RestconfError(
-                                ErrorType.APPLICATION,
-                                ErrorTag.OPERATION_FAILED,
-                                "DOM data broker service isn't available for mount point "
-                                        + mountPoint.getIdentifier()))
+                        ImmutableList.of(new RestconfError(ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED,
+                            "DOM data broker service isn't available for mount point " + mountPoint.getIdentifier()))
                 );
             }
         }
@@ -469,7 +461,7 @@ public class BrokerFacade implements Closeable {
     // POST configuration
     public FluentFuture<? extends CommitInfo> commitConfigurationDataPost(
             final EffectiveModelContext globalSchema, final YangInstanceIdentifier path,
-            final NormalizedNode<?, ?> payload, final String insert, final String point) {
+            final NormalizedNode payload, final String insert, final String point) {
         isMounted.set(false);
         FluentFuture<? extends CommitInfo> future =
                 postDataViaTransaction(this.domDataBroker.newReadWriteTransaction(), CONFIGURATION, path, payload,
@@ -479,7 +471,7 @@ public class BrokerFacade implements Closeable {
     }
 
     public FluentFuture<? extends CommitInfo> commitConfigurationDataPost(
-            final DOMMountPoint mountPoint, final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload,
+            final DOMMountPoint mountPoint, final YangInstanceIdentifier path, final NormalizedNode payload,
             final String insert, final String point) {
         isMounted.set(true);
         final Optional<DOMDataBroker> domDataBrokerService = mountPoint.getService(DOMDataBroker.class);
@@ -510,7 +502,7 @@ public class BrokerFacade implements Closeable {
 
     // RPC
     public ListenableFuture<? extends DOMRpcResult> invokeRpc(final @NonNull QName type,
-            final @NonNull NormalizedNode<?, ?> input) {
+            final @NonNull NormalizedNode input) {
         if (this.rpcService == null) {
             throw new RestconfDocumentedException(Status.SERVICE_UNAVAILABLE);
         }
@@ -537,17 +529,17 @@ public class BrokerFacade implements Closeable {
         listener.setRegistration(registration);
     }
 
-    private NormalizedNode<?, ?> readDataViaTransaction(final DOMDataTreeReadOperations transaction,
+    private NormalizedNode readDataViaTransaction(final DOMDataTreeReadOperations transaction,
             final LogicalDatastoreType datastore, final YangInstanceIdentifier path) {
         return readDataViaTransaction(transaction, datastore, path, null);
     }
 
-    private NormalizedNode<?, ?> readDataViaTransaction(final DOMDataTreeReadOperations transaction,
+    private NormalizedNode readDataViaTransaction(final DOMDataTreeReadOperations transaction,
             final LogicalDatastoreType datastore, final YangInstanceIdentifier path, final String withDefa) {
         LOG.trace("Read {} via Restconf: {}", datastore.name(), path);
 
         try {
-            final Optional<NormalizedNode<?, ?>> optional = transaction.read(datastore, path).get();
+            final Optional<NormalizedNode> optional = transaction.read(datastore, path).get();
             return optional.map(normalizedNode -> withDefa == null ? normalizedNode :
                 prepareDataByParamWithDef(normalizedNode, path, withDefa)).orElse(null);
         } catch (InterruptedException e) {
@@ -560,7 +552,7 @@ public class BrokerFacade implements Closeable {
         }
     }
 
-    private NormalizedNode<?, ?> prepareDataByParamWithDef(final NormalizedNode<?, ?> result,
+    private NormalizedNode prepareDataByParamWithDef(final NormalizedNode result,
             final YangInstanceIdentifier path, final String withDefa) {
         boolean trim;
         switch (withDefa) {
@@ -579,13 +571,13 @@ public class BrokerFacade implements Closeable {
         final DataSchemaNode baseSchemaNode = baseSchemaCtxTree.findChild(path).orElseThrow().getDataSchemaNode();
         if (result instanceof ContainerNode) {
             final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> builder =
-                    Builders.containerBuilder((ContainerSchemaNode) baseSchemaNode);
+                SchemaAwareBuilders.containerBuilder((ContainerSchemaNode) baseSchemaNode);
             buildCont(builder, (ContainerNode) result, baseSchemaCtxTree, path, trim);
             return builder.build();
         }
 
         final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> builder =
-                Builders.mapEntryBuilder((ListSchemaNode) baseSchemaNode);
+            SchemaAwareBuilders.mapEntryBuilder((ListSchemaNode) baseSchemaNode);
         buildMapEntryBuilder(builder, (MapEntryNode) result, baseSchemaCtxTree, path, trim,
             ((ListSchemaNode) baseSchemaNode).getKeyDefinition());
         return builder.build();
@@ -595,37 +587,37 @@ public class BrokerFacade implements Closeable {
             final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> builder,
             final MapEntryNode result, final DataSchemaContextTree baseSchemaCtxTree,
             final YangInstanceIdentifier actualPath, final boolean trim, final List<QName> keys) {
-        for (final DataContainerChild<? extends PathArgument, ?> child : result.getValue()) {
+        for (final DataContainerChild child : result.body()) {
             final YangInstanceIdentifier path = actualPath.node(child.getIdentifier());
             final DataSchemaNode childSchema = baseSchemaCtxTree.findChild(path).orElseThrow().getDataSchemaNode();
             if (child instanceof ContainerNode) {
                 final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> childBuilder =
-                        Builders.containerBuilder((ContainerSchemaNode) childSchema);
+                        SchemaAwareBuilders.containerBuilder((ContainerSchemaNode) childSchema);
                 buildCont(childBuilder, (ContainerNode) child, baseSchemaCtxTree, path, trim);
                 builder.withChild(childBuilder.build());
             } else if (child instanceof MapNode) {
-                final CollectionNodeBuilder<MapEntryNode, MapNode> childBuilder =
-                        Builders.mapBuilder((ListSchemaNode) childSchema);
+                final CollectionNodeBuilder<MapEntryNode, SystemMapNode> childBuilder =
+                        SchemaAwareBuilders.mapBuilder((ListSchemaNode) childSchema);
                 buildList(childBuilder, (MapNode) child, baseSchemaCtxTree, path, trim,
                         ((ListSchemaNode) childSchema).getKeyDefinition());
                 builder.withChild(childBuilder.build());
             } else if (child instanceof LeafNode) {
                 final Object defaultVal = ((LeafSchemaNode) childSchema).getType().getDefaultValue().orElse(null);
-                final Object nodeVal = child.getValue();
+                final Object nodeVal = child.body();
                 final NormalizedNodeBuilder<NodeIdentifier, Object, LeafNode<Object>> leafBuilder =
-                        Builders.leafBuilder((LeafSchemaNode) childSchema);
-                if (keys.contains(child.getNodeType())) {
-                    leafBuilder.withValue(child.getValue());
+                        SchemaAwareBuilders.leafBuilder((LeafSchemaNode) childSchema);
+                if (keys.contains(child.getIdentifier().getNodeType())) {
+                    leafBuilder.withValue(child.body());
                     builder.withChild(leafBuilder.build());
                 } else {
                     if (trim) {
                         if (defaultVal == null || !defaultVal.equals(nodeVal)) {
-                            leafBuilder.withValue(child.getValue());
+                            leafBuilder.withValue(child.body());
                             builder.withChild(leafBuilder.build());
                         }
                     } else {
                         if (defaultVal != null && defaultVal.equals(nodeVal)) {
-                            leafBuilder.withValue(child.getValue());
+                            leafBuilder.withValue(child.body());
                             builder.withChild(leafBuilder.build());
                         }
                     }
@@ -634,15 +626,15 @@ public class BrokerFacade implements Closeable {
         }
     }
 
-    private void buildList(final CollectionNodeBuilder<MapEntryNode, MapNode> builder, final MapNode result,
+    private void buildList(final CollectionNodeBuilder<MapEntryNode, SystemMapNode> builder, final MapNode result,
             final DataSchemaContextTree baseSchemaCtxTree, final YangInstanceIdentifier path, final boolean trim,
             final List<QName> keys) {
-        for (final MapEntryNode mapEntryNode : result.getValue()) {
+        for (final MapEntryNode mapEntryNode : result.body()) {
             final YangInstanceIdentifier actualNode = path.node(mapEntryNode.getIdentifier());
             final DataSchemaNode childSchema = baseSchemaCtxTree.findChild(actualNode).orElseThrow()
                     .getDataSchemaNode();
             final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder =
-                    Builders.mapEntryBuilder((ListSchemaNode) childSchema);
+                    SchemaAwareBuilders.mapEntryBuilder((ListSchemaNode) childSchema);
             buildMapEntryBuilder(mapEntryBuilder, mapEntryNode, baseSchemaCtxTree, actualNode, trim, keys);
             builder.withChild(mapEntryBuilder.build());
         }
@@ -651,33 +643,33 @@ public class BrokerFacade implements Closeable {
     private void buildCont(final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> builder,
             final ContainerNode result, final DataSchemaContextTree baseSchemaCtxTree,
             final YangInstanceIdentifier actualPath, final boolean trim) {
-        for (final DataContainerChild<? extends PathArgument, ?> child : result.getValue()) {
+        for (final DataContainerChild child : result.body()) {
             final YangInstanceIdentifier path = actualPath.node(child.getIdentifier());
             final DataSchemaNode childSchema = baseSchemaCtxTree.findChild(path).orElseThrow().getDataSchemaNode();
             if (child instanceof ContainerNode) {
                 final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> builderChild =
-                        Builders.containerBuilder((ContainerSchemaNode) childSchema);
+                        SchemaAwareBuilders.containerBuilder((ContainerSchemaNode) childSchema);
                 buildCont(builderChild, result, baseSchemaCtxTree, actualPath, trim);
                 builder.withChild(builderChild.build());
             } else if (child instanceof MapNode) {
-                final CollectionNodeBuilder<MapEntryNode, MapNode> childBuilder =
-                        Builders.mapBuilder((ListSchemaNode) childSchema);
+                final CollectionNodeBuilder<MapEntryNode, SystemMapNode> childBuilder =
+                        SchemaAwareBuilders.mapBuilder((ListSchemaNode) childSchema);
                 buildList(childBuilder, (MapNode) child, baseSchemaCtxTree, path, trim,
                         ((ListSchemaNode) childSchema).getKeyDefinition());
                 builder.withChild(childBuilder.build());
             } else if (child instanceof LeafNode) {
                 final Object defaultVal = ((LeafSchemaNode) childSchema).getType().getDefaultValue().orElse(null);
-                final Object nodeVal = child.getValue();
+                final Object nodeVal = child.body();
                 final NormalizedNodeBuilder<NodeIdentifier, Object, LeafNode<Object>> leafBuilder =
-                        Builders.leafBuilder((LeafSchemaNode) childSchema);
+                        SchemaAwareBuilders.leafBuilder((LeafSchemaNode) childSchema);
                 if (trim) {
                     if (defaultVal == null || !defaultVal.equals(nodeVal)) {
-                        leafBuilder.withValue(child.getValue());
+                        leafBuilder.withValue(child.body());
                         builder.withChild(leafBuilder.build());
                     }
                 } else {
                     if (defaultVal != null && defaultVal.equals(nodeVal)) {
-                        leafBuilder.withValue(child.getValue());
+                        leafBuilder.withValue(child.body());
                         builder.withChild(leafBuilder.build());
                     }
                 }
@@ -690,7 +682,7 @@ public class BrokerFacade implements Closeable {
      */
     private FluentFuture<? extends CommitInfo> postDataViaTransaction(
             final DOMDataTreeReadWriteTransaction rwTransaction, final LogicalDatastoreType datastore,
-            final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload,
+            final YangInstanceIdentifier path, final NormalizedNode payload,
             final EffectiveModelContext schemaContext, final String insert, final String point) {
         LOG.trace("POST {} via Restconf: {} with payload {}", datastore.name(), path, payload);
         postData(rwTransaction, datastore, path, payload, schemaContext, insert, point);
@@ -702,14 +694,14 @@ public class BrokerFacade implements Closeable {
      */
     private void postDataWithinTransaction(
             final DOMDataTreeReadWriteTransaction rwTransaction, final LogicalDatastoreType datastore,
-            final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload,
+            final YangInstanceIdentifier path, final NormalizedNode payload,
             final EffectiveModelContext schemaContext) {
         LOG.trace("POST {} within Restconf Patch: {} with payload {}", datastore.name(), path, payload);
         postData(rwTransaction, datastore, path, payload, schemaContext, null, null);
     }
 
     private void postData(final DOMDataTreeReadWriteTransaction rwTransaction, final LogicalDatastoreType datastore,
-                          final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload,
+                          final YangInstanceIdentifier path, final NormalizedNode payload,
                           final EffectiveModelContext schemaContext, final String insert, final String point) {
         if (insert == null) {
             makeNormalPost(rwTransaction, datastore, path, payload, schemaContext);
@@ -721,9 +713,9 @@ public class BrokerFacade implements Closeable {
         switch (insert) {
             case "first":
                 if (schemaNode instanceof ListSchemaNode) {
-                    final OrderedMapNode readList =
-                            (OrderedMapNode) this.readConfigurationData(path.getParent().getParent());
-                    if (readList == null || readList.getValue().isEmpty()) {
+                    final UserMapNode readList =
+                            (UserMapNode) this.readConfigurationData(path.getParent().getParent());
+                    if (readList == null || readList.isEmpty()) {
                         simplePostPut(rwTransaction, datastore, path, payload, schemaContext);
                     } else {
                         rwTransaction.delete(datastore, path.getParent().getParent());
@@ -732,9 +724,9 @@ public class BrokerFacade implements Closeable {
                             schemaContext);
                     }
                 } else {
-                    final OrderedLeafSetNode<?> readLeafList =
-                            (OrderedLeafSetNode<?>) readConfigurationData(path.getParent());
-                    if (readLeafList == null || readLeafList.getValue().isEmpty()) {
+                    final UserLeafSetNode<?> readLeafList =
+                            (UserLeafSetNode<?>) readConfigurationData(path.getParent());
+                    if (readLeafList == null || readLeafList.isEmpty()) {
                         simplePostPut(rwTransaction, datastore, path, payload, schemaContext);
                     } else {
                         rwTransaction.delete(datastore, path.getParent());
@@ -749,9 +741,9 @@ public class BrokerFacade implements Closeable {
                 break;
             case "before":
                 if (schemaNode instanceof ListSchemaNode) {
-                    final OrderedMapNode readList =
-                            (OrderedMapNode) this.readConfigurationData(path.getParent().getParent());
-                    if (readList == null || readList.getValue().isEmpty()) {
+                    final UserMapNode readList =
+                            (UserMapNode) this.readConfigurationData(path.getParent().getParent());
+                    if (readList == null || readList.isEmpty()) {
                         simplePostPut(rwTransaction, datastore, path, payload, schemaContext);
                     } else {
                         insertWithPointListPost(rwTransaction, datastore, path, payload, schemaContext, point,
@@ -759,9 +751,9 @@ public class BrokerFacade implements Closeable {
                             true);
                     }
                 } else {
-                    final OrderedLeafSetNode<?> readLeafList =
-                            (OrderedLeafSetNode<?>) readConfigurationData(path.getParent());
-                    if (readLeafList == null || readLeafList.getValue().isEmpty()) {
+                    final UserLeafSetNode<?> readLeafList =
+                            (UserLeafSetNode<?>) readConfigurationData(path.getParent());
+                    if (readLeafList == null || readLeafList.isEmpty()) {
                         simplePostPut(rwTransaction, datastore, path, payload, schemaContext);
                     } else {
                         insertWithPointLeafListPost(rwTransaction, datastore, path, payload, schemaContext, point,
@@ -771,9 +763,9 @@ public class BrokerFacade implements Closeable {
                 break;
             case "after":
                 if (schemaNode instanceof ListSchemaNode) {
-                    final OrderedMapNode readList =
-                            (OrderedMapNode) this.readConfigurationData(path.getParent().getParent());
-                    if (readList == null || readList.getValue().isEmpty()) {
+                    final UserMapNode readList =
+                            (UserMapNode) this.readConfigurationData(path.getParent().getParent());
+                    if (readList == null || readList.isEmpty()) {
                         simplePostPut(rwTransaction, datastore, path, payload, schemaContext);
                     } else {
                         insertWithPointListPost(rwTransaction, datastore, path, payload, schemaContext, point,
@@ -781,9 +773,9 @@ public class BrokerFacade implements Closeable {
                             false);
                     }
                 } else {
-                    final OrderedLeafSetNode<?> readLeafList =
-                            (OrderedLeafSetNode<?>) readConfigurationData(path.getParent());
-                    if (readLeafList == null || readLeafList.getValue().isEmpty()) {
+                    final UserLeafSetNode<?> readLeafList =
+                            (UserLeafSetNode<?>) readConfigurationData(path.getParent());
+                    if (readLeafList == null || readLeafList.isEmpty()) {
                         simplePostPut(rwTransaction, datastore, path, payload, schemaContext);
                     } else {
                         insertWithPointLeafListPost(rwTransaction, datastore, path, payload, schemaContext, point,
@@ -799,13 +791,13 @@ public class BrokerFacade implements Closeable {
     }
 
     private void insertWithPointLeafListPost(final DOMDataTreeReadWriteTransaction rwTransaction,
-            final LogicalDatastoreType datastore, final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload,
-            final SchemaContext schemaContext, final String point, final OrderedLeafSetNode<?> readLeafList,
+            final LogicalDatastoreType datastore, final YangInstanceIdentifier path, final NormalizedNode payload,
+            final SchemaContext schemaContext, final String point, final UserLeafSetNode<?> readLeafList,
             final boolean before) {
         rwTransaction.delete(datastore, path.getParent().getParent());
         final InstanceIdentifierContext<?> instanceIdentifier = controllerContext.toInstanceIdentifier(point);
         int lastItemPosition = 0;
-        for (final LeafSetEntryNode<?> nodeChild : readLeafList.getValue()) {
+        for (final LeafSetEntryNode<?> nodeChild : readLeafList.body()) {
             if (nodeChild.getIdentifier().equals(instanceIdentifier.getInstanceIdentifier().getLastPathArgument())) {
                 break;
             }
@@ -815,10 +807,9 @@ public class BrokerFacade implements Closeable {
             lastItemPosition++;
         }
         int lastInsertedPosition = 0;
-        final NormalizedNode<?, ?> emptySubtree =
-                ImmutableNodes.fromInstanceId(schemaContext, path.getParent().getParent());
+        final NormalizedNode emptySubtree = ImmutableNodes.fromInstanceId(schemaContext, path.getParent().getParent());
         rwTransaction.merge(datastore, YangInstanceIdentifier.create(emptySubtree.getIdentifier()), emptySubtree);
-        for (final LeafSetEntryNode<?> nodeChild : readLeafList.getValue()) {
+        for (final LeafSetEntryNode<?> nodeChild : readLeafList.body()) {
             if (lastInsertedPosition == lastItemPosition) {
                 checkItemDoesNotExists(rwTransaction, datastore, path);
                 simplePostPut(rwTransaction, datastore, path, payload, schemaContext);
@@ -832,12 +823,12 @@ public class BrokerFacade implements Closeable {
 
     private void insertWithPointListPost(final DOMDataTreeReadWriteTransaction rwTransaction,
             final LogicalDatastoreType datastore,
-            final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload, final SchemaContext schemaContext,
+            final YangInstanceIdentifier path, final NormalizedNode payload, final SchemaContext schemaContext,
             final String point, final MapNode readList, final boolean before) {
         rwTransaction.delete(datastore, path.getParent().getParent());
         final InstanceIdentifierContext<?> instanceIdentifier = controllerContext.toInstanceIdentifier(point);
         int lastItemPosition = 0;
-        for (final MapEntryNode mapEntryNode : readList.getValue()) {
+        for (final MapEntryNode mapEntryNode : readList.body()) {
             if (mapEntryNode.getIdentifier()
                     .equals(instanceIdentifier.getInstanceIdentifier().getLastPathArgument())) {
                 break;
@@ -848,10 +839,9 @@ public class BrokerFacade implements Closeable {
             lastItemPosition++;
         }
         int lastInsertedPosition = 0;
-        final NormalizedNode<?, ?> emptySubtree =
-                ImmutableNodes.fromInstanceId(schemaContext, path.getParent().getParent());
+        final NormalizedNode emptySubtree = ImmutableNodes.fromInstanceId(schemaContext, path.getParent().getParent());
         rwTransaction.merge(datastore, YangInstanceIdentifier.create(emptySubtree.getIdentifier()), emptySubtree);
-        for (final MapEntryNode mapEntryNode : readList.getValue()) {
+        for (final MapEntryNode mapEntryNode : readList.body()) {
             if (lastInsertedPosition == lastItemPosition) {
                 checkItemDoesNotExists(rwTransaction, datastore, path);
                 simplePostPut(rwTransaction, datastore, path, payload, schemaContext);
@@ -886,19 +876,19 @@ public class BrokerFacade implements Closeable {
     }
 
     private void makeNormalPost(final DOMDataTreeReadWriteTransaction rwTransaction,
-            final LogicalDatastoreType datastore, final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload,
+            final LogicalDatastoreType datastore, final YangInstanceIdentifier path, final NormalizedNode payload,
             final SchemaContext schemaContext) {
-        final Collection<? extends NormalizedNode<?, ?>> children;
+        final Collection<? extends NormalizedNode> children;
         if (payload instanceof MapNode) {
-            children = ((MapNode) payload).getValue();
+            children = ((MapNode) payload).body();
         } else if (payload instanceof LeafSetNode) {
-            children = ((LeafSetNode<?>) payload).getValue();
+            children = ((LeafSetNode<?>) payload).body();
         } else {
             simplePostPut(rwTransaction, datastore, path, payload, schemaContext);
             return;
         }
 
-        final NormalizedNode<?, ?> emptySubtree = ImmutableNodes.fromInstanceId(schemaContext, path);
+        final NormalizedNode emptySubtree = ImmutableNodes.fromInstanceId(schemaContext, path);
         if (children.isEmpty()) {
             if (isMounted != null && !isMounted.get()) {
 
@@ -919,7 +909,7 @@ public class BrokerFacade implements Closeable {
             rwTransaction.merge(datastore, YangInstanceIdentifier.create(emptySubtree.getIdentifier()), emptySubtree);
             ensureParentsByMerge(datastore, path, rwTransaction, schemaContext);
         }
-        for (final NormalizedNode<?, ?> child : children) {
+        for (final NormalizedNode child : children) {
             // FIXME: we really want a create(YangInstanceIdentifier, NormalizedNode) method in the transaction,
             //        as that would allow us to skip the existence checks
             rwTransaction.put(datastore, path.node(child.getIdentifier()), child);
@@ -948,7 +938,7 @@ public class BrokerFacade implements Closeable {
     }
 
     private void simplePostPut(final DOMDataTreeReadWriteTransaction rwTransaction,
-            final LogicalDatastoreType datastore, final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload,
+            final LogicalDatastoreType datastore, final YangInstanceIdentifier path, final NormalizedNode payload,
             final SchemaContext schemaContext) {
         checkItemDoesNotExists(rwTransaction, datastore, path);
         if (isMounted != null && !isMounted.get()) {
@@ -1013,7 +1003,7 @@ public class BrokerFacade implements Closeable {
      */
     private FluentFuture<? extends CommitInfo> putDataViaTransaction(
             final DOMDataTreeReadWriteTransaction readWriteTransaction, final LogicalDatastoreType datastore,
-            final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload,
+            final YangInstanceIdentifier path, final NormalizedNode payload,
             final EffectiveModelContext schemaContext, final String insert, final String point) {
         LOG.trace("Put {} via Restconf: {} with payload {}", datastore.name(), path, payload);
         putData(readWriteTransaction, datastore, path, payload, schemaContext, insert, point);
@@ -1025,7 +1015,7 @@ public class BrokerFacade implements Closeable {
      */
     private void putDataWithinTransaction(
             final DOMDataTreeReadWriteTransaction writeTransaction, final LogicalDatastoreType datastore,
-            final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload,
+            final YangInstanceIdentifier path, final NormalizedNode payload,
             final EffectiveModelContext schemaContext) {
         LOG.trace("Put {} within Restconf Patch: {} with payload {}", datastore.name(), path, payload);
         putData(writeTransaction, datastore, path, payload, schemaContext, null, null);
@@ -1033,7 +1023,7 @@ public class BrokerFacade implements Closeable {
 
     // FIXME: This is doing correct put for container and list children, not sure if this will work for choice case
     private void putData(final DOMDataTreeReadWriteTransaction rwTransaction, final LogicalDatastoreType datastore,
-            final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload,
+            final YangInstanceIdentifier path, final NormalizedNode payload,
             final EffectiveModelContext schemaContext, final String insert, final String point) {
         if (insert == null) {
             makePut(rwTransaction, datastore, path, payload, schemaContext);
@@ -1045,9 +1035,8 @@ public class BrokerFacade implements Closeable {
         switch (insert) {
             case "first":
                 if (schemaNode instanceof ListSchemaNode) {
-                    final OrderedMapNode readList =
-                            (OrderedMapNode) this.readConfigurationData(path.getParent());
-                    if (readList == null || readList.getValue().isEmpty()) {
+                    final UserMapNode readList = (UserMapNode) this.readConfigurationData(path.getParent());
+                    if (readList == null || readList.isEmpty()) {
                         simplePut(datastore, path, rwTransaction, schemaContext, payload);
                     } else {
                         rwTransaction.delete(datastore, path.getParent());
@@ -1055,9 +1044,9 @@ public class BrokerFacade implements Closeable {
                         makePut(rwTransaction, datastore, path.getParent(), readList, schemaContext);
                     }
                 } else {
-                    final OrderedLeafSetNode<?> readLeafList =
-                            (OrderedLeafSetNode<?>) readConfigurationData(path.getParent());
-                    if (readLeafList == null || readLeafList.getValue().isEmpty()) {
+                    final UserLeafSetNode<?> readLeafList =
+                            (UserLeafSetNode<?>) readConfigurationData(path.getParent());
+                    if (readLeafList == null || readLeafList.isEmpty()) {
                         simplePut(datastore, path, rwTransaction, schemaContext, payload);
                     } else {
                         rwTransaction.delete(datastore, path.getParent());
@@ -1072,18 +1061,17 @@ public class BrokerFacade implements Closeable {
                 break;
             case "before":
                 if (schemaNode instanceof ListSchemaNode) {
-                    final OrderedMapNode readList =
-                            (OrderedMapNode) this.readConfigurationData(path.getParent());
-                    if (readList == null || readList.getValue().isEmpty()) {
+                    final UserMapNode readList = (UserMapNode) this.readConfigurationData(path.getParent());
+                    if (readList == null || readList.isEmpty()) {
                         simplePut(datastore, path, rwTransaction, schemaContext, payload);
                     } else {
                         insertWithPointListPut(rwTransaction, datastore, path, payload, schemaContext, point,
                             readList, true);
                     }
                 } else {
-                    final OrderedLeafSetNode<?> readLeafList =
-                            (OrderedLeafSetNode<?>) readConfigurationData(path.getParent());
-                    if (readLeafList == null || readLeafList.getValue().isEmpty()) {
+                    final UserLeafSetNode<?> readLeafList =
+                            (UserLeafSetNode<?>) readConfigurationData(path.getParent());
+                    if (readLeafList == null || readLeafList.isEmpty()) {
                         simplePut(datastore, path, rwTransaction, schemaContext, payload);
                     } else {
                         insertWithPointLeafListPut(rwTransaction, datastore, path, payload, schemaContext, point,
@@ -1093,18 +1081,17 @@ public class BrokerFacade implements Closeable {
                 break;
             case "after":
                 if (schemaNode instanceof ListSchemaNode) {
-                    final OrderedMapNode readList =
-                            (OrderedMapNode) this.readConfigurationData(path.getParent());
-                    if (readList == null || readList.getValue().isEmpty()) {
+                    final UserMapNode readList = (UserMapNode) this.readConfigurationData(path.getParent());
+                    if (readList == null || readList.isEmpty()) {
                         simplePut(datastore, path, rwTransaction, schemaContext, payload);
                     } else {
                         insertWithPointListPut(rwTransaction, datastore, path, payload, schemaContext, point,
                             readList, false);
                     }
                 } else {
-                    final OrderedLeafSetNode<?> readLeafList =
-                            (OrderedLeafSetNode<?>) readConfigurationData(path.getParent());
-                    if (readLeafList == null || readLeafList.getValue().isEmpty()) {
+                    final UserLeafSetNode<?> readLeafList =
+                            (UserLeafSetNode<?>) readConfigurationData(path.getParent());
+                    if (readLeafList == null || readLeafList.isEmpty()) {
                         simplePut(datastore, path, rwTransaction, schemaContext, payload);
                     } else {
                         insertWithPointLeafListPut(rwTransaction, datastore, path, payload, schemaContext, point,
@@ -1120,13 +1107,13 @@ public class BrokerFacade implements Closeable {
     }
 
     private void insertWithPointLeafListPut(final DOMDataTreeWriteTransaction tx,
-            final LogicalDatastoreType datastore, final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload,
-            final SchemaContext schemaContext, final String point, final OrderedLeafSetNode<?> readLeafList,
+            final LogicalDatastoreType datastore, final YangInstanceIdentifier path, final NormalizedNode payload,
+            final SchemaContext schemaContext, final String point, final UserLeafSetNode<?> readLeafList,
             final boolean before) {
         tx.delete(datastore, path.getParent());
         final InstanceIdentifierContext<?> instanceIdentifier = controllerContext.toInstanceIdentifier(point);
         int index1 = 0;
-        for (final LeafSetEntryNode<?> nodeChild : readLeafList.getValue()) {
+        for (final LeafSetEntryNode<?> nodeChild : readLeafList.body()) {
             if (nodeChild.getIdentifier().equals(instanceIdentifier.getInstanceIdentifier().getLastPathArgument())) {
                 break;
             }
@@ -1136,10 +1123,9 @@ public class BrokerFacade implements Closeable {
             index1++;
         }
         int index2 = 0;
-        final NormalizedNode<?, ?> emptySubtree =
-                ImmutableNodes.fromInstanceId(schemaContext, path.getParent());
+        final NormalizedNode emptySubtree = ImmutableNodes.fromInstanceId(schemaContext, path.getParent());
         tx.merge(datastore, YangInstanceIdentifier.create(emptySubtree.getIdentifier()), emptySubtree);
-        for (final LeafSetEntryNode<?> nodeChild : readLeafList.getValue()) {
+        for (final LeafSetEntryNode<?> nodeChild : readLeafList.body()) {
             if (index2 == index1) {
                 simplePut(datastore, path, tx, schemaContext, payload);
             }
@@ -1150,12 +1136,12 @@ public class BrokerFacade implements Closeable {
     }
 
     private void insertWithPointListPut(final DOMDataTreeWriteTransaction tx, final LogicalDatastoreType datastore,
-            final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload, final SchemaContext schemaContext,
-            final String point, final OrderedMapNode readList, final boolean before) {
+            final YangInstanceIdentifier path, final NormalizedNode payload, final SchemaContext schemaContext,
+            final String point, final UserMapNode readList, final boolean before) {
         tx.delete(datastore, path.getParent());
         final InstanceIdentifierContext<?> instanceIdentifier = controllerContext.toInstanceIdentifier(point);
         int index1 = 0;
-        for (final MapEntryNode mapEntryNode : readList.getValue()) {
+        for (final MapEntryNode mapEntryNode : readList.body()) {
             if (mapEntryNode.getIdentifier().equals(instanceIdentifier.getInstanceIdentifier().getLastPathArgument())) {
                 break;
             }
@@ -1165,10 +1151,9 @@ public class BrokerFacade implements Closeable {
             index1++;
         }
         int index2 = 0;
-        final NormalizedNode<?, ?> emptySubtree =
-                ImmutableNodes.fromInstanceId(schemaContext, path.getParent());
+        final NormalizedNode emptySubtree = ImmutableNodes.fromInstanceId(schemaContext, path.getParent());
         tx.merge(datastore, YangInstanceIdentifier.create(emptySubtree.getIdentifier()), emptySubtree);
-        for (final MapEntryNode mapEntryNode : readList.getValue()) {
+        for (final MapEntryNode mapEntryNode : readList.body()) {
             if (index2 == index1) {
                 simplePut(datastore, path, tx, schemaContext, payload);
             }
@@ -1179,14 +1164,14 @@ public class BrokerFacade implements Closeable {
     }
 
     private void makePut(final DOMDataTreeWriteTransaction tx, final LogicalDatastoreType datastore,
-            final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload, final SchemaContext schemaContext) {
+            final YangInstanceIdentifier path, final NormalizedNode payload, final SchemaContext schemaContext) {
         if (payload instanceof MapNode) {
-            final NormalizedNode<?, ?> emptySubtree = ImmutableNodes.fromInstanceId(schemaContext, path);
+            final NormalizedNode emptySubtree = ImmutableNodes.fromInstanceId(schemaContext, path);
             if (isMounted != null && !isMounted.get()) {
                 tx.merge(datastore, YangInstanceIdentifier.create(emptySubtree.getIdentifier()), emptySubtree);
                 ensureParentsByMerge(datastore, path, tx, schemaContext);
             }
-            for (final MapEntryNode child : ((MapNode) payload).getValue()) {
+            for (final MapEntryNode child : ((MapNode) payload).body()) {
                 final YangInstanceIdentifier childPath = path.node(child.getIdentifier());
                 tx.put(datastore, childPath, child);
             }
@@ -1196,8 +1181,7 @@ public class BrokerFacade implements Closeable {
     }
 
     private void simplePut(final LogicalDatastoreType datastore, final YangInstanceIdentifier path,
-            final DOMDataTreeWriteTransaction tx, final SchemaContext schemaContext,
-            final NormalizedNode<?, ?> payload) {
+            final DOMDataTreeWriteTransaction tx, final SchemaContext schemaContext, final NormalizedNode payload) {
         if (isMounted != null && !isMounted.get()) {
             ensureParentsByMerge(datastore, path, tx, schemaContext);
         }
@@ -1220,7 +1204,7 @@ public class BrokerFacade implements Closeable {
     }
 
     private static void mergeDataWithinTransaction(final DOMDataTreeWriteTransaction tx,
-            final LogicalDatastoreType datastore, final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload,
+            final LogicalDatastoreType datastore, final YangInstanceIdentifier path, final NormalizedNode payload,
             final SchemaContext schemaContext) {
         LOG.trace("Merge {} within Restconf Patch: {} with payload {}", datastore.name(), path, payload);
         ensureParentsByMerge(datastore, path, tx, schemaContext);
@@ -1266,10 +1250,8 @@ public class BrokerFacade implements Closeable {
         }
 
         checkArgument(rootNormalizedPath != null, "Empty path received");
-
-        final NormalizedNode<?, ?> parentStructure = ImmutableNodes.fromInstanceId(schemaContext,
-                YangInstanceIdentifier.create(normalizedPathWithoutChildArgs));
-        tx.merge(store, rootNormalizedPath, parentStructure);
+        tx.merge(store, rootNormalizedPath, ImmutableNodes.fromInstanceId(schemaContext,
+            YangInstanceIdentifier.create(normalizedPathWithoutChildArgs)));
     }
 
     private static RestconfDocumentedException dataBrokerUnavailable(final YangInstanceIdentifier path) {