directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r569892 - in /directory/studio/trunk: studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/ studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/ studio-connection-core/src/mai...
Date Sun, 26 Aug 2007 22:17:51 GMT
Author: seelmann
Date: Sun Aug 26 15:17:46 2007
New Revision: 569892

URL: http://svn.apache.org/viewvc?rev=569892&view=rev
Log:
Fixed some problems with connection handling

Modified:
    directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
    directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionManager.java
    directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionParameter.java
    directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
    directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/OpenConnectionsJob.java
    directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/ConnectionParameterPage.java
    directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/properties/ConnectionPropertyPage.java
    directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java
    directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java

Modified: directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/Connection.java?rev=569892&r1=569891&r2=569892&view=diff
==============================================================================
--- directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
(original)
+++ directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
Sun Aug 26 15:17:46 2007
@@ -59,7 +59,7 @@
     public Object clone()
     {
         ConnectionParameter cp = new ConnectionParameter( getName(), getHost(), getPort(),
getEncryptionMethod(),
-            getAuthMethod(), getBindPrincipal(), getBindPassword() );
+            getAuthMethod(), getBindPrincipal(), getBindPassword(), getConnectionParameter().getExtendedProperties()
);
 
         Connection clone = new Connection( cp );
 
@@ -100,7 +100,15 @@
      */
     public void setConnectionParameter( ConnectionParameter connectionParameter )
     {
+        String oldName = this.connectionParameter.getName();
+        
         this.connectionParameter = connectionParameter;
+        
+        ConnectionEventRegistry.fireConnectionUpdated( this, this );
+        if(!oldName.equals( connectionParameter.getName() ))
+        {
+            ConnectionEventRegistry.fireConnectionRenamed( this, oldName, this );
+        }
     }
 
 
@@ -264,8 +272,8 @@
         connectionParameter.setPort( port );
         ConnectionEventRegistry.fireConnectionUpdated( this, this );
     }
-
-
+    
+    
     /**
      * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
      */

Modified: directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionManager.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionManager.java?rev=569892&r1=569891&r2=569892&view=diff
==============================================================================
--- directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionManager.java
(original)
+++ directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionManager.java
Sun Aug 26 15:17:46 2007
@@ -280,7 +280,7 @@
     /**
      * Saves the Connections
      */
-    public void saveConnections()
+    private void saveConnections()
     {
         Object[] object = new Object[connectionList.size()];
 

Modified: directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionParameter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionParameter.java?rev=569892&r1=569891&r2=569892&view=diff
==============================================================================
--- directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionParameter.java
(original)
+++ directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionParameter.java
Sun Aug 26 15:17:46 2007
@@ -142,11 +142,12 @@
      * @param authMethod the authentication method
      * @param bindPrincipal the bind principal
      * @param bindPassword the bind password
+     * @param extendedProperties the extended properties
      */
     public ConnectionParameter( String name, String host, int port, EncryptionMethod encryptionMethod,
-        AuthenticationMethod authMethod, String bindPrincipal, String bindPassword )
+        AuthenticationMethod authMethod, String bindPrincipal, String bindPassword,
+        Map<String, String> extendedProperties )
     {
-        this();
         this.name = name;
         this.host = host;
         this.port = port;
@@ -154,6 +155,11 @@
         this.authMethod = authMethod;
         this.bindPrincipal = bindPrincipal;
         this.bindPassword = bindPassword;
+        this.extendedProperties = new HashMap<String, String>();
+        if ( extendedProperties != null )
+        {
+            this.extendedProperties.putAll( extendedProperties );
+        }
     }
 
 

