From 110726757d33bae25fabde2a8dbd2d9203e85526 Mon Sep 17 00:00:00 2001
From: pgamba <pgamba@localhost>
Date: Wed, 14 Nov 2007 18:20:29 +0000
Subject: [PATCH] Fix 2424 - impact of generation ID on binary copy - add to the SetGenerationID task the possibility to clear the generation id in the topology by providing the attribute ds-task-reset-generation-id-new-value with value -1

---
 opends/src/server/org/opends/server/tasks/SetGenerationIdTask.java |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/opends/src/server/org/opends/server/tasks/SetGenerationIdTask.java b/opends/src/server/org/opends/server/tasks/SetGenerationIdTask.java
index a439155..0045309 100644
--- a/opends/src/server/org/opends/server/tasks/SetGenerationIdTask.java
+++ b/opends/src/server/org/opends/server/tasks/SetGenerationIdTask.java
@@ -63,6 +63,7 @@
   String  domainString            = null;
   ReplicationDomain domain        = null;
   TaskState initState;
+  Long generationId = null;
 
   private static final void debugInfo(String s)
   {
@@ -85,6 +86,8 @@
    */
   @Override public void initializeTask() throws DirectoryException
   {
+    List<Attribute> attrList;
+
     if (TaskState.isDone(getTaskState()))
     {
       return;
@@ -93,13 +96,32 @@
     // FIXME -- Do we need any special authorization here?
     Entry taskEntry = getTaskEntry();
 
-    AttributeType typeDomainBase;
+    // Retrieves the eventual generation-ID
+    AttributeType typeNewValue;
+    typeNewValue =
+      getAttributeType(ATTR_TASK_SET_GENERATION_ID_NEW_VALUE, true);
+    attrList = taskEntry.getAttribute(typeNewValue);
+    if ((attrList != null) && !attrList.isEmpty())
+    {
+      try
+      {
+        generationId = new Long(TaskUtils.getSingleValueString(attrList));
+      }
+      catch(Exception e)
+      {
+        MessageBuilder mb = new MessageBuilder();
+        mb.append(TaskMessages.ERR_TASK_INITIALIZE_INVALID_GENERATION_ID.get());
+        mb.append(e.getMessage());
+        throw new DirectoryException(ResultCode.CLIENT_SIDE_PARAM_ERROR,
+            mb.toMessage());
+      }
+    }
 
     // Retrieves the replication domain
+    AttributeType typeDomainBase;
     typeDomainBase =
       getAttributeType(ATTR_TASK_SET_GENERATION_ID_DOMAIN_DN, true);
 
-    List<Attribute> attrList;
     attrList = taskEntry.getAttribute(typeDomainBase);
     domainString = TaskUtils.getSingleValueString(attrList);
     DN domainDN = DN.nullDN();
@@ -128,7 +150,7 @@
     debugInfo("setGenerationIdTask is starting on domain%s" +
         domain.getBaseDN());
 
-    domain.resetGenerationId();
+    domain.resetGenerationId(generationId);
 
     debugInfo("setGenerationIdTask is ending SUCCESSFULLY");
     return TaskState.COMPLETED_SUCCESSFULLY;

--
Gitblit v1.10.0