From 935d387aca4e822929f026d987f8b95230c504d3 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 07 Mar 2016 15:12:17 +0000
Subject: [PATCH] OPENDJ-1342 Migrate AVA, RDN, and DN classes: Fix change in behaviour for DN.toNormalizedByteString()

---
 opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/Upgrade.java      |    7 ++++++-
 opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java |   14 +++++++-------
 opendj-server-legacy/src/messages/org/opends/messages/tool.properties                |   14 +++++++++-----
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/Upgrade.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/Upgrade.java
index 669d896..df06213 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/Upgrade.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/Upgrade.java
@@ -27,6 +27,7 @@
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.opends.server.core.LockFileManager;
+import org.opends.server.tools.upgrade.UpgradeTasks.UpgradeCondition;
 import org.opends.server.util.BuildVersion;
 
 import com.forgerock.opendj.cli.ClientException;
@@ -278,7 +279,7 @@
     /** See OPENDJ-992 */
     register("2.6.0",
         regressionInVersion("2.5.0",
-            rebuildSingleIndex(INFO_UPGRADE_TASK_9013_DESCRIPTION.get(),
+            rebuildIndexesNamed(INFO_UPGRADE_TASK_9013_DESCRIPTION.get(),
                 "ds-sync-hist")));
 
     /** See OPENDJ-1284 */
@@ -633,6 +634,10 @@
     /** see OPENDJ-2730 */
     register("4.0.0", removeOldJarFiles());
 
+    register("4.0.0",
+        rebuildIndexesNamed(INFO_UPGRADE_REBUILD_INDEXES_DISTINGUISHED_NAME.get(),
+            "distinguishedName", "member", "owner", "roleOccupant", "seeAlso"));
+
     /**
      * All upgrades will refresh the server configuration schema and generate a new upgrade folder.
      */
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java
index b13efc6..8ef3333 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java
@@ -28,6 +28,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedList;
@@ -604,12 +605,11 @@
    *          A message describing why the index needs to be rebuilt and asking
    *          them whether or not they wish to perform this task after the
    *          upgrade.
-   * @param index
-   *          The index to rebuild.
+   * @param indexNames
+   *          The indexes to rebuild.
    * @return The rebuild index task.
    */
-  public static UpgradeTask rebuildSingleIndex(final LocalizableMessage summary,
-      final String index)
+  public static UpgradeTask rebuildIndexesNamed(final LocalizableMessage summary, final String... indexNames)
   {
     return new AbstractUpgradeTask()
     {
@@ -628,7 +628,7 @@
       {
         if (isATaskToPerform)
         {
-          indexesToRebuild.add(index);
+          Collections.addAll(indexesToRebuild, indexNames);
         }
         else
         {
@@ -641,7 +641,7 @@
       {
         if (!isRebuildAllIndexesIsPresent)
         {
-          context.notify(INFO_UPGRADE_REBUILD_INDEX_DECLINED.get(index), TextOutputCallback.WARNING);
+          context.notify(INFO_UPGRADE_REBUILD_INDEXES_DECLINED.get(indexNames), TextOutputCallback.WARNING);
         }
       }
 
@@ -708,7 +708,7 @@
         if (backends.isEmpty())
         {
           logger.debug(INFO_UPGRADE_REBUILD_INDEX_NO_BACKEND_FOUND);
-          logger.debug(INFO_UPGRADE_REBUILD_INDEX_DECLINED, indexesToRebuild);
+          logger.debug(INFO_UPGRADE_REBUILD_INDEXES_DECLINED, indexesToRebuild);
           context.notifyProgress(pnc.setProgress(100));
           return;
         }
diff --git a/opendj-server-legacy/src/messages/org/opends/messages/tool.properties b/opendj-server-legacy/src/messages/org/opends/messages/tool.properties
index 9b57e3b..342afe5 100644
--- a/opendj-server-legacy/src/messages/org/opends/messages/tool.properties
+++ b/opendj-server-legacy/src/messages/org/opends/messages/tool.properties
@@ -2399,7 +2399,7 @@
 INFO_UPGRADE_POST_TASKS_COMPLETE_1842=Post upgrade tasks complete
 ERR_UPGRADE_PERFORMING_POST_TASKS_FAIL_1843=An error occurred during post \
 upgrade task. Process aborted. Please check log for further details
-INFO_UPGRADE_REBUILD_INDEX_DECLINED_1844 =You have to rebuild the '%s' index \
+INFO_UPGRADE_REBUILD_INDEXES_DECLINED_1844 =You have to rebuild the '%s' index(es) \
 manually to get a fully functional server
 INFO_UPGRADE_ALL_REBUILD_INDEX_DECLINED_1845=You have to rebuild all indexes \
 manually to get a fully functional server
@@ -2610,10 +2610,14 @@
 INFO_UPGRADE_TASK_RENAME_JE_DB_DIR_20022=Renaming local-db backend directory '%s' to '%s'
 INFO_UPGRADE_TASK_RENAME_JE_DB_DIR_WARNING_20023=You must reimport all your data into the PDB \
  backends in order to have a fully functional server
-INFO_UPGRADE_TASK_REMOVE_MATCHING_RULES_2683=Removing configuration for matching rules
-INFO_UPGRADE_TASK_2716_1_SUMMARY_20024=Adding 'includedAttributes' attribute type to changelog schema
-INFO_UPGRADE_TASK_2716_2_SUMMARY_20025=Updating 'changeLogEntry' object class in changelog schema
-INFO_UPGRADE_TASK_REMOVE_OLD_JARS_20024=Removing old OpenDJ library files
+INFO_UPGRADE_TASK_REMOVE_MATCHING_RULES_20024=Removing configuration for matching rules
+INFO_UPGRADE_TASK_2716_1_SUMMARY_20025=Adding 'includedAttributes' attribute type to changelog schema
+INFO_UPGRADE_TASK_2716_2_SUMMARY_20026=Updating 'changeLogEntry' object class in changelog schema
+INFO_UPGRADE_TASK_REMOVE_OLD_JARS_20027=Removing old OpenDJ library files
+INFO_UPGRADE_REBUILD_INDEXES_DISTINGUISHED_NAME_20028=OpenDJ 4.0.0 introduced a new format for all equality indexes \
+based on "distinguishedName" attribute type, like "member", "owner", "roleOccupant" and "seeAlso". \
+They all have to be rebuilt if they exist on your server and this could take a long time to proceed. \
+Do you want to launch this process automatically at the end of the upgrade?
 
 INFO_LDAP_CONN_PROMPT_SECURITY_LDAP=LDAP
 INFO_LDAP_CONN_PROMPT_SECURITY_USE_SSL=LDAP with SSL

--
Gitblit v1.10.0