opends/src/messages/messages/quicksetup.properties
@@ -1304,7 +1304,11 @@ SEVERE_ERR_COULD_NOT_FIND_REPLICATIONID=Could not find a remote peer to \ initialize the contents of local base DN: %s. INFO_NEW_UPGRADE_SCRIPT_AVAILABLE=A new version of '%s' has been made \ available. After this operation you should delete this script and rename \ '%s' to '%1$s'. available. After this operation you should delete this script and rename \ '%s' to '%1$s'. MILD_ERR_ERROR_CREATING_JAVA_HOME_SCRIPTS=Error updating scripts with java \ properties. Error code: %d SEVERE_ERR_INCOMPATIBLE_VERSION=The minimum Java version required is %s.%n%n\ The detected version is %s.%n%n\Please set OPENDS_JAVA_HOME to the root of a \ compatible Java installation or edit the java.properties file and then run \ the dsjavaproperties script to specify the java version to be used. opends/src/quicksetup/org/opends/quicksetup/Constants.java
@@ -93,4 +93,7 @@ /** The default replication port. */ public static final int DEFAULT_REPLICATION_PORT = 8989; /** The maximum chars we show in a line of a dialog. */ public static final int MAX_CHARS_PER_LINE_IN_DIALOG = 100; } opends/src/quicksetup/org/opends/quicksetup/ReturnCode.java
@@ -101,12 +101,17 @@ public static final ReturnCode BUG = new ReturnCode(12); /** * Return code: Bug. * Return code: java version non-compatible. */ public static final ReturnCode JAVA_VERSION_INCOMPATIBLE = new ReturnCode(13); /** * Return code: Print Version. */ public static final ReturnCode PRINT_VERSION = new ReturnCode(50); /** * Return code: Bug. * Return code: Print Usage. */ public static final ReturnCode PRINT_USAGE = new ReturnCode(51); opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -63,12 +63,15 @@ import org.opends.admin.ads.util.ConnectionUtils; import org.opends.admin.ads.util.PreferredConnection; import org.opends.quicksetup.ui.*; import org.opends.quicksetup.util.IncompatibleVersionException; import org.opends.quicksetup.util.Utils; import static org.opends.quicksetup.util.Utils.*; import static org.opends.quicksetup.Step.*; import org.opends.quicksetup.*; import org.opends.server.util.CertificateManager; import org.opends.quicksetup.event.ButtonActionListener; import org.opends.quicksetup.event.ButtonEvent; import org.opends.quicksetup.installer.ui.DataOptionsPanel; import org.opends.quicksetup.installer.ui.DataReplicationPanel; import org.opends.quicksetup.installer.ui.GlobalAdministratorPanel; @@ -111,6 +114,8 @@ /** When true indicates that the user has canceled this operation. */ protected boolean canceled = false; private boolean javaVersionCheckFailed; /** Map containing information about what has been configured remotely. */ Map<ServerDescriptor, ConfiguredReplication> hmConfiguredRemoteReplication = new HashMap<ServerDescriptor, ConfiguredReplication>(); @@ -403,6 +408,11 @@ "Cannot click on quit from progress step"); } else if (installStatus.isInstalled()) { qs.quit(); } else if (javaVersionCheckFailed) { qs.quit(); } else if (qs.displayConfirmation(INFO_CONFIRM_QUIT_INSTALL_MSG.get(), INFO_CONFIRM_QUIT_INSTALL_TITLE.get())) { qs.quit(); @@ -436,10 +446,42 @@ */ public JPanel createFramePanel(QuickSetupDialog dlg) { JPanel p; if (installStatus.isInstalled() && !forceToDisplaySetup) { p = dlg.getInstalledPanel(); } else { p = super.createFramePanel(dlg); javaVersionCheckFailed = true; try { Utils.checkJavaVersion(); javaVersionCheckFailed = false; if (installStatus.isInstalled() && !forceToDisplaySetup) { p = dlg.getInstalledPanel(); } else { p = super.createFramePanel(dlg); } } catch (IncompatibleVersionException ijv) { MessageBuilder sb = new MessageBuilder(); sb.append(Utils.breakHtmlString( Utils.getHtml(ijv.getMessageObject().toString()), Constants.MAX_CHARS_PER_LINE_IN_DIALOG)); QuickSetupErrorPanel errPanel = new QuickSetupErrorPanel(this, sb.toMessage()); final QuickSetupDialog fDlg = dlg; errPanel.addButtonActionListener( new ButtonActionListener() { /** * ButtonActionListener implementation. It assumes that we are * called in the event thread. * * @param ev the ButtonEvent we receive. */ public void buttonActionPerformed(ButtonEvent ev) { // Simulate a close button event fDlg.notifyButtonEvent(ButtonName.QUIT); } }); p = errPanel; } return p; } opends/src/quicksetup/org/opends/quicksetup/installer/SetupLauncher.java
@@ -39,6 +39,7 @@ import org.opends.quicksetup.Launcher; import org.opends.quicksetup.QuickSetupLog; import org.opends.quicksetup.installer.offline.OfflineInstaller; import org.opends.quicksetup.util.IncompatibleVersionException; import org.opends.quicksetup.util.Utils; import org.opends.messages.Message; import org.opends.server.tools.InstallDS; @@ -128,7 +129,6 @@ * {@inheritDoc} */ public void launch() { // Validate user provided data try { argParser.parseArguments(args); @@ -145,11 +145,15 @@ } else if (isCli()) { Utils.checkJavaVersion(); System.exit(InstallDS.mainCLI(args)); } else { willLaunchGui(); // The java version is checked in the launchGui code to be sure // that if there is a problem with the java version the message // (if possible) is displayed graphically. int exitCode = launchGui(args); if (exitCode != 0) { File logFile = QuickSetupLog.getLogFile(); @@ -161,6 +165,7 @@ { guiLaunchFailed(null); } Utils.checkJavaVersion(); System.exit(InstallDS.mainCLI(args)); } } @@ -174,6 +179,11 @@ System.exit(ReturnCode.USER_DATA_ERROR.getReturnCode()); } catch (IncompatibleVersionException ive) { System.err.println(ive.getMessageObject()); System.exit(ReturnCode.JAVA_VERSION_INCOMPATIBLE.getReturnCode()); } } /** opends/src/quicksetup/org/opends/quicksetup/ui/GuiUserInteraction.java
@@ -48,8 +48,6 @@ */ public class GuiUserInteraction implements UserInteraction { static private final int MAX_CHARS_PER_LINE = 100; private Component parent = null; /** @@ -99,9 +97,11 @@ } JOptionPane op; if (fineDetails != null) { op = new DetailsOptionPane(MAX_CHARS_PER_LINE, fineDetails); op = new DetailsOptionPane(Constants.MAX_CHARS_PER_LINE_IN_DIALOG, fineDetails); } else { op = new MaxCharactersPerLineOptionPane(MAX_CHARS_PER_LINE); op = new MaxCharactersPerLineOptionPane( Constants.MAX_CHARS_PER_LINE_IN_DIALOG); } // Create the main message using HTML formatting. The max @@ -110,12 +110,14 @@ // have to format this ourselves. MessageBuilder sb = new MessageBuilder(); sb.append(Constants.HTML_BOLD_OPEN); sb.append(Utils.breakHtmlString(summary, MAX_CHARS_PER_LINE)); sb.append(Utils.breakHtmlString(summary, Constants.MAX_CHARS_PER_LINE_IN_DIALOG)); sb.append(Constants.HTML_BOLD_CLOSE); sb.append(Constants.HTML_LINE_BREAK); sb.append(Constants.HTML_LINE_BREAK); sb.append(Utils.breakHtmlString(details, MAX_CHARS_PER_LINE)); sb.append(Utils.breakHtmlString(details, Constants.MAX_CHARS_PER_LINE_IN_DIALOG)); JEditorPane ep = UIFactory.makeHtmlPane( sb.toMessage(), UIFactory.INSTRUCTIONS_FONT); opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java
@@ -125,15 +125,6 @@ } /** * Gets the current installation status of the filesystem * bits this quick setup is managing. * @return CurrentInstallStatus indicating the install status */ public CurrentInstallStatus getInstallStatus() { return installStatus; } /** * This method displays the setup dialog. This method must be called from the * event thread. */ opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupDialog.java
@@ -270,7 +270,6 @@ { getButtonsPanel().addButtonActionListener(l); getInstalledPanel().addButtonActionListener(l); getButtonsPanel().addButtonActionListener(l); getCurrentStepPanel().addButtonActionListener(l); buttonListeners.add(l); opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupErrorPanel.java
@@ -38,6 +38,7 @@ import javax.swing.JPanel; import javax.swing.text.JTextComponent; import org.opends.messages.Message; import org.opends.quicksetup.ButtonName; import org.opends.quicksetup.CurrentInstallStatus; import org.opends.quicksetup.event.ButtonActionListener; @@ -68,6 +69,18 @@ public QuickSetupErrorPanel(GuiApplication application, CurrentInstallStatus installStatus) { this(application, installStatus.getInstallationMsg()); continueButton.setVisible(installStatus.canOverwriteCurrentInstall()); } /** * Constructor of the QuickSetupErrorPanel. * @param application Application this panel represents * @param msg the error message to display formatted in HTML. */ public QuickSetupErrorPanel(GuiApplication application, Message msg) { super(application); JPanel p1 = new JPanel(new GridBagLayout()); p1.setBackground(UIFactory.CURRENT_STEP_PANEL_BACKGROUND); @@ -83,8 +96,7 @@ gbc.fill = GridBagConstraints.BOTH; gbc.insets.left = 0; JTextComponent tf = UIFactory.makeHtmlPane( installStatus.getInstallationMsg(), UIFactory.makeHtmlPane(msg, UIFactory.INSTRUCTIONS_FONT); tf.setOpaque(false); tf.setEditable(false); @@ -143,7 +155,7 @@ gbc.gridwidth = GridBagConstraints.RELATIVE; p2.add(continueButton, gbc); continueButton.setVisible(installStatus.canOverwriteCurrentInstall()); continueButton.setVisible(false); gbc.insets.left = UIFactory.HORIZONTAL_INSET_BETWEEN_BUTTONS; gbc.gridwidth = GridBagConstraints.REMAINDER; opends/src/quicksetup/org/opends/quicksetup/util/CompatibleJava.java
New file @@ -0,0 +1,69 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at * trunk/opends/resource/legal-notices/OpenDS.LICENSE * or https://OpenDS.dev.java.net/OpenDS.LICENSE. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, * add the following below this CDDL HEADER, with the fields enclosed * by brackets "[]" replaced with your own identifying information: * Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END * * * Copyright 2008 Sun Microsystems, Inc. */ package org.opends.quicksetup.util; /** * This enumeration contains the different minimal java versions required * to run properly OpenDS. The versions specify a vendor and a java version. * */ enum CompatibleJava { JDK_SUN("Sun Microsystems Inc.", "1.5.0_08"); private String vendor; private String version; /** * Private constructor. * @param vendor the JVM vendor. * @param version the JVM version. */ private CompatibleJava(String vendor, String version) { this.vendor = vendor; this.version = version; } /** * Returns the version of this compatible java version. * @return the version of this compatible java version. */ String getVersion() { return version; } /** * Returns the vendor of this compatible java version. * @return the vendor of this compatible java version. */ String getVendor() { return vendor; } } opends/src/quicksetup/org/opends/quicksetup/util/HtmlProgressMessageFormatter.java
@@ -72,7 +72,7 @@ */ public Message getFormattedText(Message text) { return Message.raw(getHtml(String.valueOf(text))); return Message.raw(Utils.getHtml(String.valueOf(text))); } /** @@ -106,7 +106,7 @@ html = UIFactory.getIconHtml(UIFactory.IconType.ERROR_LARGE) + SPACE + SPACE + UIFactory.applyFontToHtml(getHtml(String.valueOf(text)), + UIFactory.applyFontToHtml(Utils.getHtml(String.valueOf(text)), UIFactory.PROGRESS_ERROR_FONT); } else { html = @@ -141,7 +141,7 @@ UIFactory.getIconHtml(UIFactory.IconType.WARNING_LARGE) + SPACE + SPACE + UIFactory.applyFontToHtml(getHtml(String.valueOf(text)), + UIFactory.applyFontToHtml(Utils.getHtml(String.valueOf(text)), UIFactory.PROGRESS_WARNING_FONT); } else { html = @@ -187,7 +187,7 @@ */ public Message getFormattedLogError(Message text) { String html = getHtml(String.valueOf(text)); String html = Utils.getHtml(String.valueOf(text)); return Message.raw(UIFactory.applyFontToHtml(html, UIFactory.PROGRESS_LOG_ERROR_FONT)); } @@ -201,7 +201,7 @@ */ public Message getFormattedLog(Message text) { String html = getHtml(String.valueOf(text)); String html = Utils.getHtml(String.valueOf(text)); return Message.raw(UIFactory.applyFontToHtml(html, UIFactory.PROGRESS_LOG_FONT)); } @@ -214,7 +214,7 @@ { if (doneHtml == null) { String html = getHtml(INFO_PROGRESS_DONE.get().toString()); String html = Utils.getHtml(INFO_PROGRESS_DONE.get().toString()); doneHtml = Message.raw(UIFactory.applyFontToHtml(html, UIFactory.PROGRESS_DONE_FONT)); } @@ -228,7 +228,7 @@ public Message getFormattedError() { if (errorHtml == null) { String html = getHtml(INFO_PROGRESS_ERROR.get().toString()); String html = Utils.getHtml(INFO_PROGRESS_ERROR.get().toString()); errorHtml = Message.raw(UIFactory.applyFontToHtml(html, UIFactory.PROGRESS_ERROR_FONT)); } @@ -244,9 +244,9 @@ */ public Message getFormattedWithPoints(Message text) { String html = getHtml(String.valueOf(text)); String html = Utils.getHtml(String.valueOf(text)); String points = SPACE + getHtml(INFO_PROGRESS_POINTS.get().toString()) + SPACE; Utils.getHtml(INFO_PROGRESS_POINTS.get().toString()) + SPACE; MessageBuilder buf = new MessageBuilder(); buf.append(UIFactory.applyFontToHtml(html, UIFactory.PROGRESS_FONT)) @@ -285,7 +285,8 @@ */ public Message getFormattedProgress(Message text) { return Message.raw(UIFactory.applyFontToHtml(getHtml(String.valueOf(text)), return Message.raw(UIFactory.applyFontToHtml( Utils.getHtml(String.valueOf(text)), UIFactory.PROGRESS_FONT)); } @@ -315,7 +316,7 @@ Throwable root = t.getCause(); while (root != null) { stackBuf.append(getHtml(INFO_EXCEPTION_ROOT_CAUSE.get().toString())) stackBuf.append(Utils.getHtml(INFO_EXCEPTION_ROOT_CAUSE.get().toString())) .append(Constants.HTML_LINE_BREAK); stackBuf.append(getHtmlStack(root)); root = root.getCause(); @@ -328,7 +329,7 @@ String msg = t.getMessage(); if (msg != null) { buf.append(UIFactory.applyFontToHtml(getHtml(t.getMessage()), buf.append(UIFactory.applyFontToHtml(Utils.getHtml(t.getMessage()), UIFactory.PROGRESS_ERROR_FONT)).append(Constants.HTML_LINE_BREAK); } else { @@ -416,75 +417,6 @@ } /** * 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. */ private 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(escape(lines[i])); } } return buffer.toString(); } /** * 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. */ private String escape(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 a HTML representation of the stack trace of a Throwable object. * @param ex the throwable object from which we want to obtain the stack * trace HTML representation. @@ -503,7 +435,7 @@ .append(SPACE) .append(SPACE) .append(SPACE) .append(getHtml(ex.toString())) .append(Utils.getHtml(ex.toString())) .append(Constants.HTML_LINE_BREAK); StackTraceElement[] stack = ex.getStackTrace(); for (StackTraceElement aStack : stack) { @@ -517,7 +449,7 @@ .append(SPACE) .append(SPACE) .append(SPACE) .append(getHtml(aStack.toString())) .append(Utils.getHtml(aStack.toString())) .append(Constants.HTML_LINE_BREAK); } return buf.toString(); opends/src/quicksetup/org/opends/quicksetup/util/IncompatibleVersionException.java
New file @@ -0,0 +1,50 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at * trunk/opends/resource/legal-notices/OpenDS.LICENSE * or https://OpenDS.dev.java.net/OpenDS.LICENSE. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, * add the following below this CDDL HEADER, with the fields enclosed * by brackets "[]" replaced with your own identifying information: * Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END * * * Copyright 2008 Sun Microsystems, Inc. */ package org.opends.quicksetup.util; import org.opends.messages.Message; import org.opends.server.types.OpenDsException; /** * The exception representing an incompatible java version being used. Even * if the code can be run under 1.5, some bugs have been found in some versions * of the JVM that prevent OpenDS to work properly (see */ public class IncompatibleVersionException extends OpenDsException { private static final long serialVersionUID = 4283735375192567277L; /** * Constructor of the IncompatibleVersionException. * @param msg the error message. * @param rootCause the root cause. */ public IncompatibleVersionException(Message msg, Throwable rootCause) { super(msg, rootCause); } } 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(); } } /**