mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

ludovicp
27.41.2010 3bcc70c3d28164434f018c3c8e9f775be7100708
opends/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 */
package org.opends.server.tools.dsconfig;
@@ -2401,16 +2401,48 @@
    {
      if (newValues.containsAll(previousValues))
      {
        registerAddModification(pd, newValues, previousValues);
        if (newValues.size() <= 1)
        {
          registerSetModification(pd, newValues, previousValues);
        }
        else
        {
          registerAddModification(pd, newValues, previousValues);
        }
      }
      else if (previousValues.containsAll(newValues))
      {
        registerRemoveModification(pd, newValues, previousValues);
      }
      else
      else if (newValues.size() <= 1)
      {
        registerSetModification(pd, newValues, previousValues);
      }
      else
      {
        // Split into two operations: remove and add
        SortedSet<T> removedValues = new TreeSet<T>();
        removedValues.addAll(previousValues);
        removedValues.removeAll(newValues);
        PropertyEditorModification<T> removeMod =
          PropertyEditorModification.createRemoveModification(pd,
            removedValues, previousValues);
        addModification(removeMod);
        SortedSet<T> retainedValues = new TreeSet<T>();
        retainedValues.addAll(previousValues);
        retainedValues.retainAll(newValues);
        SortedSet<T> addedValues = new TreeSet<T>();
        addedValues.addAll(newValues);
        addedValues.removeAll(retainedValues);
        PropertyEditorModification<T> addMod =
          PropertyEditorModification.createAddModification(pd,
              addedValues, retainedValues);
        addModification(addMod);
      }
    }
  }