Make RuntimeRpc revision aware 67/72967/1
authorMarek Gradzki <mgradzki@cisco.com>
Wed, 13 Jun 2018 19:12:16 +0000 (21:12 +0200)
committerMarek Gradzki <mgradzki@cisco.com>
Wed, 13 Jun 2018 19:31:14 +0000 (21:31 +0200)
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 use 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>
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 6d4ba4305ae99a1799d5e8ed90f768e76f44172a..669eb1fe121b4db824fe7a144dbec7839d2f4527 100644 (file)
@@ -106,7 +106,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 60ac65ab688f0c6a51264b99f79784cc66db5299..1c90e99d3dd506cc3faa056b3d2bfcc7f1529074 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 {
 
     }