directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1174869 [2/2] - in /directory/studio/trunk: ./ application/application-plugins/ plugins/ plugins/ldapservers.apacheds.v200/ plugins/ldapservers.apacheds.v200/resources/ plugins/ldapservers.apacheds.v200/resources/conf/ plugins/ldapservers....
Date Fri, 23 Sep 2011 16:25:12 GMT
Added: directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/CreateConnectionAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/CreateConnectionAction.java?rev=1174869&view=auto
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/CreateConnectionAction.java
(added)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/CreateConnectionAction.java
Fri Sep 23 16:25:10 2011
@@ -0,0 +1,208 @@
+/*
+ *  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.v200;
+
+
+import org.apache.directory.studio.apacheds.configuration.model.v157.ServerConfigurationV157;
+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.connection.core.ConnectionParameter.NetworkProvider;
+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 2.0.0 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.2.0.0";
+
+    /** 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.7 server
+                // TODO
+                if ( !EXTENSION_ID.equalsIgnoreCase( server.getLdapServerAdapterExtension().getId()
) )
+                {
+                    String message = Messages.getString( "CreateConnectionAction.UnableReadServerConfiguration"
) //$NON-NLS-1$
+                        + "\n\n" // TODO
+                        + Messages.getString( "CreateConnectionAction.NotA157Server" ); //$NON-NLS-1$
+
+                    reportErrorReadingServerConfiguration( view, message );
+                    return;
+                }
+
+                // Parsing the 'server.xml' file
+                ServerConfigurationV157 serverConfiguration = null;
+                try
+                {
+                    serverConfiguration = ApacheDS200LdapServerAdapter.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, ServerConfigurationV157 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() );
+        
+        // Network Provider
+        connectionParameter.setNetworkProvider( NetworkProvider.JNDI );
+
+        // 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;
+        }
+    }
+}

Added: directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/Messages.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/Messages.java?rev=1174869&view=auto
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/Messages.java
(added)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/Messages.java
Fri Sep 23 16:25:10 2011
@@ -0,0 +1,50 @@
+/*
+ *  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.v200;
+
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+
+public class Messages
+{
+    private static final String BUNDLE_NAME = "org.apache.directory.studio.ldapservers.apacheds.v200.messages";
//$NON-NLS-1$
+
+    private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME
);
+
+
+    private Messages()
+    {
+    }
+
+
+    public static String getString( String key )
+    {
+        try
+        {
+            return RESOURCE_BUNDLE.getString( key );
+        }
+        catch ( MissingResourceException e )
+        {
+            return '!' + key + '!';
+        }
+    }
+}

Added: directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/messages.properties?rev=1174869&view=auto
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/messages.properties
(added)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/messages.properties
Fri Sep 23 16:25:10 2011
@@ -0,0 +1,24 @@
+# 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.
+
+ApacheDS200Plugin.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.NotA157Server=This server is not an ApacheDS 2.0.0 server.
+CreateConnectionAction.UnableCreateConnection=Unable to create a connection
+CreateConnectionAction.UnableReadServerConfiguration=Unable to read the server configuration.

Added: directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/messages_de.properties?rev=1174869&view=auto
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/messages_de.properties
(added)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/messages_de.properties
Fri Sep 23 16:25:10 2011
@@ -0,0 +1,24 @@
+# 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.
+
+ApacheDS200Plugin.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.NotA157Server=TODO:This server is not an ApacheDS 2.0.0 server.
+CreateConnectionAction.UnableCreateConnection=Unf\u00E4hig eine Verbindung zu erstellen
+CreateConnectionAction.UnableReadServerConfiguration=Unf\u00E4hig die Server Konfiguration
zu lesen.

Added: directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/messages_fr.properties?rev=1174869&view=auto
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/messages_fr.properties
(added)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/messages_fr.properties
Fri Sep 23 16:25:10 2011
@@ -0,0 +1,24 @@
+# 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.
+
+ApacheDS200Plugin.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.NotA157Server=Ce serveur n'est pas un serveur ApacheDS 2.0.0.
+CreateConnectionAction.UnableCreateConnection=Impossible de cr\u00E9er une connexion.
+CreateConnectionAction.UnableReadServerConfiguration=Impossible de lire la configuration
du serveur.

Modified: directory/studio/trunk/plugins/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/pom.xml?rev=1174869&r1=1174868&r2=1174869&view=diff
==============================================================================
--- directory/studio/trunk/plugins/pom.xml (original)
+++ directory/studio/trunk/plugins/pom.xml Fri Sep 23 16:25:10 2011
@@ -49,6 +49,7 @@
     <module>ldapservers.apacheds.v155</module>
     <module>ldapservers.apacheds.v156</module>
     <module>ldapservers.apacheds.v157</module>
+    <module>ldapservers.apacheds.v200</module>
     <module>ldifeditor</module>
     <module>ldifparser</module>
     <module>rcp</module>

Modified: directory/studio/trunk/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/pom.xml?rev=1174869&r1=1174868&r2=1174869&view=diff
==============================================================================
--- directory/studio/trunk/pom.xml (original)
+++ directory/studio/trunk/pom.xml Fri Sep 23 16:25:10 2011
@@ -482,6 +482,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.directory.studio</groupId>
+        <artifactId>ldapservers.apacheds.v200</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.directory.studio</groupId>
         <artifactId>ldifeditor</artifactId>
         <version>${project.version}</version>
       </dependency>



Mime
View raw message