Modified: directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java?rev=569892&r1=569891&r2=569892&view=diff
==============================================================================
--- directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
(original)
+++ directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
Sun Aug 26 15:17:46 2007
@@ -82,36 +82,6 @@
      */
     public void connect( StudioProgressMonitor monitor )
     {
-        String host = connection.getConnectionParameter().getHost();
-        int port = connection.getConnectionParameter().getPort();
-
-        useLdaps = connection.getConnectionParameter().getEncryptionMethod() == ConnectionParameter.EncryptionMethod.LDAPS;
-        useStartTLS = connection.getConnectionParameter().getEncryptionMethod() == ConnectionParameter.EncryptionMethod.START_TLS;
-
-        environment = new Hashtable<String, String>();
-        environment.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"
); //$NON-NLS-1$
-        environment.put( "java.naming.ldap.version", "3" ); //$NON-NLS-1$ //$NON-NLS-2$
-
-        // timeouts
-        if ( !useLdaps )
-        {
-            environment.put( "com.sun.jndi.ldap.connect.timeout", "10000" ); //$NON-NLS-1$
//$NON-NLS-2$
-        }
-        environment.put( "com.sun.jndi.dns.timeout.initial", "2000" ); //$NON-NLS-1$ //$NON-NLS-2$
-        environment.put( "com.sun.jndi.dns.timeout.retries", "3" ); //$NON-NLS-1$ //$NON-NLS-2$
-
-        // ldaps://
-        if ( useLdaps )
-        {
-            environment.put( Context.PROVIDER_URL, "ldaps://" + host + ":" + port ); //$NON-NLS-1$
//$NON-NLS-2$
-            environment.put( Context.SECURITY_PROTOCOL, "ssl" ); //$NON-NLS-1$
-            environment.put( "java.naming.ldap.factory.socket", DummySSLSocketFactory.class.getName()
); //$NON-NLS-1$
-        }
-        else
-        {
-            environment.put( Context.PROVIDER_URL, "ldap://" + host + ":" + port ); //$NON-NLS-1$
//$NON-NLS-2$
-        }
-
         context = null;
         isConnected = false;
         jobThread = null;
@@ -161,35 +131,6 @@
      */
     public void bind( StudioProgressMonitor monitor )
     {
-        authMethod = "none";
-        if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SIMPLE
)
-        {
-            authMethod = "simple";
-        }
-        else if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SASL_DIGEST_MD5
)
-        {
-            authMethod = "DIGEST-MD5";
-        }
-        else if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SASL_CRAM_MD5
)
-        {
-            authMethod = "CRAM-MD5";
-        }
-
-        IAuthHandler authHandler = ConnectionCorePlugin.getDefault().getAuthHandler();
-        if ( authHandler == null )
-        {
-            monitor.reportError( Messages.model__no_auth_handler, new Exception() );
-        }
-
-        ICredentials credentials = authHandler.getCredentials( connection.getConnectionParameter()
);
-        if ( credentials == null )
-        {
-            monitor.reportError( Messages.model__no_credentials, new Exception() );
-        }
-
-        bindPrincipal = credentials.getBindPrincipal();
-        bindCredentials = credentials.getBindPassword();
-
         try
         {
             doBind( monitor );
@@ -591,6 +532,37 @@
         context = null;
         isConnected = true;
 
+        // setup connection parameters
+        String host = connection.getConnectionParameter().getHost();
+        int port = connection.getConnectionParameter().getPort();
+        
+        useLdaps = connection.getConnectionParameter().getEncryptionMethod() == ConnectionParameter.EncryptionMethod.LDAPS;
+        useStartTLS = connection.getConnectionParameter().getEncryptionMethod() == ConnectionParameter.EncryptionMethod.START_TLS;
+        
+        environment = new Hashtable<String, String>();
+        environment.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"
); //$NON-NLS-1$
+        environment.put( "java.naming.ldap.version", "3" ); //$NON-NLS-1$ //$NON-NLS-2$
+        
+        // timeouts
+        if ( !useLdaps )
+        {
+            environment.put( "com.sun.jndi.ldap.connect.timeout", "10000" ); //$NON-NLS-1$
//$NON-NLS-2$
+        }
+        environment.put( "com.sun.jndi.dns.timeout.initial", "2000" ); //$NON-NLS-1$ //$NON-NLS-2$
+        environment.put( "com.sun.jndi.dns.timeout.retries", "3" ); //$NON-NLS-1$ //$NON-NLS-2$
+        
+        // ldaps://
+        if ( useLdaps )
+        {
+            environment.put( Context.PROVIDER_URL, "ldaps://" + host + ":" + port ); //$NON-NLS-1$
//$NON-NLS-2$
+            environment.put( Context.SECURITY_PROTOCOL, "ssl" ); //$NON-NLS-1$
+            environment.put( "java.naming.ldap.factory.socket", DummySSLSocketFactory.class.getName()
); //$NON-NLS-1$
+        }
+        else
+        {
+            environment.put( Context.PROVIDER_URL, "ldap://" + host + ":" + port ); //$NON-NLS-1$
//$NON-NLS-2$
+        }
+        
         InnerRunnable runnable = new InnerRunnable()
         {
             private NamingException namingException = null;
@@ -673,6 +645,35 @@
     {
         if ( context != null && isConnected )
         {
+            // setup authentication methdod
+            authMethod = "none";
+            if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SIMPLE
)
+            {
+                authMethod = "simple";
+            }
+            else if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SASL_DIGEST_MD5
)
+            {
+                authMethod = "DIGEST-MD5";
+            }
+            else if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SASL_CRAM_MD5
)
+            {
+                authMethod = "CRAM-MD5";
+            }
+
+            // setup credentials
+            IAuthHandler authHandler = ConnectionCorePlugin.getDefault().getAuthHandler();
+            if ( authHandler == null )
+            {
+                monitor.reportError( Messages.model__no_auth_handler, new Exception() );
+            }
+            ICredentials credentials = authHandler.getCredentials( connection.getConnectionParameter()
);
+            if ( credentials == null )
+            {
+                monitor.reportError( Messages.model__no_credentials, new Exception() );
+            }
+            bindPrincipal = credentials.getBindPrincipal();
+            bindCredentials = credentials.getBindPassword();
+            
             InnerRunnable runnable = new InnerRunnable()
             {
                 private NamingException namingException = null;

Modified: directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/OpenConnectionsJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/OpenConnectionsJob.java?rev=569892&r1=569891&r2=569892&view=diff
==============================================================================
--- directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/OpenConnectionsJob.java
(original)
+++ directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/OpenConnectionsJob.java
Sun Aug 26 15:17:46 2007
@@ -97,7 +97,7 @@
             if ( !connections[i].getJNDIConnectionWrapper().isConnected() )
             {
                 monitor.setTaskName( Messages.bind( Messages.jobs__open_connections_task,
new String[]
-                    { this.connections[i].getName() } ) );
+                    { connections[i].getName() } ) );
                 monitor.worked( 1 );
 
                 connections[i].getJNDIConnectionWrapper().connect( monitor );

