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

Violette Roche-Montane
03.42.2013 06dc34882e70da6158464bfb18dd30ef86e1bc1d
opends/src/server/org/opends/server/tools/upgrade/UpgradeCli.java
@@ -40,7 +40,6 @@
FormattedNotificationCallback.TITLE_CALLBACK;
import static org.opends.server.tools.upgrade.Upgrade.EXIT_CODE_ERROR;
import static org.opends.server.tools.upgrade.Upgrade.EXIT_CODE_SUCCESS;
import static org.opends.server.tools.upgrade.VerificationCallback.*;
import java.io.IOException;
import java.io.InputStream;
@@ -359,12 +358,22 @@
    // Main process
    try
    {
      // Upgrade's context.
      UpgradeContext context =
          new UpgradeContext(BuildVersion.instanceVersion(), BuildVersion
              .binaryVersion(), this);
      context.setIgnoreErrorsMode(isIgnoreErrors());
      context.setAcceptLicenseMode(isAcceptLicense());
      context.setInteractiveMode(isInteractive());
      context.setForceUpgradeMode(isForceUpgrade());
      // Creates the log file.
      UpgradeLog.initLogFileHandler();
      // Starts upgrade.
      Upgrade.upgrade(BuildVersion.instanceVersion(), BuildVersion
          .binaryVersion(), this);
      Upgrade.upgrade(context);
    }
    catch (ClientException ex)
    {
@@ -437,72 +446,6 @@
          throw new IOException("Unsupported message type: ");
        }
      }
      else if (c instanceof VerificationCallback)
      {
        final VerificationCallback cc = (VerificationCallback) c;
        // Checks user's options.
        if (cc.getRequiredOptions() != null)
        {
          for (final int opt : cc.getRequiredOptions())
          {
            if (opt == NEED_USER_INTERACTION)
            {
              if (!isInteractive())
              {
                cc.setSelectedIndex(cc.getDefaultOption());
                return;
              }
            }
            if (opt == MANDATORY_USER_INTERACTION)
            {
              if (!isInteractive() && !isForceUpgrade())
              {
                println(Style.ERROR, ERR_UPGRADE_USER_INTERACTION_REQUIRED
                    .get(OPTION_LONG_NO_PROMPT, OPTION_LONG_FORCE_UPGRADE), 0);
                cc.setSelectedIndex(ConfirmationCallback.NO);
                return;
              }
              else if (!isInteractive() && isForceUpgrade())
              {
                cc.setSelectedIndex(ConfirmationCallback.YES);
              }
            }
            if (opt == TAKE_LONG_TIME_TO_COMPLETE
                || opt == CANNOT_BE_REVERTED)
            {
              if (!isInteractive() && !isForceUpgrade())
              {
                println(Style.ERROR, ERR_UPGRADE_USER_INTERACTION_REQUIRED
                    .get(OPTION_LONG_NO_PROMPT, OPTION_LONG_FORCE_UPGRADE), 0);
                cc.setSelectedIndex(ConfirmationCallback.NO);
                return;
              }
            }
            // Does the user specify the ignore errors mode ?
            if (opt == IGNORE_ERRORS_MODE) {
              if (!isIgnoreErrors())
              {
                cc.setSelectedIndex(ConfirmationCallback.NO);
                return;
              }
              cc.setSelectedIndex(ConfirmationCallback.YES);
            }
            if (opt == ACCEPT_LICENSE_MODE) {
              if (!isAcceptLicense())
              {
                cc.setSelectedIndex(ConfirmationCallback.NO);
                return;
              }
              cc.setSelectedIndex(ConfirmationCallback.YES);
            }
          }
          return;
        }
      }
      else if (c instanceof ConfirmationCallback)
      {
        final ConfirmationCallback cc = (ConfirmationCallback) c;
@@ -597,14 +540,14 @@
            LOG.log(INFO, value);
          }
        }
        else
        else // Non interactive mode :
        {
          // Non interactive mode
          // Force mode.
          if (isForceUpgrade())
          {
            cc.setSelectedIndex(ConfirmationCallback.YES);
          }
          else
          else // Default non interactive mode.
          {
            cc.setSelectedIndex(cc.getDefaultOption());
          }