Bug 5553 - Impl get operations
[netconf.git] / restconf / sal-rest-connector / src / main / java / org / opendaylight / netconf / sal / restconf / impl / ControllerContext.java
index f21823cda081bc2d5db4d59247092092687430f8..e4f71a7ff03e00a07df93422f9bd8b0eb7826cc2 100644 (file)
@@ -596,7 +596,13 @@ public class ControllerContext implements SchemaContextListener {
             targetNode = findInstanceDataChildByNameAndNamespace(parentNode, nodeName, module.getNamespace());
 
             if (targetNode == null && parentNode instanceof Module) {
-                final RpcDefinition rpc = ControllerContext.getInstance().getRpcDefinition(head, module.getRevision());
+                final RpcDefinition rpc;
+                if (mountPoint == null) {
+                    rpc = ControllerContext.getInstance().getRpcDefinition(head, module.getRevision());
+                } else {
+                    final String rpcName = toNodeName(head);
+                    rpc = ControllerContext.getInstance().getRpcDefinition(module, rpcName);
+                }
                 if (rpc != null) {
                     return new InstanceIdentifierContext<RpcDefinition>(builder.build(), rpc, mountPoint,
                             mountPoint != null ? mountPoint.getSchemaContext() : globalSchema);
@@ -829,6 +835,16 @@ public class ControllerContext implements SchemaContextListener {
         return validName == null ? null : qnameToRpc.get().get(validName);
     }
 
+    private RpcDefinition getRpcDefinition(final Module module, final String rpcName) {
+        QName rpcQName = QName.create(module.getQNameModule(), rpcName);
+        for (RpcDefinition rpcDefinition : module.getRpcs()) {
+            if (rpcQName.equals(rpcDefinition.getQName())) {
+                return rpcDefinition;
+            }
+        }
+        return null;
+    }
+
     @Override
     public void onGlobalContextUpdated(final SchemaContext context) {
         if (context != null) {