Fixed resolving rpc service classes by name and revision insted of namespace and... 05/5305/3
authorMartin Bobak <mbobak@cisco.com>
Thu, 13 Feb 2014 10:22:37 +0000 (11:22 +0100)
committerTony Tkacik <ttkacik@cisco.com>
Fri, 14 Feb 2014 08:35:21 +0000 (09:35 +0100)
Change-Id: Id68de4e3c19883509f28b8e42d05f1db65827aa6
Signed-off-by: Martin Bobak <mbobak@cisco.com>
restconf/restconf-util/src/main/java/org/opendaylight/yangtools/restconf/utils/RestconfUtils.java

index 238228ce822df913b992d1b087cbc96f76ff88f6..ff6a768d4be10632ec271f42b9f0597fa057efd6 100644 (file)
@@ -37,6 +37,7 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode;
 import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
 import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
 import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlCodecProvider;
@@ -235,12 +236,31 @@ public class RestconfUtils {
             Document doc = builder.parse(inputStream);
             Element rootElement = doc.getDocumentElement();
 
-            XmlDocumentUtils.fromElement(rootElement).getNodeType();
-
             List<Node<?>> domNodes = XmlDocumentUtils.toDomNodes(rootElement, Optional.of(schemaContext.getChildNodes()));
             Set<Class<? extends RpcService>> rpcServices = new HashSet<Class<? extends RpcService>>();
             for (Node<?> node:domNodes){
-                rpcServices.add(mappingService.getRpcServiceClassFor(node.getNodeType().getNamespace().toString(),node.getNodeType().getRevision().toString()).get());
+                if (node instanceof ImmutableCompositeNode){
+                    ImmutableCompositeNode icNode = (ImmutableCompositeNode)node;
+                    QName namespace = null;
+                    QName revision = null;
+                    QName name = null;
+                    for (QName q:icNode.keySet()){
+                        if (q.getLocalName().equals("namespace")){
+                            namespace = q;
+                        }
+                        if (q.getLocalName().equals("revision")){
+                            revision = q;
+                        }
+                        if (q.getLocalName().equals("name")){
+                            name = q;
+                        }
+
+                    }
+                    Optional<Class<? extends RpcService>> rpcService = mappingService.getRpcServiceClassFor(icNode.get(name).get(0).getValue().toString(),icNode.get(revision).get(0).getValue().toString());
+                    if (rpcService.isPresent()){
+                        rpcServices.add(rpcService.get());
+                    }
+                }
             }
 
             return rpcServices;