BUG-3436 Fix UNION type leaves resolution in config subsystem 60/21660/2
authorMaros Marsalek <mmarsale@cisco.com>
Mon, 1 Jun 2015 11:47:37 +0000 (13:47 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 4 Jun 2015 10:56:16 +0000 (10:56 +0000)
The descriptions for comoposite open types were not included in a reconstructed
open type, which affected resolution of subsequent composite attributes with
leaves of type union. Union leaves rely on description in order to find the
artificial JMX attribute in order to pass union value as string.

Change-Id: If6222e25840cb854e565ae476509d21ebc19ab3c
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
(cherry picked from commit 10438f09cbbeb252e58a7fb381e9dd723cc14e2e)

opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/resolving/CompositeAttributeResolvingStrategy.java

index 51eb20589899d4d0448a4ef0f6485d41e43da7e5..b912a491869c69e935ca7d4608d8d76cbb714123 100644 (file)
@@ -56,6 +56,7 @@ class CompositeAttributeResolvingStrategy extends
         Map<String, OpenType<?>> openTypes = Maps.newHashMap();
 
         final String[] names = new String[getOpenType().keySet().size()];
+        final String[] descriptions = new String[getOpenType().keySet().size()];
         OpenType<?>[] itemTypes = new OpenType[names.length];
         int i = 0;
 
@@ -84,6 +85,7 @@ class CompositeAttributeResolvingStrategy extends
 
             // fill names + item types in order to reconstruct the open type for current attribute
             names[i] = yangToJavaAttrMapping.get(innerAttrNameStr);
+            descriptions[i] = getOpenType().getDescription(names[i]);
             itemTypes[i] = openTypes.get(innerAttrNameStr);
             i++;
         }
@@ -91,8 +93,8 @@ class CompositeAttributeResolvingStrategy extends
         CompositeDataSupport parsedValue;
         try {
             LOG.trace("Attribute {} with open type {}. Reconstructing open type.", attrName, getOpenType());
-            setOpenType(new CompositeType(getOpenType().getTypeName(), getOpenType().getDescription(), names, names, itemTypes));
-            LOG.debug("Attribute {} with open type {}. Open type reconstructed to {}", attrName, getOpenType(), getOpenType());
+            setOpenType(new CompositeType(getOpenType().getTypeName(), getOpenType().getDescription(), names, descriptions, itemTypes));
+            LOG.debug("Attribute {}. Open type reconstructed to {}", attrName, getOpenType(), getOpenType());
             parsedValue = new CompositeDataSupport(getOpenType(), items);
         } catch (OpenDataException e) {
             throw new IllegalStateException("An error occurred during restoration of composite type " + this