();
+
+ try
+ {
+ ConfigBean configuration = getServerConfiguration( server );
+
+ // LDAP
+ if ( isEnableLdap( configuration ) )
+ {
+ if ( !AvailablePortFinder.available( getLdapPort( configuration ) ) )
+ {
+ alreadyInUseProtocolPortsList
+ .add( NLS.bind(
+ Messages.getString( "ApacheDS200LdapServerAdapter.LDAPPort" ), new Object[] { getLdapPort( configuration ) } ) ); //$NON-NLS-1$
+ }
+ }
+
+ // LDAPS
+ if ( isEnableLdaps( configuration ) )
+ {
+ if ( !AvailablePortFinder.available( getLdapsPort( configuration ) ) )
+ {
+ alreadyInUseProtocolPortsList
+ .add( NLS.bind(
+ Messages.getString( "ApacheDS200LdapServerAdapter.LDAPSPort" ), new Object[] { getLdapsPort( configuration ) } ) ); //$NON-NLS-1$
+ }
+ }
+
+ // Kerberos
+ if ( isEnableKerberos( configuration ) )
+ {
+ if ( !AvailablePortFinder.available( getKerberosPort( configuration ) ) )
+ {
+ alreadyInUseProtocolPortsList
+ .add( NLS
+ .bind(
+ Messages.getString( "ApacheDS200LdapServerAdapter.KerberosPort" ), new Object[] { getKerberosPort( configuration ) } ) ); //$NON-NLS-1$
+ }
+ }
+
+ // DNS
+ if ( isEnableDns( configuration ) )
+ {
+ if ( !AvailablePortFinder.available( getDnsPort( configuration ) ) )
+ {
+ alreadyInUseProtocolPortsList
+ .add( NLS.bind(
+ Messages.getString( "ApacheDS200LdapServerAdapter.DNSPort" ), new Object[] { getDnsPort( configuration ) } ) ); //$NON-NLS-1$
+ }
+ }
+
+ // NTP
+ if ( isEnableNtp( configuration ) )
+ {
+ if ( !AvailablePortFinder.available( getNtpPort( configuration ) ) )
+ {
+ alreadyInUseProtocolPortsList.add( NLS.bind(
+ Messages.getString( "ApacheDS200LdapServerAdapter.NTPPort" ), new Object[] //$NON-NLS-1$
+ { getNtpPort( configuration ) } ) );
+ }
+ }
+
+ // Change Password
+ if ( isEnableChangePassword( configuration ) )
+ {
+ if ( !AvailablePortFinder.available( getChangePasswordPort( configuration ) ) )
+ {
+ alreadyInUseProtocolPortsList
+ .add( NLS
+ .bind(
+ Messages.getString( "ApacheDS200LdapServerAdapter.ChangePasswordPort" ), new Object[] { getChangePasswordPort( configuration ) } ) ); //$NON-NLS-1$
+ }
+ }
+ }
+ catch ( Exception e )
+ {
+ System.out.println( e );
+ }
+
+ return alreadyInUseProtocolPortsList.toArray( new String[0] );
+ }
}
Modified: 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=1179279&r1=1179278&r2=1179279&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/messages.properties (original)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/messages.properties Wed Oct 5 15:50:16 2011
@@ -15,9 +15,15 @@
# specific language governing permissions and limitations
# under the License.
-ApacheDS200Plugin.UnableGetPluginProperties=Unable to get the plugin properties.
-
ApacheDS200LdapServerAdapter.Starting=Starting {0}...
+ApacheDS200LdapServerAdapter.LDAPPort=LDAP (port {0})
+ApacheDS200LdapServerAdapter.LDAPSPort=LDAPS (port {0})
+ApacheDS200LdapServerAdapter.KerberosPort=Kerberos (port {0})
+ApacheDS200LdapServerAdapter.DNSPort=DNS (port {0})
+ApacheDS200LdapServerAdapter.NTPPort=NTP (port {0})
+ApacheDS200LdapServerAdapter.ChangePasswordPort=ChangePassword (port {0})
+
+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.
Modified: directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/StartAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/StartAction.java?rev=1179279&r1=1179278&r2=1179279&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/StartAction.java (original)
+++ directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/StartAction.java Wed Oct 5 15:50:16 2011
@@ -25,11 +25,16 @@ import org.apache.directory.studio.ldaps
import org.apache.directory.studio.ldapservers.jobs.StartLdapServerRunnable;
import org.apache.directory.studio.ldapservers.jobs.StudioLdapServerJob;
import org.apache.directory.studio.ldapservers.model.LdapServer;
+import org.apache.directory.studio.ldapservers.model.LdapServerAdapter;
+import org.apache.directory.studio.ldapservers.model.LdapServerAdapterExtension;
import org.apache.directory.studio.ldapservers.views.ServersView;
import org.eclipse.jface.action.Action;
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.osgi.util.NLS;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
@@ -95,9 +100,56 @@ public class StartAction extends Action
// Getting the server
LdapServer server = ( LdapServer ) selection.getFirstElement();
- // Creating and scheduling the job to start the server
- StudioLdapServerJob job = new StudioLdapServerJob( new StartLdapServerRunnable( server ) );
- job.schedule();
+ LdapServerAdapterExtension ldapServerAdapterExtension = server.getLdapServerAdapterExtension();
+ if ( ( ldapServerAdapterExtension != null ) && ( ldapServerAdapterExtension.getInstance() != null ) )
+ {
+ LdapServerAdapter ldapServerAdapter = ldapServerAdapterExtension.getInstance();
+
+ // Getting the ports already in use
+ String[] portsAlreadyInUse = ldapServerAdapter.checkPortsBeforeServerStart( server );
+ if ( ( portsAlreadyInUse == null ) || ( portsAlreadyInUse.length > 0 ) )
+ {
+ String title = null;
+ String message = null;
+
+ if ( portsAlreadyInUse.length == 1 )
+ {
+ title = Messages.getString( "StartAction.PortInUse" ); //$NON-NLS-1$
+ message = NLS
+ .bind(
+ Messages.getString( "StartAction.PortOfProtocolInUse" ), new String[] { portsAlreadyInUse[0] } ); //$NON-NLS-1$
+ }
+ else
+ {
+ title = Messages.getString( "StartAction.PortsInUse" ); //$NON-NLS-1$
+ message = Messages.getString( "StartAction.PortsOfProtocolsInUse" ); //$NON-NLS-1$
+ for ( String portAlreadyInUse : portsAlreadyInUse )
+ {
+ message += "\n - " + portAlreadyInUse; //$NON-NLS-1$
+ }
+ }
+
+ message += "\n\n" + Messages.getString( "StartAction.Continue" ); //$NON-NLS-1$
+
+ MessageDialog dialog = new MessageDialog( view.getSite().getShell(), title, null, message,
+ MessageDialog.WARNING, new String[]
+ { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, MessageDialog.OK );
+ if ( dialog.open() == MessageDialog.CANCEL )
+ {
+ return;
+ }
+ }
+
+ // Creating and scheduling the job to start the server
+ StudioLdapServerJob job = new StudioLdapServerJob( new StartLdapServerRunnable( server ) );
+ job.schedule();
+ }
+ else
+ {
+ // Showing an error in case no LDAP Server Adapter can be found
+ MessageDialog.openError( view.getSite().getShell(), "No LDAP Server Adapter",
+ "This server can't be started.\nNo LDAP Server Adapter could be found for this server." );
+ }
}
}
}
Modified: directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages.properties?rev=1179279&r1=1179278&r2=1179279&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages.properties (original)
+++ directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages.properties Wed Oct 5 15:50:16 2011
@@ -39,20 +39,19 @@ RenameAction.RenameToolTip=Rename...
RenameAction.Server=Server
StartAction.ChangePasswordPort=ChangePassword (port {0})
-StartAction.Continue=Do you wish to continue?
StartAction.DNSPort=DNS (port {0})
-StartAction.FollowingErrorOccurred=The following error occurred\:
StartAction.KerberosPort=Kerberos (port {0})
StartAction.LDAPPort=LDAP (port {0})
StartAction.LDAPSPort=LDAPS (port {0})
StartAction.NTPPort=NTP (port {0})
+
+StartAction.Continue=Do you wish to continue?
StartAction.PortInUse=Port already in use
StartAction.PortOfProtocolInUse=The port of the protocol {0} is already in use.
StartAction.PortsInUse=Ports already in use
StartAction.PortsOfProtocolsInUse=The ports of the following protocols are already in use\:
StartAction.Start=&Run
StartAction.StartToolTip=Run
-StartAction.UnableReadServerConfiguration=Unable to read the server configuration.
StopAction.ErrorWhenStopping=An error occurred when stopping the server.\n\n
StopAction.ErrorWhenWriting=An error occurred when writing to the Info console message stream.\n\n
Modified: directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages_de.properties?rev=1179279&r1=1179278&r2=1179279&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages_de.properties (original)
+++ directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages_de.properties Wed Oct 5 15:50:16 2011
@@ -38,12 +38,10 @@ RenameAction.Rename=Umb&enennen...
RenameAction.RenameToolTip=Umbenennen...
StartAction.Continue=Wollen Sie weiterfahren?
-StartAction.FollowingErrorOccurred=Folgender Fehler ist aufgetreten\:
StartAction.PortInUse=Der Port wird bereits verwendet
StartAction.PortOfProtocolInUse=Der Port des Protokolls {0} wird bereits verwendet.
StartAction.PortsInUse=Die Ports werden bereits verwendet
StartAction.PortsOfProtocolsInUse=Die Ports folgender Protokolle werden bereits verwendet\:
-StartAction.UnableReadServerConfiguration=Unf\u00E4hig die Server Konfiguration zu lesen.
StartAction.Start=&Starten
StartAction.StartToolTip=Starten
Modified: directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages_fr.properties?rev=1179279&r1=1179278&r2=1179279&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages_fr.properties (original)
+++ directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages_fr.properties Wed Oct 5 15:50:16 2011
@@ -48,14 +48,12 @@ RenameAction.RenameToolTip=Renommer...
RenameAction.Server=Serveur
StartAction.Continue=Voulez-vous poursuivre l'op\u00E9ration ?
-StartAction.FollowingErrorOccurred=L'erreur suivante est survenue \:
StartAction.PortInUse=Le port est d\u00E9j\u00E0 utilis\u00E9
StartAction.PortOfProtocolInUse=Le port associ\u00E9 au protocole "{0}" est d\u00E9j\u00E0 utilis\u00E9.
StartAction.PortsInUse=Les ports sont d\u00E9j\u00E0 utilis\u00E9s.
StartAction.PortsOfProtocolsInUse=Les ports associ\u00E9s aux protocoles suivants sont d\u00E9j\u00E0 utilis\u00E9s \:
StartAction.Start=&D\u00E9marrer
StartAction.StartToolTip=D\u00E9marrer
-StartAction.UnableReadServerConfiguration=Impossible de lire la configuration du serveur.
StopAction.ErrorWhenStopping=Une erreur est survenue lors de l'arr\u00EAt du serveur.\n\n
StopAction.ErrorWhenWriting=Une erreur est survenue lors de l'\u00E9criture dans la console d'information.\n\n
Modified: directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServerAdapter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServerAdapter.java?rev=1179279&r1=1179278&r2=1179279&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServerAdapter.java (original)
+++ directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServerAdapter.java Wed Oct 5 15:50:16 2011
@@ -21,11 +21,7 @@
package org.apache.directory.studio.ldapservers.model;
-import java.util.List;
-
import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.WizardPage;
/**
@@ -96,4 +92,15 @@ public interface LdapServerAdapter
* if an error occurs when restarting the server
*/
public void stop( LdapServer server, StudioProgressMonitor monitor ) throws Exception;
+
+
+ /**
+ * Checks the ports before the server start.
+ *
+ * The return strings must have the following format: {PROTOCOL} ({PORT})
+ *
+ * @param server the server
+ * @return an array of error message, one for each port being already used.
+ */
+ public String[] checkPortsBeforeServerStart( LdapServer server );
}
Modified: directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/UnknownLdapServerAdapterExtension.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/UnknownLdapServerAdapterExtension.java?rev=1179279&r1=1179278&r2=1179279&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/UnknownLdapServerAdapterExtension.java (original)
+++ directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/UnknownLdapServerAdapterExtension.java Wed Oct 5 15:50:16 2011
@@ -110,6 +110,15 @@ public class UnknownLdapServerAdapterExt
}
} );
}
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String[] checkPortsBeforeServerStart( LdapServer server )
+ {
+ return new String[0];
+ }
} );
}