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

jvergara
18.07.2009 a8192343ef279e3fe08b024e5a1e7a49f12862d5
Fix for issue 3854 (Uninstall fails on Windows (due to log files))

There are a bunch of issues here:

1. The server was not stopped after being started if it contains replicated data.
2. The log files do not contain enough information. New debug lines have been added.
3. One of the problems also found is that one of the remote servers to be updated (to remove the replication references) could not be contacted. This is the expected behavior if the option forceOnError is NOT specified. However the error message was not very clear about what was happening. The new error message is very explicit about this and informs the user of the existence and behavior of the forceOnError option.
7 files modified
632 ■■■■■ changed files
opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java 383 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallLauncher.java 2 ●●● patch | view | raw | blame | history
opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java 41 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/messages/messages/admin_tool.properties 5 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetupCli.java 21 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/BackgroundTask.java 4 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java 176 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
@@ -134,158 +134,177 @@
  {
    parser = args;
    UninstallUserData userData = new UninstallUserData();
    boolean isInteractive;
    boolean isQuiet;
    boolean isVerbose;
    boolean isCancelled = false;
    /* Step 1: analyze the arguments.
     */
    isInteractive = args.isInteractive();
    isQuiet = args.isQuiet();
    isVerbose = args.isVerbose();
    userData.setQuiet(isQuiet);
    userData.setVerbose(isVerbose);
    userData.setForceOnError(args.isForceOnError());
    userData.setTrustManager(args.getTrustManager());
    /*
     * Step 2: check that the provided parameters are compatible.
     */
    MessageBuilder buf = new MessageBuilder();
    int v = args.validateGlobalOptions(buf);
    if (v != DsFrameworkCliReturnCode.SUCCESSFUL_NOP.getReturnCode())
    try
    {
      throw new UserDataException(null, buf.toMessage());
    }
      boolean isInteractive;
      boolean isQuiet;
      boolean isVerbose;
      boolean isCancelled = false;
    /* Step 3: If this is an interactive uninstall ask for confirmation to
     * delete the different parts of the installation if the user did not
     * specify anything to delete.  If we are not in interactive mode
     * check that the user specified something to be deleted.
     */
    Set<String> outsideDbs;
    Set<String> outsideLogs;
    Configuration config =
            Installation.getLocal().getCurrentConfiguration();
    try {
      outsideDbs = config.getOutsideDbs();
    } catch (IOException ioe) {
      outsideDbs = Collections.emptySet();
      LOG.log(Level.INFO, "error determining outside databases", ioe);
    }
      /* Step 1: analyze the arguments.
       */
    try {
      outsideLogs = config.getOutsideLogs();
    } catch (IOException ioe) {
      outsideLogs = Collections.emptySet();
      LOG.log(Level.INFO, "error determining outside logs", ioe);
    }
      isInteractive = args.isInteractive();
    boolean somethingSpecifiedToDelete =
      args.removeAll() ||
      args.removeBackupFiles() ||
      args.removeDatabases() ||
      args.removeLDIFFiles() ||
      args.removeConfigurationFiles() ||
      args.removeLogFiles() ||
      args.removeServerLibraries();
      isQuiet = args.isQuiet();
    if (somethingSpecifiedToDelete)
    {
      userData.setRemoveBackups(args.removeAll() || args.removeBackupFiles());
      userData.setRemoveConfigurationAndSchema(args.removeAll() ||
          args.removeConfigurationFiles());
      userData.setRemoveDatabases(args.removeAll() || args.removeDatabases());
      userData.setRemoveLDIFs(args.removeAll() || args.removeLDIFFiles());
      userData.setRemoveLibrariesAndTools(args.removeAll() ||
          args.removeServerLibraries());
      userData.setRemoveLogs(args.removeAll() || args.removeLogFiles());
      isVerbose = args.isVerbose();
      userData.setExternalDbsToRemove(outsideDbs);
      userData.setExternalLogsToRemove(outsideLogs);
    }
    else
    {
      if (!isInteractive)
      userData.setQuiet(isQuiet);
      userData.setVerbose(isVerbose);
      userData.setForceOnError(args.isForceOnError());
      userData.setTrustManager(args.getTrustManager());
      /*
       * Step 2: check that the provided parameters are compatible.
       */
      MessageBuilder buf = new MessageBuilder();
      int v = args.validateGlobalOptions(buf);
      if (v != DsFrameworkCliReturnCode.SUCCESSFUL_NOP.getReturnCode())
      {
        throw new UserDataException(null,
            ERR_CLI_UNINSTALL_NOTHING_TO_BE_UNINSTALLED_NON_INTERACTIVE.get());
        throw new UserDataException(null, buf.toMessage());
      }
      /* Step 3: If this is an interactive uninstall ask for confirmation to
       * delete the different parts of the installation if the user did not
       * specify anything to delete.  If we are not in interactive mode
       * check that the user specified something to be deleted.
       */
      Set<String> outsideDbs;
      Set<String> outsideLogs;
      Configuration config =
        Installation.getLocal().getCurrentConfiguration();
      try {
        outsideDbs = config.getOutsideDbs();
      } catch (IOException ioe) {
        outsideDbs = Collections.emptySet();
        LOG.log(Level.INFO, "error determining outside databases", ioe);
      }
      try {
        outsideLogs = config.getOutsideLogs();
      } catch (IOException ioe) {
        outsideLogs = Collections.emptySet();
        LOG.log(Level.INFO, "error determining outside logs", ioe);
      }
      boolean somethingSpecifiedToDelete =
        args.removeAll() ||
        args.removeBackupFiles() ||
        args.removeDatabases() ||
        args.removeLDIFFiles() ||
        args.removeConfigurationFiles() ||
        args.removeLogFiles() ||
        args.removeServerLibraries();
      if (somethingSpecifiedToDelete)
      {
        userData.setRemoveBackups(args.removeAll() || args.removeBackupFiles());
        userData.setRemoveConfigurationAndSchema(args.removeAll() ||
            args.removeConfigurationFiles());
        userData.setRemoveDatabases(args.removeAll() || args.removeDatabases());
        userData.setRemoveLDIFs(args.removeAll() || args.removeLDIFFiles());
        userData.setRemoveLibrariesAndTools(args.removeAll() ||
            args.removeServerLibraries());
        userData.setRemoveLogs(args.removeAll() || args.removeLogFiles());
        userData.setExternalDbsToRemove(outsideDbs);
        userData.setExternalLogsToRemove(outsideLogs);
      }
      else
      {
        isCancelled = askWhatToDelete(userData, outsideDbs, outsideLogs);
        if (!isInteractive)
        {
          throw new UserDataException(null,
             ERR_CLI_UNINSTALL_NOTHING_TO_BE_UNINSTALLED_NON_INTERACTIVE.get());
        }
        else
        {
          isCancelled = askWhatToDelete(userData, outsideDbs, outsideLogs);
        }
      }
    }
    String adminUid = args.getAdministratorUID();
    if ((adminUid == null) && !args.isInteractive())
    {
      adminUid = args.getDefaultAdministratorUID();
    }
    userData.setAdminUID(adminUid);
    userData.setAdminPwd(args.getBindPassword());
    String referencedHostName = args.getReferencedHostName();
    if ((referencedHostName == null) && !args.isInteractive())
    {
      referencedHostName = args.getDefaultReferencedHostName();
    }
    try
    {
      UninstallData d = new UninstallData(Installation.getLocal());
      userData.setReplicationServer(
          referencedHostName+":"+d.getReplicationServerPort());
      String adminUid = args.getAdministratorUID();
      if ((adminUid == null) && !args.isInteractive())
      {
        adminUid = args.getDefaultAdministratorUID();
      }
      userData.setAdminUID(adminUid);
      userData.setAdminPwd(args.getBindPassword());
      String referencedHostName = args.getReferencedHostName();
      if ((referencedHostName == null) && !args.isInteractive())
      {
        referencedHostName = args.getDefaultReferencedHostName();
      }
      try
      {
        UninstallData d = new UninstallData(Installation.getLocal());
        userData.setReplicationServer(
            referencedHostName+":"+d.getReplicationServerPort());
      }
      catch (Throwable t)
      {
        LOG.log(Level.SEVERE, "Could not create UninstallData: "+t, t);
        userData.setReplicationServer(
            referencedHostName+":8989");
      }
      info = ControlPanelInfo.getInstance();
      info.setTrustManager(userData.getTrustManager());
      info.regenerateDescriptor();
      info.setConnectionPolicy(ConnectionProtocolPolicy.USE_ADMIN);
      String adminConnectorUrl = info.getAdminConnectorURL();
      if (adminConnectorUrl == null)
      {
        LOG.log(Level.WARNING,
        "Error retrieving a valid LDAP URL in conf file.");
        if (!parser.isInteractive())
        {
          Message msg = ERR_COULD_NOT_FIND_VALID_LDAPURL.get();
          throw new ApplicationException(ReturnCode.APPLICATION_ERROR, msg,
              null);
        }
      }
      userData.setLocalServerUrl(adminConnectorUrl);
      userData.setReferencedHostName(referencedHostName);
      /*
       * Step 4: check if server is running.  Depending if it is running and the
       * OS we are running, ask for authentication information.
       */
      if (!isCancelled)
      {
        isCancelled = checkServerState(userData);
      }
      if (isCancelled && !userData.isForceOnError())
      {
        LOG.log(Level.INFO, "User cancelled uninstall.");
        userData = null;
      }
      if ((userData != null) && !args.isQuiet())
      {
        println();
      }
    }
    catch (Throwable t)
    {
      LOG.log(Level.SEVERE, "Could not create UninstallData: "+t, t);
      userData.setReplicationServer(
          referencedHostName+":8989");
    }
    info = ControlPanelInfo.getInstance();
    info.setTrustManager(userData.getTrustManager());
    info.regenerateDescriptor();
    info.setConnectionPolicy(ConnectionProtocolPolicy.USE_ADMIN);
    String adminConnectorUrl = info.getAdminConnectorURL();
    if (adminConnectorUrl == null)
    {
      LOG.log(Level.WARNING,
          "Error retrieving a valid LDAP URL in conf file.");
      if (!parser.isInteractive())
      LOG.log(Level.WARNING, "Exception: "+t, t);
      if (t instanceof UserDataException)
      {
        Message msg = ERR_COULD_NOT_FIND_VALID_LDAPURL.get();
        throw new ApplicationException(ReturnCode.APPLICATION_ERROR, msg, null);
        throw (UserDataException)t;
      }
      else if (t instanceof ApplicationException)
      {
        throw (ApplicationException)t;
      }
      else
      {
        throw new IllegalStateException("Unexpected error: "+t, t);
      }
    }
    userData.setLocalServerUrl(adminConnectorUrl);
    userData.setReferencedHostName(referencedHostName);
    /*
     * Step 4: check if server is running.  Depending if it is running and the
     * OS we are running, ask for authentication information.
     */
    if (!isCancelled)
    {
      isCancelled = checkServerState(userData);
    }
    if (isCancelled && !userData.isForceOnError())
    {
      LOG.log(Level.INFO, "User cancelled uninstall.");
      userData = null;
    }
    if ((userData != null) && !args.isQuiet())
    {
      println();
    }
    LOG.log(Level.INFO, "Successfully created user data");
    return userData;
  }
