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

Violette Roche-Montane
25.06.2013 0190fa66bcab9f911f23bf954eaa45f9af4aaa76
OPENDJ-1010 "upgrade --force" should not automatically accept the license
4 files modified
48 ■■■■■ changed files
opends/src/server/org/opends/server/tools/upgrade/FormattedNotificationCallback.java 4 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/upgrade/Upgrade.java 29 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/upgrade/UpgradeCli.java 13 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java 2 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/upgrade/FormattedNotificationCallback.java
@@ -46,6 +46,10 @@
  static final int NOTICE_CALLBACK = 7;
  static final int ERROR_CALLBACK = 8;
  static final int BREAKLINE = 9;
  /**
   * An integer representing the message's sub-type.
   */
opends/src/server/org/opends/server/tools/upgrade/Upgrade.java
@@ -631,18 +631,26 @@
      if (LicenseFile.exists())
      {
        context.notify(Message.raw("\n" + LicenseFile.getText()));
        // If the user asks for no-prompt. We just display the license text.
        // User doesn't asks for no-prompt. We just display the license text
        // and force to accept it.
        context.notify(INFO_LICENSE_DETAILS_CLI_LABEL.get());
        if (!context.isAcceptLicenseMode())
        {
          final int answer;
          final int answer =
              context.confirmYN(INFO_LICENSE_ACCEPT.get(),
                  ConfirmationCallback.NO);
          // The force cannot answer yes to the license's question,
          // which is not a task even if it requires a user interaction OR
          // -an accept license mode to continue the process.
          if (context.isForceUpgradeMode())
          {
            answer = ConfirmationCallback.NO;
            context.notify(Message.raw(INFO_LICENSE_ACCEPT.get() + " "
                + INFO_PROMPT_NO_COMPLETE_ANSWER.get()));
          }
          else
          {
            answer =
                context.confirmYN(INFO_LICENSE_ACCEPT.get(),
                    ConfirmationCallback.NO);
          }
          if (answer == ConfirmationCallback.NO)
          {
@@ -655,8 +663,9 @@
        }
        else
        {
          context.notify(INFO_LICENSE_ACCEPT.get());
          context.notify(INFO_PROMPT_YES_COMPLETE_ANSWER.get());
          // We automatically accept the license with this option.
          context.notify(Message.raw(INFO_LICENSE_ACCEPT.get() + " "
              + INFO_PROMPT_YES_COMPLETE_ANSWER.get()));
          LicenseFile.setApproval(true);
        }
      }
opends/src/server/org/opends/server/tools/upgrade/UpgradeCli.java
@@ -32,12 +32,7 @@
import static org.opends.server.util.StaticUtils.filterExitCode;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.SEVERE;
import static org.opends.server.tools.upgrade.
FormattedNotificationCallback.NOTICE_CALLBACK;
import static org.opends.server.tools.upgrade.
FormattedNotificationCallback.SUBTITLE_CALLBACK;
import static org.opends.server.tools.upgrade.
FormattedNotificationCallback.TITLE_CALLBACK;
import static org.opends.server.tools.upgrade.FormattedNotificationCallback.*;
import static org.opends.server.tools.upgrade.Upgrade.EXIT_CODE_ERROR;
import static org.opends.server.tools.upgrade.Upgrade.EXIT_CODE_SUCCESS;
@@ -427,6 +422,12 @@
        case NOTICE_CALLBACK:
          println(Style.NOTICE, Message.raw(fnc.getMessage()), 1);
          break;
        case ERROR_CALLBACK:
          println(Style.ERROR, Message.raw(fnc.getMessage()), 1);
          break;
        case BREAKLINE:
          println(Style.BREAKLINE, Message.raw(fnc.getMessage()), 1);
          break;
        default:
          LOG.log(SEVERE, "Unsupported message type: "
            + fnc.getMessage());
opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java
@@ -797,6 +797,8 @@
      // The option is not present ? Stops the process.
      if (!context.isInteractiveMode() && !context.isForceUpgradeMode())
      {
        context
            .notify(Message.raw(" "), FormattedNotificationCallback.BREAKLINE);
        context.notify(ERR_UPGRADE_USER_INTERACTION_REQUIRED.get(
            OPTION_LONG_NO_PROMPT, OPTION_LONG_FORCE_UPGRADE),
            FormattedNotificationCallback.NOTICE_CALLBACK);