X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2FControllerContext.java;h=16bbf9a4b144dc0e522db765cfc4755e2efde28b;hb=refs%2Fchanges%2F00%2F9400%2F1;hp=0a67c84d8b2b04c56a31fa2d7e9dd2e3e8821934;hpb=73bda4f755598599f45cc46cd51c652c0a36e532;p=controller.git 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 0a67c84d8b..16bbf9a4b1 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 @@ -9,13 +9,11 @@ package org.opendaylight.controller.sal.restconf.impl; import com.google.common.base.Function; import com.google.common.base.Objects; -import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.base.Splitter; import com.google.common.base.Strings; import com.google.common.collect.BiMap; -import com.google.common.collect.FluentIterable; import com.google.common.collect.HashBiMap; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; @@ -28,7 +26,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -262,7 +259,7 @@ public class ControllerContext implements SchemaContextListener { for (final PathArgument element : elements) { QName _nodeType = element.getNodeType(); final DataSchemaNode potentialNode = ControllerContext.childByQName(node, _nodeType); - if (potentialNode == null || !this.isListOrContainer(potentialNode)) { + if (potentialNode == null || !ControllerContext.isListOrContainer(potentialNode)) { return null; } node = (DataNodeContainer) potentialNode; @@ -284,7 +281,7 @@ public class ControllerContext implements SchemaContextListener { for (final PathArgument element : elements) { QName _nodeType = element.getNodeType(); final DataSchemaNode potentialNode = ControllerContext.childByQName(node, _nodeType); - if (!this.isListOrContainer(potentialNode)) { + if (!ControllerContext.isListOrContainer(potentialNode)) { return null; } node = ((DataNodeContainer) potentialNode); @@ -650,7 +647,7 @@ public class ControllerContext implements SchemaContextListener { targetNode = potentialSchemaNodes.iterator().next(); } - if (!this.isListOrContainer(targetNode)) { + if (!ControllerContext.isListOrContainer(targetNode)) { throw new RestconfDocumentedException("URI has bad format. Node \"" + head + "\" must be Container or List yang type.", ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); } @@ -824,34 +821,8 @@ public class ControllerContext implements SchemaContextListener { private QName toQName(final String name) { final String module = toModuleName(name); final String node = toNodeName(name); - Set modules = globalSchema.getModules(); - - final Comparator comparator = new Comparator() { - @Override - public int compare(final Module o1, final Module o2) { - return o1.getRevision().compareTo(o2.getRevision()); - } - }; - - List sorted = new ArrayList(modules); - Collections. sort(new ArrayList(modules), comparator); - - final Function transform = new Function() { - @Override - public QName apply(final Module m) { - return QName.create(m.getNamespace(), m.getRevision(), m.getName()); - } - }; - - final Predicate findFirst = new Predicate() { - @Override - public boolean apply(final QName qn) { - return Objects.equal(module, qn.getLocalName()); - } - }; - - Optional namespace = FluentIterable.from(sorted).transform(transform).firstMatch(findFirst); - return namespace.isPresent() ? QName.create(namespace.get(), node) : null; + final Module m = globalSchema.findModuleByName(module, null); + return m == null ? null : QName.create(m.getQNameModule(), node); } private static boolean isListOrContainer(final DataSchemaNode node) {