Bug 3039 - PUT augmentNode like last path element
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / main / java / org / opendaylight / controller / sal / rest / impl / XmlNormalizedNodeBodyReader.java
index 817d25847a479ba9df38d905d4df1d05fc548911..1933c91e6bd65d210c3b5cf0375f2c4460eb6db3 100644 (file)
@@ -133,7 +133,7 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro
 
         final String docRootElm = doc.getDocumentElement().getLocalName();
         final List<YangInstanceIdentifier.PathArgument> iiToDataList = new ArrayList<>();
-        InstanceIdentifierContext<SchemaNode> outIIContext;
+        InstanceIdentifierContext<? extends SchemaNode> outIIContext;
 
 
         // FIXME the factory instance should be cached if the schema context is the same
@@ -142,6 +142,10 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro
 
         if (isPost()) {
             final Deque<Object> foundSchemaNodes = findPathToSchemaNodeByName(schemaNode, docRootElm);
+            if (foundSchemaNodes.isEmpty()) {
+                throw new IllegalStateException(String.format("Child \"%s\" was not found in parent schema node \"%s\"",
+                        docRootElm, schemaNode.getQName()));
+            }
             while (!foundSchemaNodes.isEmpty()) {
                 final Object child  = foundSchemaNodes.pop();
                 if (child instanceof AugmentationSchema) {