mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
07.50.2015 40801996942cda5d3d77402e11e3fed92f4b3c04
Code cleanups


ReplicationCliArgumentParser.java:
Extracted static class ServerArgs to separate fields named "*1" and "*2" + removed many methods.
Removed all fields named "*1" and "*2" and added fields server1 and server2 to replace them.
Extracted methods createServerArgs1() and createServerArgs2().

ReplicationCliMain.java:
In setConnectionDetails() and setReplicationDetails(), reduced number of parameters.
Extracted methods getReplicationPortArg() and newBooleanArgument().
2 files modified
614 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java 460 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java 154 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java
@@ -68,6 +68,54 @@
 */
public class ReplicationCliArgumentParser extends SecureConnectionCliParser
{
  /** Arguments used when enabling replication for a server. */
  static class ServerArgs
  {
    /** The 'hostName' argument for the first server. */
    StringArgument hostNameArg;
    /** The 'port' argument for the first server. */
    IntegerArgument portArg;
    /** The 'bindDN' argument for the first server. */
    StringArgument bindDnArg;
    /** The 'bindPasswordFile' argument for the first server. */
    FileBasedArgument bindPasswordFileArg;
    /** The 'bindPassword' argument for the first server. */
    StringArgument bindPasswordArg;
    /** The 'replicationPort' argument for the first server. */
    IntegerArgument replicationPortArg;
    /** The 'noReplicationServer' argument for the first server. */
    BooleanArgument noReplicationServerArg;
    /** The 'onlyReplicationServer' argument for the first server. */
    BooleanArgument onlyReplicationServerArg;
    /** The 'secureReplication' argument for the first server. */
    BooleanArgument secureReplicationArg;
    /**
     * Get the password which has to be used for the command to connect to this server without
     * prompting the user in the enable replication subcommand. If no password was specified return
     * null.
     *
     * @return the password which has to be used for the command to connect to this server without
     *         prompting the user in the enable replication subcommand. If no password was specified
     *         return null.
     */
    String getBindPassword()
    {
      return ReplicationCliArgumentParser.getBindPassword(bindPasswordArg, bindPasswordFileArg);
    }
    boolean configureReplicationDomain()
    {
      return !onlyReplicationServerArg.isPresent();
    }
    boolean configureReplicationServer()
    {
      return !noReplicationServerArg.isPresent();
    }
  }
  private SubCommand enableReplicationSubCmd;
  private SubCommand disableReplicationSubCmd;
  private SubCommand initializeReplicationSubCmd;
@@ -83,42 +131,12 @@
  /** No-prompt argument. */
  BooleanArgument noPromptArg;
  private String defaultLocalHostValue;
  /** The 'hostName' argument for the first server. */
  private StringArgument hostName1Arg;
  /** The 'port' argument for the first server. */
  private IntegerArgument port1Arg;
  /** The 'bindDN' argument for the first server. */
  private StringArgument bindDn1Arg;
  /** The 'bindPasswordFile' argument for the first server. */
  FileBasedArgument bindPasswordFile1Arg;
  /** The 'bindPassword' argument for the first server. */
  StringArgument bindPassword1Arg;
  /** The 'replicationPort' argument for the first server. */
  IntegerArgument replicationPort1Arg;
  /** The 'noReplicationServer' argument for the first server. */
  BooleanArgument noReplicationServer1Arg;
  /** The 'onlyReplicationServer' argument for the first server. */
  BooleanArgument onlyReplicationServer1Arg;
  /** The 'secureReplication' argument for the first server. */
  private BooleanArgument secureReplication1Arg;
  /** The 'hostName' argument for the second server. */
  private StringArgument hostName2Arg;
  /** The 'port' argument for the second server. */
  private IntegerArgument port2Arg;
  /** The 'binDN' argument for the second server. */
  private StringArgument bindDn2Arg;
  /** The 'bindPasswordFile' argument for the second server. */
  FileBasedArgument bindPasswordFile2Arg;
  /** The 'bindPassword' argument for the second server. */
  StringArgument bindPassword2Arg;
  /** The 'replicationPort' argument for the second server. */
  IntegerArgument replicationPort2Arg;
  /** The 'noReplicationServer' argument for the second server. */
  BooleanArgument noReplicationServer2Arg;
  /** The 'onlyReplicationServer' argument for the second server. */
  BooleanArgument onlyReplicationServer2Arg;
  /** The 'secureReplication' argument for the second server. */
  private BooleanArgument secureReplication2Arg;
  /** Arguments for the first server. */
  ServerArgs server1 = new ServerArgs();
  /** Arguments for the second server. */
  ServerArgs server2 = new ServerArgs();
  /** The 'skipPortCheckArg' argument to not check replication ports. */
  private BooleanArgument skipPortCheckArg;
  /** The 'noSchemaReplication' argument to not replicate schema. */
@@ -506,100 +524,10 @@
   * Creates the enable replication subcommand and all the specific options
   * for the subcommand.
   */
  private void createEnableReplicationSubCommand()
  throws ArgumentException
  private void createEnableReplicationSubCommand() throws ArgumentException
  {
    hostName1Arg = new StringArgument("host1", OPTION_SHORT_HOST,
        "host1", false, false, true, INFO_HOST_PLACEHOLDER.get(),
        getDefaultHostValue(),
        null, INFO_DESCRIPTION_ENABLE_REPLICATION_HOST1.get());
    port1Arg = new IntegerArgument("port1", OPTION_SHORT_PORT, "port1",
        false, false, true, INFO_PORT_PLACEHOLDER.get(),
        defaultAdminPort, null,
        true, 1,
        true, 65336,
        INFO_DESCRIPTION_ENABLE_REPLICATION_SERVER_PORT1.get());
    bindDn1Arg = new StringArgument("bindDN1", OPTION_SHORT_BINDDN,
        "bindDN1", false, false, true, INFO_BINDDN_PLACEHOLDER.get(),
        "cn=Directory Manager", null,
        INFO_DESCRIPTION_ENABLE_REPLICATION_BINDDN1.get());
    bindPassword1Arg = new StringArgument("bindPassword1",
        null, "bindPassword1", false, false, true,
        INFO_BINDPWD_PLACEHOLDER.get(), null, null,
        INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORD1.get());
    bindPasswordFile1Arg = new FileBasedArgument("bindPasswordFile1",
        null, "bindPasswordFile1", false, false,
        INFO_BINDPWD_FILE_PLACEHOLDER.get(), null, null,
        INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORDFILE1.get());
    replicationPort1Arg = new IntegerArgument("replicationPort1", 'r',
        "replicationPort1", false, false, true, INFO_PORT_PLACEHOLDER.get(),
        8989, null,
        true, 1,
        true, 65336,
        INFO_DESCRIPTION_ENABLE_REPLICATION_PORT1.get());
    secureReplication1Arg = new BooleanArgument("secureReplication1", null,
        "secureReplication1",
        INFO_DESCRIPTION_ENABLE_SECURE_REPLICATION1.get());
    noReplicationServer1Arg = new BooleanArgument(
        "noreplicationserver1", null, "noReplicationServer1",
        INFO_DESCRIPTION_ENABLE_REPLICATION_NO_REPLICATION_SERVER1.get());
    onlyReplicationServer1Arg = new BooleanArgument(
        "onlyreplicationserver1", null, "onlyReplicationServer1",
        INFO_DESCRIPTION_ENABLE_REPLICATION_ONLY_REPLICATION_SERVER1.get());
    hostName2Arg = new StringArgument("host2", 'O',
        "host2", false, false, true, INFO_HOST_PLACEHOLDER.get(),
        getDefaultHostValue(),
        null, INFO_DESCRIPTION_ENABLE_REPLICATION_HOST2.get());
    port2Arg = new IntegerArgument("port2", null, "port2",
        false, false, true, INFO_PORT_PLACEHOLDER.get(), defaultAdminPort, null,
        true, 1,
        true, 65336,
        INFO_DESCRIPTION_ENABLE_REPLICATION_SERVER_PORT2.get());
    bindDn2Arg = new StringArgument("bindDN2", null,
        "bindDN2", false, false, true, INFO_BINDDN_PLACEHOLDER.get(),
        "cn=Directory Manager", null,
        INFO_DESCRIPTION_ENABLE_REPLICATION_BINDDN2.get());
    bindPassword2Arg = new StringArgument("bindPassword2",
        null, "bindPassword2", false, false, true,
        INFO_BINDPWD_PLACEHOLDER.get(), null, null,
        INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORD2.get());
    bindPasswordFile2Arg = new FileBasedArgument("bindPasswordFile2",
        'F', "bindPasswordFile2", false, false,
        INFO_BINDPWD_FILE_PLACEHOLDER.get(), null, null,
        INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORDFILE2.get());
    replicationPort2Arg = new IntegerArgument("replicationPort2", 'R',
        "replicationPort2", false, false, true, INFO_PORT_PLACEHOLDER.get(),
        8989, null,
        true, 1,
        true, 65336,
        INFO_DESCRIPTION_ENABLE_REPLICATION_PORT2.get());
    secureReplication2Arg = new BooleanArgument("secureReplication2", null,
        "secureReplication2",
        INFO_DESCRIPTION_ENABLE_SECURE_REPLICATION2.get());
    noReplicationServer2Arg = new BooleanArgument(
        "noreplicationserver2", null, "noReplicationServer2",
        INFO_DESCRIPTION_ENABLE_REPLICATION_NO_REPLICATION_SERVER2.get());
    onlyReplicationServer2Arg = new BooleanArgument(
        "onlyreplicationserver2", null, "onlyReplicationServer2",
        INFO_DESCRIPTION_ENABLE_REPLICATION_ONLY_REPLICATION_SERVER2.get());
    createServerArgs1();
    createServerArgs2();
    skipPortCheckArg = new BooleanArgument(
        "skipportcheck", 'S', "skipPortCheck",
@@ -619,14 +547,13 @@
        INFO_DESCRIPTION_SUBCMD_ENABLE_REPLICATION.get());
    Argument[] argsToAdd = {
        hostName1Arg, port1Arg, bindDn1Arg, bindPassword1Arg,
        bindPasswordFile1Arg, replicationPort1Arg, secureReplication1Arg,
        noReplicationServer1Arg, onlyReplicationServer1Arg,
        hostName2Arg, port2Arg, bindDn2Arg, bindPassword2Arg,
        bindPasswordFile2Arg, replicationPort2Arg, secureReplication2Arg,
        noReplicationServer2Arg, onlyReplicationServer2Arg,
        skipPortCheckArg, noSchemaReplicationArg,
        useSecondServerAsSchemaSourceArg
          server1.hostNameArg, server1.portArg, server1.bindDnArg, server1.bindPasswordArg,
          server1.bindPasswordFileArg, server1.replicationPortArg, server1.secureReplicationArg,
          server1.noReplicationServerArg, server1.onlyReplicationServerArg,
          server2.hostNameArg, server2.portArg, server2.bindDnArg, server2.bindPasswordArg,
          server2.bindPasswordFileArg, server2.replicationPortArg, server2.secureReplicationArg,
          server2.noReplicationServerArg, server2.onlyReplicationServerArg,
          skipPortCheckArg, noSchemaReplicationArg, useSecondServerAsSchemaSourceArg
    };
    for (Argument arg : argsToAdd)
    {
@@ -635,6 +562,105 @@
    }
  }
  private void createServerArgs1() throws ArgumentException
  {
    ServerArgs server = server1;
    server.hostNameArg = new StringArgument("host1", OPTION_SHORT_HOST,
        "host1", false, false, true, INFO_HOST_PLACEHOLDER.get(),
        getDefaultHostValue(),
        null, INFO_DESCRIPTION_ENABLE_REPLICATION_HOST1.get());
    server.portArg = new IntegerArgument("port1", OPTION_SHORT_PORT, "port1",
        false, false, true, INFO_PORT_PLACEHOLDER.get(),
        defaultAdminPort, null,
        true, 1,
        true, 65336,
        INFO_DESCRIPTION_ENABLE_REPLICATION_SERVER_PORT1.get());
    server.bindDnArg = new StringArgument("bindDN1", OPTION_SHORT_BINDDN,
        "bindDN1", false, false, true, INFO_BINDDN_PLACEHOLDER.get(),
        "cn=Directory Manager", null,
        INFO_DESCRIPTION_ENABLE_REPLICATION_BINDDN1.get());
    server.bindPasswordArg = new StringArgument("bindPassword1",
        null, "bindPassword1", false, false, true,
        INFO_BINDPWD_PLACEHOLDER.get(), null, null,
        INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORD1.get());
    server.bindPasswordFileArg = new FileBasedArgument("bindPasswordFile1",
        null, "bindPasswordFile1", false, false,
        INFO_BINDPWD_FILE_PLACEHOLDER.get(), null, null,
        INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORDFILE1.get());
    server.replicationPortArg = new IntegerArgument("replicationPort1", 'r',
        "replicationPort1", false, false, true, INFO_PORT_PLACEHOLDER.get(),
        8989, null,
        true, 1,
        true, 65336,
        INFO_DESCRIPTION_ENABLE_REPLICATION_PORT1.get());
    server.secureReplicationArg = new BooleanArgument("secureReplication1", null,
        "secureReplication1",
        INFO_DESCRIPTION_ENABLE_SECURE_REPLICATION1.get());
    server.noReplicationServerArg = new BooleanArgument(
        "noreplicationserver1", null, "noReplicationServer1",
        INFO_DESCRIPTION_ENABLE_REPLICATION_NO_REPLICATION_SERVER1.get());
    server.onlyReplicationServerArg = new BooleanArgument(
        "onlyreplicationserver1", null, "onlyReplicationServer1",
        INFO_DESCRIPTION_ENABLE_REPLICATION_ONLY_REPLICATION_SERVER1.get());
  }
  private void createServerArgs2() throws ArgumentException
  {
    ServerArgs server = server2;
    server.hostNameArg = new StringArgument("host2", 'O',
        "host2", false, false, true, INFO_HOST_PLACEHOLDER.get(),
        getDefaultHostValue(),
        null, INFO_DESCRIPTION_ENABLE_REPLICATION_HOST2.get());
    server.portArg = new IntegerArgument("port2", null, "port2",
        false, false, true, INFO_PORT_PLACEHOLDER.get(), defaultAdminPort, null,
        true, 1,
        true, 65336,
        INFO_DESCRIPTION_ENABLE_REPLICATION_SERVER_PORT2.get());
    server.bindDnArg = new StringArgument("bindDN2", null,
        "bindDN2", false, false, true, INFO_BINDDN_PLACEHOLDER.get(),
        "cn=Directory Manager", null,
        INFO_DESCRIPTION_ENABLE_REPLICATION_BINDDN2.get());
    server.bindPasswordArg = new StringArgument("bindPassword2",
        null, "bindPassword2", false, false, true,
        INFO_BINDPWD_PLACEHOLDER.get(), null, null,
        INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORD2.get());
    server.bindPasswordFileArg = new FileBasedArgument("bindPasswordFile2",
        'F', "bindPasswordFile2", false, false,
        INFO_BINDPWD_FILE_PLACEHOLDER.get(), null, null,
        INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORDFILE2.get());
    server.replicationPortArg = new IntegerArgument("replicationPort2", 'R',
        "replicationPort2", false, false, true, INFO_PORT_PLACEHOLDER.get(),
        8989, null,
        true, 1,
        true, 65336,
        INFO_DESCRIPTION_ENABLE_REPLICATION_PORT2.get());
    server.secureReplicationArg = new BooleanArgument("secureReplication2", null,
        "secureReplication2",
        INFO_DESCRIPTION_ENABLE_SECURE_REPLICATION2.get());
    server.noReplicationServerArg = new BooleanArgument(
        "noreplicationserver2", null, "noReplicationServer2",
        INFO_DESCRIPTION_ENABLE_REPLICATION_NO_REPLICATION_SERVER2.get());
    server.onlyReplicationServerArg = new BooleanArgument(
        "onlyreplicationserver2", null, "onlyReplicationServer2",
        INFO_DESCRIPTION_ENABLE_REPLICATION_ONLY_REPLICATION_SERVER2.get());
  }
  /**
   * Creates the disable replication subcommand and all the specific options
   * for the subcommand.  Note: this method assumes that
@@ -898,34 +924,6 @@
  }
  /**
   * Get the password which has to be used for the command to connect to the
   * first server without prompting the user in the enable replication
   * subcommand.  If no password was specified return null.
   *
   * @return the password which has to be used for the command to connect to the
   * first server without prompting the user in the enable replication
   * subcommand.  If no password was specified return null.
   */
  public String getBindPassword1()
  {
    return getBindPassword(bindPassword1Arg, bindPasswordFile1Arg);
  }
  /**
   * Get the password which has to be used for the command to connect to the
   * second server without prompting the user in the enable replication
   * subcommand.  If no password was specified return null.
   *
   * @return the password which has to be used for the command to connect to the
   * second server without prompting the user in the enable replication
   * subcommand.  If no password was specified return null.
   */
  public String getBindPassword2()
  {
    return getBindPassword(bindPassword2Arg, bindPasswordFile2Arg);
  }
  /**
   * Get the global administrator password which has to be used for the command
   * to connect to the server(s) without prompting the user.  If no password was
   * specified, return null.
@@ -969,39 +967,6 @@
  }
  /**
   * Returns the first host name explicitly provided in the enable replication
   * subcommand.
   * @return the first host name explicitly provided in the enable replication
   * subcommand.
   */
  public StringArgument getHostName1Arg()
  {
    return hostName1Arg;
  }
  /**
   * Returns the first server port explicitly provided in the enable replication
   * subcommand.
   * @return the first server port explicitly provided in the enable replication
   * subcommand.  Returns -1 if no port was explicitly provided.
   */
  public IntegerArgument getPort1Arg()
  {
    return port1Arg;
  }
  /**
   * Returns the first server bind dn explicitly provided in the enable
   * replication subcommand.
   * @return the first server bind dn explicitly provided in the enable
   * replication subcommand.
   */
  public StringArgument getBindDn1Arg()
  {
    return bindDn1Arg;
  }
  /**
   * Returns the first server replication port explicitly provided in the enable
   * replication subcommand.
   * @return the first server replication port explicitly provided in the enable
@@ -1009,62 +974,7 @@
   */
  public int getReplicationPort1()
  {
    return getValue(replicationPort1Arg);
  }
  /**
   * Returns the first server replication port default value in the enable
   * replication subcommand.
   * @return the first server replication port default value in the enable
   * replication subcommand.
   */
  public int getReplicationPort1OrDefault()
  {
    return getValueOrDefault(replicationPort1Arg);
  }
  /**
   * Returns whether the user asked to have replication communication with the
   * first server or not.
   * @return <CODE>true</CODE> the user asked to have replication communication
   * with the first server and <CODE>false</CODE> otherwise.
   */
  public boolean isSecureReplication1()
  {
    return secureReplication1Arg.isPresent();
  }
  /**
   * Returns the second host name explicitly provided in the enable replication
   * subcommand.
   * @return the second host name explicitly provided in the enable replication
   * subcommand.
   */
  public StringArgument getHostName2Arg()
  {
    return hostName2Arg;
  }
  /**
   * Returns the second server port explicitly provided in the enable
   * replication subcommand.
   * @return the second server port explicitly provided in the enable
   * replication subcommand.  Returns -1 if no port was explicitly provided.
   */
  public IntegerArgument getPort2Arg()
  {
    return port2Arg;
  }
  /**
   * Returns the second server bind dn explicitly provided in the enable
   * replication subcommand.
   * @return the second server bind dn explicitly provided in the enable
   * replication subcommand.
   */
  public StringArgument getBindDn2Arg()
  {
    return bindDn2Arg;
    return getValue(server1.replicationPortArg);
  }
  /**
@@ -1076,29 +986,7 @@
   */
  public int getReplicationPort2()
  {
    return getValue(replicationPort2Arg);
  }
  /**
   * Returns the second server replication port default value in the enable
   * replication subcommand.
   * @return the second server replication port default value in the enable
   * replication subcommand.
   */
  public int getReplicationPort2OrDefault()
  {
    return getDefaultValue(replicationPort2Arg);
  }
  /**
   * Returns whether the user asked to have replication communication with the
   * second server or not.
   * @return <CODE>true</CODE> the user asked to have replication communication
   * with the second server and <CODE>false</CODE> otherwise.
   */
  public boolean isSecureReplication2()
  {
    return secureReplication2Arg.isPresent();
    return getValue(server2.replicationPortArg);
  }
  /**
@@ -1772,12 +1660,12 @@
  {
    Argument[][] conflictingPairs =
    {
        {bindPassword1Arg, bindPasswordFile1Arg},
        {bindPassword2Arg, bindPasswordFile2Arg},
        {replicationPort1Arg, noReplicationServer1Arg},
        {noReplicationServer1Arg, onlyReplicationServer1Arg},
        {replicationPort2Arg, noReplicationServer2Arg},
        {noReplicationServer2Arg, onlyReplicationServer2Arg},
        { server1.bindPasswordArg, server1.bindPasswordFileArg },
        { server2.bindPasswordArg, server2.bindPasswordFileArg },
        { server1.replicationPortArg, server1.noReplicationServerArg },
        { server1.noReplicationServerArg, server1.onlyReplicationServerArg },
        { server2.replicationPortArg, server2.noReplicationServerArg },
        { server2.noReplicationServerArg, server2.onlyReplicationServerArg },
        {noSchemaReplicationArg, useSecondServerAsSchemaSourceArg}
    };
@@ -1793,12 +1681,12 @@
      }
    }
    if (hostName1Arg.getValue().equalsIgnoreCase(hostName2Arg.getValue())
    if (server1.hostNameArg.getValue().equalsIgnoreCase(server2.hostNameArg.getValue())
        && !isInteractive()
        && port1Arg.getValue().equals(port2Arg.getValue()))
        && server1.portArg.getValue().equals(server2.portArg.getValue()))
    {
      LocalizableMessage message = ERR_REPLICATION_ENABLE_SAME_SERVER_PORT.get(
          hostName1Arg.getValue(), port1Arg.getValue());
          server1.hostNameArg.getValue(), server1.portArg.getValue());
      addMessage(buf, message);
    }
  }
opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -1897,19 +1897,19 @@
    /*
     * Try to connect to the first server.
     */
    String host1 = getValue(argParser.getHostName1Arg());
    int port1 = getValue(argParser.getPort1Arg());
    String bindDn1 = getValue(argParser.getBindDn1Arg());
    String pwd1 = argParser.getBindPassword1();
    String host1 = getValue(argParser.server1.hostNameArg);
    int port1 = getValue(argParser.server1.portArg);
    String bindDn1 = getValue(argParser.server1.bindDnArg);
    String pwd1 = argParser.server1.getBindPassword();
    String pwd = null;
    Map<String, String> pwdFile = null;
    if (argParser.bindPassword1Arg.isPresent())
    if (argParser.server1.bindPasswordArg.isPresent())
    {
      pwd = argParser.bindPassword1Arg.getValue();
      pwd = argParser.server1.bindPasswordArg.getValue();
    }
    else if (argParser.bindPasswordFile1Arg.isPresent())
    else if (argParser.server1.bindPasswordFileArg.isPresent())
    {
      pwdFile = argParser.bindPasswordFile1Arg.getNameToValueMap();
      pwdFile = argParser.server1.bindPasswordFileArg.getNameToValueMap();
    }
    else if (bindDn1 == null)
    {
@@ -1984,11 +1984,9 @@
      uData.getServer1().setPwd(pwd1);
    }
    int replicationPort1 = -1;
    boolean secureReplication1 = argParser.isSecureReplication1();
    boolean configureReplicationServer1 =
      !argParser.noReplicationServer1Arg.isPresent();
    boolean configureReplicationDomain1 =
      !argParser.onlyReplicationServer1Arg.isPresent();
    boolean secureReplication1 = argParser.server1.secureReplicationArg.isPresent();
    boolean configureReplicationServer1 = argParser.server1.configureReplicationServer();
    boolean configureReplicationDomain1 = argParser.server1.configureReplicationDomain();
    if (ctx1 != null)
    {
      int repPort1 = getReplicationPort(ctx1);
@@ -2040,7 +2038,7 @@
          {
            replicationPort1 = askPort(
                INFO_REPLICATION_ENABLE_REPLICATIONPORT1_PROMPT.get(),
                getDefaultValue(argParser.replicationPort1Arg), logger);
                getDefaultValue(argParser.server1.replicationPortArg), logger);
            println();
          }
          if (!argParser.skipReplicationPortCheck() && isLocalHost(host1))
@@ -2140,20 +2138,20 @@
    if (!cancelled)
    {
      host2 = getValue(argParser.getHostName2Arg());
      port2 = getValue(argParser.getPort2Arg());
      bindDn2 = getValue(argParser.getBindDn2Arg());
      pwd2 = argParser.getBindPassword2();
      host2 = getValue(argParser.server2.hostNameArg);
      port2 = getValue(argParser.server2.portArg);
      bindDn2 = getValue(argParser.server2.bindDnArg);
      pwd2 = argParser.server2.getBindPassword();
      pwdFile = null;
      pwd = null;
      if (argParser.bindPassword2Arg.isPresent())
      if (argParser.server2.bindPasswordArg.isPresent())
      {
        pwd = argParser.bindPassword2Arg.getValue();
        pwd = argParser.server2.bindPasswordArg.getValue();
      }
      else if (argParser.bindPasswordFile2Arg.isPresent())
      else if (argParser.server2.bindPasswordFileArg.isPresent())
      {
        pwdFile = argParser.bindPasswordFile2Arg.getNameToValueMap();
        pwdFile = argParser.server2.bindPasswordFileArg.getNameToValueMap();
      }
      else if (bindDn2 == null)
      {
@@ -2257,11 +2255,9 @@
    }
    int replicationPort2 = -1;
    boolean secureReplication2 = argParser.isSecureReplication2();
    boolean configureReplicationServer2 =
      !argParser.noReplicationServer2Arg.isPresent();
    boolean configureReplicationDomain2 =
      !argParser.onlyReplicationServer2Arg.isPresent();
    boolean secureReplication2 = argParser.server2.secureReplicationArg.isPresent();
    boolean configureReplicationServer2 = argParser.server2.configureReplicationServer();
    boolean configureReplicationDomain2 = argParser.server2.configureReplicationDomain();
    if (ctx2 != null)
    {
      int repPort2 = getReplicationPort(ctx2);
@@ -2314,7 +2310,7 @@
            {
              replicationPort2 = askPort(
                  INFO_REPLICATION_ENABLE_REPLICATIONPORT2_PROMPT.get(),
                  getDefaultValue(argParser.replicationPort2Arg), logger);
                  getDefaultValue(argParser.server2.replicationPortArg), logger);
              println();
            }
            if (!argParser.skipReplicationPortCheck() &&
@@ -3116,28 +3112,25 @@
  private void initializeWithArgParser(EnableReplicationUserData uData)
  {
    initialize(uData);
    String adminUid = uData.getAdminUid();
    String adminPwd = uData.getAdminPwd();
    final String adminDN = getAdministratorDN(adminUid);
    setConnectionDetails(uData.getServer1(), adminPwd, adminDN,
        argParser.getHostName1Arg(), argParser.getPort1Arg(), argParser.getBindDn1Arg(), argParser.getBindPassword1());
    setConnectionDetails(uData.getServer2(), adminPwd, adminDN,
        argParser.getHostName2Arg(), argParser.getPort2Arg(), argParser.getBindDn2Arg(), argParser.getBindPassword2());
    final String adminDN = getAdministratorDN(uData.getAdminUid());
    final String adminPwd = uData.getAdminPwd();
    setConnectionDetails(uData.getServer1(), argParser.server1, adminDN, adminPwd);
    setConnectionDetails(uData.getServer2(), argParser.server2, adminDN, adminPwd);
    uData.setReplicateSchema(!argParser.noSchemaReplication());
    setReplicationDetails(uData.getServer1(), argParser.isSecureReplication1(), argParser.onlyReplicationServer1Arg,
        argParser.noReplicationServer1Arg, argParser.getReplicationPort1OrDefault());
    setReplicationDetails(uData.getServer2(), argParser.isSecureReplication2(), argParser.onlyReplicationServer2Arg,
        argParser.noReplicationServer2Arg, argParser.getReplicationPort2OrDefault());
    setReplicationDetails(uData.getServer1(), argParser.server1);
    setReplicationDetails(uData.getServer2(), argParser.server2);
  }
  private void setConnectionDetails(EnableReplicationServerData server, String adminPwd, final String adminDN,
      StringArgument hostNameArg, IntegerArgument portArg, StringArgument bindDnArg, String pwd)
  private void setConnectionDetails(
      EnableReplicationServerData server, ServerArgs args, String adminDN, String adminPwd)
  {
    server.setHostName(getValueOrDefault(hostNameArg));
    server.setPort(getValueOrDefault(portArg));
    server.setHostName(getValueOrDefault(args.hostNameArg));
    server.setPort(getValueOrDefault(args.portArg));
    String pwd = args.getBindPassword();
    if (pwd == null)
    {
      server.setBindDn(adminDN);
@@ -3156,21 +3149,20 @@
      }
      catch (Throwable t)
      {
        server.setBindDn(getDefaultValue(bindDnArg));
        server.setBindDn(getDefaultValue(args.bindDnArg));
        server.setPwd(pwd);
      }
    }
  }
  private void setReplicationDetails(EnableReplicationServerData server, boolean secureReplication,
      BooleanArgument onlyReplicationServer, BooleanArgument noReplicationServer, int replicationPort)
  private void setReplicationDetails(EnableReplicationServerData server, ServerArgs args)
  {
    server.setSecureReplication(secureReplication);
    server.setConfigureReplicationDomain(!onlyReplicationServer.isPresent());
    server.setConfigureReplicationServer(!noReplicationServer.isPresent());
    server.setSecureReplication(args.secureReplicationArg.isPresent());
    server.setConfigureReplicationDomain(args.configureReplicationDomain());
    server.setConfigureReplicationServer(args.configureReplicationServer());
    if (server.configureReplicationServer())
    {
      server.setReplicationPort(replicationPort);
      server.setReplicationPort(getValueOrDefault(args.replicationPortArg));
    }
  }
@@ -5214,10 +5206,12 @@
    }
    Set<String> alreadyConfiguredReplicationServers = new HashSet<String>();
    configureServer(ctx1, serverDesc1, uData.getServer1(), argParser.replicationPort1Arg, usedReplicationServerIds,
        allRepServers, alreadyConfiguredReplicationServers, WARN_FIRST_REPLICATION_SERVER_ALREADY_CONFIGURED);
    configureServer(ctx2, serverDesc2, uData.getServer2(), argParser.replicationPort2Arg, usedReplicationServerIds,
        allRepServers, alreadyConfiguredReplicationServers, WARN_SECOND_REPLICATION_SERVER_ALREADY_CONFIGURED);
    configureServer(ctx1, serverDesc1, uData.getServer1(), argParser.server1.replicationPortArg,
        usedReplicationServerIds, allRepServers, alreadyConfiguredReplicationServers,
        WARN_FIRST_REPLICATION_SERVER_ALREADY_CONFIGURED);
    configureServer(ctx2, serverDesc2, uData.getServer2(), argParser.server2.replicationPortArg,
        usedReplicationServerIds, allRepServers, alreadyConfiguredReplicationServers,
        WARN_SECOND_REPLICATION_SERVER_ALREADY_CONFIGURED);
    for (String baseDN : uData.getBaseDNs())
    {
@@ -8734,32 +8728,26 @@
        !server1.configureReplicationDomain())
    {
      commandBuilder.addArgument(newBooleanArgument(
          argParser.onlyReplicationServer1Arg, INFO_DESCRIPTION_ENABLE_REPLICATION_ONLY_REPLICATION_SERVER1));
          argParser.server1.onlyReplicationServerArg, INFO_DESCRIPTION_ENABLE_REPLICATION_ONLY_REPLICATION_SERVER1));
    }
    if (!server1.configureReplicationServer() &&
        server1.configureReplicationDomain())
    {
      commandBuilder.addArgument(newBooleanArgument(
          argParser.noReplicationServer1Arg, INFO_DESCRIPTION_ENABLE_REPLICATION_NO_REPLICATION_SERVER1));
          argParser.server1.noReplicationServerArg, INFO_DESCRIPTION_ENABLE_REPLICATION_NO_REPLICATION_SERVER1));
    }
    if (server1.configureReplicationServer() &&
        server1.getReplicationPort() > 0)
    {
      IntegerArgument replicationPort1 = new IntegerArgument(
          "replicationPort1", 'r',
          "replicationPort1", false, false, true, INFO_PORT_PLACEHOLDER.get(),
          8989, null,
          INFO_DESCRIPTION_ENABLE_REPLICATION_PORT1.get());
      replicationPort1.addValue(String.valueOf(server1.getReplicationPort()));
      commandBuilder.addArgument(replicationPort1);
      commandBuilder.addArgument(getReplicationPortArg(
          "replicationPort1", server1, 8989, INFO_DESCRIPTION_ENABLE_REPLICATION_PORT1));
    }
    if (server1.isSecureReplication())
    {
      commandBuilder.addArgument(new BooleanArgument("secureReplication1", null,
          "secureReplication1",
          INFO_DESCRIPTION_ENABLE_SECURE_REPLICATION1.get()));
      commandBuilder.addArgument(
          newBooleanArgument("secureReplication1", INFO_DESCRIPTION_ENABLE_SECURE_REPLICATION1));
    }
