Make RuntimeRpc revision aware 97/72997/1
authorMarek Gradzki <mgradzki@cisco.com>
Wed, 13 Jun 2018 19:12:16 +0000 (21:12 +0200)
committerMarek Gradzki <mgradzki@cisco.com>
Thu, 14 Jun 2018 10:20:36 +0000 (10:20 +0000)
Do not use SchemaContext.findModule(URI),
which looks for a module instance with specified namespace
and no revision.
Such lookup fails for modules with revision defined.

Instead (as already done in AbstractEdit)
use SchemaContext.findModules and take the newest module
if more than one module with the same namespace is found.

Change-Id: I7b6bdcb9156669645e19a6395e1b74995328154d
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
(cherry picked from commit 69c92b2bee54681ebb5c0bfaf89d269877e0b747)

netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/RuntimeRpc.java
netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/RuntimeRpcTest.java
netconf/mdsal-netconf-connector/src/test/resources/yang/mdsal-netconf-rpc-test.yang

index a2f8c1b6ef3d6f86bee692b606c9689ef2aa1cd9..55c1533d57db5483404c6d9d1ab1844007330306 100644 (file)
@@ -105,7 +105,7 @@ public class RuntimeRpc extends AbstractSingletonNetconfOperation {
 
     //this returns module with the newest revision if more then 1 module with same namespace is found
     private Optional<Module> getModule(final URI namespaceURI) {
-        return Optional.fromJavaUtil(schemaContext.getCurrentContext().findModule(namespaceURI));
+        return Optional.fromJavaUtil(schemaContext.getCurrentContext().findModules(namespaceURI).stream().findFirst());
     }
 
     private static Optional<RpcDefinition> getRpcDefinitionFromModule(final Module module, final URI namespaceURI,
index 28508dbad5d3536fc54dea7c5dcd52f1d2e21bf4..cc932996304c7e14c54c0cea68836fb7f9713e92 100644 (file)
@@ -126,7 +126,8 @@ public class RuntimeRpcTest {
                 @Nonnull final SchemaPath type, @Nullable final NormalizedNode<?, ?> input) {
             final Collection<DataContainerChild<? extends PathArgument, ?>> children =
                     (Collection<DataContainerChild<? extends PathArgument, ?>>) input.getValue();
-            final Module module = schemaContext.findModule(type.getLastComponent().getNamespace()).orElse(null);
+            final Module module = schemaContext.findModules(type.getLastComponent().getNamespace()).stream()
+                .findFirst().orElse(null);
             final RpcDefinition rpcDefinition = getRpcDefinitionFromModule(
                 module, module.getNamespace(), type.getLastComponent().getLocalName());
             final ContainerSchemaNode outputSchemaNode = rpcDefinition.getOutput();
index 6a59cdcf6e4638742a11d49facde3459b2ff09ef..b09b7d62c6c036116b75f80ed8a8462105c803c0 100644 (file)
@@ -3,6 +3,8 @@ module rpc-test {
     namespace "urn:opendaylight:mdsal:mapping:rpc:test";
     prefix "rpc";
 
+    revision "2015-04-08";
+
     rpc void-input-output-rpc {
 
     }