From f73b655466092169abac34833fb628fce1fcdebe Mon Sep 17 00:00:00 2001
From: jcduff <jcduff@localhost>
Date: Thu, 23 Oct 2008 14:04:24 +0000
Subject: [PATCH] The commit will bring the following features :     - An updated version of the underlying database. BDB JE 3.3 is now used.     - Attribute API refactoring providing a better abstraction and offering improved performances.     - A new GUI called the Control-Panel to replace the Status-Panel: the specifications for this       GUI are available on OpenDS Wiki and contains a link to a mockup.        See <https://www.opends.org/wiki/page/ControlPanelUISpecification>.     - Some changes in the replication protocol to implement "Assured Replication Mode". The        specifications are on OpenDS Wiki at <https://www.opends.org/wiki/page/AssuredMode> and section 7       described some of the replication changes required to support this. Assured Replication is not finished,       but the main replication protocol changes to support it are done. As explained by Gilles on an email on       the Dev mailing list (http://markmail.org/message/46rgo3meq3vriy4a), with these changes the newer versions       of OpenDS may not be able to replicate with OpenDS 1.0 instances.     - Support for Service Tags on the platforms where the functionality is available and enabled. Specifications       are published at <https://www.opends.org/wiki/page/OpenDSServiceTagEnabled>. For more information on       Service Tags see <http://wikis.sun.com/display/ServiceTag/Sun+Service+Tag+FAQ>.     - The Admin Connector service. In order to provide agentry of the OpenDS server at any time, a new service       has been added, dedicated to the administration, configuration and monitoring of the server.       An overview of the Admin Connector service and it's use is available on the       OpenDS wiki <https://www.opends.org/wiki/page/ManagingAdministrationTrafficToTheServer>     - Updates to the various command line tools to support the Admin Connector service.     - Some internal re-architecting of the server to put the foundation of future developments such as virtual       directory services. The new NetworkGroups and WorkFlow internal services which have been specified in       <https://www.opends.org/wiki/page/BasicOperationRoutingThroughNetworkGroup> are now implemented.     - Many bug fixes...

---
 opends/src/server/org/opends/server/tools/LDIFDiff.java |   82 +++++++++++++++-------------------------
 1 files changed, 31 insertions(+), 51 deletions(-)

diff --git a/opends/src/server/org/opends/server/tools/LDIFDiff.java b/opends/src/server/org/opends/server/tools/LDIFDiff.java
index 1d9365f..a5ca4ec 100644
--- a/opends/src/server/org/opends/server/tools/LDIFDiff.java
+++ b/opends/src/server/org/opends/server/tools/LDIFDiff.java
@@ -45,6 +45,7 @@
 import org.opends.server.extensions.ConfigFileHandler;
 import org.opends.server.protocols.ldap.LDAPResultCode;
 import org.opends.server.types.Attribute;
+import org.opends.server.types.AttributeBuilder;
 import org.opends.server.types.AttributeType;
 import org.opends.server.types.AttributeValue;
 import org.opends.server.types.DN;
