From a8bed418bf40c519bf4c49efb7e678b86a39e52b Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Mon, 31 May 2010 09:21:28 +0000
Subject: [PATCH] Remove useless local-only argument in dsreplication command

---
 opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/PreExternalInitializationUserData.java |   24 -------
 opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java                |  115 ++++----------------------------------
 opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java      |   28 +--------
 opendj-sdk/opends/src/messages/messages/admin_tool.properties                                             |   11 ---
 4 files changed, 18 insertions(+), 160 deletions(-)

diff --git a/opendj-sdk/opends/src/messages/messages/admin_tool.properties b/opendj-sdk/opends/src/messages/messages/admin_tool.properties
index b988c33..e12d4da 100644
--- a/opendj-sdk/opends/src/messages/messages/admin_tool.properties
+++ b/opendj-sdk/opends/src/messages/messages/admin_tool.properties
@@ -491,9 +491,6 @@
  initialized
 INFO_DESCRIPTION_INITIALIZE_REPLICATION_SERVER_PORT_DESTINATION=Directory \
  server administration port number of the destination server whose contents will be initialized
-INFO_DESCRIPTION_EXTERNAL_INITIALIZATION_LOCAL=Use this option when the \
- contents of only the specified directory server will be initialized with an \
- external method (import-ldif command or binary copy)
 INFO_REPLICATION_TOOL_DESCRIPTION=This utility can be used to configure \
  replication between servers so that the data of the servers is synchronized.\
  For replication to work you must first enable replication using the \
@@ -667,9 +664,6 @@
  base DN to be disabled.
 MILD_ERR_NO_SUFFIXES_SELECTED_TO_INITIALIZE_ALL=You must choose at least one \
  base DN to initialize.
-INFO_REPLICATION_PRE_EXTERNAL_INITIALIZATION_LOCAL_PROMPT=Are you going to \
- initialize only the contents of server %s (type 'no' if you will initialize \
- contents of all replicated servers for the given Base DN's)?
 MILD_ERR_NO_SUFFIXES_SELECTED_TO_PRE_EXTERNAL_INITIALIZATION=You must specify \
  the base DN's that will be initialized using the import-ldif command or the \
  binary copy.
@@ -903,11 +897,6 @@
  initialized externally
 INFO_PROGRESS_POST_EXTERNAL_INITIALIZATION=Updating replication information on \
  base DN %s
-INFO_PROGRESS_PRE_INITIALIZATION_LOCAL_FINISHED_PROCEDURE=Now you can proceed \
- to the initialization of the contents of the base DN's on server %s.  You can \
- use the command import-ldif or the binary copy to do so.%n%nWhen the \
- initialization is completed you must use the subcommand '%s' for replication \
- to work with the new base DN's.
 INFO_PROGRESS_PRE_INITIALIZATION_FINISHED_PROCEDURE=Now you can proceed \
  to the initialization of the contents of the base DN's on all the replicated \
  servers.  You can use the command import-ldif or the binary copy to do \
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/PreExternalInitializationUserData.java b/opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/PreExternalInitializationUserData.java
index 4944f6d..7dfa02d 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/PreExternalInitializationUserData.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/PreExternalInitializationUserData.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2008 Sun Microsystems, Inc.
+ *      Copyright 2008-2010 Sun Microsystems, Inc.
  */
 
 package org.opends.server.tools.dsreplication;
@@ -36,26 +36,4 @@
  */
 class PreExternalInitializationUserData extends MonoServerReplicationUserData
 {
-  private boolean localOnly;
-
-  /**
-   * Whether the operation must be applied only on the local server or not.
-   * @return <CODE>true</CODE> if the operation must be applied only on the
-   * local server and <CODE>false</CODE> otherwise.
-   */
-  public boolean isLocalOnly()
-  {
-    return localOnly;
-  }
-
-  /**
-   * Sets whether the operation must be applied only on the local server or not.
-   * @param onlyLocal whether the operation must be applied only on the local
-   * server or not.
-   */
-  public void setLocalOnly(boolean onlyLocal)
-  {
-    this.localOnly = onlyLocal;
-  }
-
 }
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java b/opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java
index ce17fbb..4409a8a 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java
@@ -222,12 +222,6 @@
   private StringArgument baseDNsArg = null;
 
   /**
-   * The argument that specifies if the external initialization will be
-   * performed only on this server.
-   */
-  private BooleanArgument externalInitializationLocalOnlyArg;
-
-  /**
    * The 'quiet' argument.
    */
   BooleanArgument quietArg;
@@ -855,13 +849,13 @@
         INFO_DESCRIPTION_SUBCMD_PRE_EXTERNAL_INITIALIZATION.get(
             POST_EXTERNAL_INITIALIZATION_SUBCMD_NAME));
     secureArgsList.hostNameArg.setDefaultValue(getDefaultHostValue());
