From fef8fc7d514743391fd93aae74e2b9db20e59baf Mon Sep 17 00:00:00 2001
From: lutoff <lutoff@localhost>
Date: Wed, 29 Apr 2009 07:38:46 +0000
Subject: [PATCH] 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
---
opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java | 121 +++++++++++++++++++++++++++++++---------
1 files changed, 94 insertions(+), 27 deletions(-)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java b/opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java
index 8aa955d..723819d 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java
+++ b/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();
+ }
+
}
--
Gitblit v1.10.0