@@ -282,7 +283,7 @@
     {
       // Bootstrap the Directory Server configuration for use as a client.
       DirectoryServer directoryServer = DirectoryServer.getInstance();
-      directoryServer.bootstrapClient();
+      DirectoryServer.bootstrapClient();
 
 
       // If we're to use the configuration then initialize it, along with the
@@ -291,7 +292,7 @@
       {
         try
         {
-          directoryServer.initializeJMX();
+          DirectoryServer.initializeJMX();
         }
         catch (Exception e)
         {
@@ -816,34 +817,32 @@
       }
     }
 
-    if (! sourceClasses.isEmpty())
+    if (!sourceClasses.isEmpty())
     {
       // Whatever is left must have been deleted.
       AttributeType attrType = DirectoryServer.getObjectClassAttributeType();
-      LinkedHashSet<AttributeValue> values =
-           new LinkedHashSet<AttributeValue>();
+      AttributeBuilder builder = new AttributeBuilder(attrType);
       for (ObjectClass oc : sourceClasses)
       {
-        values.add(new AttributeValue(attrType, oc.getNameOrOID()));
+        builder.add(new AttributeValue(attrType, oc.getNameOrOID()));
       }
 
-      Attribute attr = new Attribute(attrType, attrType.getNameOrOID(), values);
-      modifications.add(new Modification(ModificationType.DELETE, attr));
+      modifications.add(new Modification(ModificationType.DELETE, builder
+          .toAttribute()));
     }
 
     if (! targetClasses.isEmpty())
     {
       // Whatever is left must have been added.
       AttributeType attrType = DirectoryServer.getObjectClassAttributeType();
-      LinkedHashSet<AttributeValue> values =
-           new LinkedHashSet<AttributeValue>();
+      AttributeBuilder builder = new AttributeBuilder(attrType);
       for (ObjectClass oc : targetClasses)
       {
-        values.add(new AttributeValue(attrType, oc.getNameOrOID()));
+        builder.add(new AttributeValue(attrType, oc.getNameOrOID()));
       }
 
-      Attribute a = new Attribute(attrType, attrType.getNameOrOID(), values);
-      modifications.add(new Modification(ModificationType.ADD, a));
+      modifications.add(new Modification(ModificationType.ADD, builder
+          .toAttribute()));
     }
 
 
@@ -899,40 +898,25 @@
           }
           else
           {
-            // See if the value lists are equal.
-            LinkedHashSet<AttributeValue> sourceValues = sourceAttr.getValues();
-            LinkedHashSet<AttributeValue> targetValues = targetAttr.getValues();
-            LinkedHashSet<AttributeValue> deletedValues =
-                 new LinkedHashSet<AttributeValue>();
-            Iterator<AttributeValue> valueIterator = sourceValues.iterator();
-            while (valueIterator.hasNext())
+            // Compare the values.
+            AttributeBuilder addedValuesBuilder = new AttributeBuilder(
+                targetAttr);
+            addedValuesBuilder.removeAll(sourceAttr);
+            Attribute addedValues = addedValuesBuilder.toAttribute();
+            if (!addedValues.isEmpty())
             {
-              AttributeValue v = valueIterator.next();
-              valueIterator.remove();
-
-              if (! targetValues.remove(v))
-              {
-                // This particular value has been deleted.
-                deletedValues.add(v);
-              }
+              modifications.add(new Modification(ModificationType.ADD,
+                  addedValues));
             }
 
-            if (! deletedValues.isEmpty())
+            AttributeBuilder deletedValuesBuilder = new AttributeBuilder(
+                sourceAttr);
+            deletedValuesBuilder.removeAll(targetAttr);
+            Attribute deletedValues = deletedValuesBuilder.toAttribute();
+            if (!deletedValues.isEmpty())
             {
-              Attribute attr = new Attribute(type, sourceAttr.getName(),
-                                             sourceAttr.getOptions(),
-                                             deletedValues);
               modifications.add(new Modification(ModificationType.DELETE,
-                                                 attr));
-            }
-
-            // Anything left in the target list has been added.
-            if (! targetValues.isEmpty())
-            {
-              Attribute attr = new Attribute(type, sourceAttr.getName(),
-                                             sourceAttr.getOptions(),
-                                             targetValues);
-              modifications.add(new Modification(ModificationType.ADD, attr));
+                  deletedValues));
             }
           }
         }
@@ -982,8 +966,7 @@
         for (Modification m : modifications)
         {
           Attribute a = m.getAttribute();
-          LinkedHashSet<AttributeValue> values = a.getValues();
-          if (values.isEmpty())
+          if (a.isEmpty())
           {
             LinkedList<Modification> attrMods = new LinkedList<Modification>();
             attrMods.add(m);
@@ -992,14 +975,11 @@
           else
           {
             LinkedList<Modification> attrMods = new LinkedList<Modification>();
-            LinkedHashSet<AttributeValue> valueSet =
-                 new LinkedHashSet<AttributeValue>();
-            for (AttributeValue v : values)
+            for (AttributeValue v : a)
             {
-              valueSet.clear();
-              valueSet.add(v);
-              Attribute attr = new Attribute(a.getAttributeType(),
-                                             a.getName(), valueSet);
+              AttributeBuilder builder = new AttributeBuilder(a, true);
+              builder.add(v);
+              Attribute attr = builder.toAttribute();
 
               attrMods.clear();
               attrMods.add(new Modification(m.getModificationType(), attr));

--
Gitblit v1.10.0