Bug 8115: Change URI decoding from ISO-8859-1 to UTF-8
[netconf.git] / opendaylight / restconf / sal-rest-connector / src / main / java / org / opendaylight / netconf / sal / restconf / impl / ControllerContext.java
index f21823cda081bc2d5db4d59247092092687430f8..35d5206731fe342bac47c10b73ee2f382a29758a 100644 (file)
@@ -82,7 +82,7 @@ public class ControllerContext implements SchemaContextListener {
 
     public final static String MOUNT = "yang-ext:mount";
 
-    private final static String URI_ENCODING_CHAR_SET = "ISO-8859-1";
+    private final static String URI_ENCODING_CHAR_SET = "UTF-8";
 
     private static final Splitter SLASH_SPLITTER = Splitter.on('/');
 
@@ -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) {