BUG-2453 Enable nested enums in configuration
[controller.git] / opendaylight / netconf / config-netconf-connector / src / main / java / org / opendaylight / controller / netconf / confignetconfconnector / mapping / attributes / resolving / ArrayAttributeResolvingStrategy.java
index a6a521a3dda35db05ba5de02a871bc772aa0f7ed..9c17fa4892df1ef5ab4298ca1f5da8fb39dec27a 100644 (file)
@@ -14,6 +14,7 @@ import java.util.List;
 import javax.management.openmbean.ArrayType;
 import javax.management.openmbean.CompositeDataSupport;
 import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
 import javax.management.openmbean.OpenType;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.confignetconfconnector.util.Util;
@@ -73,6 +74,17 @@ final class ArrayAttributeResolvingStrategy extends AbstractAttributeResolvingSt
             i++;
         }
 
+        // Rebuild open type. Underlying composite types might have changed
+        if (innerTypeResolvingStrategy.getOpenType() instanceof CompositeType) {
+            try {
+                final ArrayType<?> openType = new ArrayType<Object>(getOpenType().getDimension(), innerTypeResolvingStrategy.getOpenType());
+                setOpenType(openType);
+            } catch (OpenDataException e) {
+                throw new IllegalStateException("An error occurred during restoration of array type " + this
+                        + " for attribute " + attrName + " from value " + value, e);
+            }
+        }
+
         LOG.debug("Attribute {} : {} parsed to type {} as {}", attrName, value, getOpenType(),
                 toStringArray(parsedArray));