Merge "Change in AbstractRaftBehavior#performSnapshotWithoutCapture"
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / main / java / org / opendaylight / controller / sal / rest / impl / XmlNormalizedNodeBodyReader.java
index f34108316bf617c687fae2c5ceb58913f6a13d4c..bf668fa7fdd1583a2d0f3626d8f5e633a5da51b7 100644 (file)
@@ -85,6 +85,11 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro
         try {
             final Optional<InstanceIdentifierContext> path = getIdentifierWithSchema();
 
+            if (entityStream.available() < 1) {
+                // represent empty nopayload input
+                return new NormalizedNodeContext(path.get(), null);
+            }
+
             final DocumentBuilder dBuilder;
             try {
                 dBuilder = BUILDERFACTORY.newDocumentBuilder();
@@ -96,7 +101,7 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro
             final NormalizedNode<?, ?> result = parse(path.get(),doc);
             return new NormalizedNodeContext(path.get(),result);
         } catch (final Exception e) {
-            LOG.debug("Error parsing json input", e);
+            LOG.debug("Error parsing xml input", e);
 
             throw new RestconfDocumentedException("Error parsing input: " + e.getMessage(), ErrorType.PROTOCOL,
                     ErrorTag.MALFORMED_MESSAGE);
@@ -119,7 +124,6 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro
         final String docRootElm = doc.getDocumentElement().getLocalName();
         final String schemaNodeName = pathContext.getSchemaNode().getQName().getLocalName();
 
-        // TODO : do we want to really follow netconf-restconf specification ?
         if (!schemaNodeName.equalsIgnoreCase(docRootElm)) {
             final Collection<DataSchemaNode> children = ((DataNodeContainer) schemaNode).getChildNodes();
             for (final DataSchemaNode child : children) {
@@ -139,7 +143,7 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro
         } else if(schemaNode instanceof ListSchemaNode) {
             final ListSchemaNode casted = (ListSchemaNode) schemaNode;
             return parserFactory.getMapEntryNodeParser().parse(elements, casted);
-        }
+        } // FIXME : add another DataSchemaNode extensions e.g. LeafSchemaNode
         return null;
     }
 }