>From 5decab24f06f714facaa7e9fdb98cb8db132a896 Mon Sep 17 00:00:00 2001
From: Ade Lee <alee@redhat.com>
Date: Thu, 18 Oct 2012 01:20:46 -0400
Subject: [PATCH 76/77] Reorder VLV indexing for clones to avoid errors

---
 base/ca/shared/conf/CS.cfg.in                                     | 4 ++--
 .../src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java  | 8 ++++----
 .../src/com/netscape/cms/servlet/csadmin/DatabasePanel.java       | 7 +++----
 .../src/com/netscape/cms/servlet/csadmin/SystemConfigService.java | 8 ++++----
 base/kra/shared/conf/CS.cfg.in                                    | 4 ++--
 5 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/base/ca/shared/conf/CS.cfg.in b/base/ca/shared/conf/CS.cfg.in
index 94a3e5b49f925d1706bc9f257d76f2588a5987fc..5a2eea6ca3b384469e5b8e645214c728ddb3a194 100644
--- a/base/ca/shared/conf/CS.cfg.in
+++ b/base/ca/shared/conf/CS.cfg.in
@@ -818,9 +818,9 @@ internaldb.ldapconn.secureConn=false
 preop.internaldb.schema.ldif=/usr/share/pki/ca/conf/schema.ldif
 preop.internaldb.ldif=/usr/share/pki/ca/conf/database.ldif
 preop.internaldb.data_ldif=/usr/share/pki/ca/conf/db.ldif,/usr/share/pki/ca/conf/acl.ldif
-preop.internaldb.index_ldif=
+preop.internaldb.index_ldif=/usr/share/pki/ca/conf/index.ldif
 preop.internaldb.manager_ldif=/usr/share/pki/ca/conf/manager.ldif
-preop.internaldb.post_ldif=/usr/share/pki/ca/conf/index.ldif,/usr/share/pki/ca/conf/vlv.ldif,/usr/share/pki/ca/conf/vlvtasks.ldif
+preop.internaldb.post_ldif=/usr/share/pki/ca/conf/vlv.ldif,/usr/share/pki/ca/conf/vlvtasks.ldif
 preop.internaldb.wait_dn=cn=index1160589769, cn=index, cn=tasks, cn=config
 internaldb.multipleSuffix.enable=false
 jobsScheduler._000=##
diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java b/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
index 89233bdc2f82c842ee3add8b7a311865bac9202c..d90ab211e6dd9598871b1eefe247a3f169c8972a 100644
--- a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
+++ b/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
@@ -1509,8 +1509,8 @@ public class ConfigurationUtils {
         return dir.delete();
     }
 
-    public static void populateIndexes() throws Exception {
-        CMS.debug("populateIndexes(): start");
+    public static void populateVLVIndexes() throws Exception {
+        CMS.debug("populateVLVIndexes(): start");
         IConfigStore cs = CMS.getConfigStore();
 
         IConfigStore dbCfg = cs.getSubStore("internaldb");
@@ -1545,7 +1545,7 @@ public class ConfigurationUtils {
                                 taskComplete = true;
                                 String val = (String) attr.getStringValues().nextElement();
                                 if (val.compareTo("0") != 0) {
-                                    CMS.debug("Error in populating local indexes: nsTaskExitCode=" + val);
+                                    CMS.debug("Error in populating local VLV indexes: nsTaskExitCode=" + val);
                                 }
                             }
                         }
@@ -1555,7 +1555,7 @@ public class ConfigurationUtils {
                 } while (!taskComplete);
             }
         } catch (Exception e) {
-            CMS.debug("populateIndexes(): Exception thrown: " + e);
+            CMS.debug("populateVLVIndexes(): Exception thrown: " + e);
             throw e;
         } finally {
             releaseConnection(conn);
diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/DatabasePanel.java b/base/common/src/com/netscape/cms/servlet/csadmin/DatabasePanel.java
index 89f01e01ccc20cd580406435312e22e061d9ab5c..67f10bd8e6f2ee732ebfd89f102cc1db7acaa023 100644
--- a/base/common/src/com/netscape/cms/servlet/csadmin/DatabasePanel.java
+++ b/base/common/src/com/netscape/cms/servlet/csadmin/DatabasePanel.java
@@ -483,15 +483,14 @@ public class DatabasePanel extends WizardPanelBase {
             cs.putString("preop.internaldb.replicationpwd", replicationpwd);
             cs.putString("preop.database.removeData", "false");
 
-            ConfigurationUtils.reInitSubsystem(csType);
-            ConfigurationUtils.populateIndexes();
-
             if (select.equals("clone")) {
                 CMS.debug("Start setting up replication.");
                 ConfigurationUtils.setupReplication();
-                ConfigurationUtils.reInitSubsystem(csType);
             }
 
+            ConfigurationUtils.reInitSubsystem(csType);
+            ConfigurationUtils.populateVLVIndexes();
+
             cs.putBoolean("preop.Database.done", true);
             cs.commit(false);
         } catch (Exception e) {
diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigService.java b/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigService.java
index 3bbe3ca8099f0e722271e9bf7ae21812bffb5404..3b6ea1a1f1854e63f9dcbb30adca149a0c17a86d 100644
--- a/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigService.java
+++ b/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigService.java
@@ -385,14 +385,14 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
             cs.putString("preop.database.removeData", "false");
             cs.commit(false);
 
-            ConfigurationUtils.reInitSubsystem(csType);
-            ConfigurationUtils.populateIndexes();
-
             if (data.getIsClone().equals("true")) {
                 CMS.debug("Start setting up replication.");
                 ConfigurationUtils.setupReplication();
-                ConfigurationUtils.reInitSubsystem(csType);
             }
+
+            ConfigurationUtils.reInitSubsystem(csType);
+            ConfigurationUtils.populateVLVIndexes();
+
         } catch (Exception e) {
             throw new PKIException("Error in populating database" + e);
         }
diff --git a/base/kra/shared/conf/CS.cfg.in b/base/kra/shared/conf/CS.cfg.in
index 28653a9585a246b7462397d0462b777616458ac9..087e40cb2ff9defcedc2404b5b8f98270fab51c3 100644
--- a/base/kra/shared/conf/CS.cfg.in
+++ b/base/kra/shared/conf/CS.cfg.in
@@ -225,9 +225,9 @@ internaldb.ldapconn.secureConn=false
 preop.internaldb.schema.ldif=/usr/share/pki/kra/conf/schema.ldif
 preop.internaldb.ldif=/usr/share/pki/kra/conf/database.ldif
 preop.internaldb.data_ldif=/usr/share/pki/kra/conf/db.ldif,/usr/share/pki/kra/conf/acl.ldif
-preop.internaldb.index_ldif=
+preop.internaldb.index_ldif=/usr/share/pki/kra/conf/index.ldif
 preop.internaldb.manager_ldif=/usr/share/pki/ca/conf/manager.ldif
-preop.internaldb.post_ldif=/usr/share/pki/kra/conf/index.ldif,/usr/share/pki/kra/conf/vlv.ldif,/usr/share/pki/kra/conf/vlvtasks.ldif
+preop.internaldb.post_ldif=/usr/share/pki/kra/conf/vlv.ldif,/usr/share/pki/kra/conf/vlvtasks.ldif
 preop.internaldb.wait_dn=cn=index1160527115, cn=index, cn=tasks, cn=config
 internaldb.multipleSuffix.enable=false
 jobsScheduler._000=##
-- 
1.7.11.4

