X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fconfig-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fconfignetconfconnector%2Fmapping%2Fattributes%2Fresolving%2FCompositeAttributeResolvingStrategy.java;h=51eb20589899d4d0448a4ef0f6485d41e43da7e5;hp=9cd2eec0260d180d10242466cee5462162468605;hb=7d4251f30d145d8b402e206a11fb4a2ff90ac351;hpb=004251a5b4552d6ac4fc555a3dfaca885fc75884 diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/resolving/CompositeAttributeResolvingStrategy.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/resolving/CompositeAttributeResolvingStrategy.java index 9cd2eec026..51eb205898 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/resolving/CompositeAttributeResolvingStrategy.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/resolving/CompositeAttributeResolvingStrategy.java @@ -16,6 +16,7 @@ import javax.management.openmbean.CompositeDataSupport; import javax.management.openmbean.CompositeType; import javax.management.openmbean.OpenDataException; import javax.management.openmbean.OpenType; +import javax.management.openmbean.SimpleType; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; import org.opendaylight.controller.netconf.confignetconfconnector.util.Util; import org.slf4j.Logger; @@ -54,6 +55,10 @@ class CompositeAttributeResolvingStrategy extends Map items = Maps.newHashMap(); Map> openTypes = Maps.newHashMap(); + final String[] names = new String[getOpenType().keySet().size()]; + OpenType[] itemTypes = new OpenType[names.length]; + int i = 0; + for (Object innerAttrName : innerTypes.keySet()) { Preconditions.checkState(innerAttrName instanceof String, "Attribute name must be string"); String innerAttrNameStr = (String) innerAttrName; @@ -65,17 +70,32 @@ class CompositeAttributeResolvingStrategy extends Optional parsedInnerValue = attributeResolvingStrategy.parseAttribute(innerAttrNameStr, valueToParse); - openTypes.put(innerAttrNameStr, attributeResolvingStrategy.getOpenType()); + if(attributeResolvingStrategy instanceof EnumAttributeResolvingStrategy) { + // Open type for enum contain the class name necessary for its resolution, however in a DTO + // the open type need to be just SimpleType.STRING so that JMX is happy + // After the enum attribute is resolved, change its open type back to STRING + openTypes.put(innerAttrNameStr, SimpleType.STRING); + } else { + openTypes.put(innerAttrNameStr, attributeResolvingStrategy.getOpenType()); + } items.put(yangToJavaAttrMapping.get(innerAttrNameStr), parsedInnerValue.isPresent() ? parsedInnerValue.get() : null); + + // fill names + item types in order to reconstruct the open type for current attribute + names[i] = yangToJavaAttrMapping.get(innerAttrNameStr); + itemTypes[i] = openTypes.get(innerAttrNameStr); + i++; } 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()); parsedValue = new CompositeDataSupport(getOpenType(), items); } catch (OpenDataException e) { - throw new IllegalStateException("An error occured during restoration of composite type " + this + throw new IllegalStateException("An error occurred during restoration of composite type " + this + " for attribute " + attrName + " from value " + value, e); } @@ -84,7 +104,10 @@ class CompositeAttributeResolvingStrategy extends return Optional.of(parsedValue); } + protected Map preprocessValueMap(Map valueMap) { return valueMap; } + + }