@@ -472,7 +491,8 @@
          {
            somethingSelected = false;
            println();
            println(ERR_CLI_UNINSTALL_NOTHING_TO_BE_UNINSTALLED.get());
            printErrorMessage(
                ERR_CLI_UNINSTALL_NOTHING_TO_BE_UNINSTALLED.get());
          }
          else
          {
@@ -516,6 +536,12 @@
      throw new UserDataException(Step.CONFIRM_UNINSTALL,
          Utils.getThrowableMsg(INFO_BUG_MSG.get(), t));
    }
    LOG.log(Level.INFO, "interactive: "+interactive);
    LOG.log(Level.INFO, "forceOnError: "+forceOnError);
    LOG.log(Level.INFO, "conf.isADS(): "+conf.isADS());
    LOG.log(Level.INFO, "conf.isReplicationServer(): "+
        conf.isReplicationServer());
    LOG.log(Level.INFO, "conf.isServerRunning(): "+conf.isServerRunning());
    if (conf.isADS() && conf.isReplicationServer())
    {
      if (conf.isServerRunning())
@@ -562,6 +588,8 @@
          boolean errorWithRemote =
            !updateUserUninstallDataWithRemoteServers(userData);
          cancelled = errorWithRemote && !parser.isForceOnError();
          LOG.log(Level.INFO, "Non interactive mode.  errorWithRemote: "+
              errorWithRemote);
        }
      }
      else
