From 8ee2559efd80ab966eef9cfcef0aeb98b9885fc2 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Fri, 20 Nov 2015 16:54:45 +0000
Subject: [PATCH] OPENDJ-2431, OPENDJ-2442, OPENDJ-2448: Fix various license checking / approval with split install - instance. Now the license is read if present from the install (read-only) and the approval is written in the instance (and the directory created if needed). Note that upgrade will require to re-approve the license.
---
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/LicenseFile.java | 27 +++++++--------------------
1 files changed, 7 insertions(+), 20 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/LicenseFile.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/LicenseFile.java
index f897bdc..665b933 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/LicenseFile.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/LicenseFile.java
@@ -53,9 +53,6 @@
*/
private static final String LEGAL_FOLDER_NAME = "legal-notices";
- /** List of possible folder of the accepted license file. */
- private static final String[] ACCEPTED_LICENSE_FOLDER_NAMES = new String[] { LEGAL_FOLDER_NAME, "Legal" };
-
/**
* The accepted license file name.
*/
@@ -65,7 +62,7 @@
* Try to find the local instance path from system property or environment. If
* both are null, return the provided fallback value.
*/
- private static String getInstanceRootPathFromSystem(final String fallBackValue)
+ private static String getInstallRootPathFromSystem(final String fallBackValue)
{
final String[] possibleValues = new String[] {
System.getProperty(INSTALL_ROOT_SYSTEM_PROPERTY), System.getenv(INSTALL_ROOT_SYSTEM_PROPERTY) };
@@ -82,7 +79,7 @@
/** Get the directory in which legal files are stored. */
private static String getLegalDirectory()
{
- return getInstanceRootPathFromSystem("") + File.separatorChar + LEGAL_FOLDER_NAME;
+ return getInstallRootPathFromSystem(".") + File.separator + LEGAL_FOLDER_NAME;
}
/**
@@ -90,7 +87,7 @@
*/
private static String getInstanceLegalDirectory()
{
- final String instanceDirname = UpgradeUtils.getInstancePathFromInstallPath(getInstanceRootPathFromSystem("."));
+ final String instanceDirname = UpgradeUtils.getInstancePathFromInstallPath(getInstallRootPathFromSystem("."));
final String instanceLegalDirName = instanceDirname + File.separator + LEGAL_FOLDER_NAME;
final File instanceLegalDir = new File(instanceLegalDirName);
if (!instanceLegalDir.exists())
@@ -115,7 +112,7 @@
*/
private static String getName()
{
- return getLegalDirectory() + File.separatorChar + LICENSE_FILE_NAME;
+ return getLegalDirectory() + File.separator + LICENSE_FILE_NAME;
}
/**
@@ -212,11 +209,10 @@
{
try
{
- new File(getInstanceLegalDirectory() + File.separatorChar
- + ACCEPTED_LICENSE_FILE_NAME).createNewFile();
+ new File(getInstanceLegalDirectory(), ACCEPTED_LICENSE_FILE_NAME).createNewFile();
}
catch (IOException e)
- {
+ { // do nothing
}
}
}
@@ -229,16 +225,7 @@
*/
public static boolean isAlreadyApproved()
{
- for (final String folderName : ACCEPTED_LICENSE_FOLDER_NAMES)
- {
- final File f = new File(getInstanceRootPathFromSystem(".") + File.separatorChar + folderName
- + File.separatorChar + ACCEPTED_LICENSE_FILE_NAME);
- if (f.exists())
- {
- return true;
- }
- }
- return false;
+ return new File(getInstanceLegalDirectory(), ACCEPTED_LICENSE_FILE_NAME).exists();
}
}
--
Gitblit v1.10.0