-    externalInitializationLocalOnlyArg = new BooleanArgument(
+    BooleanArgument externalInitializationLocalOnlyArg = new BooleanArgument(
         "local-only",
         'l',
         "local-only",
-        INFO_DESCRIPTION_EXTERNAL_INITIALIZATION_LOCAL.get());
-    externalInitializationLocalOnlyArg.setPropertyName(
-        externalInitializationLocalOnlyArg.getLongIdentifier());
+        Message.EMPTY);
+    externalInitializationLocalOnlyArg.setHidden(true);
+
     Argument[] argsToAdd = { secureArgsList.hostNameArg,
         secureArgsList.portArg,
         externalInitializationLocalOnlyArg};
@@ -887,8 +881,6 @@
         INFO_DESCRIPTION_SUBCMD_POST_EXTERNAL_INITIALIZATION.get(
             PRE_EXTERNAL_INITIALIZATION_SUBCMD_NAME));
     secureArgsList.hostNameArg.setDefaultValue(getDefaultHostValue());
-    externalInitializationLocalOnlyArg.setPropertyName(
-        externalInitializationLocalOnlyArg.getLongIdentifier());
     Argument[] argsToAdd = { secureArgsList.hostNameArg,
         secureArgsList.portArg };
     for (int i=0; i<argsToAdd.length; i++)
