From 663ed55bcb36bc5bcb22fde58b857689397844cb Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Thu, 15 Nov 2007 20:53:25 +0000
Subject: [PATCH] CLI part for Issue 2424 (Impact of generation ID on binary copy).

---
 opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliArgumentParser.java |  291 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 291 insertions(+), 0 deletions(-)

diff --git a/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliArgumentParser.java b/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliArgumentParser.java
index 67382d1..3598135 100644
--- a/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliArgumentParser.java
+++ b/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliArgumentParser.java
@@ -62,6 +62,8 @@
   private SubCommand disableReplicationSubCmd;
   private SubCommand initializeReplicationSubCmd;
   private SubCommand initializeAllReplicationSubCmd;
+  private SubCommand postExternalInitializationSubCmd;
+  private SubCommand preExternalInitializationSubCmd;
   private SubCommand statusReplicationSubCmd;
 
   private BooleanArgument noPromptArg;
@@ -219,6 +221,12 @@
   private StringArgument baseDNsArg = null;
 
   /**
+   * The argument that specifies if the external initialization will be
+   * performed only on this server.
+   */
+  private BooleanArgument externalInitializationOnlyInLocalArg;
+
+  /**
    * The 'quiet' argument.
    */
   private BooleanArgument quietArg;
@@ -250,6 +258,18 @@
     "initialize-all";
 
   /**
+   * The text of the pre external initialization subcommand.
+   */
+  public static final String PRE_EXTERNAL_INITIALIZATION_SUBCMD_NAME =
+    "pre-external-initialization";
+
+  /**
+   * The text of the initialize all replication subcommand.
+   */
+  public static final String POST_EXTERNAL_INITIALIZATION_SUBCMD_NAME =
+    "post-external-initialization";
+
+  /**
    * The text of the status replication subcommand.
    */
   public static final String STATUS_REPLICATION_SUBCMD_NAME = "status";
@@ -288,6 +308,8 @@
     createDisableReplicationSubCommand();
     createInitializeReplicationSubCommand();
     createInitializeAllReplicationSubCommand();
+    createPreExternalInitializationSubCommand();
+    createPostExternalInitializationSubCommand();
     createStatusReplicationSubCommand();
   }
 
