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

Violette Roche-Montane
30.17.2013 251930b6f131025423207a8a3ea02c21b50bf400
OPENDJ-930 setup in non-interactive mode should not accept automatically the license
- added --acceptLicense to the setup command line options.
- modified code for checking the license during the setup :
- using the no-prompt option no longer bypass the license if presents.
- displays now the license text, question and answer(yes) when used with the --acceptLicense.
2 files modified
76 ■■■■■ changed files
opends/src/server/org/opends/server/tools/InstallDS.java 71 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/InstallDSArgumentParser.java 5 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/InstallDS.java
@@ -428,11 +428,10 @@
      PrintStream printStreamOut = getOutputStream();
      String licenseString = LicenseFile.getText();
      printStreamOut.println(licenseString);
      if (! argParser.noPromptArg.isPresent())
      // If the user asks for acceptLicense, license is displayed
      // and automatically accepted.
      if (! argParser.acceptLicense.isPresent())
      {
        // 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.
        String yes = INFO_LICENSE_CLI_ACCEPT_YES.get().toString();
        String no = INFO_LICENSE_CLI_ACCEPT_NO.get().toString();
        String yesShort = INFO_PROMPT_YES_FIRST_LETTER_ANSWER.get().toString();
@@ -441,39 +440,53 @@
            INFO_LICENSE_DETAILS_CLI_LABEL.get());
        BufferedReader in = getInputStream();
        while (true)
        // No-prompt arg automatically rejects the license.
        if (!argParser.noPromptArg.isPresent())
        {
          print(INFO_LICENSE_CLI_ACCEPT_QUESTION.get(yes,no,no));
          try
          while (true)
          {
            String response = in.readLine();
            if ((response == null)
                || (response.equalsIgnoreCase(no))
                || (response.equalsIgnoreCase(noShort))
                || (response.length() == 0))
            print(INFO_LICENSE_CLI_ACCEPT_QUESTION.get(yes, no, no));
            try
            {
              return ErrorReturnCode.ERROR_LICENSE_NOT_ACCEPTED
                  .getReturnCode();
              String response = in.readLine();
              if ((response == null) || (response.equalsIgnoreCase(no))
                  || (response.equalsIgnoreCase(noShort))
                  || (response.length() == 0))
              {
                return ErrorReturnCode.ERROR_LICENSE_NOT_ACCEPTED
                    .getReturnCode();
              }
              else if (response.equalsIgnoreCase(yes)
                  || response.equalsIgnoreCase(yesShort))
              {
                LicenseFile.setApproval(true);
                break;
              }
              else
              {
                println(
                    QuickSetupMessages.INFO_LICENSE_CLI_ACCEPT_INVALID_RESPONSE
                    .get());
              }
            }
            else
            if (response.equalsIgnoreCase(yes)
                || response.equalsIgnoreCase(yesShort))
            catch (IOException e)
            {
              LicenseFile.setApproval(true);
              break ;
              println(
                  QuickSetupMessages.INFO_LICENSE_CLI_ACCEPT_INVALID_RESPONSE
                  .get());
            }
            else
            {
              println(QuickSetupMessages
                  .INFO_LICENSE_CLI_ACCEPT_INVALID_RESPONSE.get());
            }
          }
          catch (IOException e)
          {
            println(QuickSetupMessages.
                INFO_LICENSE_CLI_ACCEPT_INVALID_RESPONSE.get());
          }
        }
        else
        {
          return ErrorReturnCode.ERROR_LICENSE_NOT_ACCEPTED.getReturnCode();
        }
      }
      else
      {
        print(INFO_LICENSE_ACCEPT.get());
        print(INFO_PROMPT_YES_COMPLETE_ANSWER.get());
        LicenseFile.setApproval(true);
      }
    }
opends/src/server/org/opends/server/tools/InstallDSArgumentParser.java
@@ -99,6 +99,7 @@
  StringArgument    certNicknameArg;
  StringArgument    progNameArg;
  IntegerArgument   connectTimeoutArg = null;
  BooleanArgument   acceptLicense;
  private static final Logger LOG = Logger.getLogger(
      InstallDSArgumentParser.class.getName());
@@ -404,6 +405,10 @@
    connectTimeoutArg.setHidden(true);
    addArgument(connectTimeoutArg);
    acceptLicense = new BooleanArgument(OPTION_LONG_ACCEPT_LICENSE, null,
        OPTION_LONG_ACCEPT_LICENSE, INFO_OPTION_ACCEPT_LICENSE.get());
    addArgument(acceptLicense);
    showUsageArg = new BooleanArgument(
        OPTION_LONG_HELP.toLowerCase(), OPTION_SHORT_HELP,
        OPTION_LONG_HELP,