@@ -595,6 +623,7 @@
                    cancelled = !confirmToStopServer();
                  }
                }
                userData.setStopServer(true);
              }
              else
              {
@@ -639,6 +668,8 @@
        /* During all the confirmations, the server might be stopped. */
        userData.setStopServer(
            Installation.getLocal().getStatus().isServerRunning());
        LOG.log(Level.INFO, "Must stop the server after confirmations? "+
            userData.getStopServer());
      }
    }
    else
@@ -659,6 +690,8 @@
            /* During all the confirmations, the server might be stopped. */
            userData.setStopServer(
                Installation.getLocal().getStatus().isServerRunning());
            LOG.log(Level.INFO, "Must stop the server after confirmations? "+
                userData.getStopServer());
          }
        }
        catch (CLIException ce)
@@ -684,6 +717,7 @@
        }
      }
    }
    LOG.log(Level.INFO, "cancelled: "+cancelled);
    return cancelled;
  }
@@ -862,11 +896,11 @@
        couldConnect = true;
      }
      catch (ArgumentException e) {
        println(e.getMessageObject());
        printErrorMessage(e.getMessageObject());
        println();
      }
      catch (ClientException e) {
        println(e.getMessageObject());
        printErrorMessage(e.getMessageObject());
        println();
      }
      finally