@@ -695,6 +717,65 @@
   }
 
   /**
+   * Creates the subcommand that the user must launch before doing an external
+   * initialization of the topology ( and all the specific
+   * options for the subcommand.  Note: this method assumes that
+   * initializeGlobalArguments has already been called and that hostNameArg,
+   * portArg, startTLSArg and useSSLArg have been created.
+   */
+  private void createPreExternalInitializationSubCommand()
+  throws ArgumentException
+  {
+    preExternalInitializationSubCmd = new SubCommand(this,
+        PRE_EXTERNAL_INITIALIZATION_SUBCMD_NAME,
+        INFO_DESCRIPTION_SUBCMD_PRE_EXTERNAL_INITIALIZATION.get(
+            POST_EXTERNAL_INITIALIZATION_SUBCMD_NAME));
+    secureArgsList.hostNameArg.setDefaultValue(getDefaultHostValue());
+    externalInitializationOnlyInLocalArg = new BooleanArgument(
+        "only-local",
+        'l',
+        "only-local",
+        INFO_DESCRIPTION_EXTERNAL_INITIALIZATION_LOCAL.get());
+    externalInitializationOnlyInLocalArg.setPropertyName(
+        externalInitializationOnlyInLocalArg.getLongIdentifier());
+    Argument[] argsToAdd = { secureArgsList.hostNameArg,
+        secureArgsList.portArg, secureArgsList.useSSLArg,
+        secureArgsList.useStartTLSArg,
+        externalInitializationOnlyInLocalArg};
+
+    for (int i=0; i<argsToAdd.length; i++)
+    {
+      preExternalInitializationSubCmd.addArgument(argsToAdd[i]);
+    }
+  }
+
+  /**
+   * Creates the subcommand that the user must launch after doing an external
+   * initialization of the topology ( and all the specific
+   * options for the subcommand.  Note: this method assumes that
+   * initializeGlobalArguments has already been called and that hostNameArg,
+   * portArg, startTLSArg and useSSLArg have been created.
+   */
+  private void createPostExternalInitializationSubCommand()
+  throws ArgumentException
+  {
+    postExternalInitializationSubCmd = new SubCommand(this,
+        POST_EXTERNAL_INITIALIZATION_SUBCMD_NAME,
+        INFO_DESCRIPTION_SUBCMD_POST_EXTERNAL_INITIALIZATION.get(
+            PRE_EXTERNAL_INITIALIZATION_SUBCMD_NAME));
+    secureArgsList.hostNameArg.setDefaultValue(getDefaultHostValue());
+    externalInitializationOnlyInLocalArg.setPropertyName(
+        externalInitializationOnlyInLocalArg.getLongIdentifier());
+    Argument[] argsToAdd = { secureArgsList.hostNameArg,
+        secureArgsList.portArg, secureArgsList.useSSLArg,
+        secureArgsList.useStartTLSArg};
+    for (int i=0; i<argsToAdd.length; i++)
+    {
+      postExternalInitializationSubCmd.addArgument(argsToAdd[i]);
+    }
+  }
+
+  /**
    * Creates the status replication subcommand and all the specific options
    * for the subcommand.  Note: this method assumes that
    * initializeGlobalArguments has already been called and that hostNameArg,
@@ -1012,6 +1093,56 @@
   }
 
   /**
+   * Indicate if the SSL mode is required for the server in the pre external
+   * initialization subcommand.
+   *
+   * @return <CODE>true</CODE> if SSL mode is required for the server in the
+   * pre external initialization subcommand and <CODE>false</CODE> otherwise.
+   */
+  public boolean useSSLToPreExternalInitialization()
+  {
+    return secureArgsList.useSSLArg.isPresent();
+  }
+
+  /**
+   * Indicate if the SSL mode is required for the server in the pre external
+   * initialization subcommand.
+   *
+   * @return <CODE>true</CODE> if StartTLS mode is required for the server in
+   * the pre external initialization subcommand and <CODE>false</CODE>
+   * otherwise.
+   */
+  public boolean useStartTLSToPreExternalInitialization()
+  {
+    return secureArgsList.useStartTLSArg.isPresent();
+  }
+
+  /**
+   * Indicate if the SSL mode is required for the server in the post external
+   * initialization subcommand.
+   *
+   * @return <CODE>true</CODE> if SSL mode is required for the server in the
+   * post external initialization subcommand and <CODE>false</CODE> otherwise.
+   */
+  public boolean useSSLToPostExternalInitialization()
+  {
+    return secureArgsList.useSSLArg.isPresent();
+  }
+
+  /**
+   * Indicate if the SSL mode is required for the server in the post external
+   * initialization subcommand.
+   *
+   * @return <CODE>true</CODE> if StartTLS mode is required for the server in
+   * the post external initialization subcommand and <CODE>false</CODE>
+   * otherwise.
+   */
+  public boolean useStartTLSToPostExternalInitialization()
+  {
+    return secureArgsList.useStartTLSArg.isPresent();
+  }
+
+  /**
    * Indicate if the SSL mode is required for the server in the status
    * replication subcommand.
    *
@@ -1371,6 +1502,50 @@
   }
 
   /**
+   * Returns the host name explicitly provided in the pre external
+   * initialization subcommand.
+   * @return the host name explicitly provided in the pre external
+   * initialization subcommand.
+   */
+  public String getHostNameToPreExternalInitialization()
+  {
+    return getValue(secureArgsList.hostNameArg);
+  }
+
+  /**
+   * Returns the host name default value in the pre external initialization
+   * subcommand.
+   * @return the host name default value in the pre external initialization
+   * subcommand.
+   */
+  public String getDefaultHostNameToPreExternalInitialization()
+  {
+    return getDefaultValue(secureArgsList.hostNameArg);
+  }
+
+  /**
+   * Returns the host name explicitly provided in the post external
+   * initialization subcommand.
+   * @return the host name explicitly provided in the post external
+   * initialization subcommand.
+   */
+  public String getHostNameToPostExternalInitialization()
+  {
+    return getValue(secureArgsList.hostNameArg);
+  }
+
+  /**
+   * Returns the host name default value in the post external initialization
+   * subcommand.
+   * @return the host name default value in the post external initialization
+   * subcommand.
+   */
+  public String getDefaultHostNameToPostExternalInitialization()
+  {
+    return getDefaultValue(secureArgsList.hostNameArg);
+  }
+
+  /**
    * Returns the source host name explicitly provided in the initialize
    * replication subcommand.
    * @return the source host name explicitly provided in the initialize
@@ -1503,6 +1678,50 @@
   }
 
   /**
+   * Returns the server port explicitly provided in the pre external
+   * initialization subcommand.
+   * @return the server port explicitly provided in the pre external
+   * initialization subcommand.  Returns -1 if no port was explicitly provided.
+   */
+  public int getPortToPreExternalInitialization()
+  {
+    return getValue(secureArgsList.portArg);
+  }
+
+  /**
+   * Returns the server port default value in the pre external initialization
+   * subcommand.
+   * @return the server port default value in the pre external initialization
+   * subcommand.
+   */
+  public int getDefaultPortToPreExternalInitialization()
+  {
+    return getDefaultValue(secureArgsList.portArg);
+  }
+
+  /**
+   * Returns the server port explicitly provided in the post external
+   * initialization subcommand.
+   * @return the server port explicitly provided in the post external
+   * initialization subcommand.  Returns -1 if no port was explicitly provided.
+   */
+  public int getPortToPostExternalInitialization()
+  {
+    return getValue(secureArgsList.portArg);
+  }
+
+  /**
+   * Returns the server port default value in the post external initialization
+   * subcommand.
+   * @return the server port default value in the post external initialization
+   * subcommand.
+   */
+  public int getDefaultPortToPostExternalInitialization()
+  {
+    return getDefaultValue(secureArgsList.portArg);
+  }
+
+  /**
    * Returns the server port explicitly provided in the status replication
    * subcommand.
    * @return the server port explicitly provided in the status replication
@@ -1634,6 +1853,14 @@
     {
       validateInitializeAllReplicationOptions(buf);
     }
+    else if (isPreExternalInitializationSubcommand())
+    {
+      validatePreExternalInitializationOptions(buf);
+    }
+    else if (isPostExternalInitializationSubcommand())
+    {
+      validatePostExternalInitializationOptions(buf);
+    }
 
     else
     {
@@ -1688,6 +1915,28 @@
   }
 
   /**
+   * Returns whether the user provided subcommand is the pre external
+   * initialization or not.
+   * @return <CODE>true</CODE> if the user provided subcommand is the
+   * pre external initialization and <CODE>false</CODE> otherwise.
+   */
+  public boolean isPreExternalInitializationSubcommand()
+  {
+    return isSubcommand(PRE_EXTERNAL_INITIALIZATION_SUBCMD_NAME);
+  }
+
+  /**
+   * Returns whether the user provided subcommand is the post external
+   * initialization or not.
+   * @return <CODE>true</CODE> if the user provided subcommand is the
+   * post external initialization and <CODE>false</CODE> otherwise.
+   */
+  public boolean isPostExternalInitializationSubcommand()
+  {
+    return isSubcommand(POST_EXTERNAL_INITIALIZATION_SUBCMD_NAME);
+  }
+
+  /**
    * Returns whether the user provided subcommand is the initialize replication
    * or not.
    * @return <CODE>true</CODE> if the user provided subcommand is the
@@ -1699,6 +1948,18 @@
   }
 
   /**
+   * 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 isExternalInitializationOnlyInLocal()
+  {
+    return externalInitializationOnlyInLocalArg.isPresent();
+  }
+
+  /**
    * Returns whether the command-line subcommand has the name provided
    * or not.
    * @param name the name of the subcommand.
@@ -1823,6 +2084,36 @@
   }
 
   /**
+   * Checks the pre external initialization subcommand options and updates the
+   * provided MessageBuilder with the errors that were encountered with the
+   * subcommand options.
+   *
+   * This method assumes that the method parseArguments for the parser has
+   * already been called.
+   * @param buf the MessageBuilder object where we add the error messages
+   * describing the errors encountered.
+   */
+  private void validatePreExternalInitializationOptions(MessageBuilder buf)
+  {
+    validateInitializeAllReplicationOptions(buf);
+  }
+
+  /**
+   * Checks the post external initialization subcommand options and updates the
+   * provided MessageBuilder with the errors that were encountered with the
+   * subcommand options.
+   *
+   * This method assumes that the method parseArguments for the parser has
+   * already been called.
+   * @param buf the MessageBuilder object where we add the error messages
+   * describing the errors encountered.
+   */
+  private void validatePostExternalInitializationOptions(MessageBuilder buf)
+  {
+    validateInitializeAllReplicationOptions(buf);
+  }
+
+  /**
    * Checks the status replication subcommand options and updates the provided
    * MessageBuilder with the errors that were encountered with the subcommand
    * options.

--
Gitblit v1.10.0