BUG 2596: Use base service name in service serialization. 71/21671/2
authorTomas Cere <tcere@cisco.com>
Mon, 1 Jun 2015 14:58:20 +0000 (16:58 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 4 Jun 2015 10:34:32 +0000 (10:34 +0000)
Serialization of config was incorrectly using derived service name
instead of the name that was configured in xml.

Change-Id: Idf455f62b1ade06a3e52e4936227f485f74c8ef3
Signed-off-by: Tomas Cere <tcere@cisco.com>
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/mapping/ObjectMapper.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/mapping/ObjectNameAttributeMappingStrategy.java

index 463e98100c2578138932340df7470d9df27935d1..2608c57e000316e1cd2df3aa80d38a34b5c72890 100644 (file)
@@ -43,10 +43,8 @@ public class ObjectMapper extends AttributeIfcSwitchStatement<AttributeMappingSt
     public AttributeMappingStrategy<?, ? extends OpenType<?>> prepareStrategy(AttributeIfc attributeIfc) {
 
         if(attributeIfc instanceof DependencyAttribute) {
-            serviceNameOfDepAttr = ((DependencyAttribute)attributeIfc).getDependency().getSie().getQName().getLocalName();
             namespaceOfDepAttr = ((DependencyAttribute)attributeIfc).getDependency().getSie().getQName().getNamespace().toString();
         } else if (attributeIfc instanceof ListDependenciesAttribute) {
-            serviceNameOfDepAttr = ((ListDependenciesAttribute)attributeIfc).getDependency().getSie().getQName().getLocalName();
             namespaceOfDepAttr = ((ListDependenciesAttribute)attributeIfc).getDependency().getSie().getQName().getNamespace().toString();
         }
 
@@ -110,14 +108,12 @@ public class ObjectMapper extends AttributeIfcSwitchStatement<AttributeMappingSt
         return new UnionCompositeAttributeMappingStrategy(compositeType, innerStrategies, attributeMapping);
     }
 
-    private String serviceNameOfDepAttr;
     private String namespaceOfDepAttr;
 
     @Override
     protected AttributeMappingStrategy<?, ? extends OpenType<?>> caseDependencyAttribute(
             SimpleType<?> openType) {
-        return new ObjectNameAttributeMappingStrategy(openType,
-                serviceNameOfDepAttr, namespaceOfDepAttr);
+        return new ObjectNameAttributeMappingStrategy(openType, namespaceOfDepAttr);
     }
 
     @Override
index b827a5b03965d7f7471731a646b80e44ee835266..b0569dec6276a8a851e6f3965a52afb1f76267cd 100644 (file)
@@ -14,16 +14,15 @@ import javax.management.ObjectName;
 import javax.management.openmbean.SimpleType;
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
 import org.opendaylight.controller.netconf.confignetconfconnector.util.Util;
+import org.opendaylight.yangtools.yang.common.QName;
 
 public class ObjectNameAttributeMappingStrategy extends
         AbstractAttributeMappingStrategy<ObjectNameAttributeMappingStrategy.MappedDependency, SimpleType<?>> {
 
-    private final String serviceName;
     private final String namespace;
 
-    public ObjectNameAttributeMappingStrategy(SimpleType<?> openType,  String serviceName, String namespace) {
+    public ObjectNameAttributeMappingStrategy(SimpleType<?> openType, String namespace) {
         super(openType);
-        this.serviceName = serviceName;
         this.namespace = namespace;
     }
 
@@ -43,7 +42,9 @@ public class ObjectNameAttributeMappingStrategy extends
 
         String refName = ObjectNameUtil.getReferenceName(on);
 
-        return Optional.of(new MappedDependency(namespace, serviceName, refName));
+        //we want to use the exact service name that was configured in xml so services that are referencing it can be resolved
+        return Optional.of(new MappedDependency(namespace,
+                QName.create(ObjectNameUtil.getServiceQName(on)).getLocalName(), refName));
     }
 
     public static class MappedDependency {