@@ -8767,31 +8755,25 @@
        !server2.configureReplicationDomain())
    {
      commandBuilder.addArgument(newBooleanArgument(
          argParser.onlyReplicationServer2Arg, INFO_DESCRIPTION_ENABLE_REPLICATION_ONLY_REPLICATION_SERVER2));
          argParser.server2.onlyReplicationServerArg, INFO_DESCRIPTION_ENABLE_REPLICATION_ONLY_REPLICATION_SERVER2));
    }
    if (!server2.configureReplicationServer() &&
        server2.configureReplicationDomain())
    {
      commandBuilder.addArgument(newBooleanArgument(
          argParser.noReplicationServer2Arg, INFO_DESCRIPTION_ENABLE_REPLICATION_NO_REPLICATION_SERVER2));
          argParser.server2.noReplicationServerArg, INFO_DESCRIPTION_ENABLE_REPLICATION_NO_REPLICATION_SERVER2));
    }
    if (server2.configureReplicationServer() &&
        server2.getReplicationPort() > 0)
    {
      IntegerArgument replicationPort2 = new IntegerArgument(
          "replicationPort2", 'r',
          "replicationPort2", false, false, true, INFO_PORT_PLACEHOLDER.get(),
          server2.getReplicationPort(), null,
          INFO_DESCRIPTION_ENABLE_REPLICATION_PORT2.get());
      replicationPort2.addValue(String.valueOf(server2.getReplicationPort()));
      commandBuilder.addArgument(replicationPort2);
      commandBuilder.addArgument(getReplicationPortArg(
          "replicationPort2", server2, server2.getReplicationPort(), INFO_DESCRIPTION_ENABLE_REPLICATION_PORT2));
    }
    if (server2.isSecureReplication())
    {
      commandBuilder.addArgument(new BooleanArgument("secureReplication2", null,
          "secureReplication2",
          INFO_DESCRIPTION_ENABLE_SECURE_REPLICATION2.get()));
      commandBuilder.addArgument(
          newBooleanArgument("secureReplication2", INFO_DESCRIPTION_ENABLE_SECURE_REPLICATION2));
    }
@@ -8817,6 +8799,22 @@
    }
  }
  private IntegerArgument getReplicationPortArg(
      String name, EnableReplicationServerData server, int defaultValue, Arg0 description) throws ArgumentException
  {
    IntegerArgument replicationPort = new IntegerArgument(
        name, 'r', name, false, false, true,
        INFO_PORT_PLACEHOLDER.get(), defaultValue, null, description.get());
    int value = server.getReplicationPort();
    replicationPort.addValue(String.valueOf(value));
    return replicationPort;
  }
  private BooleanArgument newBooleanArgument(String name, Arg0 msg) throws ArgumentException
  {
    return new BooleanArgument(name, null, name, msg.get());
  }
  private BooleanArgument newBooleanArgument(BooleanArgument arg, Arg0 msg) throws ArgumentException
  {
    return new BooleanArgument(arg.getName(), arg.getShortIdentifier(), arg.getLongIdentifier(), msg.get());