From 635173d8f4111104fa5a12125fcd4f2cd3d92c22 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Wed, 4 May 2016 11:19:34 +0200 Subject: Added importContent(). --- .../cms/servlet/csadmin/ConfigurationUtils.java | 86 ++++++++++++---------- 1 file changed, 49 insertions(+), 37 deletions(-) diff --git a/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java b/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java index 8c353f0c7..94a301ad3 100644 --- a/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java +++ b/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java @@ -1300,7 +1300,7 @@ public class ConfigurationUtils { } } - public static void populateDB() throws IOException, EBaseException { + public static void populateDB() throws Exception { IConfigStore cs = CMS.getConfigStore(); String baseDN = cs.getString("internaldb.basedn"); @@ -1309,7 +1309,6 @@ public class ConfigurationUtils { boolean remove = cs.getBoolean("preop.database.removeData", false); boolean createNewDB = cs.getBoolean("preop.database.createNewDB", true); boolean setupReplication = cs.getBoolean("preop.database.setupReplication", true); - boolean reindexData = cs.getBoolean("preop.database.reindexData", false); IConfigStore dbCfg = cs.getSubStore("internaldb"); ILdapConnFactory dbFactory = CMS.getLdapBoundConnFactory("ConfigurationUtils"); @@ -1374,46 +1373,59 @@ public class ConfigurationUtils { } } - try { - if (select.equals("clone")) { - // in most cases, we want to replicate the schema and therefore - // NOT add it here. We provide this option though in case the - // clone already has schema and we want to replicate back to the - // master. - // On the other hand, if we are not setting up replication, then we - // are assuming that replication is already taken care of, and schema - // has already been replicated. No need to add. - - // Also, data will be replicated from master to clone - // so clone does not need the data - boolean replicateSchema = cs.getBoolean("preop.internaldb.replicateSchema", true); - if (!replicateSchema || !setupReplication) { - importLDIFS("preop.internaldb.schema.ldif", conn); - } - importLDIFS("preop.internaldb.ldif", conn); + importContent(conn); - // add the index before replication, add VLV indexes afterwards - importLDIFS("preop.internaldb.index_ldif", conn); + } finally { + releaseConnection(conn); + } + } - if (!setupReplication && reindexData) { - // data has already been replicated but not yet indexed - - // re-index here - populateIndexes(conn); - } - } else { - // this is the normal non-clone case - // import schema, database, initial data and indexes + private static void importContent(LDAPConnection conn) throws Exception { + + IConfigStore cs = CMS.getConfigStore(); + String select = cs.getString("preop.subsystem.select", ""); + boolean reindexData = cs.getBoolean("preop.database.reindexData", false); + boolean setupReplication = cs.getBoolean("preop.database.setupReplication", true); + + try { + if (select.equals("clone")) { + // in most cases, we want to replicate the schema and therefore + // NOT add it here. We provide this option though in case the + // clone already has schema and we want to replicate back to the + // master. + // On the other hand, if we are not setting up replication, then we + // are assuming that replication is already taken care of, and schema + // has already been replicated. No need to add. + + // Also, data will be replicated from master to clone + // so clone does not need the data + boolean replicateSchema = cs.getBoolean("preop.internaldb.replicateSchema", true); + if (!replicateSchema || !setupReplication) { importLDIFS("preop.internaldb.schema.ldif", conn); - importLDIFS("preop.internaldb.ldif", conn); - importLDIFS("preop.internaldb.data_ldif", conn); - importLDIFS("preop.internaldb.index_ldif", conn); } - } catch (Exception e) { - CMS.debug("Failed to import ldif files: " + e); - throw new EBaseException("Failed to import ldif files: " + e, e); + importLDIFS("preop.internaldb.ldif", conn); + + // add the index before replication, add VLV indexes afterwards + importLDIFS("preop.internaldb.index_ldif", conn); + + if (!setupReplication && reindexData) { + // data has already been replicated but not yet indexed - + // re-index here + populateIndexes(conn); + } + + } else { + // this is the normal non-clone case + // import schema, database, initial data and indexes + importLDIFS("preop.internaldb.schema.ldif", conn); + importLDIFS("preop.internaldb.ldif", conn); + importLDIFS("preop.internaldb.data_ldif", conn); + importLDIFS("preop.internaldb.index_ldif", conn); } - } finally { - releaseConnection(conn); + + } catch (Exception e) { + CMS.debug("Failed to import ldif files: " + e); + throw new EBaseException("Failed to import ldif files: " + e, e); } } -- cgit