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

lutoff
29.38.2009 fef8fc7d514743391fd93aae74e2b9db20e59baf
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();
  }
}