directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1063363 - in /directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor: LdapLdapsServersPage.java OverviewPage.java ServerConfigurationEditorUtils.java
Date Tue, 25 Jan 2011 17:14:41 GMT
Author: pamarcelot
Date: Tue Jan 25 17:14:41 2011
New Revision: 1063363

URL: http://svn.apache.org/viewvc?rev=1063363&view=rev
Log:
Shared methods between the "Overview" and "LDAP/LDAPS Server" pages.
Cleaning.

Modified:
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/LdapLdapsServersPage.java
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/OverviewPage.java
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditorUtils.java

Modified: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/LdapLdapsServersPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/LdapLdapsServersPage.java?rev=1063363&r1=1063362&r2=1063363&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/LdapLdapsServersPage.java
(original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/LdapLdapsServersPage.java
Tue Jan 25 17:14:41 2011
@@ -20,6 +20,7 @@
 package org.apache.directory.studio.apacheds.configuration.v2.editor;
 
 
+import org.apache.directory.server.config.beans.DirectoryServiceBean;
 import org.apache.directory.server.config.beans.LdapServerBean;
 import org.apache.directory.server.config.beans.TransportBean;
 import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
@@ -49,6 +50,14 @@ import org.eclipse.ui.forms.widgets.Tabl
  */
 public class LdapLdapsServersPage extends ServerConfigurationEditorPage
 {
+    private static final int LDAPS_DEFAULT_PORT = 10636;
+
+    private static final int LDAP_DEFAULT_PORT = 10389;
+
+    private static final String TRANSPORT_ID_LDAP = "ldap";
+
+    private static final String TRANSPORT_ID_LDAPS = "ldaps";
+
     /** The Page ID*/
     public static final String ID = LdapLdapsServersPage.class.getName(); //$NON-NLS-1$
 
@@ -130,6 +139,7 @@ public class LdapLdapsServersPage extend
             {
                 // TODO Auto-generated catch block
                 e1.printStackTrace();
+
             }
         }
     };
@@ -372,29 +382,6 @@ public class LdapLdapsServersPage extend
 
 
     /**
-     * {@inheritDoc}
-     */
-    protected void refreshUI()
-    {
-        removeListeners();
-
-        LdapServerBean ldapServerBean = getLdapServerBean();
-
-        setSelection( enableLdapCheckbox, ldapServerBean.isEnabled() );
-        setText( ldapPortText, getLdapServerTransportBean().getSystemPort() + "" );
-
-        setSelection( enableLdapsCheckbox, true );
-        setText( ldapsPortText, getLdapsServerTransportBean().getSystemPort() + "" );
-
-        setText( saslHostText, ldapServerBean.getLdapServerSaslHost() );
-        setText( saslPrincipalText, ldapServerBean.getLdapServerSaslPrincipal() );
-        setText( saslSearchBaseDnText, ldapServerBean.getSearchBaseDn().toString() );
-
-        addListeners();
-    }
-
-
-    /**
      * Adds listeners to UI Controls.
      */
     private void addListeners()
