Author: pamarcelot
Date: Mon Sep 29 02:59:02 2008
New Revision: 700040
URL: http://svn.apache.org/viewvc?rev=700040&view=rev
Log:
Part of a fix for DIRSTUDIO-405 (Update the Apache DS plugin to use Apache DS 1.5.4 dependencies).
Modified:
directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginUtils.java
directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/CreateConnectionAction.java
directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/CreateConnectionActionHelper.java
directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RunAction.java
directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/jobs/LaunchServerJob.java
Modified: directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginUtils.java?rev=700040&r1=700039&r2=700040&view=diff
==============================================================================
--- directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginUtils.java
(original)
+++ directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginUtils.java
Mon Sep 29 02:59:02 2008
@@ -21,12 +21,17 @@
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
+import org.apache.directory.studio.apacheds.configuration.model.ServerConfiguration;
+import org.apache.directory.studio.apacheds.configuration.model.ServerXmlIOException;
+import org.apache.directory.studio.apacheds.configuration.model.v153.ServerXmlIOV153;
+import org.apache.directory.studio.apacheds.configuration.model.v154.ServerXmlIOV154;
import org.apache.directory.studio.apacheds.model.Server;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
@@ -90,7 +95,7 @@
{
try
{
- copyLibrary( apachedsLibraryFilename, apachedsLibrary );
+ copyLibrary( apachedsLibraryFilename, apachedsLibrary, server );
}
catch ( IOException e )
{
@@ -179,14 +184,17 @@
* the name of the library
* @param destination
* the destination
+ * @param server
+ * the server
* @throws IOException
* if an error occurrs when copying the jar file
*/
- private static void copyLibrary( String library, File destination ) throws IOException
+ private static void copyLibrary( String library, File destination, Server server ) throws
IOException
{
// Getting he URL of the library within the bundle
URL libraryUrl = FileLocator.find( ApacheDsPlugin.getDefault().getBundle(), new Path(
RESOURCES
- + IPath.SEPARATOR + LIBS + IPath.SEPARATOR + library ), null );
+ + IPath.SEPARATOR + LIBS + IPath.SEPARATOR + APACHEDS + "-" + server.getVersion().toString()
+ + IPath.SEPARATOR + library ), null );
// Creating the input and output streams
InputStream libraryInputStream = libraryUrl.openStream();
@@ -513,4 +521,35 @@
{ IDialogConstants.OK_LABEL }, MessageDialog.OK );
dialog.open();
}
+
+ /**
+ * Gets the server configuration.
+ *
+ * @param server
+ * the server
+ * @return
+ * the associated server configuration
+ * @throws ServerXmlIOException
+ * @throws ServerXmlIOException
+ * @throws IOException
+ */
+ public static ServerConfiguration getServerConfiguration( Server server ) throws ServerXmlIOException,
IOException
+ {
+ InputStream fis = new FileInputStream( new File( ApacheDsPluginUtils.getApacheDsServersFolder().append(
+ server.getId() ).append( "conf" ).append( "server.xml" ).toOSString() ) );
+
+ // Parsing and returning the server configuration
+ switch ( server.getVersion() )
+ {
+ case VERSION_1_5_4:
+ ServerXmlIOV154 serverXmlIOV154 = new ServerXmlIOV154();
+ return serverXmlIOV154.parse( fis );
+ case VERSION_1_5_3:
+ ServerXmlIOV153 serverXmlIOV153 = new ServerXmlIOV153();
+ return serverXmlIOV153.parse( fis );
+ }
+
+ // No corresponding reader has been found, we return null
+ return null;
+ }
}
Modified: directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/CreateConnectionAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/CreateConnectionAction.java?rev=700040&r1=700039&r2=700040&view=diff
==============================================================================
--- directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/CreateConnectionAction.java
(original)
+++ directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/CreateConnectionAction.java
Mon Sep 29 02:59:02 2008
@@ -20,17 +20,16 @@
package org.apache.directory.studio.apacheds.actions;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
+import java.io.IOException;
import java.util.PropertyResourceBundle;
import org.apache.directory.studio.apacheds.ApacheDsPlugin;
import org.apache.directory.studio.apacheds.ApacheDsPluginConstants;
import org.apache.directory.studio.apacheds.ApacheDsPluginUtils;
+import org.apache.directory.studio.apacheds.configuration.model.ServerConfiguration;
import org.apache.directory.studio.apacheds.configuration.model.ServerXmlIOException;
import org.apache.directory.studio.apacheds.configuration.model.v153.ServerConfigurationV153;
-import org.apache.directory.studio.apacheds.configuration.model.v153.ServerXmlIOV153;
+import org.apache.directory.studio.apacheds.configuration.model.v154.ServerConfigurationV154;
import org.apache.directory.studio.apacheds.model.Server;
import org.apache.directory.studio.apacheds.views.ServersView;
import org.eclipse.core.runtime.Platform;
@@ -111,15 +110,12 @@
Server server = ( Server ) selection.getFirstElement();
// Parsing the 'server.xml' file
- ServerXmlIOV153 serverXmlIOV153 = new ServerXmlIOV153();
- ServerConfigurationV153 serverConfiguration = null;
+ ServerConfiguration serverConfiguration = null;
try
{
- serverConfiguration = ( ServerConfigurationV153 ) serverXmlIOV153.parse(
new FileInputStream(
- new File( ApacheDsPluginUtils.getApacheDsServersFolder().append(
server.getId() ).append(
- "conf" ).append( "server.xml" ).toOSString() ) ) );
+ serverConfiguration = ApacheDsPluginUtils.getServerConfiguration( server
);
}
- catch ( FileNotFoundException e )
+ catch ( IOException e )
{
reportErrorReadingServerConfiguration( e.getMessage() );
return;
@@ -137,7 +133,7 @@
return;
}
- if ( ( serverConfiguration.isEnableLdap() ) || ( serverConfiguration.isEnableLdaps()
) )
+ if ( isEnableLdapOrLdaps( serverConfiguration ))
{
// Creating the connection using the helper class
CreateConnectionActionHelper.createLdapBrowserConnection( server.getName(),
serverConfiguration );
@@ -186,6 +182,31 @@
/**
+ * Indicates if LDAP or LDAPS is enabled.
+ *
+ * @param serverConfiguration
+ * the server configuration
+ * @return
+ * <code>true</code> if LDAP or LDAPS is enabled, <code>false</code>
if not
+ */
+ private boolean isEnableLdapOrLdaps( ServerConfiguration serverConfiguration )
+ {
+ if ( serverConfiguration instanceof ServerConfigurationV154 )
+ {
+ ServerConfigurationV154 serverConfiguration154 = ( ServerConfigurationV154 )
serverConfiguration;
+ return ( serverConfiguration154.isEnableLdap() ) || ( serverConfiguration154.isEnableLdaps()
);
+ }
+ else if ( serverConfiguration instanceof ServerConfigurationV153 )
+ {
+ ServerConfigurationV153 serverConfiguration153 = ( ServerConfigurationV153 )
serverConfiguration;
+ return ( serverConfiguration153.isEnableLdap() ) || ( serverConfiguration153.isEnableLdaps()
);
+ }
+
+ return false;
+ }
+
+
+ /**
* Sets the enabled state of this action.
* <p>
* When an action is in the enabled state, the control associated with
@@ -230,7 +251,7 @@
private boolean isLdapBrowserPluginsAvailable()
{
PropertyResourceBundle properties = ApacheDsPlugin.getDefault().getPluginProperties();
-
+
// Connection Core Plugin
Bundle connectionCoreBundle = Platform.getBundle( properties.getString( "Plugin_ConnectionCore_id"
) );
if ( connectionCoreBundle != null )
@@ -252,7 +273,8 @@
}
// LDAP Browser Common Plugin
- Bundle ldapBrowserCommonBundle = Platform.getBundle( properties.getString(
"Plugin_LdapBrowserCommon_id" ) );
+ Bundle ldapBrowserCommonBundle = Platform.getBundle( properties
+ .getString( "Plugin_LdapBrowserCommon_id" ) );
if ( ldapBrowserCommonBundle != null )
{
// Checking the state of the plugin
@@ -262,7 +284,8 @@
}
// LDAP Browser Core Plugin
- Bundle ldapBrowserCoreBundle = Platform.getBundle( properties.getString(
"Plugin_LdapBrowserCore_id" ) );
+ Bundle ldapBrowserCoreBundle = Platform.getBundle( properties
+ .getString( "Plugin_LdapBrowserCore_id" ) );
if ( ldapBrowserCoreBundle != null )
{
// Checking the state of the plugin
@@ -272,7 +295,8 @@
}
// LDAP Browser UI Plugin
- Bundle ldapBrowserUiBundle = Platform.getBundle(properties.getString(
"Plugin_LdapBrowserUi_id" ) );
+ Bundle ldapBrowserUiBundle = Platform.getBundle( properties
+ .getString( "Plugin_LdapBrowserUi_id" ) );
if ( ldapBrowserUiBundle != null )
{
// Checking the state of the plugin
@@ -282,7 +306,8 @@
}
// LDIF Editor Plugin
- Bundle ldifEditorBundle = Platform.getBundle( properties.getString(
"Plugin_LdifEditor_id" ) );
+ Bundle ldifEditorBundle = Platform
+ .getBundle( properties.getString( "Plugin_LdifEditor_id"
) );
if ( ldifEditorBundle != null )
{
// Checking the state of the plugin
@@ -292,7 +317,8 @@
}
// LDIF Parser Plugin
- Bundle ldifParserBundle = Platform.getBundle( properties.getString(
"Plugin_LdifParser_id" ) );
+ Bundle ldifParserBundle = Platform.getBundle( properties
+ .getString( "Plugin_LdifParser_id" ) );
if ( ldifParserBundle != null )
{
// Checking the state of the plugin
Modified: directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/CreateConnectionActionHelper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/CreateConnectionActionHelper.java?rev=700040&r1=700039&r2=700040&view=diff
==============================================================================
--- directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/CreateConnectionActionHelper.java
(original)
+++ directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/CreateConnectionActionHelper.java
Mon Sep 29 02:59:02 2008
@@ -21,7 +21,9 @@
import org.apache.directory.studio.apacheds.ApacheDsPlugin;
+import org.apache.directory.studio.apacheds.configuration.model.ServerConfiguration;
import org.apache.directory.studio.apacheds.configuration.model.v153.ServerConfigurationV153;
+import org.apache.directory.studio.apacheds.configuration.model.v154.ServerConfigurationV154;
import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
import org.apache.directory.studio.connection.core.ConnectionParameter;
@@ -50,81 +52,96 @@
* @param serverConfiguration
* the server configuration
*/
- public static void createLdapBrowserConnection( String serverName, ServerConfigurationV153
serverConfiguration )
+ public static void createLdapBrowserConnection( String serverName, ServerConfiguration
serverConfiguration )
{
- if ( ( serverConfiguration.isEnableLdap() ) || ( serverConfiguration.isEnableLdaps()
) )
- {
- //Creating the connection parameter object
- ConnectionParameter connectionParameter = new ConnectionParameter();
+ //Creating the connection parameter object
+ ConnectionParameter connectionParameter = new ConnectionParameter();
- // Auth method
- connectionParameter.setAuthMethod( AuthenticationMethod.SIMPLE );
+ // Auth method
+ connectionParameter.setAuthMethod( AuthenticationMethod.SIMPLE );
- // Encryption method and port
- if ( serverConfiguration.isEnableLdap() )
+ // Encryption method and port
+ if ( serverConfiguration instanceof ServerConfigurationV154 )
+ {
+ ServerConfigurationV154 serverConfiguration154 = ( ServerConfigurationV154 )
serverConfiguration;
+ if ( serverConfiguration154.isEnableLdap() )
{
connectionParameter.setEncryptionMethod( EncryptionMethod.NONE );
- connectionParameter.setPort( serverConfiguration.getLdapPort() );
+ connectionParameter.setPort( serverConfiguration154.getLdapPort() );
}
- else if ( serverConfiguration.isEnableLdaps() )
+ else if ( serverConfiguration154.isEnableLdaps() )
{
connectionParameter.setEncryptionMethod( EncryptionMethod.LDAPS );
- connectionParameter.setPort( serverConfiguration.getLdapsPort() );
+ connectionParameter.setPort( serverConfiguration154.getLdapsPort() );
}
+ }
+ else if ( serverConfiguration instanceof ServerConfigurationV153 )
+ {
+ ServerConfigurationV153 serverConfiguration153 = ( ServerConfigurationV153 )
serverConfiguration;
+ if ( serverConfiguration153.isEnableLdap() )
+ {
+ connectionParameter.setEncryptionMethod( EncryptionMethod.NONE );
+ connectionParameter.setPort( serverConfiguration153.getLdapPort() );
+ }
+ else if ( serverConfiguration153.isEnableLdaps() )
+ {
+ connectionParameter.setEncryptionMethod( EncryptionMethod.LDAPS );
+ connectionParameter.setPort( serverConfiguration153.getLdapsPort() );
+ }
+ }
- // Bind password
- connectionParameter.setBindPassword( "secret" );
+ // Bind password
+ connectionParameter.setBindPassword( "secret" );
- // Bind principal
- connectionParameter.setBindPrincipal( "uid=admin,ou=system" );
+ // Bind principal
+ connectionParameter.setBindPrincipal( "uid=admin,ou=system" );
- // Host
- connectionParameter.setHost( "localhost" );
-
- // Name
- connectionParameter.setName( serverName );
-
- // Creating the connection
- Connection connection = new Connection( connectionParameter );
-
- // Adding the connection to the connection manager
- ConnectionCorePlugin.getDefault().getConnectionManager().addConnection( connection
);
-
- // Adding the connection to the root connection folder
- ConnectionCorePlugin.getDefault().getConnectionFolderManager().getRootConnectionFolder().addConnectionId(
- connection.getId() );
-
- // Getting the window, LDAP perspective and current perspective
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- IPerspectiveDescriptor ldapPerspective = getLdapPerspective();
- IPerspectiveDescriptor currentPerspective = window.getActivePage().getPerspective();
-
- // Checking if we are already in the LDAP perspective
- if ( ( ldapPerspective != null ) && ( ldapPerspective.equals( currentPerspective
) ) )
- {
- // As we're already in the LDAP perspective, we only indicate to the user
- // the name of the connection that has been created
- MessageDialog dialog = new MessageDialog( window.getShell(), "Connection
created", null,
- "A connection called '" + connection.getName() + "' has been created.",
MessageDialog.INFORMATION,
- new String[]
- { IDialogConstants.OK_LABEL }, MessageDialog.OK );
- dialog.open();
- }
- else
- {
- // We're not already in the LDAP perspective, we indicate to the user
- // the name of the connection that has been created and we ask him
- // if we wants to switch to the LDAP perspective
- MessageDialog dialog = new MessageDialog( window.getShell(), "Connection
created", null,
- "A connection called '" + connection.getName()
- + "' has been created.\n\nDo you want to switch to the LDAP perspective
?",
- MessageDialog.INFORMATION, new String[]
- { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, MessageDialog.OK
);
- if ( dialog.open() == MessageDialog.OK )
- {
- // Switching to the LDAP perspective
- window.getActivePage().setPerspective( ldapPerspective );
- }
+ // Host
+ connectionParameter.setHost( "localhost" );
+
+ // Name
+ connectionParameter.setName( serverName );
+
+ // Creating the connection
+ Connection connection = new Connection( connectionParameter );
+
+ // Adding the connection to the connection manager
+ ConnectionCorePlugin.getDefault().getConnectionManager().addConnection( connection
);
+
+ // Adding the connection to the root connection folder
+ ConnectionCorePlugin.getDefault().getConnectionFolderManager().getRootConnectionFolder().addConnectionId(
+ connection.getId() );
+
+ // Getting the window, LDAP perspective and current perspective
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IPerspectiveDescriptor ldapPerspective = getLdapPerspective();
+ IPerspectiveDescriptor currentPerspective = window.getActivePage().getPerspective();
+
+ // Checking if we are already in the LDAP perspective
+ if ( ( ldapPerspective != null ) && ( ldapPerspective.equals( currentPerspective
) ) )
+ {
+ // As we're already in the LDAP perspective, we only indicate to the user
+ // the name of the connection that has been created
+ MessageDialog dialog = new MessageDialog( window.getShell(), "Connection created",
null,
+ "A connection called '" + connection.getName() + "' has been created.", MessageDialog.INFORMATION,
+ new String[]
+ { IDialogConstants.OK_LABEL }, MessageDialog.OK );
+ dialog.open();
+ }
+ else
+ {
+ // We're not already in the LDAP perspective, we indicate to the user
+ // the name of the connection that has been created and we ask him
+ // if we wants to switch to the LDAP perspective
+ MessageDialog dialog = new MessageDialog( window.getShell(), "Connection created",
null,
+ "A connection called '" + connection.getName()
+ + "' has been created.\n\nDo you want to switch to the LDAP perspective
?",
+ MessageDialog.INFORMATION, new String[]
+ { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, MessageDialog.OK
);
+ if ( dialog.open() == MessageDialog.OK )
+ {
+ // Switching to the LDAP perspective
+ window.getActivePage().setPerspective( ldapPerspective );
}
}
}
Modified: directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RunAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RunAction.java?rev=700040&r1=700039&r2=700040&view=diff
==============================================================================
--- directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RunAction.java
(original)
+++ directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RunAction.java
Mon Sep 29 02:59:02 2008
@@ -118,7 +118,7 @@
ServerConfiguration serverConfiguration = null;
try
{
- serverConfiguration = getServerConfiguration( server );
+ serverConfiguration = ApacheDsPluginUtils.getServerConfiguration( server
);
}
catch ( IOException e )
{
@@ -188,55 +188,6 @@
/**
- * Gets the server configuration.
- *
- * @param server
- * the server
- * @return
- * the associated server configuration
- * @throws ServerXmlIOException
- * @throws ServerXmlIOException
- * @throws IOException
- */
- private ServerConfiguration getServerConfiguration( Server server ) throws ServerXmlIOException,
IOException
- {
- InputStream fis = new FileInputStream( new File( ApacheDsPluginUtils.getApacheDsServersFolder().append(
- server.getId() ).append( "conf" ).append( "server.xml" ).toOSString() ) );
-
- // First we test with version 1.5.4
- ServerXmlIOV154 serverXmlIOV154 = new ServerXmlIOV154();
- if ( serverXmlIOV154.isValid( fis ) )
- {
- // Reseting the input stream
- fis = new FileInputStream( new File( ApacheDsPluginUtils.getApacheDsServersFolder().append(
server.getId() )
- .append( "conf" ).append( "server.xml" ).toOSString() ) );
-
- // Parsing and returning the server configuration
- return serverXmlIOV154.parse( fis );
- }
-
- // Reseting the input stream
- fis = new FileInputStream( new File( ApacheDsPluginUtils.getApacheDsServersFolder().append(
server.getId() )
- .append( "conf" ).append( "server.xml" ).toOSString() ) );
-
- // Then we test with version 1.5.3
- ServerXmlIOV153 serverXmlIOV153 = new ServerXmlIOV153();
- if ( serverXmlIOV153.isValid( fis ) )
- {
- // Reseting the input stream
- fis = new FileInputStream( new File( ApacheDsPluginUtils.getApacheDsServersFolder().append(
server.getId() )
- .append( "conf" ).append( "server.xml" ).toOSString() ) );
-
- // Parsing and returning the server configuration
- return serverXmlIOV153.parse( fis );
- }
-
- // No corresponding reader has been found, we return null
- return null;
- }
-
-
- /**
* Reports to the user an error message indicating the server
* configuration could not be read correctly.
*
Modified: directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/jobs/LaunchServerJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/jobs/LaunchServerJob.java?rev=700040&r1=700039&r2=700040&view=diff
==============================================================================
--- directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/jobs/LaunchServerJob.java
(original)
+++ directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/jobs/LaunchServerJob.java
Mon Sep 29 02:59:02 2008
@@ -236,7 +236,7 @@
{
return getTestingPortVersion154( ( ServerConfigurationV154 ) configuration
);
}
- else if ( configuration instanceof ServerConfigurationV154 )
+ else if ( configuration instanceof ServerConfigurationV153 )
{
return getTestingPortVersion153( ( ServerConfigurationV153 ) configuration
);
}
@@ -251,7 +251,7 @@
* Gets the testing port.
*
* @param configuration
- * the 1.5.4 server configuration
+ * the 1.5.3 server configuration
* @return
* the testing port
*/
|