From 9dae9033e8e485cea0b24b48cfe22f7b1a0f5463 Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Fri, 05 Jul 2013 14:07:51 +0000
Subject: [PATCH] CR-1962 OPENDJ-1048 OpenDJ QuickSetup creates the "licenseAccepted" file in the wrong place

---
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java                          |   54 ++++++++++++++++++------------------------------------
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java   |    4 ++--
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java |    2 +-
 3 files changed, 21 insertions(+), 39 deletions(-)

diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java
index 207438c..8fbeb84 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java
@@ -42,9 +42,8 @@
 import org.opends.server.util.StaticUtils;
 
 /**
- * Represents information about the license file.
- *
- * NOTE: the license file location must be kept in sync with build.xml and
+ * Represents information about the license file. NOTE: the license file
+ * location must be kept in sync with build.xml and
  * org.opends.server.tools.upgrade.LicenseFile.
  */
 public class LicenseFile
@@ -68,28 +67,6 @@
   /**
    * Get the directory in which legal files are stored.
    */
-  private static String getLegalDirectory()
-  {
-
-    String installRootFromSystem = System.getProperty("INSTALL_ROOT");
-
-    if (installRootFromSystem == null)
-    {
-      installRootFromSystem = System.getenv("INSTALL_ROOT");
-    }
-
-    if (installRootFromSystem == null)
-    {
-      installRootFromSystem = "";
-    }
-
-    return installRootFromSystem + File.separatorChar + LEGAL_FOLDER_NAME;
-
-  }
-
-  /**
-   * Get the directory in which legal files are stored.
-   */
   private static String getInstanceLegalDirectory()
   {
     String instanceLegalDirName;
@@ -131,7 +108,8 @@
    */
   static private String getName()
   {
-    return getLegalDirectory() + File.separatorChar + LICENSE_FILE_NAME;
+    return getInstanceLegalDirectory() + File.separatorChar
+        + LICENSE_FILE_NAME;
   }
 
   /**
@@ -152,8 +130,8 @@
    */
   static private URL getWebStartLicenseFile()
   {
-    final String licenseResource = LEGAL_FOLDER_NAME + File.separatorChar
-        + LICENSE_FILE_NAME;
+    final String licenseResource =
+        LEGAL_FOLDER_NAME + File.separatorChar + LICENSE_FILE_NAME;
     return Thread.currentThread().getContextClassLoader().getResource(
         licenseResource);
   }
@@ -161,9 +139,9 @@
   /**
    * Checks if the license file exists.
    *
-   * @return <CODE>true</CODE> if the license file exists
-   *         in the Legal directory in the top level installation directory
-   *         <CODE>false</CODE> otherwise.
+   * @return <CODE>true</CODE> if the license file exists in the Legal directory
+   *         in the top level installation directory <CODE>false</CODE>
+   *         otherwise.
    */
   static public boolean exists()
   {
@@ -267,16 +245,20 @@
   }
 
   /**
-   * Create a file which indicates that the license has been approved.
+   * Creates a file - in the legal folder from the specified directory; which
+   * indicates that the license has been approved.
+   *
+   * @param installationPath
+   *          The server installation's path.
    */
-  static public void createFileLicenseApproved()
+  static public void createFileLicenseApproved(final String installationPath)
   {
-    if (getApproval())
+    if (getApproval() && installationPath != null)
     {
       try
       {
-        new File(getInstanceLegalDirectory() + File.separatorChar
-            + ACCEPTED_LICENSE_FILE_NAME).createNewFile();
+        new File(installationPath + File.separatorChar + LEGAL_FOLDER_NAME
+            + File.separatorChar + ACCEPTED_LICENSE_FILE_NAME).createNewFile();
       }
       catch (IOException e)
       {
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java
index bb1705b..27eb4aa 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java
@@ -23,7 +23,7 @@
  *
  *
  *      Copyright 2006-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2011-2012 ForgeRock AS
+ *      Portions Copyright 2011-2013 ForgeRock AS
  */
 
 package org.opends.quicksetup.installer.offline;
@@ -110,7 +110,7 @@
       checkAbort();
 
       // create license accepted file
-      LicenseFile.createFileLicenseApproved();
+      LicenseFile.createFileLicenseApproved(this.getInstallationPath());
 
       checkAbort() ;
 
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
index 7223f4d..bdaa453 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
@@ -158,7 +158,7 @@
       checkAbort();
 
       // create license accepted file
-      LicenseFile.createFileLicenseApproved();
+      LicenseFile.createFileLicenseApproved(this.getInstallationPath());
 
       createData();
 

--
Gitblit v1.10.0