@@ -943,6 +977,7 @@
  private boolean startServer(boolean supressOutput)
  {
    LOG.log(Level.INFO, "startServer, supressOutput: "+supressOutput);
    boolean serverStarted = false;
    Application application = new Application()
    {
@@ -1074,14 +1109,22 @@
        printlnProgress();
      }
      serverStarted = Installation.getLocal().getStatus().isServerRunning();
      LOG.log(Level.INFO, "server started successfully. serverStarted: "+
          serverStarted);
    }
    catch (ApplicationException ae)
    {
      LOG.log(Level.WARNING, "ApplicationException: "+ae, ae);
      if (!supressOutput)
      {
        println(ae.getMessageObject());
        printErrorMessage(ae.getMessageObject());
      }
    }
    catch (Throwable t)
    {
      LOG.log(Level.SEVERE, "Unexpected error: "+t, t);
      throw new IllegalStateException("Unexpected error: "+t, t);
    }
    return serverStarted;
  }
@@ -1110,6 +1153,10 @@
    boolean exceptionOccurred = true;
    Message exceptionMsg = null;
    LOG.log(Level.INFO, "Updating user data with remote servers.");
    InitialLdapContext ctx = null;
    try
    {
@@ -1146,6 +1193,7 @@
        forceTrustManagerInitialization();
        updateTrustManager(userData, ci);
      }
      LOG.log(Level.INFO, "Reloading topology");
      TopologyCache cache = new TopologyCache(adsContext,
          userData.getTrustManager());
      cache.getFilter().setSearchMonitoringInformation(false);
@@ -1160,21 +1208,20 @@
      LOG.log(Level.WARNING, "Error connecting to server: "+ne, ne);
      if (Utils.isCertificateException(ne))
      {
        println();
        println(INFO_ERROR_READING_CONFIG_LDAP_CERTIFICATE.get(
            ne.getMessage()));
        String details = ne.getMessage() != null ?
            ne.getMessage() : ne.toString();
        exceptionMsg =
          INFO_ERROR_READING_CONFIG_LDAP_CERTIFICATE.get(details);
      }
      else
      {
        println();
        println(
            Utils.getThrowableMsg(INFO_ERROR_CONNECTING_TO_LOCAL.get(), ne));
        exceptionMsg = Utils.getThrowableMsg(
            INFO_ERROR_CONNECTING_TO_LOCAL.get(), ne);
      }
    } catch (TopologyCacheException te)
    {
      LOG.log(Level.WARNING, "Error connecting to server: "+te, te);
      println();
      println(Utils.getMessage(te));
      exceptionMsg = Utils.getMessage(te);
    } catch (ApplicationException ae)
    {
@@ -1183,8 +1230,7 @@
    } catch (Throwable t)
    {
      LOG.log(Level.WARNING, "Error connecting to server: "+t, t);
      println();
      println(Utils.getThrowableMsg(INFO_BUG_MSG.get(), t));
      exceptionMsg = Utils.getThrowableMsg(INFO_BUG_MSG.get(), t);
    }
    finally
    {
@@ -1206,20 +1252,24 @@
      {
        if (forceOnError)
        {
          println(ERR_UNINSTALL_ERROR_UPDATING_REMOTE_FORCE.get(
          println();
          printErrorMessage(ERR_UNINSTALL_ERROR_UPDATING_REMOTE_FORCE.get(
              "--"+parser.getSecureArgsList().adminUidArg.getLongIdentifier(),
              "--"+ToolConstants.OPTION_LONG_BINDPWD,
              "--"+ToolConstants.OPTION_LONG_BINDPWD_FILE));
              "--"+ToolConstants.OPTION_LONG_BINDPWD_FILE,
              String.valueOf(exceptionMsg)));
        }
        else
        {
          println();
          throw new UserDataException(null,
              ERR_UNINSTALL_ERROR_UPDATING_REMOTE_NO_FORCE.get(
                  "--"+
                  parser.getSecureArgsList().adminUidArg.getLongIdentifier(),
                  "--"+ToolConstants.OPTION_LONG_BINDPWD,
                  "--"+ToolConstants.OPTION_LONG_BINDPWD_FILE,
                  "--"+parser.forceOnErrorArg.getLongIdentifier()));
                  "--"+parser.forceOnErrorArg.getLongIdentifier(),
                  String.valueOf(exceptionMsg)));
        }
      }
      else
@@ -1237,6 +1287,7 @@
      }
    }
    userData.setUpdateRemoteReplication(accepted);
    LOG.log(Level.INFO, "accepted: "+accepted);
    return accepted;
  }
