BUG-3625 Allow replace nested composite nodes in cfg-subsystem
[controller.git] / opendaylight / netconf / config-netconf-connector / src / main / java / org / opendaylight / controller / netconf / confignetconfconnector / mapping / attributes / fromxml / ArrayAttributeReadingStrategy.java
index 1b74d49c4f6fc4b30069c12fd5d9416e5561af63..80e549e719e4c33a242e11f2a02cd847301b8bfe 100644 (file)
@@ -9,11 +9,11 @@
 package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
 
 import com.google.common.collect.Lists;
+import java.util.List;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.netconf.confignetconfconnector.operations.editconfig.EditStrategyType;
 import org.opendaylight.controller.netconf.util.xml.XmlElement;
 
-import java.util.List;
-
 public class ArrayAttributeReadingStrategy extends AbstractAttributeReadingStrategy {
 
     private final AttributeReadingStrategy innerStrategy;
@@ -30,10 +30,17 @@ public class ArrayAttributeReadingStrategy extends AbstractAttributeReadingStrat
     @Override
     AttributeConfigElement readElementHook(List<XmlElement> configNodes) throws NetconfDocumentedException {
         List<Object> innerList = Lists.newArrayList();
+        EditStrategyType innerEditStrategy= null;
         for (XmlElement configNode : configNodes) {
-            innerList.add(innerStrategy.readElement(Lists.newArrayList(configNode)).getValue());
+            final AttributeConfigElement attributeConfigElement = innerStrategy.readElement(Lists.newArrayList(configNode));
+            if(attributeConfigElement.getEditStrategy().isPresent()) {
+                // TODO this sets the last operation for the entire array
+                innerEditStrategy = attributeConfigElement.getEditStrategy().get();
+            }
+            innerList.add(attributeConfigElement.getValue());
         }
-        return AttributeConfigElement.create(getNullableDefault(), innerList);
+        return innerEditStrategy == null ? AttributeConfigElement.create(getNullableDefault(), innerList) :
+                AttributeConfigElement.create(getNullableDefault(), innerList, innerEditStrategy);
     }
 
 }