Fix some issues with the dialog position when they were displayed.
Fix some minor bugs related to focus.
Fix some minor layout bugs related to the background color.
Modify the code to check whether the server is running or not.
Fix issue 1112 by adding an additional check to detect if we can use a port or not: use a Socket to bind to the port.
| | |
| | | import java.util.HashSet; |
| | | import java.util.Set; |
| | | |
| | | import javax.naming.NamingException; |
| | | |
| | | import org.opends.quicksetup.i18n.ResourceProvider; |
| | | import org.opends.quicksetup.util.Utils; |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether there is the server is running in the localhost on the |
| | | * LDAP port specified in config.ldif file. Note that this method performs |
| | | * LDAP requests which can be time consuming. |
| | | * Indicates whether there is the server is running. |
| | | * |
| | | * @return <CODE>true</CODE> if the server is running, or <CODE>false</CODE> |
| | | * if not. |
| | | */ |
| | | public boolean isServerRunning() |
| | | { |
| | | boolean isServerRunning = false; |
| | | |
| | | try |
| | | { |
| | | Utils.createLdapContext(getLdapUrl(), null, null, 3000, null); |
| | | isServerRunning = true; |
| | | } catch (NamingException ne) |
| | | { |
| | | try |
| | | { |
| | | if (getSecurePort() != -1) |
| | | { |
| | | Utils.createLdapContext(getLdapsUrl(), null, null, 3000, null); |
| | | isServerRunning = true; |
| | | } |
| | | } catch (NamingException ne2) |
| | | { |
| | | } |
| | | } |
| | | |
| | | return isServerRunning; |
| | | return Utils.isServerRunning(Utils.getInstallPathFromClasspath()); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | if (ldapUrl == null) |
| | | { |
| | | ldapUrl = "ldap://localhost:"+getPort(); |
| | | if (getPort() != -1) |
| | | { |
| | | ldapUrl = "ldap://localhost:"+getPort(); |
| | | } |
| | | } |
| | | return ldapUrl; |
| | | } |
| | |
| | | { |
| | | if (ldapsUrl == null) |
| | | { |
| | | ldapsUrl = "ldaps://localhost:"+getSecurePort(); |
| | | if (getSecurePort() != -1) |
| | | { |
| | | ldapsUrl = "ldaps://localhost:"+getSecurePort(); |
| | | } |
| | | } |
| | | return ldapsUrl; |
| | | } |
| | |
| | | * message id informing that it started. So it seems that everything |
| | | * went fine. |
| | | * |
| | | * However in Windows we can have issues with the firewalls. Just check |
| | | * if we can connect to the server. Try 5 times with an interval of |
| | | * 1 second between try. |
| | | * However we can have issues with the firewalls or do not have rights |
| | | * to connect. Just check if we can connect to the server. |
| | | * Try 5 times with an interval of 1 second between try. |
| | | */ |
| | | boolean connected = false; |
| | | for (int i=0; i<5 && !connected; i++) |
| | |
| | | } |
| | | if (!connected) |
| | | { |
| | | String[] arg = {String.valueOf(userData.getServerPort())}; |
| | | throw new InstallException(InstallException.Type.START_ERROR, |
| | | getMsg("error-starting-server-in-windows", arg), null); |
| | | if (Utils.isWindows()) |
| | | { |
| | | String[] arg = {String.valueOf(userData.getServerPort())}; |
| | | throw new InstallException(InstallException.Type.START_ERROR, |
| | | getMsg("error-starting-server-in-windows", arg), null); |
| | | } |
| | | else |
| | | { |
| | | String[] arg = {String.valueOf(userData.getServerPort())}; |
| | | throw new InstallException(InstallException.Type.START_ERROR, |
| | | getMsg("error-starting-server-in-unix", arg), null); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | you sure you want to continue? |
| | | cli-uninstall-stop-authentication-generic-prompt1=The server is currently \ |
| | | running and must be stopped before uninstallation can continue. |
| | | cli-uninstall-stop-authentication-generic-prompt2=You must provide the \ |
| | | cli-uninstall-stop-authentication-generic-prompt2=You must provide an \ |
| | | Administrative User DN and password to stop the server. |
| | | cli-uninstall-error-reading-pwd-file=Could not read the password from \ |
| | | file {0}. Check that the file path is correct, that you have access rights to \ |
| | |
| | | # |
| | | # Icon tooltips. |
| | | # |
| | | current-step-icon-tooltip=Current Step Indicator. |
| | | splash-icon-tooltip=Open DS QuickSetup Launching. |
| | | minimized-icon-tooltip=OpenDS QuickSetup. |
| | | background-icon-tooltip=OpenDS QuickSetup. |
| | | warning-icon-tooltip=Warning. |
| | | error-icon-tooltip=Error. |
| | | information-icon-tooltip=Information. |
| | | current-step-icon-tooltip=Current Step Indicator |
| | | splash-icon-tooltip=Open DS QuickSetup Launching |
| | | minimized-icon-tooltip=OpenDS QuickSetup |
| | | background-icon-tooltip=OpenDS QuickSetup |
| | | warning-icon-tooltip=Warning |
| | | error-icon-tooltip=Error |
| | | information-icon-tooltip=Information |
| | | |
| | | # |
| | | # Icon paths. This is done to be able to provide localizable icons (for |
| | |
| | | following locations outside the server path: |
| | | delete-outside-dbs-label=Delete these Database Files |
| | | delete-outside-dbs-tooltip=Check this box to Delete the Database Files located \ |
| | | outside the install directory. |
| | | outside the install directory |
| | | delete-outside-logs-msg=The Directory Server contains log files in the \ |
| | | following locations outside the server path: |
| | | delete-outside-logs-label=Delete these Log Files |
| | | delete-outside-logs-tooltip=Check this box to Delete the Log Files located \ |
| | | outside the install directory. |
| | | outside the install directory |
| | | |
| | | # |
| | | # Miscellaneous labels |
| | |
| | | error-starting-server=Error Starting Directory Server. |
| | | error-starting-server-in-windows=Could not connect to Server after Start. \ |
| | | If you have a firewall configured check that it allows connections to port {0}. |
| | | error-starting-server-in-unix=Could not connect to Server after Start. \ |
| | | Verify that you have the rights to access to port {0}. |
| | | error-stopping-server=Error Stopping Directory Server. |
| | | error-stopping-server-code=Error Stopping Directory Server. Error code: {0}. |
| | | error-reading-erroroutput=Error Reading error output. |
| | |
| | | this.parent = parent; |
| | | this.installStatus = installStatus; |
| | | getContentPane().add(createPanel()); |
| | | // TODO: find a way to calculate this dynamically |
| | | setPreferredSize(new Dimension(500, 300)); |
| | | addComponentListener(new MinimumSizeComponentListener(this, |
| | | 500, 300)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public void packAndShow() |
| | | { |
| | | /* |
| | | * TODO: find a way to calculate this dynamically. This is done to avoid |
| | | * all the text in a single line. |
| | | */ |
| | | setPreferredSize(new Dimension(500, 300)); |
| | | addComponentListener(new MinimumSizeComponentListener(this, |
| | | 500, 300)); |
| | | getRootPane().setDefaultButton(shutDownButton); |
| | | pack(); |
| | | Utils.centerOnComponent(this, parent); |
| | | tfPwd.requestFocusInWindow(); |
| | | getRootPane().setDefaultButton(shutDownButton); |
| | | setVisible(true); |
| | | } |
| | | |
| | |
| | | gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD; |
| | | gbc.fill = GridBagConstraints.NONE; |
| | | gbc.gridwidth = GridBagConstraints.REMAINDER; |
| | | JPanel p3 = new JPanel(new GridBagLayout()); |
| | | p3.setOpaque(false); |
| | | tfPwd = UIFactory.makeJPasswordField(null, |
| | | getMsg("shutdown-directory-manager-pwd-tooltip"), |
| | | UIFactory.PASSWORD_FIELD_SIZE, UIFactory.TextStyle.PASSWORD_FIELD); |
| | | p2.add(tfPwd, gbc); |
| | | p2.add(p3, gbc); |
| | | gbc.insets = UIFactory.getEmptyInsets(); |
| | | gbc.gridwidth = GridBagConstraints.RELATIVE; |
| | | gbc.weightx = 0.0; |
| | | p3.add(tfPwd, gbc); |
| | | gbc.gridwidth = GridBagConstraints.REMAINDER; |
| | | gbc.weightx = 1.0; |
| | | p3.add(Box.createHorizontalGlue(), gbc); |
| | | |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | gbc.insets = UIFactory.getEmptyInsets(); |
| | |
| | | pwdInvalid = true; |
| | | possibleCauses.add(getMsg("empty-pwd")); |
| | | } |
| | | if (possibleCauses.size() > 0) |
| | | { |
| | | // Message with causes |
| | | String[] arg = { |
| | | Utils.getStringFromCollection(possibleCauses, "\n") |
| | | }; |
| | | displayError( |
| | | getMsg("cannot-connect-to-shutdown-with-cause", arg), |
| | | getMsg("error-title")); |
| | | } |
| | | else |
| | | { |
| | | // Generic message |
| | | displayError( |
| | | getMsg("cannot-connect-to-shutdown-without-cause"), |
| | | getMsg("error-title")); |
| | | } |
| | | |
| | | if (dnInvalid) |
| | | { |
| | |
| | | UIFactory.setTextStyle(lPwd, |
| | | UIFactory.TextStyle.PRIMARY_FIELD_VALID); |
| | | } |
| | | |
| | | if (possibleCauses.size() > 0) |
| | | { |
| | | // Message with causes |
| | | String[] arg = { |
| | | Utils.getStringFromCollection(possibleCauses, "\n") |
| | | }; |
| | | displayError( |
| | | getMsg("cannot-connect-to-shutdown-with-cause", arg), |
| | | getMsg("error-title")); |
| | | } |
| | | else |
| | | { |
| | | // Generic message |
| | | displayError( |
| | | getMsg("cannot-connect-to-shutdown-without-cause"), |
| | | getMsg("error-title")); |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | setLayout(new GridBagLayout()); |
| | | setBackground(UIFactory.DEFAULT_BACKGROUND); |
| | | setOpaque(true); |
| | | gbc.insets = UIFactory.getEmptyInsets(); |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | gbc.gridwidth = GridBagConstraints.REMAINDER; |
| | |
| | | |
| | | private ProgressMessageFormatter formatter; |
| | | |
| | | // We can use a HashMap (not multi-thread safe) because all |
| | | // the calls to this object are done in the event-thread. |
| | | /* We can use a HashMap (not multi-thread safe) because all |
| | | the calls to this object are done in the event-thread. |
| | | */ |
| | | private HashMap<String, URLWorker> hmURLWorkers = |
| | | new HashMap<String, URLWorker>(); |
| | | |
| | |
| | | import javax.swing.JPanel; |
| | | import javax.swing.text.JTextComponent; |
| | | |
| | | import org.opends.quicksetup.event.MinimumSizeComponentListener; |
| | | import org.opends.quicksetup.i18n.ResourceProvider; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.quicksetup.util.WebBrowserException; |
| | |
| | | public void packAndShow() |
| | | { |
| | | pack(); |
| | | int minWidth = (int) getPreferredSize().getWidth(); |
| | | int minHeight = (int) getPreferredSize().getHeight(); |
| | | addComponentListener(new MinimumSizeComponentListener(this, |
| | | minWidth, minHeight)); |
| | | Utils.centerOnComponent(this, parent); |
| | | setVisible(true); |
| | | } |
| | |
| | | gbc.gridwidth = GridBagConstraints.RELATIVE; |
| | | Insets pInsets = UIFactory.getCurrentStepPanelInsets(); |
| | | gbc.insets.left = 0; |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | String msg = getMsg("error-browser-display-msg", new String[] |
| | | { url }); |
| | | JTextComponent tf = |
| | |
| | | package org.opends.quicksetup.uninstaller; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.BufferedWriter; |
| | | import java.io.File; |
| | | import java.io.FileFilter; |
| | | import java.io.FileWriter; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.io.Writer; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | |
| | | /* Create these objects to resend the stop process output to the details |
| | | * area. |
| | | */ |
| | | new StopReader(err, true); |
| | | new StopReader(out, false); |
| | | StopReader errorReader = new StopReader(err, true); |
| | | StopReader outputReader = new StopReader(out, false); |
| | | |
| | | int returnValue = process.waitFor(); |
| | | |
| | |
| | | */ |
| | | int nTries = 10; |
| | | boolean stopped = false; |
| | | String testPath = Utils.getInstallPathFromClasspath()+File.separator+ |
| | | "locks"+File.separator+"server.lock"; |
| | | File testFile = new File(testPath); |
| | | |
| | | for (int i=0; i<nTries && !stopped; i++) |
| | | { |
| | | stopped = canWriteFile(testFile); |
| | | stopped = !Utils.isServerRunning( |
| | | Utils.getInstallPathFromClasspath()); |
| | | if (!stopped) |
| | | { |
| | | String msg = |
| | |
| | | */ |
| | | private class StopReader |
| | | { |
| | | private UninstallException ex; |
| | | |
| | | private boolean isFirstLine; |
| | | |
| | | /** |
| | |
| | | } catch (IOException ioe) |
| | | { |
| | | String errorMsg = getThrowableMsg(errorTag, ioe); |
| | | ex = |
| | | new UninstallException(UninstallException.Type.STOP_ERROR, |
| | | errorMsg, ioe); |
| | | notifyListeners(errorMsg); |
| | | |
| | | } catch (Throwable t) |
| | | { |
| | | String errorMsg = getThrowableMsg(errorTag, t); |
| | | ex = |
| | | new UninstallException(UninstallException.Type.STOP_ERROR, |
| | | errorMsg, t); |
| | | notifyListeners(errorMsg); |
| | | } |
| | | } |
| | | }); |
| | | t.start(); |
| | | } |
| | | |
| | | /** |
| | | * Returns the UninstallException that occurred reading the Stop error and |
| | | * output or <CODE>null</CODE> if no exception occurred. |
| | | * @return the exception that occurred reading or <CODE>null</CODE> if |
| | | * no exception occurred. |
| | | */ |
| | | public UninstallException getException() |
| | | { |
| | | return ex; |
| | | } |
| | | } |
| | | |
| | | private boolean canWriteFile(File file) |
| | | { |
| | | boolean canWriteFile = false; |
| | | Writer output = null; |
| | | try { |
| | | //use buffering |
| | | //FileWriter always assumes default encoding is OK! |
| | | output = new BufferedWriter( new FileWriter(file) ); |
| | | output.write("test"); |
| | | output.close(); |
| | | canWriteFile = true; |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | return canWriteFile; |
| | | } |
| | | |
| | | /** |
| | |
| | | import java.awt.Toolkit; |
| | | import java.awt.Window; |
| | | import java.io.BufferedOutputStream; |
| | | import java.io.BufferedWriter; |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.FileWriter; |
| | |
| | | import java.io.InputStream; |
| | | import java.io.PrintWriter; |
| | | import java.io.RandomAccessFile; |
| | | import java.io.Writer; |
| | | import java.net.ConnectException; |
| | | import java.net.InetSocketAddress; |
| | | import java.net.ServerSocket; |
| | | import java.net.Socket; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.HashSet; |
| | |
| | | } |
| | | serverSocket.bind(socketAddress); |
| | | canUseAsPort = true; |
| | | |
| | | serverSocket.close(); |
| | | |
| | | /* Try to create a socket because sometimes even if we can create a server |
| | | * socket there is already someone listening to the port (is the case |
| | | * of products as Sun DS 6.0). |
| | | */ |
| | | try |
| | | { |
| | | new Socket("localhost", port); |
| | | canUseAsPort = false; |
| | | |
| | | } catch (IOException ioe) |
| | | { |
| | | } |
| | | |
| | | } catch (IOException ex) |
| | | { |
| | | canUseAsPort = false; |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns if the server is running on the given path. |
| | | * @param serverPath the installation path of the server. |
| | | * @return <CODE>true</CODE> if the server is running and <CODE>false</CODE> |
| | | * otherwise. |
| | | */ |
| | | public static boolean isServerRunning(String serverPath) |
| | | { |
| | | boolean isServerRunning; |
| | | if (isWindows()) |
| | | { |
| | | String testPath = serverPath+File.separator+ |
| | | "locks"+File.separator+"server.lock"; |
| | | File testFile = new File(testPath); |
| | | |
| | | boolean canWriteFile = false; |
| | | Writer output = null; |
| | | try { |
| | | //use buffering |
| | | //FileWriter always assumes default encoding is OK! |
| | | output = new BufferedWriter( new FileWriter(testFile) ); |
| | | output.write("test"); |
| | | output.close(); |
| | | output = new BufferedWriter( new FileWriter(testFile) ); |
| | | output.write(""); |
| | | output.close(); |
| | | |
| | | canWriteFile = true; |
| | | |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | finally |
| | | { |
| | | if (output != null) |
| | | { |
| | | try |
| | | { |
| | | output.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | } |
| | | isServerRunning = !canWriteFile; |
| | | } |
| | | else |
| | | { |
| | | isServerRunning = fileExists(serverPath+File.separator+ |
| | | "logs"+File.separator+"server.pid"); |
| | | } |
| | | return isServerRunning; |
| | | } |
| | | |
| | | /** |
| | | * This is just a commodity method used to try to get an InitialLdapContext. |
| | | * @param t the Thread to be used to create the InitialLdapContext. |
| | | * @param pair an Object[] array that contains the InitialLdapContext and the |