@@ -1261,6 +1312,8 @@
    boolean reloadTopologyCache = false;
    boolean interactive = parser.isInteractive();
    LOG.log(Level.INFO, "Handle topology cache.");
    Set<TopologyCacheException> exceptions =
      new HashSet<TopologyCacheException>();
    /* Analyze if we had any exception while loading servers.  For the moment
@@ -1282,6 +1335,7 @@
    /* Check the exceptions and see if we throw them or not. */
    for (TopologyCacheException e : exceptions)
    {
      LOG.log(Level.INFO, "Analyzing exception: "+e, e);
      if (stopProcessing)
      {
        break;
@@ -1290,7 +1344,7 @@
      {
      case NOT_GLOBAL_ADMINISTRATOR:
        println();
        println(INFO_NOT_GLOBAL_ADMINISTRATOR_PROVIDED.get());
        printErrorMessage(INFO_NOT_GLOBAL_ADMINISTRATOR_PROVIDED.get());
        stopProcessing = true;
        break;
      case GENERIC_CREATING_CONNECTION:
@@ -1356,18 +1410,28 @@
    }
    else
    {
      LOG.log(Level.INFO, "exceptionMsgs: "+exceptionMsgs);
      if (exceptionMsgs.size() > 0)
      {
        Message msg = Utils.getMessageFromCollection(exceptionMsgs,
            Constants.LINE_SEPARATOR);
        if (parser.isForceOnError())
        {
          Message msg = Utils.getMessageFromCollection(exceptionMsgs,
              Constants.LINE_SEPARATOR);
          println();
          println(msg);
          printErrorMessage(msg);
          returnValue = false;
        }
        else
        {
          Message msg =
            ERR_UNINSTALL_ERROR_UPDATING_REMOTE_NO_FORCE.get(
              "--"+
              parser.getSecureArgsList().adminUidArg.getLongIdentifier(),
              "--"+ToolConstants.OPTION_LONG_BINDPWD,
              "--"+ToolConstants.OPTION_LONG_BINDPWD_FILE,
              "--"+parser.forceOnErrorArg.getLongIdentifier(),
              Utils.getMessageFromCollection(exceptionMsgs,
                  Constants.LINE_SEPARATOR).toString());
          throw new ApplicationException(ReturnCode.APPLICATION_ERROR, msg,
              null);
        }
@@ -1377,6 +1441,7 @@
        returnValue = true;
      }
    }
    LOG.log(Level.INFO, "Return value: "+returnValue);
    return returnValue;
  }
@@ -1485,4 +1550,10 @@
     }
     forceNonInteractive = false;
   }
   private void printErrorMessage(Message msg)
   {
     super.println(msg);
     LOG.log(Level.WARNING, msg.toString());
   }
}
opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallLauncher.java
@@ -73,7 +73,7 @@
    try {
      QuickSetupLog.initLogFileHandler(
              File.createTempFile(LOG_FILE_PREFIX, LOG_FILE_SUFFIX),
              "org.opends.guitools.uninstaller");
              "org.opends.guitools");
    } catch (Throwable t) {
      System.err.println("Unable to initialize log");
opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.uninstaller;
@@ -65,6 +65,7 @@
import org.opends.server.admin.std.client.RootCfgClient;
import org.opends.server.core.DirectoryServer;
import org.opends.server.tools.ConfigureWindowsService;
import org.opends.server.tools.ToolConstants;
import org.opends.messages.Message;
import org.opends.messages.MessageBuilder;
import static org.opends.messages.AdminToolMessages.*;
@@ -95,6 +96,8 @@
  private boolean errorOnRemoteOccurred;
  private boolean errorDeletingOccurred;
  private UninstallerArgumentParser parser;
  private HashMap<ProgressStep, Integer> hmRatio =
          new HashMap<ProgressStep, Integer>();
@@ -143,6 +146,8 @@
    // Switch off attribute type name validation in client.
    AttributeTypePropertyDefinition.setCheckSchema(false);
    LOG.log(Level.INFO, "Uninstaller is created.");
  }
  /**
   * {@inheritDoc}
@@ -573,8 +578,9 @@
   */
  public UserData createUserData(Launcher launcher)
          throws UserDataException, ApplicationException {
    parser = (UninstallerArgumentParser)launcher.getArgumentParser();
    return cliHelper.createUserData(
        (UninstallerArgumentParser)launcher.getArgumentParser(),
        parser,
        launcher.getArguments());
  }
