Bug 5836 - Set namespace for DOM nodes 92/39492/2
authorJakub Morvay <jmorvay@cisco.com>
Thu, 26 May 2016 14:35:24 +0000 (16:35 +0200)
committerTom Pantelis <tpanteli@brocade.com>
Tue, 31 May 2016 07:45:25 +0000 (07:45 +0000)
Subtree filtering expects nodes with correct namespaces. XML constructed
in config subsystem netconf server does not contain correct namespaces
when in DOM format. Always include namespace when constructing DOM
nodes.

Change-Id: I4d67f224421b5951fd2a83442870add299e70c1c
Signed-off-by: Jakub Morvay <jmorvay@cisco.com>
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/ModuleConfig.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/Services.java

index 764f694..1b0aaa2 100644 (file)
@@ -34,17 +34,19 @@ public class ModuleConfig {
     }
 
     public Element toXml(ObjectName instanceON, Document document, String namespace, final EnumResolver enumResolver) {
-        Element root = XmlUtil.createElement(document, XmlMappingConstants.MODULE_KEY, Optional.<String>absent());
+        final Optional<String> configNs =
+                Optional.of(XmlMappingConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG);
+        Element root = XmlUtil.createElement(document, XmlMappingConstants.MODULE_KEY, configNs);
 
         // type belongs to config.yang namespace, but needs to be <type prefix:moduleNS>prefix:moduleName</type>
 
         Element typeElement = XmlUtil.createTextElementWithNamespacedContent(document, XmlMappingConstants.TYPE_KEY,
-                XmlMappingConstants.PREFIX, namespace, moduleName);
+                XmlMappingConstants.PREFIX, namespace, moduleName, configNs);
 
         root.appendChild(typeElement);
         // name belongs to config.yang namespace
         String instanceName = ObjectNameUtil.getInstanceName(instanceON);
-        Element nameElement = XmlUtil.createTextElement(document, XmlMappingConstants.NAME_KEY, instanceName, Optional.<String>absent());
+        Element nameElement = XmlUtil.createTextElement(document, XmlMappingConstants.NAME_KEY, instanceName, configNs);
 
         root.appendChild(nameElement);
 
index 2f0d73e..c2683d4 100644 (file)
@@ -155,19 +155,23 @@ public final class Services {
 
                 // type belongs to config.yang namespace
                 String serviceType = serviceEntry.getKey();
-                Element typeElement = XmlUtil.createTextElementWithNamespacedContent(document, XmlMappingConstants.TYPE_KEY,
-                        XmlMappingConstants.PREFIX, namespaceToRefEntry.getKey(), serviceType);
+                Element typeElement = XmlUtil.createTextElementWithNamespacedContent(
+                        document, XmlMappingConstants.TYPE_KEY, XmlMappingConstants.PREFIX,
+                        namespaceToRefEntry.getKey(), serviceType, configNs);
 
                 serviceElement.appendChild(typeElement);
 
                 for (Entry<String, String> instanceEntry : serviceEntry.getValue().entrySet()) {
-                    Element instanceElement = XmlUtil.createElement(document, XmlMappingConstants.INSTANCE_KEY, Optional.<String>absent());
+                    Element instanceElement = XmlUtil.createElement(
+                            document, XmlMappingConstants.INSTANCE_KEY, configNs);
                     serviceElement.appendChild(instanceElement);
 
-                    Element nameElement = XmlUtil.createTextElement(document, NAME_KEY, instanceEntry.getKey(), Optional.<String>absent());
+                    Element nameElement = XmlUtil.createTextElement(
+                            document, NAME_KEY, instanceEntry.getKey(), configNs);
                     instanceElement.appendChild(nameElement);
 
-                    Element providerElement = XmlUtil.createTextElement(document, PROVIDER_KEY, instanceEntry.getValue(), Optional.<String>absent());
+                    Element providerElement = XmlUtil.createTextElement(
+                            document, PROVIDER_KEY, instanceEntry.getValue(), configNs);
                     instanceElement.appendChild(providerElement);
                 }
             }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.