@@ -1847,18 +1839,6 @@
   }
 
   /**
-   * Tells whether the user specified to apply the pre (or post) external
-   * initialization operations only on the local server.
-   * @return <CODE>true</CODE> if the user specified to apply the pre (or post)
-   * external initialization operations only on the local server and
-   * <CODE>false</CODE> otherwise.
-   */
-  public boolean isExternalInitializationLocalOnly()
-  {
-    return externalInitializationLocalOnlyArg.isPresent();
-  }
-
-  /**
    * Returns whether the command-line subcommand has the name provided
    * or not.
    * @param name the name of the subcommand.
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java b/opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
index 9f3b6bf..e111222 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -1944,28 +1944,6 @@
     }
     if (!cancelled)
     {
-      boolean localOnly = false;
-      if (!argParser.isExternalInitializationLocalOnly())
-      {
-        println();
-        try
-        {
-          localOnly = askConfirmation(
-              INFO_REPLICATION_PRE_EXTERNAL_INITIALIZATION_LOCAL_PROMPT.get(
-                  ConnectionUtils.getHostPort(ctx)), false, LOG);
-        }
-        catch (CLIException ce)
-        {
-          println(ce.getMessageObject());
-          cancelled = true;
-        }
-      }
-      else
-      {
-        localOnly = true;
-      }
-      uData.setLocalOnly(localOnly);
-
       uData.setHostName(host);
       uData.setPort(port);
       uData.setAdminUid(adminUid);
@@ -2725,7 +2703,6 @@
     int port = getValue(argParser.getPortToInitializeAll(),
         argParser.getDefaultPortToInitializeAll());
     uData.setPort(port);
-    uData.setLocalOnly(argParser.isExternalInitializationLocalOnly());
   }
 
   /**
@@ -4023,7 +4000,7 @@
             Message msg = formatter.getFormattedWithPoints(
                 INFO_PROGRESS_PRE_EXTERNAL_INITIALIZATION.get(baseDN));
             printProgress(msg);
-            preExternalInitialization(baseDN, ctx, uData.isLocalOnly(), false);
+            preExternalInitialization(baseDN, ctx, false);
             printProgress(formatter.getFormattedDone());
             printlnProgress();
           }
@@ -4035,25 +4012,12 @@
             LOG.log(Level.SEVERE, "Complete error stack:", rce);
           }
         }
-        if (uData.isLocalOnly())
-        {
-          printlnProgress();
-          printProgress(
-              INFO_PROGRESS_PRE_INITIALIZATION_LOCAL_FINISHED_PROCEDURE.get(
-                  ConnectionUtils.getHostPort(ctx),
-                  ReplicationCliArgumentParser.
-                  POST_EXTERNAL_INITIALIZATION_SUBCMD_NAME));
-          printlnProgress();
-        }
-        else
-        {
-          printlnProgress();
-          printProgress(
-            INFO_PROGRESS_PRE_INITIALIZATION_FINISHED_PROCEDURE.get(
-                ReplicationCliArgumentParser.
-                POST_EXTERNAL_INITIALIZATION_SUBCMD_NAME));
-          printlnProgress();
-        }
+        printlnProgress();
+        printProgress(
+          INFO_PROGRESS_PRE_INITIALIZATION_FINISHED_PROCEDURE.get(
+              ReplicationCliArgumentParser.
+              POST_EXTERNAL_INITIALIZATION_SUBCMD_NAME));
+        printlnProgress();
       }
       else
       {
@@ -7635,8 +7599,7 @@
       try
       {
         initializeAllSuffixTry(baseDN, ctx, displayProgress);
-        postPreExternalInitialization(baseDN, ctx, false, displayProgress,
-            false);
+        postPreExternalInitialization(baseDN, ctx, displayProgress, false);
         initDone = true;
       }
       catch (PeerNotFoundException pnfe)
@@ -7671,16 +7634,14 @@
    * connection on a given base DN.
    * @param baseDN the base DN that we want to reset.
    * @param ctx the connection to the server.
-   * @param localOnly whether the resetting internal operations must only apply
-   * to the server to which we are connected.
    * @param displayProgress whether to display operation progress or not.
    * @throws ReplicationCliException if there is an error performing the
    * operation.
    */
   private void preExternalInitialization(String baseDN, InitialLdapContext ctx,
-      boolean localOnly, boolean displayProgress) throws ReplicationCliException
+      boolean displayProgress) throws ReplicationCliException
   {
-    postPreExternalInitialization(baseDN, ctx, localOnly, displayProgress,
+    postPreExternalInitialization(baseDN, ctx, displayProgress,
         true);
   }
 
@@ -7696,7 +7657,7 @@
   private void postExternalInitialization(String baseDN, InitialLdapContext ctx,
       boolean displayProgress) throws ReplicationCliException
   {
-    postPreExternalInitialization(baseDN, ctx, false, displayProgress, false);
+    postPreExternalInitialization(baseDN, ctx, displayProgress, false);
   }
 
   /**
@@ -7704,15 +7665,13 @@
    * provided connection on a given base DN.
    * @param baseDN the base DN that we want to reset.
    * @param ctx the connection to the server.
-   * @param localOnly whether the resetting internal operations must only apply
-   * to the server to which we are connected.
    * @param displayProgress whether to display operation progress or not.
    * @param isPre whether this is the pre operation or the post operation.
    * @throws ReplicationCliException if there is an error performing the
    * operation.
    */
   private void postPreExternalInitialization(String baseDN,
-      InitialLdapContext ctx, boolean localOnly, boolean displayProgress,
+      InitialLdapContext ctx, boolean displayProgress,
       boolean isPre) throws ReplicationCliException
   {
     boolean taskCreated = false;
@@ -7729,27 +7688,7 @@
         "org.opends.server.tasks.SetGenerationIdTask");
     if (isPre)
     {
-      if (!localOnly)
-      {
-        attrs.put("ds-task-reset-generation-id-new-value", "-1");
-      }
-      else
-      {
-        try
-        {
-          attrs.put("ds-task-reset-generation-id-new-value",
-            String.valueOf(getReplicationDomainId(ctx, baseDN)));
-        }
-        catch (NamingException ne)
-        {
-          LOG.log(Level.SEVERE, "Error get replication domain id for base DN "+
-              baseDN+" on server "+ConnectionUtils.getHostPort(ctx), ne);
-
-          throw new ReplicationCliException(getThrowableMsg(
-              ERR_LAUNCHING_PRE_EXTERNAL_INITIALIZATION.get(), ne),
-              ERROR_LAUNCHING_PRE_EXTERNAL_INITIALIZATION, ne);
-        }
-      }
+      attrs.put("ds-task-reset-generation-id-new-value", "-1");
     }
     attrs.put("ds-task-reset-generation-id-domain-base-dn", baseDN);
     while (!taskCreated)
@@ -8754,34 +8693,6 @@
   }
 
   /**
-   * Returns the replication domain ID for a given baseDN on the server.
-   * @param ctx the connection to the server.
-   * @param baseDN the baseDN for which we want the replication domain ID.
-   * @return the replication domain ID or -1 if the replication domain ID
-   * could not be found.
-   * @throws NamingException if an error occurred reading the configuration
-   * information.
-   */
-  private int getReplicationDomainId(InitialLdapContext ctx, String baseDN)
-  throws NamingException
-  {
-    int domainId = -1;
-    TopologyCacheFilter filter = new TopologyCacheFilter();
-    filter.setSearchMonitoringInformation(false);
-    filter.addBaseDNToSearch(baseDN);
-    ServerDescriptor server = ServerDescriptor.createStandalone(ctx, filter);
-    for (ReplicaDescriptor replica : server.getReplicas())
-    {
-      if (Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN))
-      {
-        domainId = replica.getReplicationId();
-        break;
-      }
-    }
-    return domainId;
-  }
-
-  /**
    * Method used to compare two server registries.
    * @param registry1 the first registry to compare.
    * @param registry2 the second registry to compare.

--
Gitblit v1.10.0