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

Ludovic Poitou
23.25.2013 73a7f0d0c650739c667dc965f6ed2cd34756bd1e
Small cleanup of use of maps, lists and also few typos in comments, and constants in the QuickSetup.
Side effect of renaming a constant, the ReplicationCliMain was touched, and I run more cleanup on it.
5 files modified
683 ■■■■ changed files
opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java 63 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java 20 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/ui/CurrentStepPanel.java 30 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java 19 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java 551 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -122,13 +122,13 @@
   * If the user decides to import more than this number of entries, the import
   * process of automatically generated data will be verbose.
   */
  private static final int THRESOLD_AUTOMATIC_DATA_VERBOSE = 20000;
  private static final int THRESHOLD_AUTOMATIC_DATA_VERBOSE = 20000;
  /**
   * If the user decides to import a number of entries higher than this
   * threshold, the start process will be verbose.
   */
  private static final int NENTRIES_THRESOLD_FOR_VERBOSE_START = 100000;
  private static final int THRESHOLD_VERBOSE_START = 100000;
  /** Set of progress steps that have been completed. */
  protected Set<InstallProgressStep>
@@ -167,7 +167,7 @@
  /** The threshold in minutes used to know whether we must display a warning
   * informing that there is a server clock difference between two servers
   * whose contents are being replicated. */
  public static final int WARNING_CLOCK_DIFFERENCE_THRESOLD_MINUTES = 5;
  public static final int THRESHOLD_CLOCK_DIFFERENCE_WARNING = 5;
  /**
   * Creates a default instance.
@@ -292,51 +292,32 @@
  @Override
  public boolean isVisible(WizardStep step, UserData userData)
  {
    boolean isVisible;
    if (step == CREATE_GLOBAL_ADMINISTRATOR)
    {
       isVisible = userData.mustCreateAdministrator();
       return userData.mustCreateAdministrator();
    }
    else if (step == NEW_SUFFIX_OPTIONS)
    {
      SuffixesToReplicateOptions suf =
        userData.getSuffixesToReplicateOptions();
      if (suf != null)
      {
        isVisible = suf.getType() !=
      return suf != null && suf.getType() !=
          SuffixesToReplicateOptions.Type.REPLICATE_WITH_EXISTING_SUFFIXES;
      }
      else
      {
        isVisible = false;
      }
    }
    else if (step == SUFFIXES_OPTIONS)
    {
      DataReplicationOptions repl = userData.getReplicationOptions();
      if (repl != null)
      {
        isVisible =
          (repl.getType() != DataReplicationOptions.Type.STANDALONE) &&
          (repl.getType() != DataReplicationOptions.Type.FIRST_IN_TOPOLOGY);
      }
      else
      {
        isVisible = false;
      }
      return repl != null
          && (repl.getType() != DataReplicationOptions.Type.STANDALONE)
          && (repl.getType() != DataReplicationOptions.Type.FIRST_IN_TOPOLOGY);
    }
    else if (step == REMOTE_REPLICATION_PORTS)
    {
      isVisible = isVisible(SUFFIXES_OPTIONS, userData) &&
      return isVisible(SUFFIXES_OPTIONS, userData) &&
      (userData.getRemoteWithNoReplicationPort().size() > 0) &&
      (userData.getSuffixesToReplicateOptions().getType() ==
        SuffixesToReplicateOptions.Type.REPLICATE_WITH_EXISTING_SUFFIXES);
    }
    else
    {
      isVisible = true;
    }
    return isVisible;
    return true;
  }
  /**
@@ -1464,7 +1445,7 @@
    File templatePath = createTemplateFile();
    int nEntries = getUserData().getNewSuffixOptions().getNumberEntries();
    MessageBuilder mb = new MessageBuilder();
    if (isVerbose() || (nEntries > THRESOLD_AUTOMATIC_DATA_VERBOSE))
    if (isVerbose() || (nEntries > THRESHOLD_AUTOMATIC_DATA_VERBOSE))
    {
      mb.append(getFormattedProgress(
            INFO_PROGRESS_IMPORT_AUTOMATICALLY_GENERATED.get(
@@ -1783,10 +1764,6 @@
        }
      }
    }
    catch (ApplicationException ae)
    {
      throw ae;
    }
    catch (NamingException ne)
    {
      Message failedMsg = getThrowableMsg(
@@ -1923,10 +1900,6 @@
      localTime = Utils.getServerClock(ctx);
      localServerDisplay = ConnectionUtils.getHostPort(ctx);
    }
    catch (ApplicationException ae)
    {
      throw ae;
    }
    catch (NamingException ne)
    {
      Message failedMsg = getThrowableMsg(
@@ -2041,13 +2014,13 @@
        {
          if (Math.abs(localTime - remoteTime - localTimeMeasureTime +
              remoteTimeMeasureTime) >
          (WARNING_CLOCK_DIFFERENCE_THRESOLD_MINUTES * 60 * 1000))
          (THRESHOLD_CLOCK_DIFFERENCE_WARNING * 60 * 1000))
          {
            notifyListeners(getFormattedWarning(
                INFO_WARNING_SERVERS_CLOCK_DIFFERENCE.get(
                    localServerDisplay, ConnectionUtils.getHostPort(ctx),
                    String.valueOf(
                        WARNING_CLOCK_DIFFERENCE_THRESOLD_MINUTES))));
                        THRESHOLD_CLOCK_DIFFERENCE_WARNING))));
          }
        }
@@ -2079,7 +2052,7 @@
   * @param isCli a boolean to indicate if the install is using CLI or GUI
   */
  protected void initSummaryMap(
      Map<InstallProgressStep, Message> hmSummary,
      Map<ProgressStep, Message> hmSummary,
      boolean isCli)
  {
    hmSummary.put(InstallProgressStep.NOT_STARTED,
@@ -2153,7 +2126,7 @@
   * @param isCli a boolean to indicate if the install is using CLI or GUI
   */
  protected void updateSummaryWithServerState(
      Map<InstallProgressStep, Message> hmSummary, Boolean isCli)
      Map<ProgressStep, Message> hmSummary, Boolean isCli)
  {
   Installation installation = getInstallation();
   String cmd = getPath(installation.getControlPanelCommandFile());
@@ -2668,8 +2641,6 @@
        adsContext = new ADSContext(localCtx); // adsContext owns localCtx
        adsContext.createAdminData(null);
      }
      assert null != adsContext ; // Bound either to local or remote ADS.
      /* Register new server in ADS. */
      TopologyCacheFilter filter = new TopologyCacheFilter();
      filter.setSearchMonitoringInformation(false);
@@ -2847,7 +2818,7 @@
        mbTotalSize += f.length();
      }
      // Assume entries of 1kb
      if (mbTotalSize > NENTRIES_THRESOLD_FOR_VERBOSE_START * 1024)
      if (mbTotalSize > THRESHOLD_VERBOSE_START * 1024)
      {
        manyEntriesToImport = true;
      }
