directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r994948 - in /directory/studio/trunk/plugins/ldapservers.apacheds.v156: ./ resources/icons/ src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/
Date Wed, 08 Sep 2010 09:49:16 GMT
Author: pamarcelot
Date: Wed Sep  8 09:49:16 2010
New Revision: 994948

URL: http://svn.apache.org/viewvc?rev=994948&view=rev
Log:
Added an action to create a new connection from a server instance for Apache DS Server Adapter
version 1.5.6.

Added:
    directory/studio/trunk/plugins/ldapservers.apacheds.v156/resources/icons/
    directory/studio/trunk/plugins/ldapservers.apacheds.v156/resources/icons/connection_new.gif
  (with props)
    directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/CreateConnectionAction.java
Modified:
    directory/studio/trunk/plugins/ldapservers.apacheds.v156/plugin.xml
    directory/studio/trunk/plugins/ldapservers.apacheds.v156/pom.xml
    directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/ApacheDS156LdapServerAdapter.java
    directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/messages.properties
    directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/messages_de.properties
    directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/messages_fr.properties

Modified: directory/studio/trunk/plugins/ldapservers.apacheds.v156/plugin.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v156/plugin.xml?rev=994948&r1=994947&r2=994948&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v156/plugin.xml (original)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v156/plugin.xml Wed Sep  8 09:49:16
2010
@@ -11,4 +11,25 @@
             version="1.5.6">
       </ldapServerAdapter>
    </extension>
+   
+   <extension
+         point="org.eclipse.ui.popupMenus">
+      <objectContribution
+            objectClass="org.apache.directory.studio.ldapservers.model.LdapServer"
+            id="org.apache.directory.studio.ldapservers.model.LdapServer">
+         <action
+               class="org.apache.directory.studio.ldapservers.apacheds.v156.CreateConnectionAction"
+               enablesFor="1"
+               id="org.apache.directory.studio.ldapservers.apacheds.v156.CreateConnectionAction"
+               label="Create a Connection"
+               icon="resources/icons/connection_new.gif">
+         </action>
+         <visibility>
+               <objectState
+                     name="extensionId"
+                     value="org.apache.directory.server.1.5.6">
+               </objectState>
+         </visibility>
+      </objectContribution>
+   </extension>
 </plugin>

Modified: directory/studio/trunk/plugins/ldapservers.apacheds.v156/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v156/pom.xml?rev=994948&r1=994947&r2=994948&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v156/pom.xml (original)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v156/pom.xml Wed Sep  8 09:49:16 2010
@@ -118,6 +118,7 @@
  org.apache.directory.studio.apacheds.configuration,
  org.apache.directory.studio.common.core,
  org.apache.directory.studio.common.ui,
+ org.apache.directory.studio.connection.core,
  org.apache.directory.studio.ldapservers,
  org.dom4j.dom4j;bundle-version="${org.dom4j.version}",
  org.eclipse.core.runtime,
@@ -550,6 +551,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.directory.studio</groupId>
+      <artifactId>connection.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.directory.studio</groupId>
       <artifactId>ldapservers</artifactId>
       <scope>provided</scope>
     </dependency>

Added: directory/studio/trunk/plugins/ldapservers.apacheds.v156/resources/icons/connection_new.gif
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v156/resources/icons/connection_new.gif?rev=994948&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/studio/trunk/plugins/ldapservers.apacheds.v156/resources/icons/connection_new.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/ApacheDS156LdapServerAdapter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/ApacheDS156LdapServerAdapter.java?rev=994948&r1=994947&r2=994948&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/ApacheDS156LdapServerAdapter.java
(original)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/ApacheDS156LdapServerAdapter.java
Wed Sep  8 09:49:16 2010
@@ -216,14 +216,14 @@ public class ApacheDS156LdapServerAdapte
     * @throws ServerXmlIOException 
     * @throws FileNotFoundException 
     */
-    private ServerConfiguration getServerConfiguration( LdapServer server ) throws ServerXmlIOException,
+    public static ServerConfigurationV156 getServerConfiguration( LdapServer server ) throws
ServerXmlIOException,
         FileNotFoundException
     {
         InputStream fis = new FileInputStream( LdapServersManager.getServerFolder( server
).append( "conf" )
             .append( "server.xml" ).toFile() );
 
         ServerXmlIOV156 serverXmlIOV156 = new ServerXmlIOV156();
-        return serverXmlIOV156.parse( fis );
+        return (ServerConfigurationV156) serverXmlIOV156.parse( fis );
     }
 
 