Modified: directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/ConnectionParameterPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/ConnectionParameterPage.java?rev=569892&r1=569891&r2=569892&view=diff
==============================================================================
--- directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/ConnectionParameterPage.java
(original)
+++ directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/ConnectionParameterPage.java
Sun Aug 26 15:17:46 2007
@@ -146,4 +146,23 @@
      */
     public void setFocus();
 
+
+    /**
+     * The implementing class must return true if important
+     * connection parameters were modified that require a
+     * reconnection to take effect.
+     *
+     * @return true if a reconnection if required
+     */
+    public boolean isReconnectionRequired();
+
+
+    /**
+     * The implementing class must return true if any
+     * parameter was modified.
+     * 
+     * @return true, if parameters were modifed
+     */
+    public boolean areParametersModifed();
+
 }

Modified: directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/properties/ConnectionPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/properties/ConnectionPropertyPage.java?rev=569892&r1=569891&r2=569892&view=diff
==============================================================================
--- directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/properties/ConnectionPropertyPage.java
(original)
+++ directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/properties/ConnectionPropertyPage.java
Sun Aug 26 15:17:46 2007
@@ -28,11 +28,13 @@
 import org.apache.directory.studio.connection.ui.ConnectionParameterPage;
 import org.apache.directory.studio.connection.ui.ConnectionParameterPageManager;
 import org.apache.directory.studio.connection.ui.ConnectionParameterPageModifyListener;
+import org.apache.directory.studio.connection.ui.widgets.BaseWidgetUtils;
 import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.TabFolder;
 import org.eclipse.swt.widgets.TabItem;
 import org.eclipse.ui.dialogs.PropertyPage;
@@ -162,30 +164,34 @@
         if ( connection != null )
         {
             super.setMessage( "Connection " + Utils.shorten( connection.getName(), 30 ) );
+            
+            pages = ConnectionParameterPageManager.getConnectionParameterPages();
+            
+            tabFolder = new TabFolder( parent, SWT.TOP );
+            
+            tabs = new TabItem[pages.length];
+            for ( int i = 0; i < pages.length; i++ )
+            {
+                Composite composite = new Composite( tabFolder, SWT.NONE );
+                GridLayout gl = new GridLayout( 1, false );
+                composite.setLayout( gl );
+                
+                pages[i].createComposite( composite );
+                pages[i].setRunnableContext( null );
+                pages[i].setConnectionParameterPageModifyListener( this );
+                pages[i].loadParameters( connection.getConnectionParameter() );
+                
+                tabs[i] = new TabItem( tabFolder, SWT.NONE );
+                tabs[i].setText( pages[i].getPageName() );
+                tabs[i].setControl( composite );
+            }
+            
+            return tabFolder;
         }
