From 37aa81d301af72a6ea4ddf5e51c3f26f53c66a3d Mon Sep 17 00:00:00 2001 From: Vaclav Demcak Date: Fri, 29 May 2015 11:53:14 +0200 Subject: [PATCH] Bug 3104 - fixed XmlNormalizedNodeBodyReader Note: add missing key is relevant only for a POST scenario. Change-Id: Ibe97f83de4411c0fa5e28ced192f69aa65454027 Signed-off-by: Vaclav Demcak --- .../rest/impl/XmlNormalizedNodeBodyReader.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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 50186b8dc7..817d25847a 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 @@ -132,7 +132,7 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro } final String docRootElm = doc.getDocumentElement().getLocalName(); - List iiToDataList = new ArrayList<>(); + final List iiToDataList = new ArrayList<>(); InstanceIdentifierContext outIIContext; @@ -143,7 +143,7 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro if (isPost()) { final Deque foundSchemaNodes = findPathToSchemaNodeByName(schemaNode, docRootElm); while (!foundSchemaNodes.isEmpty()) { - Object child = foundSchemaNodes.pop(); + final Object child = foundSchemaNodes.pop(); if (child instanceof AugmentationSchema) { final AugmentationSchema augmentSchemaNode = (AugmentationSchema) child; iiToDataList.add(SchemaUtils.getNodeIdentifierForAugmentation(augmentSchemaNode)); @@ -161,11 +161,13 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro } else if(schemaNode instanceof ListSchemaNode) { final ListSchemaNode casted = (ListSchemaNode) schemaNode; parsed = parserFactory.getMapEntryNodeParser().parse(elements, casted); - iiToDataList.add(parsed.getIdentifier()); + if (isPost()) { + iiToDataList.add(parsed.getIdentifier()); + } } // FIXME : add another DataSchemaNode extensions e.g. LeafSchemaNode - YangInstanceIdentifier fullIIToData = YangInstanceIdentifier.create(Iterables.concat( + final YangInstanceIdentifier fullIIToData = YangInstanceIdentifier.create(Iterables.concat( pathContext.getInstanceIdentifier().getPathArguments(), iiToDataList)); outIIContext = new InstanceIdentifierContext<>(fullIIToData, pathContext.getSchemaNode(), pathContext.getMountPoint(), @@ -174,7 +176,7 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro return new NormalizedNodeContext(outIIContext, parsed); } - private static Deque findPathToSchemaNodeByName(DataSchemaNode schemaNode, String elementName) { + private static Deque findPathToSchemaNodeByName(final DataSchemaNode schemaNode, final String elementName) { final Deque result = new ArrayDeque<>(); final ArrayList choiceSchemaNodes = new ArrayList<>(); final Collection children = ((DataNodeContainer) schemaNode).getChildNodes(); @@ -213,8 +215,8 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro private static AugmentationSchema findCorrespondingAugment(final DataSchemaNode parent, final DataSchemaNode child) { if (parent instanceof AugmentationTarget && !(parent instanceof ChoiceSchemaNode)) { - for (AugmentationSchema augmentation : ((AugmentationTarget) parent).getAvailableAugmentations()) { - DataSchemaNode childInAugmentation = augmentation.getDataChildByName(child.getQName()); + for (final AugmentationSchema augmentation : ((AugmentationTarget) parent).getAvailableAugmentations()) { + final DataSchemaNode childInAugmentation = augmentation.getDataChildByName(child.getQName()); if (childInAugmentation != null) { return augmentation; } -- 2.36.6