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

lutoff
29.38.2009 fef8fc7d514743391fd93aae74e2b9db20e59baf
Fix for issue #3944 : upgrade tool should support the click-through license
Fix for issue #3945 : Need to way to determine if a license had already been accepted

With this modification, the upgrade tool display the license if the
<INSTALL_DIR>/Legal/license_to_accept.txt is present into the new zip
file (issue #3944).

We also create the file <INSTANCE_DIR>/Legal/licenseAccepted when the
license has been accepted (issue #3945)
setup tools (GUI and CLI) create it after the server configuration and
before data creation (backend) upgrade tool creates it in the unzipped layout.
4 files modified
192 ■■■■ changed files
opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java 121 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java 8 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java 62 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/InstallDS.java 1 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java
@@ -38,6 +38,68 @@
 */
public class LicenseFile {
  /**
   * Get the directory in which legal files are stored.
   */
  private static String getLegalDirectory()
  {
    if (Utils.isWebStart())
    {
      return File.separatorChar + "Legal";
    }
    else
    {
      String installRootFromSystem = System.getProperty("INSTALL_ROOT");
      if (installRootFromSystem == null)
      {
        installRootFromSystem = System.getenv("INSTALL_ROOT");
      }
      if (installRootFromSystem == null)
      {
        installRootFromSystem = "";
      }
      return installRootFromSystem + File.separatorChar + "Legal";
    }
  }
  /**
   * Get the directory in which legal files are stored.
   */
  private static String getInstanceLegalDirectory()
  {
    String instanceLegalDirName;
    if (Utils.isWebStart())
    {
      instanceLegalDirName = File.separatorChar + "Legal";
    }
    else
    {
      String installDirName = System.getProperty("INSTALL_ROOT");
      if (installDirName == null)
      {
        installDirName = System.getenv("INSTALL_ROOT");
      }
      if (installDirName == null)
      {
        installDirName = ".";
      }
      String instanceDirname = Utils
          .getInstancePathFromClasspath(installDirName);
      instanceLegalDirName = instanceDirname + File.separator + "Legal";
      File instanceLegalDir = new File(instanceLegalDirName);
      if (!instanceLegalDir.exists())
      {
        instanceLegalDir.mkdir();
      }
    }
    return instanceLegalDirName ;
  }
  /**
   * The File object related to the license file.
@@ -54,33 +116,7 @@
   */
  static private String getName()
  {
    if (Utils.isWebStart())
    {
      return
      File.separatorChar +
      "Legal" +
      File.separatorChar +
      "license_to_accept.txt";
    }
    else
    {
      String installRootFromSystem = System.getProperty("INSTALL_ROOT");
      if (installRootFromSystem == null) {
        installRootFromSystem = System.getenv("INSTALL_ROOT");
      }
      if (installRootFromSystem == null) {
        installRootFromSystem = "";
      }
      return installRootFromSystem +
      File.separatorChar +
      "Legal" +
      File.separatorChar +
      "license_to_accept.txt";
    }
    return getLegalDirectory() + File.separatorChar + "license_to_accept.txt";
  }
  /**
@@ -162,4 +198,35 @@
  {
    approved = p_approved;
  }
  /**
   * Create a file which indicates that the license has been approved.
   */
  static public void createFileLicenseApproved()
  {
    if ( getApproval() )
    {
      try
      {
        new File(getInstanceLegalDirectory() + File.separatorChar
            + "licenseAccepted").createNewFile();
      }
      catch (IOException e)
      {
      }
    }
  }
  /**
   * Indicate if the license had already been approved..
   * @return <CODE>true</CODE> if the license had already been approved
   * by the user <CODE>false</CODE> otherwise.
   */
  static public boolean isAlreadyApproved()
  {
    File f = new File(getInstanceLegalDirectory() + File.separatorChar
        + "licenseAccepted");
    return f.exists();
  }
}
opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 */
package org.opends.quicksetup.installer.offline;
@@ -40,6 +40,7 @@
import java.security.KeyStoreException;
import org.opends.quicksetup.ApplicationException;
import org.opends.quicksetup.LicenseFile;
import org.opends.quicksetup.ReturnCode;
import org.opends.quicksetup.ProgressStep;
import org.opends.quicksetup.Installation;
@@ -102,6 +103,11 @@
      checkAbort();
      // create license accepted file
      LicenseFile.createFileLicenseApproved();
      checkAbort() ;
      createData();
      checkAbort();
opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
@@ -28,6 +28,8 @@
package org.opends.quicksetup.upgrader;
import org.opends.quicksetup.CliApplication;
import org.opends.quicksetup.LicenseFile;
import static org.opends.quicksetup.Installation.*;
import static org.opends.messages.QuickSetupMessages.*;
@@ -72,12 +74,14 @@
import org.opends.server.tools.JavaPropertiesTool;
import java.awt.event.WindowEvent;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileFilter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.InetSocketAddress;
import java.net.MalformedURLException;
import java.net.Proxy;
@@ -814,6 +818,64 @@
      checkAbort();
      // Check license
      if (!LicenseFile.isAlreadyApproved())
      {
        String installRootFromSystem = System.getProperty("INSTALL_ROOT");
        System.setProperty("INSTALL_ROOT", installRootFromSystem
            + File.separator + "tmp" + File.separator + "upgrade");
        if (LicenseFile.exists())
        {
          String licenseString = LicenseFile.getText();
          System.out.println(licenseString);
          if (getUserData().isInteractive())
          {
            // 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();
            System.out.println(INFO_LICENSE_DETAILS_LABEL.get().toString());
            BufferedReader in = new BufferedReader(new InputStreamReader(
                System.in));
            while (true)
            {
              System.out.print(INFO_LICENSE_CLI_ACCEPT_QUESTION
                  .get(yes, no, no).toString());
              try
              {
                String response = in.readLine();
                if ((response == null)
                    || (response.toLowerCase().equals(no.toLowerCase()))
                    || (response.length() == 0))
                {
                  System.exit(ReturnCode.CANCELLED.getReturnCode());
                }
                else if (response.toLowerCase().equals(yes.toLowerCase()))
                {
                  // create the file
                  LicenseFile.setApproval(true);
                  LicenseFile.createFileLicenseApproved();
                  break;
                }
                else
                {
                  System.out.println(INFO_LICENSE_CLI_ACCEPT_INVALID_RESPONSE
                      .get().toString());
                }
              }
              catch (IOException e)
              {
                System.out.println(INFO_LICENSE_CLI_ACCEPT_INVALID_RESPONSE
                    .get().toString());
              }
            }
          }
        }
        System.setProperty("INSTALL_ROOT", installRootFromSystem);
      }
      if (!Utils.isWebStart())
      {
        // The command-line upgrade has not the option of leaving the server
opends/src/server/org/opends/server/tools/InstallDS.java
@@ -441,6 +441,7 @@
            else
            if (response.toLowerCase().equals(yes.toLowerCase()))
            {
              LicenseFile.setApproval(true);
              break ;
            }
            else