From 84e3c2e819f9921255bdc11041fdb45d61557f55 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Wed, 26 Mar 2008 12:00:42 +0000
Subject: [PATCH] Fix for issue 3064 (The setup command should check the Java version)
---
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java | 94 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 94 insertions(+), 0 deletions(-)
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index 16744f1..581b16a 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -1454,6 +1454,100 @@
}
return time;
}
+
+ /**
+ * Checks that the java version we are running is compatible with OpenDS.
+ * @throws IncompatibleVersionException if the java version we are running
+ * is not compatible with OpenDS.
+ */
+ public static void checkJavaVersion() throws IncompatibleVersionException
+ {
+ String vendor = System.getProperty("java.vendor");
+ String version = System.getProperty("java.version");
+ for (CompatibleJava i : CompatibleJava.values())
+ {
+ if (i.getVendor().equalsIgnoreCase(vendor))
+ {
+ // Compare versions.
+ boolean versionCompatible =
+ i.getVersion().compareToIgnoreCase(version) <= 0;
+ if (!versionCompatible)
+ {
+ throw new IncompatibleVersionException(
+ ERR_INCOMPATIBLE_VERSION.get(i.getVersion(), version), null);
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the HTML representation of a plain text string which is obtained
+ * by converting some special characters (like '<') into its equivalent
+ * escaped HTML representation.
+ *
+ * @param rawString the String from which we want to obtain the HTML
+ * representation.
+ * @return the HTML representation of the plain text string.
+ */
+ static String escapeHtml(String rawString)
+ {
+ StringBuilder buffer = new StringBuilder();
+ for (int i = 0; i < rawString.length(); i++)
+ {
+ char c = rawString.charAt(i);
+ switch (c)
+ {
+ case '<':
+ buffer.append("<");
+ break;
+
+ case '>':
+ buffer.append(">");
+ break;
+
+ case '&':
+ buffer.append("&");
+ break;
+
+ case '"':
+ buffer.append(""");
+ break;
+
+ default:
+ buffer.append(c);
+ break;
+ }
+ }
+
+ return buffer.toString();
+ }
+
+ /**
+ * Returns the HTML representation for a given text. without adding any kind
+ * of font or style elements. Just escapes the problematic characters
+ * (like '<') and transform the break lines into '\n' characters.
+ *
+ * @param text the source text from which we want to get the HTML
+ * representation
+ * @return the HTML representation for the given text.
+ */
+ public static String getHtml(String text)
+ {
+ StringBuilder buffer = new StringBuilder();
+ if (text != null) {
+ text = text.replaceAll("\r\n", "\n");
+ String[] lines = text.split("[\n\r\u0085\u2028\u2029]");
+ for (int i = 0; i < lines.length; i++)
+ {
+ if (i != 0)
+ {
+ buffer.append(Constants.HTML_LINE_BREAK);
+ }
+ buffer.append(escapeHtml(lines[i]));
+ }
+ }
+ return buffer.toString();
+ }
}
/**
--
Gitblit v1.10.0