@@ -2855,7 +2826,7 @@
    else if (type == NewSuffixOptions.Type.IMPORT_AUTOMATICALLY_GENERATED_DATA)
    {
      int nEntries = getUserData().getNewSuffixOptions().getNumberEntries();
      if (nEntries > NENTRIES_THRESOLD_FOR_VERBOSE_START)
      if (nEntries > THRESHOLD_VERBOSE_START)
      {
        manyEntriesToImport = true;
      }
opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
@@ -34,6 +34,8 @@
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -80,11 +82,11 @@
 *
 */
public class WebStartInstaller extends Installer {
  private final HashMap<InstallProgressStep, Integer> hmRatio =
      new HashMap<InstallProgressStep, Integer>();
  private final Map<ProgressStep, Integer> hmRatio =
      new HashMap<ProgressStep, Integer>();
  private final HashMap<InstallProgressStep, Message> hmSummary =
      new HashMap<InstallProgressStep, Message>();
  private final Map<ProgressStep, Message> hmSummary =
      new HashMap<ProgressStep, Message>();
  private static final Logger LOG =
    Logger.getLogger(WebStartInstaller.class.getName());
@@ -371,9 +373,9 @@
     * extracting, the value for downloading will be the double of the value for
     * extracting.
     */
    HashMap<InstallProgressStep, Integer> hmTime =
        new HashMap<InstallProgressStep, Integer>();
    hmTime.put(InstallProgressStep.DOWNLOADING, 15);
    Map<ProgressStep, Integer> hmTime =
        new HashMap<ProgressStep, Integer>();
    hmTime.put(InstallProgressStep.DOWNLOADING, 30);
    hmTime.put(InstallProgressStep.EXTRACTING, 15);
    hmTime.put(InstallProgressStep.CONFIGURING_SERVER, 5);
    hmTime.put(InstallProgressStep.CREATING_BASE_ENTRY, 10);
@@ -387,7 +389,7 @@
    hmTime.put(InstallProgressStep.INITIALIZE_REPLICATED_SUFFIXES, 25);
    int totalTime = 0;
    ArrayList<InstallProgressStep> steps =
    List<InstallProgressStep> steps =
        new ArrayList<InstallProgressStep>();
    totalTime += hmTime.get(InstallProgressStep.DOWNLOADING);
    steps.add(InstallProgressStep.DOWNLOADING);
@@ -521,7 +523,7 @@
  /**
   * This method extracts the zip file.
   * @param is the inputstream with the contents of the zip file.
   * @param is the input stream with the contents of the zip file.
   * @param minRatio the value of the ratio in the install that corresponds to
   * the moment where we start extracting the zip files.  Used to update
   * properly the install progress ratio.
opends/src/quicksetup/org/opends/quicksetup/ui/CurrentStepPanel.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013 ForgeRock AS.
 */
package org.opends.quicksetup.ui;
@@ -32,6 +33,7 @@
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.opends.quicksetup.event.ButtonActionListener;
@@ -58,7 +60,7 @@
  private static final String LOADING_PANEL = "loading";
  private HashMap<WizardStep, QuickSetupStepPanel> hmPanels =
  private Map<WizardStep, QuickSetupStepPanel> hmPanels =
      new HashMap<WizardStep, QuickSetupStepPanel>();
  /**
@@ -94,7 +96,7 @@
  /**
   * Marks as invalid (or valid depending on the value of the invalid parameter)
   * a field corresponding to FieldName.  This basically implies udpating the
   * a field corresponding to FieldName.  This basically implies updating the
   * style of the JLabel associated with fieldName (the association is done
   * using the LabelFieldDescriptor class).
   * @param fieldName the FieldName to be marked as valid or invalid.
@@ -108,15 +110,6 @@
    }
  }
  /**
   * Returns the panel we use to display the progress.  This method is used
   * to be able to retrieve the message formatter.
   * @return the panel we use to display the progress.
   */
  ProgressPanel getProgressPanel()
  {
    return (ProgressPanel)hmPanels.get(Step.PROGRESS);
  }
  /**
   * Create the layout of the panel.
@@ -156,7 +149,7 @@
            new GridBagConstraints());
    add(loadingPanel, LOADING_PANEL);
    // For aesthetical reasons we add a little bit of height
    // For aesthetic reasons we add a little bit of height
    minHeight += getApplication().getExtraDialogHeight();
    setPreferredSize(new Dimension(minWidth, minHeight));
@@ -165,7 +158,7 @@
  /**
   * Adds a button listener.  All the button listeners will be notified when
   * the buttons are clicked (by the user or programatically).
   * the buttons are clicked (by the user or programmatically).
   * @param l the ButtonActionListener to be added.
   */
  public void addButtonActionListener(ButtonActionListener l)
@@ -176,17 +169,6 @@
    }
  }
  /**
   * Removes a button listener.
   * @param l the ButtonActionListener to be removed.
   */
  public void removeButtonActionListener(ButtonActionListener l)
  {
    for (WizardStep s : hmPanels.keySet())
    {
      getPanel(s).removeButtonActionListener(l);
    }
  }
  /**
   * Displays the panel corresponding to the provided step.  The panel contents
opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java
@@ -23,7 +23,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011 ForgeRock AS
 *      Portions Copyright 2011-2013 ForgeRock AS
 */
