From: adetalhouet Date: Tue, 2 Feb 2016 17:36:17 +0000 (-0500) Subject: Bug 5175: RPC called on mount point not being correctly handled when multiple revisio... X-Git-Tag: release/lithium-sr4~11 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=967558bda496952706e78581b7a185e11e66806e;p=controller.git Bug 5175: RPC called on mount point not being correctly handled when multiple revision-date coexist The ControllerContext#toQname was just looking for module using the module name. In scenarios where you have multiple revision for the same module, the method was returning the latest schema. This fix is to retreive the schema based on the revision date Change-Id: Ief10dab8925bc942f446895fe7078ebcb1105a3a Signed-off-by: adetalhouet --- diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java index b33d79e1d0..df734eecf9 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -595,7 +596,7 @@ public class ControllerContext implements SchemaContextListener { targetNode = findInstanceDataChildByNameAndNamespace(parentNode, nodeName, module.getNamespace()); if (targetNode == null && parentNode instanceof Module) { - final RpcDefinition rpc = ControllerContext.getInstance().getRpcDefinition(head); + final RpcDefinition rpc = ControllerContext.getInstance().getRpcDefinition(head, module.getRevision()); if (rpc != null) { return new InstanceIdentifierContext(builder.build(), rpc, mountPoint, mountPoint != null ? mountPoint.getSchemaContext() : globalSchema); @@ -770,7 +771,7 @@ public class ControllerContext implements SchemaContextListener { String additionalInfo = ""; if (decoded == null) { if ((baseType instanceof IdentityrefTypeDefinition)) { - decoded = toQName(urlDecoded); + decoded = toQName(urlDecoded, null); additionalInfo = "For key which is of type identityref it should be in format module_name:identity_name."; } } @@ -811,11 +812,11 @@ public class ControllerContext implements SchemaContextListener { return str.substring(idx + 1); } - private QName toQName(final String name) { + private QName toQName(final String name, final Date revisionDate) { checkPreconditions(); final String module = toModuleName(name); final String node = toNodeName(name); - final Module m = globalSchema.findModuleByName(module, null); + final Module m = globalSchema.findModuleByName(module, revisionDate); return m == null ? null : QName.create(m.getQNameModule(), node); } @@ -823,8 +824,8 @@ public class ControllerContext implements SchemaContextListener { return node instanceof ListSchemaNode || node instanceof ContainerSchemaNode; } - public RpcDefinition getRpcDefinition(final String name) { - final QName validName = toQName(name); + public RpcDefinition getRpcDefinition(final String name, final Date revisionDate) { + final QName validName = toQName(name, revisionDate); return validName == null ? null : qnameToRpc.get().get(validName); } diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java index 6bdc98c36e..2384821332 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java @@ -598,7 +598,7 @@ public class RestconfImpl implements RestconfService { RpcDefinition rpc = null; if (mountPoint == null) { - rpc = controllerContext.getRpcDefinition(identifierDecoded); + rpc = controllerContext.getRpcDefinition(identifierDecoded, null); } else { rpc = findRpc(mountPoint.getSchemaContext(), identifierDecoded); }