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/replication/plugin/HistVal.java |   87 ++++++++++++++++++++++++++++++++++---------
 1 files changed, 69 insertions(+), 18 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/plugin/HistVal.java b/opends/src/server/org/opends/server/replication/plugin/HistVal.java
index 630909d..eae4433 100644
--- a/opends/src/server/org/opends/server/replication/plugin/HistVal.java
+++ b/opends/src/server/org/opends/server/replication/plugin/HistVal.java
@@ -32,6 +32,7 @@
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.replication.common.ChangeNumber;
 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.Modification;
@@ -41,8 +42,6 @@
 /**
  * This Class is used to encode/decode historical information
  * from the String form to the internal usable form.
- *
- * @author Gilles Bellaton
  */
 public class HistVal
 {
@@ -54,8 +53,12 @@
   private HistKey histKey;
   private String stringValue;
 
+  // This flag indicates that this HistVal was generated to store the last date
+  // when the entry was renamed.
+  private boolean ismodDN = false;
+
   /**
-   * Create a new HistVal form the String encoded form.
+   * Create a new HistVal from the String encoded form.
    *
    * @param strVal The String encoded form of historical information.
    */
@@ -73,10 +76,13 @@
      *  or
      *  description:00000108b3a6554100000001:add
      *  or
+     *  dn:00000108b3a6554100000001:add (ADD operation)
+     *  or
+     *  dn:00000108b3a6554100000001:moddn (MODIFYDN operation)
      *
      *  so after split
      *  token[0] will contain the attribute name
-     *  token[1] will contain the changenumber
+     *  token[1] will contain the change number
      *  token[2] will contain the type of historical information
      *  token[3] will contain the attribute value
      *
@@ -103,9 +109,24 @@
       attrString = token[0];
     }
 
-    attrType = DirectoryServer.getSchema().getAttributeType(attrString);
-    if (attrType == null)
-      attrType = DirectoryServer.getDefaultAttributeType(attrString);
+    if (attrString.compareTo("dn") != 0)
+    {
+      // This HistVal was used to store the date when some
+       // modifications were done to the entries.
+      attrType = DirectoryServer.getSchema().getAttributeType(attrString);
+      if (attrType == null)
+        attrType = DirectoryServer.getDefaultAttributeType(attrString);
+    }
+    else
+    {
+      // This HistVal is used to store the date when the entry
+      // was added to the directory or when it was last renamed.
+      attrType = null;
+      if ((token.length >= 3) && (token[2].compareTo("moddn") == 0))
+      {
+        ismodDN = true;
+      }
+    }
 
     cn = new ChangeNumber(token[1]);
     histKey = HistKey.decodeKey(token[2]);
@@ -139,7 +160,9 @@
 
   /**
    * Get the type of this HistVal.
+   *
    * @return Returns the type of this HistVal.
+   *         Can return NULL if the HistVal was generated for a ADD Operation.
    */
   public AttributeType getAttrType()
   {
@@ -198,27 +221,55 @@
    */
   public Modification generateMod()
   {
-    Attribute attr = new Attribute(attrType, attrString, options, null);
-    Modification mod;
+    AttributeBuilder builder = new AttributeBuilder(attrType, attrString);
+    builder.setOptions(options);
+
     if (histKey != HistKey.DELATTR)
     {
-      LinkedHashSet<AttributeValue> values =
-                                 new LinkedHashSet<AttributeValue>(1);
-      values.add(attributeValue);
-      attr.setValues(values);
+      builder.add(attributeValue);
     }
+    Attribute attr = builder.toAttribute();
+
+    Modification mod;
     switch (histKey)
     {
-      case ADD : mod = new Modification(ModificationType.ADD, attr);
+    case ADD:
+      mod = new Modification(ModificationType.ADD, attr);
       break;
-      case DEL : mod = new Modification(ModificationType.DELETE, attr);
+    case DEL:
+      mod = new Modification(ModificationType.DELETE, attr);
       break;
-      case REPL: mod = new Modification(ModificationType.REPLACE, attr);
+    case REPL:
+      mod = new Modification(ModificationType.REPLACE, attr);
       break;
-      case DELATTR: mod = new Modification(ModificationType.DELETE, attr);
+    case DELATTR:
+      mod = new Modification(ModificationType.DELETE, attr);
       break;
-      default: mod = null;
+    default:
+      mod = null;
     }
     return mod;
   }
+
+  /**
+   * Indicates if the HistVal was generated for a ADD operation.
+   *
+   * @return a boolean indicating if the HistVal was generated for a ADD
+   *         operation.
+   */
+  public boolean isADDOperation()
+  {
+    return ((attrType == null) && (ismodDN == false));
+  }
+
+  /**
+   * Indicates if the HistVal was generated for a MODDN operation.
+   *
+   * @return a boolean indicating if the HistVal was generated for a ADDMODDN
+   *         operation.
+   */
+  public boolean isMODDNOperation()
+  {
+    return ((attrType == null) && (ismodDN == true));
+  }
 }

--
Gitblit v1.10.0