// Getting the selection
StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
{
// Getting the server
final Server server = ( Server ) selection.getFirstElement();
// Parsing the 'server.xml' file
ServerXmlIOV153 serverXmlIOV153 = new ServerXmlIOV153();
ServerConfigurationV153 serverConfiguration = null;
try
{
serverConfiguration = ( ServerConfigurationV153 ) serverXmlIOV153.parse( new FileInputStream(
new File( ApacheDsPluginUtils.getApacheDsServersFolder().append( server.getId() ).append(
"conf" ).append( "server.xml" ).toOSString() ) ) );
}
catch ( FileNotFoundException e )
{
reportErrorReadingServerConfiguration( e.getMessage() );
return;
}
catch ( ServerXmlIOException e )
{
reportErrorReadingServerConfiguration( e.getMessage() );
return;
}
// Checking if we could read the 'server.xml' file
if ( serverConfiguration == null )
{
reportErrorReadingServerConfiguration( null );
return;
}
// Verifying if the protocol ports are currently available
String[] alreadyInUseProtocolPortsList = getAlreadyInUseProtocolPorts( serverConfiguration );
if ( ( alreadyInUseProtocolPortsList != null ) && ( alreadyInUseProtocolPortsList.length > 0 ) )
{
String title = null;
String message = null;
if ( alreadyInUseProtocolPortsList.length == 1 )
{
title = "Port already in use";
message = "The port of the protocol " + alreadyInUseProtocolPortsList[0]
+ " is already in use.";
}
else
{
title = "Ports already in use";
message = "The ports of the following protocols are already in use:";
for ( String alreadyInUseProtocolPort : alreadyInUseProtocolPortsList )
{
message += ApacheDsPluginUtils.LINE_SEPARATOR + " - " + alreadyInUseProtocolPort;
}
}
message += ApacheDsPluginUtils.LINE_SEPARATOR + ApacheDsPluginUtils.LINE_SEPARATOR
+ "Do you wish to continue?";
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;
}
}
// Verifying the libraries in the plugin's folder
ApacheDsPluginUtils.verifyLibrariesFolder();
// Creating, setting and launching the launch job
LaunchServerJob job = new LaunchServerJob( server, serverConfiguration );
job.setLogsLevel( ApacheDsPluginUtils.getServerLogsLevel() );
job.setLogsPattern( ApacheDsPluginUtils.getServerLogsPattern() );
server.setLaunchJob( job );
job.schedule();
}
}
}