From: Jan Hajnar Date: Tue, 9 Jun 2015 11:02:45 +0000 (+0200) Subject: Bug 3640 - RPC call error - impossible to call rpc X-Git-Tag: release/lithium~46 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=bc9579fb5cbb7db3b5ce071a9ce4a858c819caf7 Bug 3640 - RPC call error - impossible to call rpc * disabled children search in post if request is rpc input * fixed XmlNormalizedNodeBodyReader tests that were testing on wrong rpc input data Change-Id: I2602d34a4ab42169959b867acaffa988a11601f3 Signed-off-by: Jan Hajnar --- 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 1933c91e6b..294e56a651 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 @@ -123,8 +123,10 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro final List elements = Collections.singletonList(doc.getDocumentElement()); final SchemaNode schemaNodeContext = pathContext.getSchemaNode(); DataSchemaNode schemaNode; + boolean isRpc = false; if (schemaNodeContext instanceof RpcDefinition) { schemaNode = ((RpcDefinition) schemaNodeContext).getInput(); + isRpc = true; } else if (schemaNodeContext instanceof DataSchemaNode) { schemaNode = (DataSchemaNode) schemaNodeContext; } else { @@ -140,14 +142,14 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro final DomToNormalizedNodeParserFactory parserFactory = DomToNormalizedNodeParserFactory.getInstance(XmlUtils.DEFAULT_XML_CODEC_PROVIDER, pathContext.getSchemaContext()); - if (isPost()) { + if (isPost() && !isRpc) { 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(); + final Object child = foundSchemaNodes.pop(); if (child instanceof AugmentationSchema) { final AugmentationSchema augmentSchemaNode = (AugmentationSchema) child; iiToDataList.add(SchemaUtils.getNodeIdentifierForAugmentation(augmentSchemaNode)); diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReader.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReader.java index bb55b45221..67f4822c30 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReader.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReader.java @@ -162,8 +162,14 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest { .readFrom(null, null, null, mediaType, null, inputStream); checkNormalizedNodeContext(returnValue); final ContainerNode contNode = (ContainerNode) returnValue.getData(); - final YangInstanceIdentifier yangleaf = YangInstanceIdentifier.of(QName.create(contNode.getNodeType(), "lf")); - final Optional> leafDataNode = contNode.getChild(yangleaf.getLastPathArgument()); + final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName.create(contNode.getNodeType(), "cont")); + final Optional> contDataNodePotential = contNode.getChild(yangCont + .getLastPathArgument()); + assertTrue(contDataNodePotential.isPresent()); + final ContainerNode contDataNode = (ContainerNode) contDataNodePotential.get(); + final YangInstanceIdentifier yangLeaf = YangInstanceIdentifier.of(QName.create(contDataNode.getNodeType(), "lf")); + final Optional> leafDataNode = contDataNode.getChild(yangLeaf + .getLastPathArgument()); assertTrue(leafDataNode.isPresent()); assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue().toString())); } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReaderMountPoint.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReaderMountPoint.java index f1be296c4d..888008ca60 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReaderMountPoint.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReaderMountPoint.java @@ -132,13 +132,16 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest { null, null, mediaType, null, inputStream); checkNormalizedNodeContext(returnValue); final ContainerNode contNode = (ContainerNode) returnValue.getData(); - final YangInstanceIdentifier yangleaf = YangInstanceIdentifier.of(QName - .create(contNode.getNodeType(), "lf")); - final Optional> leafDataNode = contNode - .getChild(yangleaf.getLastPathArgument()); + final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName.create(contNode.getNodeType(), "cont")); + final Optional> contDataNodePotential = contNode.getChild(yangCont + .getLastPathArgument()); + assertTrue(contDataNodePotential.isPresent()); + final ContainerNode contDataNode = (ContainerNode) contDataNodePotential.get(); + final YangInstanceIdentifier yangLeaf = YangInstanceIdentifier.of(QName.create(contDataNode.getNodeType(), "lf")); + final Optional> leafDataNode = contDataNode.getChild(yangLeaf + .getLastPathArgument()); assertTrue(leafDataNode.isPresent()); - assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue() - .toString())); + assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue().toString())); } private void checkExpectValueNormalizeNodeContext( diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/xml/rpc-input.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/xml/rpc-input.xml index 20a3ecb93f..48fb557070 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/xml/rpc-input.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/xml/rpc-input.xml @@ -1,3 +1,5 @@ - - lf-test - \ No newline at end of file + + + lf-test + + \ No newline at end of file