@@ -759,6 +765,8 @@
   */
  public void run() {
    runStarted = true;
    LOG.log(Level.INFO, "run of the Uninstaller started");
    initMaps();
    PrintStream origErr = System.err;
    PrintStream origOut = System.out;
@@ -772,6 +780,8 @@
      boolean displaySeparator = false;
      LOG.log(Level.INFO, "Update remote replication? "+
          getUninstallUserData().getUpdateRemoteReplication());
      if (getUninstallUserData().getUpdateRemoteReplication())
      {
        status = UninstallProgressStep.UNCONFIGURING_REPLICATION;
@@ -779,6 +789,7 @@
        displaySeparator = true;
      }
      LOG.log(Level.INFO, "Stop server? "+getUserData().getStopServer());
      if (getUserData().getStopServer()) {
        status = UninstallProgressStep.STOPPING_SERVER;
        if (displaySeparator && isVerbose()) {
@@ -796,6 +807,8 @@
        }
        displaySeparator = true;
      }
      LOG.log(Level.INFO, "Is Windows Service Enabled? "+
          isWindowsServiceEnabled());
      if (isWindowsServiceEnabled()) {
        status = UninstallProgressStep.DISABLING_WINDOWS_SERVICE;
        if (displaySeparator && isVerbose()) {
@@ -1569,8 +1582,9 @@
      BackgroundTask worker = new BackgroundTask()
      {
        public Object processBackgroundTask()throws TopologyCacheException
        public Object processBackgroundTask() throws Throwable
        {
          LOG.log(Level.INFO, "Loading Topology Cache in askForAuthentication");
          ADSContext adsContext = new ADSContext(ctx);
          TopologyCache cache = new TopologyCache(adsContext,
              getTrustManager());
@@ -1583,6 +1597,7 @@
          qs.getDialog().workerFinished();
          if (throwable != null)
          {
            LOG.log(Level.WARNING, "Throwable: "+throwable, throwable);
            if (throwable instanceof TopologyCacheException)
            {
              qs.displayError(
@@ -1596,6 +1611,7 @@
                  getThrowableMsg(INFO_BUG_MSG.get(), throwable),
                  INFO_ERROR_TITLE.get());
            }
            LOG.log(Level.INFO, "Error was displayed");
          }
          else
          {
@@ -1633,6 +1649,7 @@
   */
  private void handleTopologyCache(QuickSetup qs, TopologyCache cache)
  {
    LOG.log(Level.INFO, "Handling TopologyCache");
    boolean stopProcessing = false;
    Set<TopologyCacheException> exceptions =
      new HashSet<TopologyCacheException>();
@@ -1769,8 +1786,10 @@
        getTrustManager().acceptCertificate(chain, authType, host);
        BackgroundTask worker = new BackgroundTask()
        {
          public Object processBackgroundTask() throws TopologyCacheException
          public Object processBackgroundTask() throws Throwable
          {
            LOG.log(Level.INFO, "Reloading topology");
            cache.getFilter().setSearchMonitoringInformation(false);
            cache.reloadTopology();
            return cache;
          }
@@ -1936,6 +1955,10 @@
      }
    }
    if (!hasReferences)
    {
      LOG.log(Level.INFO, "No references in: "+ server.getHostPort(true));
    }
    if (hasReferences)
    {
      LOG.log(Level.INFO, "Updating references in: "+ server.getHostPort(true));
@@ -1964,7 +1987,15 @@
        if (!getUninstallUserData().isForceOnError())
        {
          throw ae;
          Message msg =
            ERR_UNINSTALL_ERROR_UPDATING_REMOTE_NO_FORCE.get(
              "--"+
              parser.getSecureArgsList().adminUidArg.getLongIdentifier(),
              "--"+ToolConstants.OPTION_LONG_BINDPWD,
              "--"+ToolConstants.OPTION_LONG_BINDPWD_FILE,
              "--"+parser.forceOnErrorArg.getLongIdentifier(),
              ae.getMessageObject().toString());
          throw new ApplicationException(ae.getType(), msg, ae);
        }
        else
        {
opendj-sdk/opends/src/messages/messages/admin_tool.properties
@@ -165,14 +165,15 @@
 references to it in the replicated servers.  Note that to be able to remove \
 remote references you must provide Global Administrator credentials using the \
 %s and %s (or %s) options.%nContinuing uninstall as we are \
 on force on error mode.
 on force on error mode.%n%n The error found was:%n%s
SEVERE_ERR_UNINSTALL_ERROR_UPDATING_REMOTE_NO_FORCE=This server is configured \
 to replicate some of its Base DN's.  There was an error retrieving the \
 references to it in the replicated servers.  Note that to be able to remove \
 remote references you must provide Global Administrator credentials using the \
 %s and %s (or %s) options.%nCheck that the connection parameters you \
 provided are correct.%nIf you want to uninstall the server even when remote \
 references cannot be removed, you can use the %s option.
 references cannot be removed, you can use the %s option.%n%n The error found \
 was:%n%s
MILD_ERR_UNINSTALL_NOT_UPDATE_REMOTE_PROMPT=This server is configured \
 to replicate some of its Base DN's.  There was an error retrieving the \
 references to it in the replicated servers.%nDo you want to continue?
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetupCli.java
@@ -22,11 +22,14 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.quicksetup;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.opends.quicksetup.util.ProgressMessageFormatter;
import org.opends.quicksetup.util.PlainTextProgressMessageFormatter;
import org.opends.quicksetup.util.Utils;
@@ -49,6 +52,9 @@
  private UserData userData;
  static private final Logger LOG =
    Logger.getLogger(QuickSetupCli.class.getName());
  /**
   * Creates a QuickSetupCli instance.
   * @param cliApp the application to be run
@@ -69,7 +75,7 @@
  /**
   * Parses the user data and prompts the user for data if required.  If the
   * user provides all the required data it launches the Uninstaller.
   * user provides all the required data it launches the application.
   *
   * @return the return code (SUCCESSFUL, CANCELLED, USER_DATA_ERROR,
   * ERROR_ACCESSING_FILE_SYSTEM, ERROR_STOPPING_SERVER or BUG.
@@ -102,6 +108,7 @@
                  });
        }
        Thread appThread = new Thread(cliApp, "CLI Application");
        LOG.log(Level.INFO, "Launching application");
        appThread.start();
        while (!Thread.State.TERMINATED.equals(appThread.getState())) {
          try {
@@ -111,10 +118,12 @@
          }
        }
        returnValue = cliApp.getReturnCode();
        LOG.log(Level.INFO, "Application returnValue: "+returnValue);
        if (returnValue == null) {
          ApplicationException ue = cliApp.getRunError();
          if (ue != null)
          {
            LOG.log(Level.INFO, "Application run error: "+ue, ue);
            returnValue = ue.getType();
          }
          else
@@ -131,6 +140,7 @@
    }
    catch (UserDataException uude)
    {
      LOG.log(Level.SEVERE, "UserDataException: "+uude, uude);
      System.err.println();
      System.err.println(StaticUtils.wrapText(uude.getLocalizedMessage(),
              Utils.getCommandLineMaxLineWidth()));
@@ -146,11 +156,18 @@
    }
    catch (ApplicationException ae)
    {
      LOG.log(Level.SEVERE, "ApplicationException: "+ae, ae);
      System.err.println();
      System.err.println(ae.getLocalizedMessage());
      System.err.println();
      returnValue = ae.getType();
    }
    catch (Throwable t)
    {
      LOG.log(Level.SEVERE, "Unexpected error: "+t, t);
      returnValue = ReturnCode.UNKNOWN;
    }
    LOG.log(Level.INFO, "returnValue: "+returnValue.getReturnCode());
    return returnValue;
  }
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/BackgroundTask.java
@@ -55,10 +55,10 @@
   * @return  An {@code Object} with information about the processing performed
   *          for this task, or {@code null} if no return value is needed.
   *
   * @throws Exception exception that will be passed through the method
   * @throws Throwable throwable that will be passed through the method
   *          backgroundTaskCompleted.
   */
  public abstract T processBackgroundTask() throws Exception;
  public abstract T processBackgroundTask() throws Throwable;
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.quicksetup.util;
@@ -33,6 +33,7 @@
import static org.opends.messages.QuickSetupMessages.*;
import org.opends.quicksetup.*;
import static org.opends.quicksetup.util.Utils.*;
import org.opends.quicksetup.installer.InstallerHelper;
import org.opends.server.util.SetupUtils;
@@ -141,99 +142,120 @@
      env.put(SetupUtils.OPENDS_JAVA_HOME, System.getProperty("java.home"));
      env.remove(SetupUtils.OPENDS_JAVA_ARGS);
      try {
        Process process = pb.start();
      LOG.log(Level.INFO, "Before calling stop-ds.  Is server running? "+
          installation.getStatus().isServerRunning());
        BufferedReader err =
                new BufferedReader(
                        new InputStreamReader(process.getErrorStream()));
        BufferedReader out =
                new BufferedReader(
                        new InputStreamReader(process.getInputStream()));
      int stopTries = 3;
      while (stopTries > 0)
      {
        stopTries --;
        LOG.log(Level.INFO, "Launching stop command, stopTries left: "+
            stopTries);
        /* Create these objects to resend the stop process output to the details
        * area.
        */
        new StopReader(err, true);
        new StopReader(out, false);
        try
        {
          LOG.log(Level.INFO, "Launching stop command, argList: "+argList);
          Process process = pb.start();
        int returnValue = process.waitFor();
          BufferedReader err =
            new BufferedReader(
                new InputStreamReader(process.getErrorStream()));
          BufferedReader out =
            new BufferedReader(
                new InputStreamReader(process.getInputStream()));
        int clientSideError =
                org.opends.server.protocols.ldap.
                        LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR;
        if ((returnValue == clientSideError) || (returnValue == 0)) {
          if (Utils.isWindows()) {
            /*
            * Sometimes the server keeps some locks on the files.
            * TODO: remove this code once stop-ds returns properly when server
            * is stopped.
            */
            int nTries = 10;
            boolean stopped = false;
          /* Create these objects to resend the stop process output to the
           * details area.
           */
          new StopReader(err, true);
          new StopReader(out, false);
            for (int i = 0; i < nTries && !stopped; i++) {
              stopped = !installation.getStatus().isServerRunning();
              if (!stopped) {
                if (application != null) {
                  MessageBuilder mb = new MessageBuilder();
                  mb.append(application.getFormattedLog(
                          INFO_PROGRESS_SERVER_WAITING_TO_STOP.get()));
                  mb.append(application.getLineBreak());
                  application.notifyListeners(mb.toMessage());
                }
          int returnValue = process.waitFor();
          int clientSideError =
            org.opends.server.protocols.ldap.
            LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR;
          if ((returnValue == clientSideError) || (returnValue == 0)) {
            if (Utils.isWindows()) {
              /*
               * Sometimes the server keeps some locks on the files.
               * TODO: remove this code once stop-ds returns properly when
               * server is stopped.
               */
              int nTries = 10;
              boolean stopped = false;
              for (int i = 0; i < nTries && !stopped; i++) {
                LOG.log(Level.FINE, "waiting for server to stop");
                try {
                  Thread.sleep(5000);
                }
                catch (Exception ex) {
                catch (Exception ex)
                {
                }
              } else {
                break;
                stopped = !installation.getStatus().isServerRunning();
                LOG.log(Level.INFO,
                    "After calling stop-ds.  Is server running? "+!stopped);
                if (!stopped) {
                  if (application != null) {
                    MessageBuilder mb = new MessageBuilder();
                    mb.append(application.getFormattedLog(
                        INFO_PROGRESS_SERVER_WAITING_TO_STOP.get()));
                    mb.append(application.getLineBreak());
                    application.notifyListeners(mb.toMessage());
                  }
                } else {
                  break;
                }
              }
              if (!stopped) {
                returnValue = -1;
              }
            }
            if (!stopped) {
              returnValue = -1;
          }
          if (returnValue == clientSideError) {
            if (application != null) {
              MessageBuilder mb = new MessageBuilder();
              mb.append(application.getLineBreak());
              mb.append(application.getFormattedLog(
                  INFO_PROGRESS_SERVER_ALREADY_STOPPED.get()));
              mb.append(application.getLineBreak());
              application.notifyListeners(mb.toMessage());
            }
          }
        }
        if (returnValue == clientSideError) {
          if (application != null) {
            MessageBuilder mb = new MessageBuilder();
            mb.append(application.getLineBreak());
            mb.append(application.getFormattedLog(
                            INFO_PROGRESS_SERVER_ALREADY_STOPPED.get()));
            mb.append(application.getLineBreak());
            application.notifyListeners(mb.toMessage());
          }
          LOG.log(Level.INFO, "server already stopped");
        } else if (returnValue != 0) {
          /*
          * The return code is not the one expected, assume the server could
          * not be stopped.
          */
          throw new ApplicationException(
              ReturnCode.STOP_ERROR,
            LOG.log(Level.INFO, "server already stopped");
            break;
          } else if (returnValue != 0) {
            if (stopTries <= 0)
            {
              /*
               * The return code is not the one expected, assume the server
               * could not be stopped.
               */
              throw new ApplicationException(
                  ReturnCode.STOP_ERROR,
                  INFO_ERROR_STOPPING_SERVER_CODE.get(
                          String.valueOf(returnValue)),
                  null);
        } else {
          if (application != null) {
            application.notifyListeners(application.getFormattedLog(
                    INFO_PROGRESS_SERVER_STOPPED.get()));
                      String.valueOf(returnValue)),
                      null);
            }
          } else {
            if (application != null) {
              application.notifyListeners(application.getFormattedLog(
                  INFO_PROGRESS_SERVER_STOPPED.get()));
            }
            LOG.log(Level.INFO, "server stopped");
            break;
          }
          LOG.log(Level.INFO, "server stopped");
        }
      } catch (Exception e) {
        throw new ApplicationException(
            ReturnCode.STOP_ERROR, getThrowableMsg(
                INFO_ERROR_STOPPING_SERVER.get(), e), e);
        } catch (Exception e) {
          throw new ApplicationException(
              ReturnCode.STOP_ERROR, getThrowableMsg(
                  INFO_ERROR_STOPPING_SERVER.get(), e), e);
        }
      }
    } finally {
    }
    finally {
      if (suppressOutput && StandardOutputSuppressor.isSuppressed()) {
        StandardOutputSuppressor.unsuppress();
      }