-
-        pages = ConnectionParameterPageManager.getConnectionParameterPages();
-
-        tabFolder = new TabFolder( parent, SWT.TOP );
-
-        tabs = new TabItem[pages.length];
-        for ( int i = 0; i < pages.length; i++ )
-        {
-            Composite composite = new Composite( tabFolder, SWT.NONE );
-            GridLayout gl = new GridLayout( 1, false );
-            composite.setLayout( gl );
-
-            pages[i].createComposite( composite );
-            pages[i].setRunnableContext( null );
-            pages[i].setConnectionParameterPageModifyListener( this );
-            pages[i].loadParameters( connection.getConnectionParameter() );
-
-            tabs[i] = new TabItem( tabFolder, SWT.NONE );
-            tabs[i].setText( pages[i].getPageName() );
-            tabs[i].setControl( composite );
+        else {
+            Label label = BaseWidgetUtils.createLabel( parent, "No connection", 1 );
+            return label;
         }
-
-        return tabFolder;
     }
 
 
@@ -196,22 +202,30 @@
     {
         // get current connection parameters
         Connection connection = ( Connection ) getConnection( getElement() );
-        ConnectionParameter connectionParameter = connection.getConnectionParameter();
         
         // save modified parameters
+        boolean parametersModified = false;
+        boolean reconnectionRequired = false;
+        ConnectionParameter connectionParameter = new ConnectionParameter();
         for ( int i = 0; i < pages.length; i++ )
         {
             pages[i].saveParameters( connectionParameter );
             pages[i].saveDialogSettings();
+            parametersModified |= pages[i].areParametersModifed();
+            reconnectionRequired |= pages[i].isReconnectionRequired();
+        }
+
+        if ( parametersModified )
+        {
+            // update connection parameters
+            connection.setConnectionParameter( connectionParameter );
+
+            if ( reconnectionRequired )
+            {
+                // close connection
+                new CloseConnectionsJob( connection ).execute();
+            }
         }
-        
-        // update persistent connection
-        connection.setConnectionParameter( connectionParameter );
-        connection.setName( connection.getName() );
-        connection.setHost( connection.getHost() );
-        
-        // close connection
-        new CloseConnectionsJob( connection ).execute();
 
         return true;
     }

Modified: directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java?rev=569892&r1=569891&r2=569892&view=diff
==============================================================================
--- directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java
(original)
+++ directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java
Sun Aug 26 15:17:46 2007
@@ -326,4 +326,24 @@
         bindPrincipalCombo.setFocus();
     }
 
+
+    /**
+     * @see org.apache.directory.studio.connection.ui.ConnectionParameterPage#areParametersModifed()
+     */
+    public boolean areParametersModifed()
+    {
+        return isReconnectionRequired();
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.connection.ui.ConnectionParameterPage#isReconnectionRequired()
+     */
+    public boolean isReconnectionRequired()
+    {
+        return connectionParameter == null || connectionParameter.getAuthMethod() != getAuthenticationMethod()
+            || !( connectionParameter.getBindPrincipal().equals( getBindPrincipal() ) )
+            || !( connectionParameter.getBindPassword().equals( getBindPassword() ) );
+    }
+
 }

Modified: directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java?rev=569892&r1=569891&r2=569892&view=diff
==============================================================================
--- directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
(original)
+++ directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
Sun Aug 26 15:17:46 2007
@@ -140,7 +140,7 @@
     private Connection getTestConnection()
     {
         ConnectionParameter cp = new ConnectionParameter( null, getHostName(), getPort(),
getEncyrptionMethod(),
-            ConnectionParameter.AuthenticationMethod.NONE, null, null );
+            ConnectionParameter.AuthenticationMethod.NONE, null, null, null );
         Connection conn = new Connection( cp );
         return conn;
     }
@@ -342,6 +342,26 @@
     public void setFocus()
     {
         nameText.setFocus();
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.connection.ui.ConnectionParameterPage#areParametersModifed()
+     */
+    public boolean areParametersModifed()
+    {
+        return isReconnectionRequired() || !( connectionParameter.getName().equals( getName()
) );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.connection.ui.ConnectionParameterPage#isReconnectionRequired()
+     */
+    public boolean isReconnectionRequired()
+    {
+        return connectionParameter == null || !( connectionParameter.getHost().equals( getHostName()
) )
+            || connectionParameter.getPort() != getPort()
+            || connectionParameter.getEncryptionMethod() != getEncyrptionMethod();
     }
 
 }



Mime
View raw message