@@ -239,7 +239,7 @@ public class ApacheDS156LdapServerAdapte
      */
     private int getTestingPort( LdapServer server ) throws ServerXmlIOException, IOException
     {
-        ServerConfigurationV156 configuration = ( ServerConfigurationV156 ) getServerConfiguration(
server );
+        ServerConfigurationV156 configuration = getServerConfiguration( server );
 
         // LDAP
         if ( configuration.isEnableLdap() )

Added: directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/CreateConnectionAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/CreateConnectionAction.java?rev=994948&view=auto
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/CreateConnectionAction.java
(added)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/CreateConnectionAction.java
Wed Sep  8 09:49:16 2010
@@ -0,0 +1,204 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapservers.apacheds.v156;
+
+
+import org.apache.directory.studio.apacheds.configuration.model.v156.ServerConfigurationV156;
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.ConnectionParameter;
+import org.apache.directory.studio.connection.core.ConnectionParameter.AuthenticationMethod;
+import org.apache.directory.studio.connection.core.ConnectionParameter.EncryptionMethod;
+import org.apache.directory.studio.ldapservers.actions.CreateConnectionActionHelper;
+import org.apache.directory.studio.ldapservers.model.LdapServer;
+import org.apache.directory.studio.ldapservers.views.ServersView;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+
+/**
+ * This class implements the create connection action for an ApacheDS 1.5.6 server.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class CreateConnectionAction implements IObjectActionDelegate
+{
+    private static final String EXTENSION_ID = "org.apache.directory.server.1.5.6";
+
+    /** The {@link ServersView} */
+    private ServersView view;
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run( IAction action )
+    {
+        if ( view != null )
+        {
+            // Getting the selection
+            StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
+            if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
+            {
+                // Getting the server
+                LdapServer server = ( LdapServer ) selection.getFirstElement();
+
+                // Checking that the server is really an ApacheDS 1.5.6 server
+                // TODO
+                if ( !EXTENSION_ID.equalsIgnoreCase( server.getLdapServerAdapterExtension().getId()
) )
+                {
+                    String message = Messages.getString( "CreateConnectionAction.UnableReadServerConfiguration"
) //$NON-NLS-1$
+                        + "\n\n" // TODO
+                        + Messages.getString( "CreateConnectionAction.NotA156Server" ); //$NON-NLS-1$
+
+                    reportErrorReadingServerConfiguration( view, message );
+                    return;
+                }
+
+                // Parsing the 'server.xml' file
+                ServerConfigurationV156 serverConfiguration = null;
+                try
+                {
+                    serverConfiguration = ApacheDS156LdapServerAdapter.getServerConfiguration(
server );
+                }
+                catch ( Exception e )
+                {
+                    String message = Messages.getString( "CreateConnectionAction.UnableReadServerConfiguration"
) //$NON-NLS-1$
+                        + "\n\n" // TODO
+                        + Messages.getString( "CreateConnectionAction.FollowingErrorOccurred"
) + e.getMessage(); //$NON-NLS-1$
+
+                    reportErrorReadingServerConfiguration( view, message );
+                    return;
+                }
+
+                // Checking if we could read the 'server.xml' file
+                if ( serverConfiguration == null )
+                {
+                    reportErrorReadingServerConfiguration( view,
+                        Messages.getString( "CreateConnectionAction.UnableReadServerConfiguration"
) ); //$NON-NLS-1$
+                    return;
+                }
+
+                // Checking is LDAP and/or LDAPS is/are enabled
+                if ( ( serverConfiguration.isEnableLdap() ) || ( serverConfiguration.isEnableLdaps()
) )
+                {
+                    // Creating the connection using the helper class
+                    createConnection( server, serverConfiguration );
+                }
+                else
+                {
+                    // LDAP and LDAPS protocols are disabled, we report this error to the
user
+                    MessageDialog dialog = new MessageDialog( view.getSite().getShell(),
+                        Messages.getString( "CreateConnectionAction.UnableCreateConnection"
), null, //$NON-NLS-1$
+                        Messages.getString( "CreateConnectionAction.LDAPAndLDAPSDisabled"
), MessageDialog.ERROR, //$NON-NLS-1$
+                        new String[]
+                            { IDialogConstants.OK_LABEL }, MessageDialog.OK );
+                    dialog.open();
+                    // TODO use common methods in Common UI plugin
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Reports to the user an error message indicating the server 
+     * configuration could not be read correctly.
+     *
+     * @param message
+     *      the message
+     */
+    private void reportErrorReadingServerConfiguration( ServersView view, String message
)
+    {
+        MessageDialog dialog = new MessageDialog( view.getSite().getShell(),
+            Messages.getString( "CreateConnectionAction.UnableReadServerConfiguration" ),
//$NON-NLS-1$
+            null, message, MessageDialog.ERROR, new String[]
+                { IDialogConstants.OK_LABEL }, MessageDialog.OK );
+        dialog.open();
+        // TODO use common methods in Common UI plugin
+    }
+
+
+    /**
+     * Creates the connection
+     */
+    private void createConnection( LdapServer server, ServerConfigurationV156 configuration
)
+    {
+        // Creating the connection parameter object
+        ConnectionParameter connectionParameter = new ConnectionParameter();
+
+        // Authentication method
+        connectionParameter.setAuthMethod( AuthenticationMethod.SIMPLE );
+
+        // LDAP or LDAPS?
+        if ( configuration.isEnableLdap() )
+        {
+            connectionParameter.setEncryptionMethod( EncryptionMethod.NONE );
+            connectionParameter.setPort( configuration.getLdapPort() );
+        }
+        else if ( configuration.isEnableLdaps() )
+        {
+            connectionParameter.setEncryptionMethod( EncryptionMethod.LDAPS );
+            connectionParameter.setPort( configuration.getLdapsPort() );
+        }
+
+        // Bind password
+        connectionParameter.setBindPassword( "secret" ); //$NON-NLS-1$
+
+        // Bind principal
+        connectionParameter.setBindPrincipal( "uid=admin,ou=system" ); //$NON-NLS-1$
+
+        // Host
+        connectionParameter.setHost( "localhost" ); //$NON-NLS-1$
+
+        // Name
+        connectionParameter.setName( server.getName() );
+
+        // Creating the connection
+        CreateConnectionActionHelper.createLdapBrowserConnection( server, new Connection(
connectionParameter ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void selectionChanged( IAction action, ISelection selection )
+    {
+        // Nothing to do
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setActivePart( IAction action, IWorkbenchPart targetPart )
+    {
+        // Storing the Servers view
+        if ( targetPart instanceof ServersView )
+        {
+            view = ( ServersView ) targetPart;
+        }
+    }
+}

Modified: directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/messages.properties?rev=994948&r1=994947&r2=994948&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/messages.properties
(original)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/messages.properties
Wed Sep  8 09:49:16 2010
@@ -16,3 +16,9 @@
 # under the License.
 
 ApacheDS156Plugin.UnableGetPluginProperties=Unable to get the plugin properties.
+
+CreateConnectionAction.FollowingErrorOccurred=The following error occurred\: 
+CreateConnectionAction.LDAPAndLDAPSDisabled=LDAP and LDAPS protocols are disabled. A connection
cannot be created.
+CreateConnectionAction.NotA156Server=This server is not an ApacheDS 1.5.6 server.
+CreateConnectionAction.UnableCreateConnection=Unable to create a connection
+CreateConnectionAction.UnableReadServerConfiguration=Unable to read the server configuration.

Modified: directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/messages_de.properties?rev=994948&r1=994947&r2=994948&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/messages_de.properties
(original)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/messages_de.properties
Wed Sep  8 09:49:16 2010
@@ -16,3 +16,9 @@
 # under the License.
 
 ApacheDS156Plugin.UnableGetPluginProperties=Die Plugin Eigenschaften k\u00F6nnen nicht geladen
werden.
+
+CreateConnectionAction.FollowingErrorOccurred=Es ist folgender Fehler aufgetreten\: 
+CreateConnectionAction.LDAPAndLDAPSDisabled=Die Protokolle LDAP und LDAPS sind gesperrt.
Es kann keine Verbindung erstellt werden.
+CreateConnectionAction.NotA156Server=TODO:This server is not an ApacheDS 1.5.6 server.
+CreateConnectionAction.UnableCreateConnection=Unf\u00E4hig eine Verbindung zu erstellen
+CreateConnectionAction.UnableReadServerConfiguration=Unf\u00E4hig die Server Konfiguration
zu lesen.

Modified: directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/messages_fr.properties?rev=994948&r1=994947&r2=994948&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/messages_fr.properties
(original)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/messages_fr.properties
Wed Sep  8 09:49:16 2010
@@ -16,3 +16,9 @@
 # under the License.
 
 ApacheDS156Plugin.UnableGetPluginProperties=Impossible de r\u00E9cup\u00E9rer les propri\u00E9t\u00E9s
de ce plugin
+
+CreateConnectionAction.FollowingErrorOccurred= L'erreur suivante est survenue \:
+CreateConnectionAction.LDAPAndLDAPSDisabled=Les protocoles LDAP et LDAPS sont d\u00E9sactiv\u00E9s.
Il n'est pas possible de cr\u00E9er une connexion. 
+CreateConnectionAction.NotA156Server=Ce serveur n'est pas un serveur ApacheDS 1.5.6.
+CreateConnectionAction.UnableCreateConnection=Impossible de cr\u00E9er une connexion.
+CreateConnectionAction.UnableReadServerConfiguration=Impossible de lire la configuration
du serveur.



Mime
View raw message