@@ -513,6 +500,30 @@ public class LdapLdapsServersPage extend
 
 
     /**
+     * {@inheritDoc}
+     */
+    protected void refreshUI()
+    {
+        removeListeners();
+
+        TransportBean ldapServerTransportBean = getLdapServerTransportBean();
+        setSelection( enableLdapCheckbox, ldapServerTransportBean.isEnabled() );
+        setText( ldapPortText, ldapServerTransportBean.getSystemPort() + "" );
+
+        TransportBean ldapsServerTransportBean = getLdapsServerTransportBean();
+        setSelection( enableLdapsCheckbox, ldapsServerTransportBean.isEnabled() );
+        setText( ldapsPortText, ldapsServerTransportBean.getSystemPort() + "" );
+
+        LdapServerBean ldapServerBean = getLdapServerBean();
+        setText( saslHostText, ldapServerBean.getLdapServerSaslHost() );
+        setText( saslPrincipalText, ldapServerBean.getLdapServerSaslPrincipal() );
+        setText( saslSearchBaseDnText, ldapServerBean.getSearchBaseDn().toString() );
+
+        addListeners();
+    }
+
+
+    /**
      * Gets the LDAP Server bean.
      *
      * @return
@@ -520,12 +531,24 @@ public class LdapLdapsServersPage extend
      */
     private LdapServerBean getLdapServerBean()
     {
-        LdapServerBean ldapServerBean = getDirectoryServiceBean().getLdapServerBean();
+        return getLdapServerBean( getDirectoryServiceBean() );
+    }
+
+
+    /**
+     * Gets the LDAP Server bean.
+     *
+     * @return
+     *      the LDAP Server bean
+     */
+    public static LdapServerBean getLdapServerBean( DirectoryServiceBean directoryServiceBean
)
+    {
+        LdapServerBean ldapServerBean = directoryServiceBean.getLdapServerBean();
 
         if ( ldapServerBean == null )
         {
             ldapServerBean = new LdapServerBean();
-            getDirectoryServiceBean().addServers( ldapServerBean );
+            directoryServiceBean.addServers( ldapServerBean );
         }
 
         return ldapServerBean;
@@ -540,7 +563,26 @@ public class LdapLdapsServersPage extend
      */
     private TransportBean getLdapServerTransportBean()
     {
-        return getTransportBean( "ldap" );
+        return getTransportBean( TRANSPORT_ID_LDAP );
+    }
+
+
+    /**
+     * Gets the LDAP Server transport bean.
+     *
+     * @param directoryServiceBean
+     *      the directory service bean
+     * @return
+     *      the LDAP Server transport bean
+     */
+    /**
+     * TODO getLdapServerTransportBean.
+     *
+     * @return
+     */
+    public static TransportBean getLdapServerTransportBean( DirectoryServiceBean directoryServiceBean
)
+    {
+        return getTransportBean( directoryServiceBean, TRANSPORT_ID_LDAP );
     }
 
 
@@ -552,7 +594,21 @@ public class LdapLdapsServersPage extend
      */
     private TransportBean getLdapsServerTransportBean()
     {
-        return getTransportBean( "ldaps" );
+        return getTransportBean( TRANSPORT_ID_LDAPS );
+    }
+
+
+    /**
+     * Gets the LDAPS Server transport bean.
+     *
+     * @param directoryServiceBean
+     *      the directory service bean
+     * @return
+     *      the LDAPS Server transport bean
+     */
+    public static TransportBean getLdapsServerTransportBean( DirectoryServiceBean directoryServiceBean
)
+    {
+        return getTransportBean( directoryServiceBean, TRANSPORT_ID_LDAPS );
     }
 
 
@@ -566,7 +622,21 @@ public class LdapLdapsServersPage extend
      */
     private TransportBean getTransportBean( String id )
     {
-        LdapServerBean ldapServerBean = getLdapServerBean();
+        return getTransportBean( getDirectoryServiceBean(), id );
+    }
+
+
+    /**
+     * Gets a transport bean based on its id.
+     *
+     * @param id
+     *      the id
+     * @return
+     *      the corresponding transport bean
+     */
+    public static TransportBean getTransportBean( DirectoryServiceBean directoryServiceBean,
String id )
+    {
+        LdapServerBean ldapServerBean = getLdapServerBean( directoryServiceBean );
 
         TransportBean transportBean = null;
 
@@ -587,9 +657,28 @@ public class LdapLdapsServersPage extend
         // No corresponding transport has been found
         if ( transportBean == null )
         {
+            // Creating a transport bean
             transportBean = new TransportBean();
-            transportBean.setTransportId( id );
             ldapServerBean.addTransports( transportBean );
+
+            // ID
+            transportBean.setTransportId( id );
+
+            // Port
+            if ( TRANSPORT_ID_LDAP.equals( id ) )
+            {
+                transportBean.setSystemPort( LDAP_DEFAULT_PORT );
+            }
+            else if ( TRANSPORT_ID_LDAPS.equals( id ) )
+            {
+                transportBean.setSystemPort( LDAPS_DEFAULT_PORT );
+            }
+
+            // SSL
+            if ( TRANSPORT_ID_LDAPS.equals( id ) )
+            {
+                transportBean.setTransportEnableSSL( true );
+            }
         }
 
         return transportBean;

Modified: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/OverviewPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/OverviewPage.java?rev=1063363&r1=1063362&r2=1063363&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/OverviewPage.java
(original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/OverviewPage.java
Tue Jan 25 17:14:41 2011
@@ -27,7 +27,7 @@ import org.apache.directory.server.confi
 import org.apache.directory.server.config.beans.ConfigBean;
 import org.apache.directory.server.config.beans.DirectoryServiceBean;
 import org.apache.directory.server.config.beans.KdcServerBean;
-import org.apache.directory.server.config.beans.LdapServerBean;
+import org.apache.directory.server.config.beans.TransportBean;
 import org.apache.directory.studio.apacheds.configuration.v2.ApacheDS2ConfigurationPlugin;
 import org.apache.directory.studio.apacheds.configuration.v2.ApacheDS2ConfigurationPluginConstants;
 import org.eclipse.jface.viewers.ArrayContentProvider;
@@ -44,7 +44,6 @@ import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.forms.events.HyperlinkAdapter;
 import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.events.IHyperlinkListener;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.Hyperlink;
 import org.eclipse.ui.forms.widgets.Section;
@@ -332,15 +331,17 @@ public class OverviewPage extends Server
 
         DirectoryServiceBean directoryServiceBean = configBean.getDirectoryServiceBean();
 
-        LdapServerBean ldapServerBean = directoryServiceBean.getLdapServerBean();
         KdcServerBean kdcServerBean = directoryServiceBean.getKdcServerBean();
         ChangePasswordServerBean changePasswordServerBean = directoryServiceBean.getChangePasswordServerBean();
 
-        enableLdapCheckbox.setSelection( ldapServerBean.isEnabled() );
-        ldapPortText.setText( ldapServerBean.getTransports()[0].getSystemPort() + "" );
-
-        enableLdapsCheckbox.setSelection( true );
-        ldapsPortText.setText( "10636" );
+        TransportBean ldapServerTransportBean = LdapLdapsServersPage.getLdapServerTransportBean(
directoryServiceBean );
+        setSelection( enableLdapCheckbox, ldapServerTransportBean.isEnabled() );
+        setText( ldapPortText, ldapServerTransportBean.getSystemPort() + "" );
+
+        TransportBean ldapsServerTransportBean = LdapLdapsServersPage
+            .getLdapsServerTransportBean( directoryServiceBean );
+        setSelection( enableLdapsCheckbox, ldapsServerTransportBean.isEnabled() );
+        setText( ldapsPortText, ldapsServerTransportBean.getSystemPort() + "" );
 
         enableKerberosCheckbox.setSelection( kdcServerBean.isEnabled() );
         kerberosPortText.setText( "" + kdcServerBean.getTransports()[0].getSystemPort() );

Modified: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditorUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditorUtils.java?rev=1063363&r1=1063362&r2=1063363&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditorUtils.java
(original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditorUtils.java
Tue Jan 25 17:14:41 2011
@@ -369,8 +369,6 @@ public class ServerConfigurationEditorUt
         }
         else
         {
-            System.out.println( "swapping partition" );
-
             // Swapping the new configuration partition
             input.setOriginalPartition( newconfigurationPartition );
         }



Mime
View raw message