+ logger.error("Error while merging objectnames of {}", on, e);
+ throw new NetconfConfigHandlingException(String.format("Unable to set attributes for %s, Error with attribute %s : %s ",
+ on,
+ configAttributeEntry.getKey(),
+ configAttributeEntry.getValue()),
+ NetconfDocumentedException.ErrorType.application,
+ NetconfDocumentedException.ErrorTag.operation_failed,
+ NetconfDocumentedException.ErrorSeverity.error);
+ }
+ }
+ }
+
+ /**
+ * Merge value into current value
+ * Currently, this is only implemented for arrays of ObjectNames, but that is the
+ * most common case for which it is needed.
+ */
+ protected Object merge(Object oldValue, Object toBeMergedIn) {
+ if (oldValue instanceof ObjectName[] && toBeMergedIn instanceof ObjectName[]) {
+ toBeMergedIn = mergeObjectNameArrays((ObjectName[]) oldValue, (ObjectName[]) toBeMergedIn);
+ }
+ return toBeMergedIn;
+ }
+
+ /**
+ * Merge value into current values
+ * This implements for arrays of ObjectNames, but that is the
+ * most common case for which it is needed.
+ *
+ * @param oldValue - the new values to be merged into existing values
+ * @param toBeMergedIn - the existing values
+ *
+ * @return an ObjectName[] consisting the elements of currentValue with an elements from values not already present in currentValue added
+ *
+ */
+ protected ObjectName[] mergeObjectNameArrays(ObjectName[] oldValue, ObjectName[] toBeMergedIn) {
+ List<ObjectName> newValueList = new ArrayList<>();
+ newValueList.addAll(asList(oldValue));
+ /*
+ It is guaranteed that old values do not contain transaction name.
+ Since toBeMergedIn is filled using service references translated by ServiceRegistryWrapper, it
+ is also guaranteed that this list will not contain transaction names.
+ Run through the list of values to be merged. If we don't have them already, add them to the list.
+ */
+ for (ObjectName objName : toBeMergedIn) {
+ if (!newValueList.contains(objName)) {
+ newValueList.add(objName);