X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2FControllerContext.xtend;h=b26810347c160c1114057e3819263cfa2ee2890e;hp=61237f01a16933ef742041c787874ec9ee8fc957;hb=b29204146ca6957b5f968e07d9e7e2052ba70ef1;hpb=765f74bd08b61de6896411eb1a9d8377a981ec82 diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend index 61237f01a1..b26810347c 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend @@ -45,7 +45,7 @@ class ControllerContext implements SchemaServiceListener { val static NULL_VALUE = "null" val static MOUNT_MODULE = "yang-ext" val static MOUNT_NODE = "mount" - val static MOUNT = "yang-ext:mount" + public val static MOUNT = "yang-ext:mount" @Property var SchemaContext globalSchema; @@ -129,6 +129,7 @@ class ControllerContext implements SchemaServiceListener { def findModuleByNamespace(URI namespace) { checkPreconditions + checkArgument(namespace !== null) val moduleSchemas = globalSchema.findModuleByNamespace(namespace) return moduleSchemas?.filterLatestModule } @@ -170,28 +171,36 @@ class ControllerContext implements SchemaServiceListener { def findModuleNameByNamespace(URI namespace) { checkPreconditions - var module = uriToModuleName.get(namespace) - if (module === null) { - val moduleSchemas = globalSchema.findModuleByNamespace(namespace); - if(moduleSchemas === null) return null - var latestModule = moduleSchemas.filterLatestModule - if(latestModule === null) return null - uriToModuleName.put(namespace, latestModule.name) - module = latestModule.name; + var moduleName = uriToModuleName.get(namespace) + if (moduleName === null) { + val module = findModuleByNamespace(namespace) + if (module === null) return null + moduleName = module.name + uriToModuleName.put(namespace, moduleName) } - return module + return moduleName + } + + def findModuleNameByNamespace(MountInstance mountPoint, URI namespace) { + val module = mountPoint.findModuleByNamespace(namespace); + return module?.name } - def findNamespaceByModuleName(String module) { - var namespace = moduleNameToUri.get(module) + def findNamespaceByModuleName(String moduleName) { + var namespace = moduleNameToUri.get(moduleName) if (namespace === null) { - var latestModule = globalSchema.getLatestModule(module) - if(latestModule === null) return null - namespace = latestModule.namespace - uriToModuleName.put(namespace, latestModule.name) + var module = findModuleByName(moduleName) + if(module === null) return null + namespace = module.namespace + uriToModuleName.put(namespace, moduleName) } return namespace } + + def findNamespaceByModuleName(MountInstance mountPoint, String moduleName) { + val module = mountPoint.findModuleByName(moduleName) + return module?.namespace + } def CharSequence toRestconfIdentifier(QName qname) { checkPreconditions