From c9febc3cbe1a223869869602f732d827f8995e9f Mon Sep 17 00:00:00 2001 From: Vaclav Demcak Date: Thu, 4 Jun 2015 18:13:48 +0200 Subject: [PATCH] Bug 3039 - PUT augmentNode like last path element * fixed JsonNormalizedNodeBodyReader error when PUT operation was used and data were wrapped in augmentation or choice nodes * fixed bug that allowed XmlNormalizedNodeBodyReader to parse PUT with incorrect data (when PUT request was written as POST) note: testet manualy describled scenario + CSIT OFP_test_suite Change-Id: Ia25b6b45a1154866dea29c763be67cdb17fa0ce1 Signed-off-by: Jan Hajnar Signed-off-by: Vaclav Demcak --- .../sal/rest/impl/JsonNormalizedNodeBodyReader.java | 11 +++++++---- .../sal/rest/impl/XmlNormalizedNodeBodyReader.java | 4 ++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonNormalizedNodeBodyReader.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonNormalizedNodeBodyReader.java index 265811a86b..42024cab08 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonNormalizedNodeBodyReader.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonNormalizedNodeBodyReader.java @@ -96,12 +96,15 @@ public class JsonNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPr final List iiToDataList = new ArrayList<>(); InstanceIdentifierContext newIIContext; - if (isPost()) { - while (result instanceof AugmentationNode || result instanceof ChoiceNode) { - final Object childNode = ((DataContainerNode) result).getValue().iterator().next(); + while (result instanceof AugmentationNode || result instanceof ChoiceNode) { + final Object childNode = ((DataContainerNode) result).getValue().iterator().next(); + if (isPost()) { iiToDataList.add(result.getIdentifier()); - result = (NormalizedNode) childNode; } + result = (NormalizedNode) childNode; + } + + if (isPost()) { if (result instanceof MapEntryNode) { iiToDataList.add(new YangInstanceIdentifier.NodeIdentifier(result.getNodeType())); iiToDataList.add(result.getIdentifier()); diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlNormalizedNodeBodyReader.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlNormalizedNodeBodyReader.java index d2c75f7e0c..1933c91e6b 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlNormalizedNodeBodyReader.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlNormalizedNodeBodyReader.java @@ -142,6 +142,10 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro if (isPost()) { final Deque 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) { -- 2.36.6