package org.opends.quicksetup.ui;
@@ -47,6 +47,7 @@
import java.awt.Cursor;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.logging.Handler;
@@ -137,7 +138,7 @@
    }
    /* In the calls to setCurrentStep the dialog will be created */
    setCurrentStep(application.getFirstWizardStep());
      setCurrentStep(application.getFirstWizardStep());
  }
  /**
@@ -404,7 +405,7 @@
          }
          ProcessBuilder pb;
          if (isMacOS()) {
            ArrayList<String> cmd = new ArrayList<String>();
            List<String> cmd = new ArrayList<String>();
            cmd.add(MAC_APPLICATIONS_OPENER);
            cmd.add(getScriptPath(
                getPath(installation.getControlPanelCommandFile())));
@@ -433,7 +434,7 @@
          {
            returnValue = process.exitValue();
          }
          catch (IllegalThreadStateException ithse)
          catch (IllegalThreadStateException e)
          {
            // The process has not exited: assume that the status panel could
            // be launched successfully.
@@ -684,10 +685,12 @@
    {
      progressDetails.append(additionalDetails);
    }
    // Note: progressDetails might have a certain number of characters that
    // break Message Formatter (for instance percentages).  When fix for
    // issue 2142 was committed it broke this code.  So here
    // we use Message.raw instead of calling directly progressDetails.toMessage
    /*
    Note: progressDetails might have a certain number of characters that
    break Message Formatter (for instance percentages).  When fix for
    issue 2142 was committed it broke this code.  So here
    we use Message.raw instead of calling directly progressDetails.toMessage
    */
    return new ProgressDescriptor(status, ratio, newProgressLabel,
        Message.raw(progressDetails.toString()));
  }
opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -30,75 +30,17 @@
package org.opends.server.tools.dsreplication;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import static org.opends.admin.ads.ServerDescriptor.*;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.messages.QuickSetupMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.messages.UtilityMessages.*;
import static org.opends.quicksetup.util.Utils.*;
import static org.opends.server.tools.ToolConstants.*;
import static org.opends.server.tools.dsreplication.ReplicationCliReturnCode.*;
import javax.naming.NameAlreadyBoundException;
import javax.naming.NameNotFoundException;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.BasicAttributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import javax.naming.ldap.InitialLdapContext;
import javax.net.ssl.TrustManager;
import org.opends.admin.ads.ADSContext;
import org.opends.admin.ads.*;
import org.opends.admin.ads.ADSContext.ADSPropertySyntax;
import org.opends.admin.ads.ADSContext.AdministratorProperty;
import org.opends.admin.ads.ADSContext.ServerProperty;
import org.opends.admin.ads.ADSContextException;
import org.opends.admin.ads.ReplicaDescriptor;
import org.opends.admin.ads.ServerDescriptor;
import org.opends.admin.ads.SuffixDescriptor;
import org.opends.admin.ads.TopologyCache;
import org.opends.admin.ads.TopologyCacheException;
import org.opends.admin.ads.TopologyCacheFilter;
import org.opends.admin.ads.util.ApplicationTrustManager;
import org.opends.admin.ads.util.ConnectionUtils;
import org.opends.admin.ads.util.PreferredConnection;
import org.opends.admin.ads.util.ServerLoader;
import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor;
import org.opends.guitools.controlpanel.util.ConfigFromDirContext;
import org.opends.guitools.controlpanel.util.ConfigFromFile;
import org.opends.guitools.controlpanel.util.ControlPanelLog;
import org.opends.guitools.controlpanel.util.ProcessReader;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.guitools.controlpanel.util.*;
import org.opends.messages.Message;
import org.opends.messages.MessageBuilder;
import org.opends.quicksetup.ApplicationException;
@@ -113,16 +55,15 @@
import org.opends.quicksetup.installer.offline.OfflineInstaller;
import org.opends.quicksetup.util.PlainTextProgressMessageFormatter;
import org.opends.quicksetup.util.Utils;
import org.opends.server.admin.AttributeTypePropertyDefinition;
import org.opends.server.admin.ClassLoaderProvider;
import org.opends.server.admin.ClassPropertyDefinition;
import org.opends.server.admin.DefaultBehaviorException;
import org.opends.server.admin.ManagedObjectNotFoundException;
import org.opends.server.admin.*;
import org.opends.server.admin.client.ManagementContext;
import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor;
import org.opends.server.admin.client.ldap.LDAPManagementContext;
import org.opends.server.admin.std.client.*;
import org.opends.server.admin.std.meta.*;
import org.opends.server.admin.std.meta.ReplicationDomainCfgDefn;
import org.opends.server.admin.std.meta.ReplicationServerCfgDefn;
import org.opends.server.admin.std.meta.
    ReplicationSynchronizationProviderCfgDefn;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.tasks.PurgeConflictsHistoricalTask;
@@ -139,24 +80,36 @@
import org.opends.server.util.ServerConstants;
import org.opends.server.util.SetupUtils;
import org.opends.server.util.StaticUtils;
import org.opends.server.util.args.Argument;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.BooleanArgument;
import org.opends.server.util.args.FileBasedArgument;
import org.opends.server.util.args.IntegerArgument;
import org.opends.server.util.args.StringArgument;
import org.opends.server.util.cli.CLIException;
import org.opends.server.util.cli.CommandBuilder;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.LDAPConnectionConsoleInteraction;
import org.opends.server.util.cli.MenuBuilder;
import org.opends.server.util.cli.MenuResult;
import org.opends.server.util.cli.PointAdder;
import org.opends.server.util.args.*;
import org.opends.server.util.cli.*;
import org.opends.server.util.table.TabSeparatedTablePrinter;
import org.opends.server.util.table.TableBuilder;
import org.opends.server.util.table.TablePrinter;
import org.opends.server.util.table.TextTablePrinter;
import javax.naming.NameAlreadyBoundException;
import javax.naming.NameNotFoundException;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.*;
import javax.naming.ldap.InitialLdapContext;
import java.io.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import static org.opends.admin.ads.ServerDescriptor.*;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.messages.QuickSetupMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.messages.UtilityMessages.
    ERR_CONFIRMATION_TRIES_LIMIT_REACHED;
