Bug Id : 84611
authorNagakishore Sidde <kishore320@netbeans.org>
Wed, 15 Sep 2010 11:58:07 +0530
changeset 16377fb6708125ce4
parent 16376 33c5b4afbbf8
child 16381 88087e92b614
Bug Id : 84611
Description : Allow the user to modify the port after adding the server, only if server
is not running. User can change the port by clicking properties and editing port field
in the connection panel. User entered port is validated against the ports specified in
the server.xml (if user selects ssl port while adding the server then validation is done
only against the ssl ports specified in the server.xml).
If validation fails user will be prompted to re-enter the port in case of local server and
user will be just warned in case of remote server.
Reviewed By: Isvaran Krishnamurthy <ikrishna@netbeans.org>
j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/dm/WS70SunDeploymentFactory.java
j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/dm/WS70SunDeploymentManager.java
j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/ui/Bundle.properties
j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/ui/WS70AddServerChoiceVisualPanel.java
j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/ui/WS70ConnectionTabVisualPanel.form
j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/ui/WS70ConnectionTabVisualPanel.java
j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/ui/WS70ServerUIWizardIterator.java
j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/ui/WS70URIManager.java
j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/util/Util.java
     1.1 --- a/j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/dm/WS70SunDeploymentFactory.java	Mon Sep 06 10:27:45 2010 +0200
     1.2 +++ b/j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/dm/WS70SunDeploymentFactory.java	Wed Sep 15 11:58:07 2010 +0530
     1.3 @@ -265,4 +265,9 @@
     1.4      // Dummy class for WS70Deployment Factory to get classloader of this class
     1.5      public static class Dummy{
     1.6      }
     1.7 +
     1.8 +    // Remove the specified uri from the connected managers' list
     1.9 +    public static void removeConnectedManager(String uri) {
    1.10 +        connectedManagers.remove(uri);
    1.11 +    }
    1.12  }
     2.1 --- a/j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/dm/WS70SunDeploymentManager.java	Mon Sep 06 10:27:45 2010 +0200
     2.2 +++ b/j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/dm/WS70SunDeploymentManager.java	Wed Sep 15 11:58:07 2010 +0530
     2.3 @@ -155,11 +155,35 @@
     2.4      }
     2.5      
     2.6      // Called from Manager Node Customizer only
     2.7 -    public void refreshInnerDM(String uname, String pword) {
     2.8 -        if(uname.equals(userName) && pword.equals(password)){            
     2.9 +    public void refreshInnerDM(String uname, String pword, String pport) {
    2.10 +        if (uname.equals(userName) && pword.equals(password) && Integer.parseInt(pport) == port) {            
    2.11              // Nothing is changed, take no action
    2.12              return;
    2.13          }
    2.14 +        // If any changes to the jmx-connector url, like port is changed, then create a new instance and delete the old one
    2.15 +        if (Integer.parseInt(pport) != port) {
    2.16 +            try {
    2.17 +                // Get the old instance properties and reset them again for the new instance
    2.18 +                InstanceProperties ip =  InstanceProperties.getInstanceProperties(uri);
    2.19 +                String isSSL = ip.getProperty(WS70ServerUIWizardIterator.PROP_SSL_PORT);
    2.20 +                String isLocal = ip.getProperty(WS70ServerUIWizardIterator.PROP_LOCAL_SERVER);
    2.21 +
    2.22 +                // Remove the old instance
    2.23 +                ip.removeInstance(uri);
    2.24 +                // Remove the uri from the connected managers list
    2.25 +                WS70SunDeploymentFactory.removeConnectedManager(uri);
    2.26 +
    2.27 +                // Get the new uri with the updated port
    2.28 +                uri = WS70URIManager.getUpdatedUri(uri, pport);
    2.29 +                InstanceProperties nip = InstanceProperties.createInstanceProperties(uri, uname, pword, WS70ServerUIWizardIterator.displayName); 
    2.30 +                nip.setProperty(WS70ServerUIWizardIterator.PROP_SSL_PORT, isSSL);
    2.31 +                nip.setProperty(WS70ServerUIWizardIterator.PROP_LOCAL_SERVER, isLocal);
    2.32 +                nip.setProperty(InstanceProperties.HTTP_PORT_NUMBER, pport);
    2.33 +            } catch(Exception e) {
    2.34 +                e.printStackTrace();
    2.35 +            }
    2.36 +        }
    2.37 +
    2.38          ClassLoader origClassLoader=Thread.currentThread().getContextClassLoader();
    2.39          try{
    2.40              String ws70url = WS70URIManager.getURIWithoutLocation(uri);
     3.1 --- a/j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/ui/Bundle.properties	Mon Sep 06 10:27:45 2010 +0200
     3.2 +++ b/j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/ui/Bundle.properties	Wed Sep 15 11:58:07 2010 +0530
     3.3 @@ -105,6 +105,8 @@
     3.4  MSG_ENTER_VALID_PORT=Please enter valid Administration Port Number
     3.5  MSG_ENTER_USERNAME=Please enter User Name for the Oracle iPlanet Web Server 7.0 Administrator
     3.6  MSG_ADMIN_CONNECT_ERROR=<html>Unable to connect with the administration server. Please check if the server is up <br> and running and that the host and port provided are correct. </html>
     3.7 +MSG_INVALID_PORT=Error: Invalid port
     3.8 +MSG_CONNECT_WARNING=Warning: Unable to connect with the admin server
     3.9  
    3.10  MSG_Server_Instance_Added=Server instance "{0}" was added successfully.
    3.11  
    3.12 @@ -136,22 +138,26 @@
    3.13  #
    3.14  # WS70ConnectionTabVisualPanel
    3.15  #
    3.16 -LBL_ConnectionAdminUrl=Server URL:
    3.17 +LBL_ConnectionAdminHost=Server Host:
    3.18 +LBL_ConnectionAdminPort=Server Port:
    3.19  LBL_ConnectionLocation=Server Location:
    3.20  LBL_ConnectionAdminUser=Username:
    3.21  LBL_ConnectionPassword=Password:
    3.22  
    3.23 -A11Y_NAME_ConnectionAdminUrl=Server URL:
    3.24 +A11Y_NAME_ConnectionAdminHost=Server Host:
    3.25 +A11Y_NAME_ConnectionAdminPort=Server Port:
    3.26  A11Y_NAME_ConnectionLocation=Server Location:
    3.27  A11Y_NAME_ConnectionAdminUser=Username:
    3.28  A11Y_NAME_ConnectionPassword=Password:
    3.29  
    3.30 -A11Y_DESC_ConnectionAdminUrl=Server URL:
    3.31 +A11Y_DESC_ConnectionAdminHost=Server Host:
    3.32 +A11Y_DESC_ConnectionAdminPort=Server Port:
    3.33  A11Y_DESC_ConnectionLocation=Server Location:
    3.34  A11Y_DESC_ConnectionAdminUser=Username:
    3.35  A11Y_DESC_ConnectionPassword=Password:
    3.36  
    3.37 -A11Y_Connection_Url_Mnem=U
    3.38 +A11Y_Connection_Host_Mnem=H
    3.39 +A11Y_Connection_Port_Mnem=P
    3.40  A11Y_Connection_Location_Mnem=L
    3.41  A11Y_Connection_User_Mnem=S
    3.42  A11Y_Connection_Password_Mnem=P
     4.1 --- a/j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/ui/WS70AddServerChoiceVisualPanel.java	Mon Sep 06 10:27:45 2010 +0200
     4.2 +++ b/j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/ui/WS70AddServerChoiceVisualPanel.java	Wed Sep 15 11:58:07 2010 +0530
     4.3 @@ -54,6 +54,7 @@
     4.4  import java.util.ArrayList;
     4.5  import java.util.List;
     4.6  import java.util.Iterator;
     4.7 +import java.util.HashMap;
     4.8  import java.lang.reflect.*;
     4.9  
    4.10  import org.openide.util.NbBundle;
    4.11 @@ -118,49 +119,11 @@
    4.12      // Use the java Reflexion to access the admin generated schema2beans classes especially Server class (which are  part of webserv-rt.jar) 
    4.13      // and then parse the server.xml to get the http-listeners 
    4.14      public void parseServerXml(String location) {
    4.15 -        File serverXml = new File(location+File.separator+"admin-server"+File.separator+"config"+File.separator+"server.xml");
    4.16          try {
    4.17 -            WS7LibsClassLoader wscl = new WS7LibsClassLoader();
    4.18 -            wscl.addURL(new File(location + File.separator + "lib" + File.separator + "webserv-rt.jar"));
    4.19 -            Class serverCls = wscl.loadClass("com.sun.webserver.config.serverbeans.Server");
    4.20 +            HashMap ports = org.netbeans.modules.j2ee.sun.ws7.util.Util.getPorts(location);
    4.21 +            ssl_ports = (ArrayList<String>)ports.get("ssl_ports");
    4.22 +            non_ssl_ports = (ArrayList<String>)ports.get("non_ssl_ports");
    4.23  
    4.24 -            // Call create graph method (on serverXml file)  and getHttpListener method from the server class
    4.25 -            Method cgMth = serverCls.getMethod("createGraph", new Class[] {serverXml.getClass()});
    4.26 -            Method hlMth = serverCls.getMethod("getHttpListener", null);
    4.27 -
    4.28 -            // Load HttpListenerType class and get the required methods
    4.29 -            Class hlCls = wscl.loadClass("com.sun.webserver.config.serverbeans.HttpListenerType");
    4.30 -            Method getPortMth = hlCls.getMethod("getPort", null);
    4.31 -            Method getSslMth =  hlCls.getMethod("getSsl", null);
    4.32 -            Method isHLEnabledMth = hlCls.getMethod("isEnabled", null);
    4.33 -
    4.34 -            // Load SslType class as getSsl method returns a SslType class, which will be used to invoke the getEnabled method
    4.35 -            Class sslTypeCls = wscl.loadClass("com.sun.webserver.config.serverbeans.SslType");
    4.36 -            Method isSSLEnabledMth = sslTypeCls.getMethod("getEnabled", new Class[] {Integer.TYPE});
    4.37 -
    4.38 -            // Make sure that no previous ports exist
    4.39 -            ssl_ports.clear();
    4.40 -            non_ssl_ports.clear();
    4.41 -
    4.42 -            Object createGraph = cgMth.invoke(serverCls, new Object[]{serverXml});
    4.43 -            Object[] httpListeners = (Object[]) hlMth.invoke(createGraph, null); 
    4.44 -
    4.45 -            // Iterate through all the http-listeners to separte ssl and non-ssl ports
    4.46 -            for(Object hl : httpListeners) {
    4.47 -                Object isHLEnabled = isHLEnabledMth.invoke(hl, null);
    4.48 -                if (!((Boolean)isHLEnabled))
    4.49 -                    continue;
    4.50 -
    4.51 -                Object port = getPortMth.invoke(hl, null);
    4.52 -                Object ssl = getSslMth.invoke(hl, null);
    4.53 -                Object isSSLEnabled = isSSLEnabledMth.invoke(ssl, new Object[] {new Integer(0)});
    4.54 -                if ((Boolean)isSSLEnabled) {
    4.55 -                    ssl_ports.add(port.toString());
    4.56 -                } else {
    4.57 -                    non_ssl_ports.add(port.toString());
    4.58 -                }
    4.59 -            }
    4.60 - 
    4.61              // Set the initial display based on the http-listener ports detected
    4.62              if (ssl_ports.size() > 0 || non_ssl_ports.size() > 0)
    4.63                  setInitialDisplay();
     5.1 --- a/j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/ui/WS70ConnectionTabVisualPanel.form	Mon Sep 06 10:27:45 2010 +0200
     5.2 +++ b/j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/ui/WS70ConnectionTabVisualPanel.form	Wed Sep 15 11:58:07 2010 +0530
     5.3 @@ -18,7 +18,8 @@
     5.4            <Group type="102" alignment="0" attributes="0">
     5.5                <EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
     5.6                <Group type="103" groupAlignment="0" attributes="0">
     5.7 -                  <Component id="jAdminUrlLbl" alignment="0" min="-2" max="-2" attributes="0"/>
     5.8 +                  <Component id="jAdminHostLbl" alignment="0" min="-2" max="-2" attributes="0"/>
     5.9 +                  <Component id="jAdminPortLbl" alignment="0" min="-2" max="-2" attributes="0"/>
    5.10                    <Component id="jLocationLbl" alignment="0" min="-2" max="-2" attributes="0"/>
    5.11                    <Component id="jAdminUserLbl" min="-2" max="-2" attributes="0"/>
    5.12                    <Component id="jPasswordLbl" min="-2" max="-2" attributes="0"/>
    5.13 @@ -32,7 +33,8 @@
    5.14                    <Group type="103" alignment="0" groupAlignment="0" attributes="0">
    5.15                        <Group type="102" attributes="0">
    5.16                            <Group type="103" groupAlignment="0" attributes="0">
    5.17 -                              <Component id="jAdminUrlTxt" linkSize="1" alignment="0" pref="248" max="32767" attributes="1"/>
    5.18 +                              <Component id="jAdminHostTxt" linkSize="1" alignment="0" pref="248" max="32767" attributes="1"/>
    5.19 +                              <Component id="jAdminPortTxt" linkSize="1" alignment="0" pref="248" max="32767" attributes="1"/>
    5.20                                <Component id="jLocationTxt" linkSize="1" alignment="0" pref="248" max="32767" attributes="1"/>
    5.21                            </Group>
    5.22                            <EmptySpace min="-2" pref="96" max="-2" attributes="0"/>
    5.23 @@ -51,8 +53,13 @@
    5.24            <Group type="102" alignment="0" attributes="0">
    5.25                <EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
    5.26                <Group type="103" groupAlignment="3" attributes="0">
    5.27 -                  <Component id="jAdminUrlLbl" linkSize="3" alignment="3" min="-2" max="-2" attributes="0"/>
    5.28 -                  <Component id="jAdminUrlTxt" linkSize="2" alignment="3" min="-2" max="-2" attributes="0"/>
    5.29 +                  <Component id="jAdminHostLbl" linkSize="3" alignment="3" min="-2" max="-2" attributes="0"/>
    5.30 +                  <Component id="jAdminHostTxt" linkSize="2" alignment="3" min="-2" max="-2" attributes="0"/>
    5.31 +              </Group>
    5.32 +              <EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
    5.33 +              <Group type="103" groupAlignment="3" attributes="0">
    5.34 +                  <Component id="jAdminPortLbl" linkSize="3" alignment="3" min="-2" max="-2" attributes="0"/>
    5.35 +                  <Component id="jAdminPortTxt" linkSize="2" alignment="3" min="-2" max="-2" attributes="0"/>
    5.36                </Group>
    5.37                <EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
    5.38                <Group type="103" groupAlignment="3" attributes="0">
    5.39 @@ -75,35 +82,64 @@
    5.40      </DimensionLayout>
    5.41    </Layout>
    5.42    <SubComponents>
    5.43 -    <Component class="javax.swing.JLabel" name="jAdminUrlLbl">
    5.44 +    <Component class="javax.swing.JLabel" name="jAdminHostLbl">
    5.45        <Properties>
    5.46          <Property name="displayedMnemonic" type="int" editor="org.netbeans.modules.i18n.form.FormI18nMnemonicEditor">
    5.47 -          <ResourceString bundle="org/netbeans/modules/j2ee/sun/ws7/ui/Bundle.properties" key="A11Y_Connection_Url_Mnem" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
    5.48 +          <ResourceString bundle="org/netbeans/modules/j2ee/sun/ws7/ui/Bundle.properties" key="A11Y_Connection_Host_Mnem" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
    5.49          </Property>
    5.50          <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
    5.51 -          <ComponentRef name="jAdminUrlTxt"/>
    5.52 +          <ComponentRef name="jAdminHostTxt"/>
    5.53          </Property>
    5.54          <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
    5.55 -          <ResourceString bundle="org/netbeans/modules/j2ee/sun/ws7/ui/Bundle.properties" key="LBL_ConnectionAdminUrl" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
    5.56 +          <ResourceString bundle="org/netbeans/modules/j2ee/sun/ws7/ui/Bundle.properties" key="LBL_ConnectionAdminHost" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
    5.57          </Property>
    5.58        </Properties>
    5.59        <AccessibilityProperties>
    5.60          <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
    5.61 -          <ResourceString bundle="org/netbeans/modules/j2ee/sun/ws7/ui/Bundle.properties" key="A11Y_NAME_ConnectionAdminUrl" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
    5.62 +          <ResourceString bundle="org/netbeans/modules/j2ee/sun/ws7/ui/Bundle.properties" key="A11Y_NAME_ConnectionAdminHost" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
    5.63          </Property>
    5.64          <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
    5.65 -          <ResourceString bundle="org/netbeans/modules/j2ee/sun/ws7/ui/Bundle.properties" key="A11Y_DESC_ConnectionAdminUrl" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
    5.66 +          <ResourceString bundle="org/netbeans/modules/j2ee/sun/ws7/ui/Bundle.properties" key="A11Y_DESC_ConnectionAdminHost" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
    5.67          </Property>
    5.68          <Property name="AccessibleContext.accessibleParent" type="javax.accessibility.Accessible" editor="org.netbeans.modules.form.RADVisualComponent$AccessibleParentEditor">
    5.69            <ComponentRef name="Form"/>
    5.70          </Property>
    5.71        </AccessibilityProperties>
    5.72      </Component>
    5.73 -    <Component class="javax.swing.JTextField" name="jAdminUrlTxt">
    5.74 +    <Component class="javax.swing.JTextField" name="jAdminHostTxt">
    5.75        <Properties>
    5.76          <Property name="editable" type="boolean" value="false"/>
    5.77        </Properties>
    5.78      </Component>
    5.79 +    <Component class="javax.swing.JLabel" name="jAdminPortLbl">
    5.80 +      <Properties>
    5.81 +        <Property name="displayedMnemonic" type="int" editor="org.netbeans.modules.i18n.form.FormI18nMnemonicEditor">
    5.82 +          <ResourceString bundle="org/netbeans/modules/j2ee/sun/ws7/ui/Bundle.properties" key="A11Y_Connection_Port_Mnem" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
    5.83 +        </Property>
    5.84 +        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
    5.85 +          <ComponentRef name="jAdminPortTxt"/>
    5.86 +        </Property>
    5.87 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
    5.88 +          <ResourceString bundle="org/netbeans/modules/j2ee/sun/ws7/ui/Bundle.properties" key="LBL_ConnectionAdminPort" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
    5.89 +        </Property>
    5.90 +      </Properties>
    5.91 +      <AccessibilityProperties>
    5.92 +        <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
    5.93 +          <ResourceString bundle="org/netbeans/modules/j2ee/sun/ws7/ui/Bundle.properties" key="A11Y_NAME_ConnectionAdminPort" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
    5.94 +        </Property>
    5.95 +        <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
    5.96 +          <ResourceString bundle="org/netbeans/modules/j2ee/sun/ws7/ui/Bundle.properties" key="A11Y_DESC_ConnectionAdminPort" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
    5.97 +        </Property>
    5.98 +        <Property name="AccessibleContext.accessibleParent" type="javax.accessibility.Accessible" editor="org.netbeans.modules.form.RADVisualComponent$AccessibleParentEditor">
    5.99 +          <ComponentRef name="Form"/>
   5.100 +        </Property>
   5.101 +      </AccessibilityProperties>
   5.102 +    </Component>
   5.103 +    <Component class="javax.swing.JTextField" name="jAdminPortTxt">
   5.104 +      <Properties>
   5.105 +        <Property name="editable" type="boolean" value="true"/>
   5.106 +      </Properties>
   5.107 +    </Component>
   5.108      <Component class="javax.swing.JLabel" name="jLocationLbl">
   5.109        <Properties>
   5.110          <Property name="displayedMnemonic" type="int" editor="org.netbeans.modules.i18n.form.FormI18nMnemonicEditor">
     6.1 --- a/j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/ui/WS70ConnectionTabVisualPanel.java	Mon Sep 06 10:27:45 2010 +0200
     6.2 +++ b/j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/ui/WS70ConnectionTabVisualPanel.java	Wed Sep 15 11:58:07 2010 +0530
     6.3 @@ -44,9 +44,12 @@
     6.4   */
     6.5  
     6.6  package org.netbeans.modules.j2ee.sun.ws7.ui;
     6.7 +import org.openide.util.NbBundle;
     6.8  import org.netbeans.modules.j2ee.sun.ws7.dm.WS70SunDeploymentManager;
     6.9 +import org.netbeans.modules.j2ee.sun.ws7.util.Util;
    6.10  import javax.swing.*;
    6.11  import java.awt.event.*;
    6.12 +import java.util.*;
    6.13  /**
    6.14   *
    6.15   * @author  Mukesh Garg
    6.16 @@ -54,16 +57,20 @@
    6.17  public class WS70ConnectionTabVisualPanel extends javax.swing.JPanel {
    6.18  
    6.19      private WS70SunDeploymentManager manager;
    6.20 +    private ArrayList ports;
    6.21      /** Creates new form WS70ConnectionTabVisualPanel */
    6.22      public WS70ConnectionTabVisualPanel(WS70SunDeploymentManager dm) {
    6.23          manager = dm;
    6.24          initComponents();
    6.25  
    6.26 -        jAdminUrlTxt.setText(manager.getHost()+":"+manager.getPort());
    6.27 +        jAdminHostTxt.setText(manager.getHost());
    6.28 +        jAdminPortTxt.setText(Integer.toString(manager.getPort()));
    6.29          jAdminUserTxt.setText(manager.getUserName());
    6.30          jPasswordTxt.setText(manager.getPassword());
    6.31          jLocationTxt.setText(manager.getServerLocation());       
    6.32 -
    6.33 +        if (manager.isRunning()) {
    6.34 +            jAdminPortTxt.setEditable(false);
    6.35 +        }
    6.36      }
    6.37      
    6.38      /** This method is called from within the constructor to
    6.39 @@ -73,8 +80,10 @@
    6.40       */
    6.41      // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    6.42      private void initComponents() {
    6.43 -        jAdminUrlLbl = new javax.swing.JLabel();
    6.44 -        jAdminUrlTxt = new javax.swing.JTextField();
    6.45 +        jAdminHostLbl = new javax.swing.JLabel();
    6.46 +        jAdminHostTxt = new javax.swing.JTextField();
    6.47 +        jAdminPortLbl = new javax.swing.JLabel();
    6.48 +        jAdminPortTxt = new javax.swing.JTextField();
    6.49          jLocationLbl = new javax.swing.JLabel();
    6.50          jLocationTxt = new javax.swing.JTextField();
    6.51          jAdminUserLbl = new javax.swing.JLabel();
    6.52 @@ -93,14 +102,29 @@
    6.53              }
    6.54          });
    6.55  
    6.56 -        jAdminUrlLbl.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ws7/ui/Bundle").getString("A11Y_Connection_Url_Mnem").charAt(0));
    6.57 -        jAdminUrlLbl.setLabelFor(jAdminUrlTxt);
    6.58 -        jAdminUrlLbl.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ws7/ui/Bundle").getString("LBL_ConnectionAdminUrl"));
    6.59 -        jAdminUrlLbl.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ws7/ui/Bundle").getString("A11Y_NAME_ConnectionAdminUrl"));
    6.60 -        jAdminUrlLbl.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ws7/ui/Bundle").getString("A11Y_DESC_ConnectionAdminUrl"));
    6.61 -        jAdminUrlLbl.getAccessibleContext().setAccessibleParent(this);
    6.62 +        jAdminHostLbl.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ws7/ui/Bundle").getString("A11Y_Connection_Host_Mnem").charAt(0));
    6.63 +        jAdminHostLbl.setLabelFor(jAdminHostTxt);
    6.64 +        jAdminHostLbl.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ws7/ui/Bundle").getString("LBL_ConnectionAdminHost"));
    6.65 +        jAdminHostLbl.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ws7/ui/Bundle").getString("A11Y_NAME_ConnectionAdminHost"));
    6.66 +        jAdminHostLbl.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ws7/ui/Bundle").getString("A11Y_DESC_ConnectionAdminHost"));
    6.67 +        jAdminHostLbl.getAccessibleContext().setAccessibleParent(this);
    6.68  
    6.69 -        jAdminUrlTxt.setEditable(false);
    6.70 +        jAdminHostTxt.setEditable(false);
    6.71 +
    6.72 +        jAdminPortLbl.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ws7/ui/Bundle").getString("A11Y_Connection_Port_Mnem").charAt(0));
    6.73 +        jAdminPortLbl.setLabelFor(jAdminPortTxt);
    6.74 +        jAdminPortLbl.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ws7/ui/Bundle").getString("LBL_ConnectionAdminPort"));
    6.75 +        jAdminPortLbl.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ws7/ui/Bundle").getString("A11Y_NAME_ConnectionAdminPort"));
    6.76 +        jAdminPortLbl.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ws7/ui/Bundle").getString("A11Y_DESC_ConnectionAdminPort"));
    6.77 +        jAdminPortLbl.getAccessibleContext().setAccessibleParent(this);
    6.78 +
    6.79 +        jAdminPortTxt.setEditable(true);
    6.80 +        jAdminPortTxt.addFocusListener(new java.awt.event.FocusAdapter() {
    6.81 +            public void focusLost(java.awt.event.FocusEvent evt) {
    6.82 +                jAdminPortTxtFocusLost(evt);
    6.83 +            }
    6.84 +        });
    6.85 +
    6.86  
    6.87          jLocationLbl.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ws7/ui/Bundle").getString("A11Y_Connection_Location_Mnem").charAt(0));
    6.88          jLocationLbl.setLabelFor(jLocationTxt);
    6.89 @@ -149,7 +173,8 @@
    6.90              .add(layout.createSequentialGroup()
    6.91                  .add(22, 22, 22)
    6.92                  .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    6.93 -                    .add(jAdminUrlLbl)
    6.94 +                    .add(jAdminHostLbl)
    6.95 +                    .add(jAdminPortLbl)
    6.96                      .add(jLocationLbl)
    6.97                      .add(jAdminUserLbl)
    6.98                      .add(jPasswordLbl))
    6.99 @@ -161,7 +186,8 @@
   6.100                      .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
   6.101                          .add(layout.createSequentialGroup()
   6.102                              .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
   6.103 -                                .add(jAdminUrlTxt, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)
   6.104 +                                .add(jAdminHostTxt, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)
   6.105 +                                .add(jAdminPortTxt, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)
   6.106                                  .add(jLocationTxt, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE))
   6.107                              .add(96, 96, 96))
   6.108                          .add(layout.createSequentialGroup()
   6.109 @@ -169,15 +195,19 @@
   6.110                              .addContainerGap()))))
   6.111          );
   6.112  
   6.113 -        layout.linkSize(new java.awt.Component[] {jAdminUrlTxt, jAdminUserTxt, jLocationTxt, jPasswordTxt}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
   6.114 +        layout.linkSize(new java.awt.Component[] {jAdminHostTxt, jAdminPortTxt, jAdminUserTxt, jLocationTxt, jPasswordTxt}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
   6.115  
   6.116          layout.setVerticalGroup(
   6.117              layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
   6.118              .add(layout.createSequentialGroup()
   6.119                  .add(28, 28, 28)
   6.120                  .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
   6.121 -                    .add(jAdminUrlLbl)
   6.122 -                    .add(jAdminUrlTxt, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
   6.123 +                    .add(jAdminHostLbl)
   6.124 +                    .add(jAdminHostTxt, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
   6.125 +                .add(18, 18, 18)
   6.126 +                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
   6.127 +                    .add(jAdminPortLbl)
   6.128 +                    .add(jAdminPortTxt, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
   6.129                  .add(18, 18, 18)
   6.130                  .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
   6.131                      .add(jLocationLbl)
   6.132 @@ -193,9 +223,9 @@
   6.133                  .addContainerGap(138, Short.MAX_VALUE))
   6.134          );
   6.135  
   6.136 -        layout.linkSize(new java.awt.Component[] {jAdminUrlTxt, jAdminUserTxt, jLocationTxt, jPasswordTxt}, org.jdesktop.layout.GroupLayout.VERTICAL);
   6.137 +        layout.linkSize(new java.awt.Component[] {jAdminHostTxt, jAdminPortTxt, jAdminUserTxt, jLocationTxt, jPasswordTxt}, org.jdesktop.layout.GroupLayout.VERTICAL);
   6.138  
   6.139 -        layout.linkSize(new java.awt.Component[] {jAdminUrlLbl, jAdminUserLbl, jLocationLbl, jPasswordLbl}, org.jdesktop.layout.GroupLayout.VERTICAL);
   6.140 +        layout.linkSize(new java.awt.Component[] {jAdminHostLbl, jAdminPortLbl, jAdminUserLbl, jLocationLbl, jPasswordLbl}, org.jdesktop.layout.GroupLayout.VERTICAL);
   6.141  
   6.142      }// </editor-fold>//GEN-END:initComponents
   6.143  
   6.144 @@ -210,9 +240,10 @@
   6.145          if(propertyname!=null && propertyname.equals("ancestor")){
   6.146              if(oldValue!=null && newValue==null){
   6.147                  String uname = jAdminUserTxt.getText();                              
   6.148 +                String port = jAdminPortTxt.getText().trim();
   6.149                  char[] passWd = jPasswordTxt.getPassword();
   6.150                  String password = new String(passWd);
   6.151 -                manager.refreshInnerDM(uname, password);
   6.152 +                manager.refreshInnerDM(uname, password, port);
   6.153              }
   6.154          }        
   6.155      }//GEN-LAST:event_formPropertyChange
   6.156 @@ -220,6 +251,26 @@
   6.157      private void formFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_formFocusLost
   6.158      }//GEN-LAST:event_formFocusLost
   6.159  
   6.160 +    private void jAdminPortTxtFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jAdminPortTxtFocusLost
   6.161 +        String host = jAdminHostTxt.getText().trim();
   6.162 +        String port = jAdminPortTxt.getText().trim();
   6.163 +        if(WS70ServerUIWizardIterator.localserver) {
   6.164 +            String location = jLocationTxt.getText().trim();
   6.165 +            HashMap hm = org.netbeans.modules.j2ee.sun.ws7.util.Util.getPorts(location);
   6.166 +            ports = (WS70ServerUIWizardIterator.sslport) ? (ArrayList<String>)hm.get("ssl_ports") : (ArrayList<String>)hm.get("non_ssl_ports");
   6.167 +            if (ports.size() != 0 && !ports.contains(port)) {
   6.168 +                JOptionPane.showMessageDialog(null, NbBundle.getBundle(WS70ConnectionTabVisualPanel.class).getString("MSG_ENTER_VALID_PORT") 
   6.169 +                                                  , NbBundle.getBundle(WS70ConnectionTabVisualPanel.class).getString("MSG_INVALID_PORT") 
   6.170 +                                                  , JOptionPane.ERROR_MESSAGE);
   6.171 +                jAdminPortTxt.requestFocusInWindow();
   6.172 +            }
   6.173 +        } else if (!Util.isRunning(host, Integer.parseInt(port))) {
   6.174 +            JOptionPane.showMessageDialog(null, NbBundle.getBundle(WS70AddServerChoiceVisualPanel.class).getString("MSG_ADMIN_CONNECT_ERROR")
   6.175 +                                              , NbBundle.getBundle(WS70AddServerChoiceVisualPanel.class).getString("MSG_CONNECT_WARNING") 
   6.176 +                                              , JOptionPane.WARNING_MESSAGE);
   6.177 +        }
   6.178 +    }//GEN-LAST:event_jAdminPortTxtFocusLost
   6.179 +
   6.180      private void jPasswordTxtFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jPasswordTxtFocusLost
   6.181      }//GEN-LAST:event_jPasswordTxtFocusLost
   6.182  
   6.183 @@ -230,8 +281,10 @@
   6.184      }//GEN-LAST:event_jAdminUserTxtKeyReleased
   6.185      
   6.186      // Variables declaration - do not modify//GEN-BEGIN:variables
   6.187 -    private javax.swing.JLabel jAdminUrlLbl;
   6.188 -    private javax.swing.JTextField jAdminUrlTxt;
   6.189 +    private javax.swing.JLabel jAdminHostLbl;
   6.190 +    private javax.swing.JTextField jAdminHostTxt;
   6.191 +    private javax.swing.JLabel jAdminPortLbl;
   6.192 +    private javax.swing.JTextField jAdminPortTxt;
   6.193      private javax.swing.JLabel jAdminUserLbl;
   6.194      private javax.swing.JTextField jAdminUserTxt;
   6.195      private javax.swing.JLabel jLocationLbl;
     7.1 --- a/j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/ui/WS70ServerUIWizardIterator.java	Mon Sep 06 10:27:45 2010 +0200
     7.2 +++ b/j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/ui/WS70ServerUIWizardIterator.java	Wed Sep 15 11:58:07 2010 +0530
     7.3 @@ -74,6 +74,9 @@
     7.4      private final static String PROP_DISPLAY_NAME = "ServInstWizard_displayName"; // NOI18N
     7.5      public final static String PROP_LOCAL_SERVER = "LocalServer"; // NOI18N
     7.6      public final static String PROP_SSL_PORT = "SSLAdminPort"; // NOI18N
     7.7 +    public static String displayName;
     7.8 +    public static boolean sslport;
     7.9 +    public static boolean localserver;
    7.10      private WS70AddServerChoicePanel panel;
    7.11      private WizardDescriptor wizard;
    7.12      /**
    7.13 @@ -96,9 +99,9 @@
    7.14              String user = visualPanel.getAdminUserName();
    7.15              String password = visualPanel.getAdminPassword();
    7.16              String location  = visualPanel.getServerLocation();
    7.17 -            String displayName = (String)wizard.getProperty(PROP_DISPLAY_NAME);
    7.18 -            boolean localserver = visualPanel.isLocalServer();
    7.19 -            boolean sslport = visualPanel.isAdminOnSSL();
    7.20 +            displayName = (String)wizard.getProperty(PROP_DISPLAY_NAME);
    7.21 +            localserver = visualPanel.isLocalServer();
    7.22 +            sslport = visualPanel.isAdminOnSSL();
    7.23              InstanceProperties ip = WS70URIManager.createInstanceProperties(location, host, port, user, password, displayName);
    7.24              ip.setProperty(PROP_LOCAL_SERVER, Boolean.toString(localserver));
    7.25              ip.setProperty(PROP_SSL_PORT, Boolean.toString(sslport));
     8.1 --- a/j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/ui/WS70URIManager.java	Mon Sep 06 10:27:45 2010 +0200
     8.2 +++ b/j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/ui/WS70URIManager.java	Wed Sep 15 11:58:07 2010 +0530
     8.3 @@ -140,5 +140,14 @@
     8.4          String[] vals = newUrl.split(":");      
     8.5          return vals[1];                
     8.6      }
     8.7 +
     8.8 +    public static String getUpdatedUri(String uri, String port){
     8.9 +        // uri is a complete connector url
    8.10 +        // prefix is [<serverlocation>]+WS70SERVERURI and suffix is <host>:<port>
    8.11 +        int index = uri.lastIndexOf("::");
    8.12 +        String prefix = (index!=-1) ? uri.substring(0, index+2) : "";
    8.13 +        String suffix = (index!=-1) ? uri.substring(index+2) : uri;
    8.14 +        return prefix + suffix.split(":")[0] + ":" + port;
    8.15 +    }
    8.16      
    8.17  }
     9.1 --- a/j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/util/Util.java	Mon Sep 06 10:27:45 2010 +0200
     9.2 +++ b/j2ee.sun.ws7/src/org/netbeans/modules/j2ee/sun/ws7/util/Util.java	Wed Sep 15 11:58:07 2010 +0530
     9.3 @@ -45,6 +45,10 @@
     9.4  import java.io.BufferedReader;
     9.5  import java.io.FileReader;
     9.6  import java.io.IOException;
     9.7 +import java.util.*;
     9.8 +import java.lang.reflect.*;
     9.9 +
    9.10 +import org.netbeans.modules.j2ee.sun.ws7.WS7LibsClassLoader;
    9.11  
    9.12  public class Util {
    9.13      // Get the instance location from wsenv file
    9.14 @@ -98,5 +102,60 @@
    9.15  
    9.16      }
    9.17  
    9.18 +    public static HashMap getPorts(String serverXmlLocation) {
    9.19 +        List<String> ssl_ports = new ArrayList<String>();
    9.20 +        List<String> non_ssl_ports = new ArrayList<String>();
    9.21 +        File serverXml = new File(serverXmlLocation+File.separator+"admin-server"+File.separator+"config"+File.separator+"server.xml");
    9.22 +        try {
    9.23 +            WS7LibsClassLoader wscl = new WS7LibsClassLoader();
    9.24 +            wscl.addURL(new File(serverXmlLocation + File.separator + "lib" + File.separator + "webserv-rt.jar"));
    9.25 +            Class serverCls = wscl.loadClass("com.sun.webserver.config.serverbeans.Server");
    9.26 +
    9.27 +            // Call create graph method (on serverXml file)  and getHttpListener method from the server class
    9.28 +            Method cgMth = serverCls.getMethod("createGraph", new Class[] {serverXml.getClass()});
    9.29 +            Method hlMth = serverCls.getMethod("getHttpListener", null);
    9.30 +
    9.31 +            // Load HttpListenerType class and get the required methods
    9.32 +            Class hlCls = wscl.loadClass("com.sun.webserver.config.serverbeans.HttpListenerType");
    9.33 +            Method getPortMth = hlCls.getMethod("getPort", null);
    9.34 +            Method getSslMth =  hlCls.getMethod("getSsl", null);
    9.35 +            Method isHLEnabledMth = hlCls.getMethod("isEnabled", null);
    9.36 +
    9.37 +            // Load SslType class as getSsl method returns a SslType class, which will be used to invoke the getEnabled method
    9.38 +            Class sslTypeCls = wscl.loadClass("com.sun.webserver.config.serverbeans.SslType");
    9.39 +            Method isSSLEnabledMth = sslTypeCls.getMethod("getEnabled", new Class[] {Integer.TYPE});
    9.40 +
    9.41 +            // Make sure that no previous ports exist
    9.42 +            ssl_ports.clear();
    9.43 +            non_ssl_ports.clear();
    9.44 +
    9.45 +            Object createGraph = cgMth.invoke(serverCls, new Object[]{serverXml});
    9.46 +            Object[] httpListeners = (Object[]) hlMth.invoke(createGraph, null);
    9.47 +
    9.48 +            // Iterate through all the http-listeners to separte ssl and non-ssl ports
    9.49 +            for(Object hl : httpListeners) {
    9.50 +                Object isHLEnabled = isHLEnabledMth.invoke(hl, null);
    9.51 +                if (!((Boolean)isHLEnabled))
    9.52 +                    continue;
    9.53 +
    9.54 +                Object port = getPortMth.invoke(hl, null);
    9.55 +                Object ssl = getSslMth.invoke(hl, null);
    9.56 +                Object isSSLEnabled = isSSLEnabledMth.invoke(ssl, new Object[] {new Integer(0)});
    9.57 +                if ((Boolean)isSSLEnabled) {
    9.58 +                    ssl_ports.add(port.toString());
    9.59 +                } else {
    9.60 +                    non_ssl_ports.add(port.toString());
    9.61 +                }
    9.62 +            }
    9.63 +        } catch(Exception e) {
    9.64 +            e.printStackTrace();
    9.65 +        }
    9.66 +
    9.67 +        HashMap ports = new HashMap();
    9.68 +        ports.put("ssl_ports", ssl_ports);
    9.69 +        ports.put("non_ssl_ports", non_ssl_ports);
    9.70 +        return ports;
    9.71 +
    9.72 +    }
    9.73  }
    9.74