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

jvergara
02.59.2008 96fa4208d42b8e9a3d3ffe4fbb7d7ae349b1b740
Fix for issue 3221 (uninstall returns 0 but fails when LDAP connection is rejected)
There was a bug in the manner the option forceOnError. Appart from that there were some issues due to the fact that most of the methods in UninstallCliHelper do not throw exceptions. I have updated some interfaces and now the behavior is the following:

4 files modified
70 ■■■■ changed files
opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java 53 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java 4 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/CliApplication.java 6 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/QuickSetupCli.java 7 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
@@ -43,7 +43,6 @@
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.messages.QuickSetupMessages.*;
import static org.opends.messages.UtilityMessages.*;
import org.opends.quicksetup.*;
import org.opends.quicksetup.event.ProgressUpdateEvent;
@@ -118,10 +117,13 @@
   * and null if the user cancels the uninstallation.
   * @throws UserDataException if there is an error with the data
   * in the arguments.
   * @throws ApplicationException if there is an error processing data in
   * non-interactive mode and an error must be thrown (not in force on error
   * mode).
   */
  public UninstallUserData createUserData(UninstallerArgumentParser args,
      String[] rawArguments)
  throws UserDataException
  throws UserDataException, ApplicationException
  {
    parser = args;
    UninstallUserData userData = new UninstallUserData();
@@ -485,11 +487,14 @@
   * @return <CODE>true</CODE> if the user wants to continue with uninstall and
   * <CODE>false</CODE> otherwise.
   * @throws UserDataException if there is a problem with the data
   * provided by the user (in the particular case where we are on quiet
   * uninstall and some data is missing or not valid).
   * provided by the user (in the particular case where we are on
   * non-interactive uninstall and some data is missing or not valid).
   * @throws ApplicationException if there is an error processing data in
   * non-interactive mode and an error must be thrown (not in force on error
   * mode).
   */
  private boolean checkServerState(UninstallUserData userData)
  throws UserDataException
  throws UserDataException, ApplicationException
  {
    boolean cancelled = false;
    boolean interactive = parser.isInteractive();
@@ -548,8 +553,9 @@
        }
        else
        {
          cancelled =
          boolean errorWithRemote =
            !updateUserUninstallDataWithRemoteServers(userData);
          cancelled = errorWithRemote && !parser.isForceOnError();
        }
      }
      else
@@ -611,8 +617,9 @@
          if (startWorked)
          {
            userData.setStopServer(true);
            cancelled =
            boolean errorWithRemote =
              !updateUserUninstallDataWithRemoteServers(userData);
            cancelled = errorWithRemote && !parser.isForceOnError();
          }
          else
          {
@@ -1063,9 +1070,12 @@
   * <CODE>false</CODE> otherwise.
   * @throws UserDataException if were are not in interactive mode and not in
   * force on error mode and the operation must be stopped.
   * @throws ApplicationException if there is an error processing data in
   * non-interactive mode and an error must be thrown (not in force on error
   * mode).
   */
  private boolean updateUserUninstallDataWithRemoteServers(
      UninstallUserData userData) throws UserDataException
      UninstallUserData userData) throws UserDataException, ApplicationException
  {
    boolean accepted = false;
    boolean interactive = parser.isInteractive();
@@ -1150,6 +1160,10 @@
      println();
      println(Utils.getMessage(te));
    } catch (ApplicationException ae)
    {
      throw ae;
    } catch (Throwable t)
    {
      LOG.log(Level.WARNING, "Error connecting to server: "+t, t);
@@ -1219,9 +1233,12 @@
   * @param userData the user data.
   * @throws UserDataException if there is an error with the information
   * provided by the user when we are in non-interactive mode.
   * @throws ApplicationException if there is an error processing data in
   * non-interactive mode and an error must be thrown (not in force on error
   * mode).
   */
  private boolean handleTopologyCache(TopologyCache cache,
      UninstallUserData userData) throws UserDataException
      UninstallUserData userData) throws UserDataException, ApplicationException
  {
    boolean returnValue;
    boolean stopProcessing = false;
@@ -1281,9 +1298,8 @@
          }
          else
          {
            stopProcessing = true;
            println();
            println(INFO_ERROR_READING_CONFIG_LDAP_CERTIFICATE_SERVER.get(
            exceptionMsgs.add(
                INFO_ERROR_READING_CONFIG_LDAP_CERTIFICATE_SERVER.get(
                e.getHostPort(), e.getCause().getMessage()));
          }
        }
@@ -1326,13 +1342,22 @@
    {
      if (exceptionMsgs.size() > 0)
      {
        Message msg = Utils.getMessageFromCollection(exceptionMsgs,
            Constants.LINE_SEPARATOR);
        if (parser.isForceOnError())
        {
        println();
        println(Utils.getMessageFromCollection(exceptionMsgs,
            Constants.LINE_SEPARATOR));
          println(msg);
        returnValue = false;
      }
      else
      {
          throw new ApplicationException(ReturnCode.APPLICATION_ERROR, msg,
              null);
        }
      }
      else
      {
        returnValue = true;
      }
    }
opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
@@ -571,7 +571,7 @@
   * @param launcher
   */
  public UserData createUserData(Launcher launcher)
          throws UserDataException {
          throws UserDataException, ApplicationException {
    return cliHelper.createUserData(
        (UninstallerArgumentParser)launcher.getArgumentParser(),
        launcher.getArguments());
@@ -1884,7 +1884,7 @@
        LOG.log(Level.INFO, "Error updating replication references in: "+
            server.getHostPort(true), ae);
        if (getUninstallUserData().isForceOnError())
        if (!getUninstallUserData().isForceOnError())
        {
          throw ae;
        }
opends/src/quicksetup/org/opends/quicksetup/CliApplication.java
@@ -40,10 +40,12 @@
   * status.
   * @param launcher that launched this application
   * @return UserData object populated to reflect the input args and status
   * @throws UserDataException if something is wrong
   * @throws UserDataException if something is wrong with the data provided
   * by the user
   * @throws ApplicationException if there is an application specific problem
   */
  UserData createUserData(Launcher launcher)
          throws UserDataException;
          throws UserDataException, ApplicationException;
  /**
   * Gets the user data this application will use when running.
opends/src/quicksetup/org/opends/quicksetup/QuickSetupCli.java
@@ -144,6 +144,13 @@
        returnValue = ReturnCode.USER_DATA_ERROR;
      }
    }
    catch (ApplicationException ae)
    {
      System.err.println();
      System.err.println(ae.getLocalizedMessage());
      System.err.println();
      returnValue = ae.getType();
    }
    return returnValue;
  }