import static org.opends.quicksetup.util.Utils.getFirstValue;
import static org.opends.quicksetup.util.Utils.getThrowableMsg;
import static org.opends.server.tools.ToolConstants.*;
import static org.opends.server.tools.dsreplication.ReplicationCliReturnCode.*;
import static org.opends.server.util.StaticUtils.close;
/**
 * This class provides a tool that can be used to enable and disable replication
 * and also to initialize the contents of a replicated suffix with the contents
@@ -1077,16 +1030,7 @@
      returnValue = ERROR_CONNECTING;
    }
    if (ctx != null)
    {
      try
      {
        ctx.close();
      }
      catch (Throwable t)
      {
      }
    }
    close(ctx);
    return returnValue;
  }
@@ -1152,8 +1096,13 @@
        LOG.log(Level.INFO, "created task entry: "+attrs);
        dirCtx.close();
      }
      catch (NameAlreadyBoundException x)
      catch (NameAlreadyBoundException ex)
      {
        LOG.log(Level.SEVERE, "Error creating task "+attrs, ex);
        Message msg = ERR_LAUNCHING_PURGE_HISTORICAL.get();
        ReplicationCliReturnCode code = ERROR_LAUNCHING_PURGE_HISTORICAL;
        throw new ReplicationCliException(
            getThrowableMsg(msg, ex), code, ex);
      }
      catch (NamingException ne)
      {
@@ -1665,18 +1614,7 @@
        cancelled = true;
      }
    }
    if (ctx != null)
    {
      try
      {
        ctx.close();
      }
      catch (Throwable t)
      {
      }
    }
    close(ctx);
    return !cancelled;
  }
@@ -1940,9 +1878,12 @@
      // enableReplication(EnableReplicationUserData) method.  Here we have
      // to load the ADS to ask the user to accept the certificates and
      // eventually admin authentication data.
      InitialLdapContext[] aux = new InitialLdapContext[] {ctx1};
      cancelled = !loadADSAndAcceptCertificates(aux, uData, true);
      ctx1 = aux[0];
      if (!cancelled)
      {
        InitialLdapContext[] aux = new InitialLdapContext[] {ctx1};
        cancelled = !loadADSAndAcceptCertificates(aux, uData, true);
        ctx1 = aux[0];
      }
      if (!cancelled)
      {
        administratorDefined |= hasAdministrator(ctx1);
@@ -2241,9 +2182,12 @@
      // there are issues with the ADS they will be encountered in the
      // enableReplication(EnableReplicationUserData) method.  Here we have
      // to load the ADS to ask the user to accept the certificates.
      InitialLdapContext[] aux = new InitialLdapContext[] {ctx2};
      cancelled = !loadADSAndAcceptCertificates(aux, uData, false);
      ctx2 = aux[0];
      if (!cancelled)
      {
        InitialLdapContext[] aux = new InitialLdapContext[] {ctx2};
        cancelled = !loadADSAndAcceptCertificates(aux, uData, false);
        ctx2 = aux[0];
      }
      if (!cancelled)
      {
        administratorDefined |= hasAdministrator(ctx2);
@@ -2333,28 +2277,7 @@
      uData.setBaseDNs(suffixes);
    }
    if (ctx1 != null)
    {
      try
      {
        ctx1.close();
      }
      catch (Throwable t)
      {
      }
    }
    if (ctx2 != null)
    {
      try
      {
        ctx2.close();
      }
      catch (Throwable t)
      {
      }
    }
    close(ctx1, ctx2);
    uData.setReplicateSchema(!argParser.noSchemaReplication());
    return !cancelled;
@@ -2588,22 +2511,12 @@
        println();
        try
        {
          if (uData.disableAll())
          if (!uData.disableAll() &&
              !uData.getBaseDNs().isEmpty())
          {
            // Another confirmation is redundant: we already asked the user...
          }
          else
          {
            if (!uData.getBaseDNs().isEmpty())
            {
               cancelled = !askConfirmation(
                INFO_REPLICATION_CONFIRM_DISABLE_GENERIC.get(), true,
                LOG);
            }
            else
            {
              // Another confirmation for the replication server is redundant.
            }
            cancelled = !askConfirmation(
              INFO_REPLICATION_CONFIRM_DISABLE_GENERIC.get(), true,
              LOG);
          }
        }
        catch (CLIException ce)
@@ -2615,16 +2528,7 @@
      }
    }
    if (ctx != null)
    {
      try
      {
        ctx.close();
      }
      catch (Throwable t)
      {
      }
    }
    close(ctx);
    return !cancelled;
  }
@@ -2753,17 +2657,7 @@
      }
    }
    if (ctx != null)
    {
      try
      {
        ctx.close();
      }
      catch (Throwable t)
      {
      }
    }
    close(ctx);
    return !cancelled;
  }
@@ -2842,17 +2736,7 @@
      uData.setBaseDNs(suffixes);
    }
    if (ctx != null)
    {
      try
      {
        ctx.close();
      }
      catch (Throwable t)
      {
      }
    }
    close(ctx);
    return !cancelled;
  }
@@ -2931,17 +2815,7 @@
      uData.setBaseDNs(suffixes);
    }
    if (ctx != null)
    {
      try
      {
        ctx.close();
      }
      catch (Throwable t)
      {
      }
    }
    close(ctx);
    return !cancelled;
  }
@@ -3032,17 +2906,7 @@
      uData.setBaseDNs(suffixes);
    }
    if (ctx != null)
    {
      try
      {
        ctx.close();
      }
      catch (Throwable t)
      {
      }
    }
    close(ctx);
    return !cancelled;
  }
@@ -3271,27 +3135,7 @@
      }
    }
    if (ctxSource != null)
    {
      try
      {
        ctxSource.close();
      }
      catch (Throwable t)
      {
      }
    }
    if (ctxDestination != null)
    {
      try
      {
        ctxDestination.close();
      }
      catch (Throwable t)
      {
      }
    }
    close(ctxSource, ctxDestination);
    return !cancelled;
  }
@@ -3346,19 +3190,7 @@
    ApplicationTrustManager trust;
    if (isInteractive())
    {
      TrustManager t = ci.getTrustManager();
      if (t == null)
      {
        trust = null;
      }
      else if (t instanceof ApplicationTrustManager)
      {
        trust = (ApplicationTrustManager)t;
      }
      else
      {
        trust = new ApplicationTrustManager(ci.getKeyStore());
      }
      trust = ci.getTrustManager();
    }
    else
    {
@@ -3801,13 +3633,7 @@
                    adminPwd = askForAdministratorPwd(LOG);
                    println();
                  }
                  try
                  {
                    ctx[0].close();
                  }
                  catch (Throwable t)
                  {
                  }
                  close(ctx[0]);
                  try
                  {
                    ctx[0] = createAdministrativeContext(host, port, isSSL,
@@ -4368,13 +4194,13 @@
      if ((time1 != -1) && (time2 != -1))
      {
        if (Math.abs(time1 - time2) >
        (Installer.WARNING_CLOCK_DIFFERENCE_THRESOLD_MINUTES * 60 * 1000))
        (Installer.THRESHOLD_CLOCK_DIFFERENCE_WARNING * 60 * 1000))
        {
          println(INFO_WARNING_SERVERS_CLOCK_DIFFERENCE.get(
              ConnectionUtils.getHostPort(ctx1),
              ConnectionUtils.getHostPort(ctx2),
              String.valueOf(
                  Installer.WARNING_CLOCK_DIFFERENCE_THRESOLD_MINUTES)));
                  Installer.THRESHOLD_CLOCK_DIFFERENCE_WARNING)));
        }
      }
      printlnProgress();
@@ -4383,27 +4209,7 @@
      printlnProgress();
    }
    if (ctx1 != null)
    {
      try
      {
        ctx1.close();
      }
      catch (Throwable t)
      {
      }
    }
    if (ctx2 != null)
    {
      try
      {
        ctx2.close();
      }
      catch (Throwable t)
      {
      }
    }
    close(ctx1, ctx2);
    return returnValue;
  }
@@ -4521,16 +4327,7 @@
      returnValue = ERROR_CONNECTING;
    }
    if (ctx != null)
    {
      try
      {
        ctx.close();
      }
      catch (Throwable t)
      {
      }
    }
    close(ctx);
    return returnValue;
  }
@@ -4583,16 +4380,7 @@
      returnValue = ERROR_CONNECTING;
    }
    if (ctx != null)
    {
      try
      {
        ctx.close();
      }
      catch (Throwable t)
      {
      }
    }
    close(ctx);
    return returnValue;
  }
@@ -4609,21 +4397,20 @@
      InitializeReplicationUserData uData)
  {
    ReplicationCliReturnCode returnValue = SUCCESSFUL_NOP;
    InitialLdapContext ctxSource = null;
    InitialLdapContext ctxDestination = null;
     ctxSource = getAdministrativeContext(uData.getHostNameSource(),
         uData.getPortSource(), useSSL,
         useStartTLS,
         ADSContext.getAdministratorDN(uData.getAdminUid()),
         uData.getAdminPwd(), getConnectTimeout(), getTrustManager());
    InitialLdapContext ctxSource = getAdministrativeContext(
        uData.getHostNameSource(),
        uData.getPortSource(), useSSL,
        useStartTLS,
        ADSContext.getAdministratorDN(uData.getAdminUid()),
        uData.getAdminPwd(), getConnectTimeout(), getTrustManager());
     ctxDestination = getAdministrativeContext(
         uData.getHostNameDestination(),
         uData.getPortDestination(), useSSL,
         useStartTLS,
         ADSContext.getAdministratorDN(uData.getAdminUid()),
         uData.getAdminPwd(), getConnectTimeout(), getTrustManager());
    InitialLdapContext ctxDestination = getAdministrativeContext(
        uData.getHostNameDestination(),
        uData.getPortDestination(), useSSL,
        useStartTLS,
        ADSContext.getAdministratorDN(uData.getAdminUid()),
        uData.getAdminPwd(), getConnectTimeout(), getTrustManager());
    if ((ctxSource != null) && (ctxDestination != null))
    {
@@ -4681,27 +4468,7 @@
      returnValue = ERROR_CONNECTING;
    }
    if (ctxSource != null)
    {
      try
      {
        ctxSource.close();
      }
      catch (Throwable t)
      {
      }
    }
    if (ctxDestination != null)
    {
      try
      {
        ctxDestination.close();
      }
      catch (Throwable t)
      {
      }
    }
    close(ctxDestination, ctxSource);
    return returnValue;
  }
@@ -4810,23 +4577,12 @@
      {
        returnValue = REPLICATION_CANNOT_BE_INITIALIZED_ON_BASEDN;
      }
      close(ctx);
    }
    else
    {
      returnValue = ERROR_CONNECTING;
    }
    if (ctx != null)
    {
      try
      {
        ctx.close();
      }
      catch (Throwable t)
      {
      }
    }
    return returnValue;
  }
@@ -4843,7 +4599,7 @@
  private ReplicationCliReturnCode preExternalInitialization(
      PreExternalInitializationUserData uData)
  {
    ReplicationCliReturnCode returnValue;
    ReplicationCliReturnCode returnValue = ERROR_CONNECTING;
    InitialLdapContext ctx = null;
    try
    {
@@ -4914,23 +4670,8 @@
      {
        returnValue = REPLICATION_CANNOT_BE_INITIALIZED_ON_BASEDN;
      }
      close(ctx);
    }
    else
    {
      returnValue = ERROR_CONNECTING;
    }
    if (ctx != null)
    {
      try
      {
        ctx.close();
      }
      catch (Throwable t)
      {
      }
    }
    return returnValue;
  }
@@ -4947,7 +4688,7 @@
  private ReplicationCliReturnCode postExternalInitialization(
      PostExternalInitializationUserData uData)
  {
    ReplicationCliReturnCode returnValue;
    ReplicationCliReturnCode returnValue = ERROR_CONNECTING;
    InitialLdapContext ctx = null;
    try
    {
@@ -5016,23 +4757,8 @@
      {
        returnValue = REPLICATION_CANNOT_BE_INITIALIZED_ON_BASEDN;
      }
      close(ctx);
    }
    else
    {
      returnValue = ERROR_CONNECTING;
    }
    if (ctx != null)
    {
      try
      {
        ctx.close();
      }
      catch (Throwable t)
      {
      }
    }
    return returnValue;
  }
@@ -6297,7 +6023,7 @@
      }
      hmUsedReplicationDomainIds.put(baseDN, ids);
    }
    for (LinkedHashSet<String> v : hmRepServers.values())
    for (Set<String> v : hmRepServers.values())
    {
      allRepServers.addAll(v);
    }
@@ -6394,7 +6120,7 @@
    for (String baseDN : uData.getBaseDNs())
    {
      LinkedHashSet<String> repServers = hmRepServers.get(baseDN);
      Set<String> repServers = hmRepServers.get(baseDN);
      Set<Integer> usedIds = hmUsedReplicationDomainIds.get(baseDN);
      Set<String> alreadyConfiguredServers = new HashSet<String>();
@@ -7069,7 +6795,7 @@
    ADSContext adsCtx = new ADSContext(ctx);
    boolean somethingDisplayed = false;
    TopologyCache cache = null;
    TopologyCache cache;
    try
    {
      cache = new TopologyCache(adsCtx, getTrustManager(),
@@ -7107,10 +6833,7 @@
    {
      // Inform the user of the potential errors that we found.
      LinkedHashSet<Message> messages = new LinkedHashSet<Message>();
      if (cache != null)
      {
        messages.addAll(cache.getErrorMessages());
      }
      messages.addAll(cache.getErrorMessages());
      if (!messages.isEmpty())
      {
        Message msg =
@@ -7121,8 +6844,8 @@
      }
    }
    LinkedList<String> userBaseDNs = uData.getBaseDNs();
    LinkedList<Set<ReplicaDescriptor>> replicaLists =
    List<String> userBaseDNs = uData.getBaseDNs();
    List<Set<ReplicaDescriptor>> replicaLists =
      new LinkedList<Set<ReplicaDescriptor>>();
    boolean oneReplicated = false;
@@ -7210,7 +6933,7 @@
    if (!replicaLists.isEmpty())
    {
      LinkedList<Set<ReplicaDescriptor>> orderedReplicaLists =
      List<Set<ReplicaDescriptor>> orderedReplicaLists =
        new LinkedList<Set<ReplicaDescriptor>>();
      for (Set<ReplicaDescriptor> replicas : replicaLists)
      {
@@ -7282,9 +7005,10 @@
   * all the replicas are replicated with each other.
   * Note: the code assumes that all the objects come from the same read of the
   * topology cache.  So comparisons in terms of pointers can be made.
   * @param replicas the list of replicas that we are trying to display.
   * @param orderedReplicaLists the list of replicas that we are trying to
   * display.
   * @param scriptFriendly whether to display it on script-friendly mode or not.
   * @param cnx the preferred connections used to connect to the server.
   * @param scriptFriendly wheter to display it on script-friendly mode or not.
   * @param servers all the servers configured in the topology.
   * @param replicasWithNoReplicationServer the set of replicas that will be
   * updated with all the replicas that have no replication server.
@@ -7293,7 +7017,7 @@
   * no replica.
   */
  private void displayStatus(
      LinkedList<Set<ReplicaDescriptor>> orderedReplicaLists,
      List<Set<ReplicaDescriptor>> orderedReplicaLists,
      boolean scriptFriendly, LinkedHashSet<PreferredConnection> cnx,
      Set<ServerDescriptor> servers,
      Set<ReplicaDescriptor> replicasWithNoReplicationServer,
@@ -7615,7 +7339,7 @@
    }
    PrintStream out = getOutputStream();
    TablePrinter printer = null;
    TablePrinter printer;
    if (scriptFriendly)
    {
@@ -7659,10 +7383,10 @@
   * to replicate the baseDN defined in the server described by the
   * ServerDescriptor.
   */
  private LinkedHashSet<String> getReplicationServers(String baseDN,
  private Set<String> getReplicationServers(String baseDN,
      TopologyCache cache, ServerDescriptor server)
  {
    LinkedHashSet<String> servers = new LinkedHashSet<String>();
    Set<String> servers = new LinkedHashSet<String>();
    for (ReplicaDescriptor replica : server.getReplicas())
    {
      if (Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN))
@@ -7683,7 +7407,7 @@
          // If we do: we are dealing with the same replication topology
          // (we must consider the case of disjoint replication topologies
          // replicating the same base DN).
          HashSet<String> copy = new HashSet<String>(s);
          Set<String> copy = new HashSet<String>(s);
          copy.retainAll(servers);
          if (!copy.isEmpty())
          {
@@ -7871,7 +7595,7 @@
    /*
     * Configure the replication server.
     */
    ReplicationServerCfgClient replicationServer = null;
    ReplicationServerCfgClient replicationServer;
    boolean mustCommit = false;
@@ -7929,7 +7653,7 @@
   * @throws OpenDsException if there is an error updating the configuration.
   */
  private void updateReplicationServer(InitialLdapContext ctx,
      LinkedHashSet<String> replicationServers) throws OpenDsException
      Set<String> replicationServers) throws OpenDsException
  {
    printProgress(formatter.getFormattedWithPoints(
        INFO_REPLICATION_ENABLE_UPDATING_REPLICATION_SERVER.get(
@@ -8000,11 +7724,11 @@
   */
  private void configureToReplicateBaseDN(InitialLdapContext ctx,
      String baseDN,
      LinkedHashSet<String> replicationServers,
      Set<String> replicationServers,
      Set<Integer> usedReplicationDomainIds) throws OpenDsException
  {
    boolean userSpecifiedAdminBaseDN = false;
    LinkedList<String> l = argParser.getBaseDNs();
    List<String> l = argParser.getBaseDNs();
    if (l != null)
    {
      for (String dn : l)
@@ -8118,9 +7842,9 @@
   * @throws ReplicationCliException if something goes wrong.
   */
  private void configureToReplicateBaseDN(String baseDN,
      LinkedHashSet<String> repServers, Set<Integer> usedIds,
      Set<String> repServers, Set<Integer> usedIds,
      TopologyCache cache, ServerDescriptor server,
      Set<String> alreadyConfiguredServers, LinkedHashSet<String> allRepServers,
      Set<String> alreadyConfiguredServers, Set<String> allRepServers,
      Set<String> alreadyConfiguredReplicationServers)
  throws ReplicationCliException
  {
@@ -8201,16 +7925,7 @@
      }
      finally
      {
        if (ctx != null)
        {
          try
          {
            ctx.close();
          }
          catch (Throwable t)
          {
          }
        }
        close(ctx);
      }
      alreadyConfiguredServers.add(s.getId());
      alreadyConfiguredReplicationServers.add(s.getId());
@@ -8867,9 +8582,9 @@
   * @param pwd the password that must be used to log to the server.
   * @param baseDNs the list of base DNs where we want to remove the references
   * to the provided replication server.
   * @param removeFromReplicationServers if references must be removed from
   * the replication servers.
   * @param preferredURLs the preferred LDAP URLs to be used to connect to the
   * @param updateReplicationServers if references in the replication servers
   * must be updated.
   * @param cnx the preferred LDAP URLs to be used to connect to the
   * server.
   * @throws ReplicationCliException if there is an error updating the
   * configuration.
@@ -9017,16 +8732,7 @@
    }
    finally
    {
      if (ctx != null)
      {
        try
        {
          ctx.close();
        }
        catch (Throwable t)
        {
        }
      }
      close(ctx);
    }
  }
@@ -9312,7 +9018,7 @@
      {
        s = c.toString();
      }
      if (mb.toString().indexOf(s) == -1)
      if (!mb.toString().contains(s))
      {
        mb.append(Constants.LINE_SEPARATOR);
        mb.append(INFO_REPLICATION_CRITICAL_ERROR_DETAILS.get(s));
@@ -9329,14 +9035,7 @@
    {
      String id1 = server1.getSchemaReplicationID();
      String id2 = server2.getSchemaReplicationID();
      if (id1 != null)
      {
        mustInitializeSchema = !id1.equals(id2);
      }
      else
      {
        mustInitializeSchema = true;
      }
      mustInitializeSchema = id1 == null || !id1.equals(id2);
    }
    if (mustInitializeSchema)
    {
@@ -9352,7 +9051,7 @@
   * already registered it unregisters it and registers again (some properties
   * might have changed).
   * @param adsContext the ADS Context to be used.
   * @param server the server to be registered.
   * @param serverProperties the properties of the server to be registered.
   * @throws ADSContextException if an error occurs during the registration or
   * unregistration of the server.
   */
@@ -9396,14 +9095,7 @@
   */
  @Override
  public boolean isInteractive() {
    if (forceNonInteractive)
    {
      return false;
    }
    else
    {
      return argParser.isInteractive();
    }
    return !forceNonInteractive && argParser.isInteractive();
  }
  /**
@@ -11169,10 +10861,7 @@
            }
            finally
            {
              if (ctx != null)
              {
                ctx.close();
              }
              close(ctx);
            }
          }
        }