formatting
git-svn-id: https://svn.apache.org/repos/asf/incubator/kalumet/trunk@1565554 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/assembly/pom.xml b/assembly/pom.xml
index d4d5288..f9b279b 100644
--- a/assembly/pom.xml
+++ b/assembly/pom.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--
diff --git a/documentation/pom.xml b/documentation/pom.xml
index 1823140..3aa8045 100644
--- a/documentation/pom.xml
+++ b/documentation/pom.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--
@@ -185,7 +186,7 @@
<configuration>
<tasks>
<exec executable="svn">
- <arg line="checkout ${svnUrl} ${scmPubCheckoutDirectory}" />
+ <arg line="checkout ${svnUrl} ${scmPubCheckoutDirectory}"/>
</exec>
</tasks>
diff --git a/kalumet-modules/agent/pom.xml b/kalumet-modules/agent/pom.xml
index f8ae929..20338eb 100644
--- a/kalumet-modules/agent/pom.xml
+++ b/kalumet-modules/agent/pom.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/Configuration.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/Configuration.java
index be0bc87..079b63c 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/Configuration.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/Configuration.java
@@ -26,10 +26,10 @@
public class Configuration
{
- public static String CONFIG_LOCATION;
+ public static String CONFIG_LOCATION;
- public static String AGENT_ID;
+ public static String AGENT_ID;
- public static Kalumet CONFIG_CACHE = null;
+ public static Kalumet CONFIG_CACHE = null;
}
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/Main.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/Main.java
index bb6d125..eeb2777 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/Main.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/Main.java
@@ -42,114 +42,120 @@
public final class Main
{
- private final static transient Logger LOGGER = LoggerFactory.getLogger( Main.class );
+ private final static transient Logger LOGGER = LoggerFactory.getLogger( Main.class );
- /**
- * Main agent launcher.
- *
- * @param args
- */
- public final static void main( String[] args )
- {
- System.out.println( "Starting Apache Kalumet agent " + AgentUtils.getVersion() );
- System.out.println();
-
- Options options = new Options();
- Option config = OptionBuilder.withArgName( "config" ).hasArg().withDescription(
- "The location URL (local: or http:) to the Kalumet configuration (e.g. http://hostname/kalumet/ConfigurationWrapper)" ).isRequired().create(
- "config" );
- options.addOption( config );
- Option agentid = OptionBuilder.withArgName( "id" ).hasArg().withDescription(
- "The Kalumet agent identification as defined in the configuration" ).isRequired().create( "id" );
- options.addOption( agentid );
- CommandLineParser parser = new GnuParser();
- CommandLine cmd = null;
-
- try
+ /**
+ * Main agent launcher.
+ *
+ * @param args
+ */
+ public final static void main( String[] args )
{
- // parse the command line
- cmd = parser.parse( options, args );
- }
- catch ( ParseException parseException )
- {
- HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp( "Apache Kalumet", options );
- System.exit( 1 );
- }
+ System.out.println( "Starting Apache Kalumet agent " + AgentUtils.getVersion() );
+ System.out.println();
- String configLocation = cmd.getOptionValue( "config" );
- LOGGER.info( "Loading configuration from {}", configLocation );
- String agentId = cmd.getOptionValue( "id" );
- LOGGER.info( "Agent ID is {}", agentId );
+ Options options = new Options();
+ Option config = OptionBuilder.withArgName( "config" ) //
+ .hasArg() //
+ .withDescription( "The location URL (local: or http:) to the Kalumet configuration (e.g. http://hostname/kalumet/ConfigurationWrapper)" ) //
+ .isRequired() //
+ .create( "config" );
+ options.addOption( config );
- // parse the Kalumet configuration to get the the agent cron
- Kalumet kalumet = null;
- String cronString = null;
- try
- {
- kalumet = Kalumet.digeste( configLocation );
- }
- catch ( Exception e )
- {
- LOGGER.error( "Can't load Apache Kalumet configuration", e );
- System.err.println( "Can't load Apache Kalumet configuration" );
- e.printStackTrace();
- System.exit( 1 );
- }
+ Option agentid = OptionBuilder.withArgName( "id" ) //
+ .hasArg() //
+ .withDescription( "The Kalumet agent identification as defined in the configuration" ) //
+ .isRequired() //
+ .create( "id" );
+ options.addOption( agentid );
+ CommandLineParser parser = new GnuParser();
+ CommandLine cmd = null;
- if ( kalumet.getAgent( agentId ) == null )
- {
- LOGGER.error( "Agent ID {} is not found in the Kalumet configuration", agentId );
- System.err.println( "Agent ID " + agentId + " is not found in the Kalumet configuration" );
- System.exit( 1 );
- }
+ try
+ {
+ // parse the command line
+ cmd = parser.parse( options, args );
+ }
+ catch ( ParseException parseException )
+ {
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.printHelp( "Apache Kalumet", options );
+ System.exit( 1 );
+ }
- // init the agent configuration store
- Configuration.CONFIG_LOCATION = configLocation;
- Configuration.AGENT_ID = agentId;
+ String configLocation = cmd.getOptionValue( "config" );
+ LOGGER.info( "Loading configuration from {}", configLocation );
+ String agentId = cmd.getOptionValue( "id" );
+ LOGGER.info( "Agent ID is {}", agentId );
- cronString = kalumet.getAgent( agentId ).getCron();
- LOGGER.debug( "Cron definition: " + cronString );
+ // parse the Kalumet configuration to get the the agent cron
+ Kalumet kalumet = null;
+ String cronString = null;
+ try
+ {
+ kalumet = Kalumet.digeste( configLocation );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Can't load Apache Kalumet configuration", e );
+ System.err.println( "Can't load Apache Kalumet configuration" );
+ e.printStackTrace();
+ System.exit( 1 );
+ }
- // start the WS server
- try
- {
- int port = kalumet.getAgent( agentId ).getPort();
- WsServer wsServer = new WsServer( port, "/apache-kalumet.wsdd" );
- wsServer.start();
- LOGGER.info( "WS server started on {}", port );
- }
- catch ( Exception e )
- {
- LOGGER.error( "Can't start WS server", e );
- System.err.println( "Can't start WS server" );
- e.printStackTrace();
- System.exit( 2 );
- }
+ if ( kalumet.getAgent( agentId ) == null )
+ {
+ LOGGER.error( "Agent ID {} is not found in the Kalumet configuration", agentId );
+ System.err.println( "Agent ID " + agentId + " is not found in the Kalumet configuration" );
+ System.exit( 1 );
+ }
- // start the scheduler
- try
- {
- SchedulerFactory schedulerFactory = new StdSchedulerFactory();
- Scheduler scheduler = schedulerFactory.getScheduler();
- scheduler.addGlobalJobListener( new SchedulerJobListener() );
- LOGGER.debug( "Scheduler job listener plugged" );
- scheduler.start();
- JobDetail job = new JobDetail( "Apache Kalumet agent job", Scheduler.DEFAULT_GROUP, SchedulerJob.class );
- CronTrigger cron = new CronTrigger( "Apache Kalumet agent trigger", Scheduler.DEFAULT_GROUP, cronString );
- LOGGER.debug( "{} cron created", cronString );
- scheduler.scheduleJob( job, cron );
- LOGGER.info( "Scheduler started with {} trigger", cronString );
- }
- catch ( Exception e )
- {
- LOGGER.error( "Can't start scheduler", e );
- System.err.println( "Can't start scheduler" );
- e.printStackTrace();
- System.exit( 3 );
- }
+ // init the agent configuration store
+ Configuration.CONFIG_LOCATION = configLocation;
+ Configuration.AGENT_ID = agentId;
- LOGGER.info( "Apache Kalumet agent started" );
- }
+ cronString = kalumet.getAgent( agentId ).getCron();
+ LOGGER.debug( "Cron definition: " + cronString );
+
+ // start the WS server
+ try
+ {
+ int port = kalumet.getAgent( agentId ).getPort();
+ WsServer wsServer = new WsServer( port, "/apache-kalumet.wsdd" );
+ wsServer.start();
+ LOGGER.info( "WS server started on {}", port );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Can't start WS server", e );
+ System.err.println( "Can't start WS server" );
+ e.printStackTrace();
+ System.exit( 2 );
+ }
+
+ // start the scheduler
+ try
+ {
+ SchedulerFactory schedulerFactory = new StdSchedulerFactory();
+ Scheduler scheduler = schedulerFactory.getScheduler();
+ scheduler.addGlobalJobListener( new SchedulerJobListener() );
+ LOGGER.debug( "Scheduler job listener plugged" );
+ scheduler.start();
+ JobDetail job = new JobDetail( "Apache Kalumet agent job", Scheduler.DEFAULT_GROUP, SchedulerJob.class );
+ CronTrigger cron = new CronTrigger( "Apache Kalumet agent trigger", Scheduler.DEFAULT_GROUP, cronString );
+ LOGGER.debug( "{} cron created", cronString );
+ scheduler.scheduleJob( job, cron );
+ LOGGER.info( "Scheduler started with {} trigger", cronString );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Can't start scheduler", e );
+ System.err.println( "Can't start scheduler" );
+ e.printStackTrace();
+ System.exit( 3 );
+ }
+
+ LOGGER.info( "Apache Kalumet agent started" );
+ }
}
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/SchedulerJob.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/SchedulerJob.java
index 5428ecc..ab50f69 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/SchedulerJob.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/SchedulerJob.java
@@ -33,56 +33,56 @@
* Kalumet job in the quartz scheduler.
*/
public class SchedulerJob
- implements StatefulJob
+ implements StatefulJob
{
- private final static transient Logger LOGGER = LoggerFactory.getLogger( SchedulerJob.class );
+ private final static transient Logger LOGGER = LoggerFactory.getLogger( SchedulerJob.class );
- public SchedulerJob()
- {
- }
+ public SchedulerJob()
+ {
+ }
- /**
- * Launch the main agent job.
- *
- * @param path the Kalumet configuration file location.
- * @param agentId the Kalumet agent ID.
- */
- public static void perform( String path, String agentId )
- {
- Kalumet kalumet = null;
- try
+ /**
+ * Launch the main agent job.
+ *
+ * @param path the Kalumet configuration file location.
+ * @param agentId the Kalumet agent ID.
+ */
+ public static void perform( String path, String agentId )
{
- LOGGER.debug( "Loading Kalumet configuration" );
- kalumet = Kalumet.digeste( path );
+ Kalumet kalumet = null;
+ try
+ {
+ LOGGER.debug( "Loading Kalumet configuration" );
+ kalumet = Kalumet.digeste( path );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Can't load Apache Kalumet configuration from {}", path, e );
+ throw new RuntimeException( "Can't load Apache Kalumet configuration from " + path, e );
+ }
+ // loop to update all environments managed by the agent
+ for ( Iterator environmentIterator = kalumet.getEnvironmentsByAgent( agentId ).iterator();
+ environmentIterator.hasNext(); )
+ {
+ try
+ {
+ EnvironmentUpdater.update( (Environment) environmentIterator.next() );
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
}
- catch ( Exception e )
- {
- LOGGER.error( "Can't load Apache Kalumet configuration from {}", path, e );
- throw new RuntimeException( "Can't load Apache Kalumet configuration from " + path, e );
- }
- // loop to update all environments managed by the agent
- for ( Iterator environmentIterator = kalumet.getEnvironmentsByAgent( agentId ).iterator();
- environmentIterator.hasNext(); )
- {
- try
- {
- EnvironmentUpdater.update( (Environment) environmentIterator.next() );
- }
- catch ( Exception e )
- {
- // ignore
- }
- }
- }
- /**
- * @see org.quartz.StatefulJob#execute(org.quartz.JobExecutionContext)
- */
- public void execute( JobExecutionContext context )
- throws JobExecutionException
- {
- SchedulerJob.perform( Configuration.CONFIG_LOCATION, Configuration.AGENT_ID );
- }
+ /**
+ * @see org.quartz.StatefulJob#execute(org.quartz.JobExecutionContext)
+ */
+ public void execute( JobExecutionContext context )
+ throws JobExecutionException
+ {
+ SchedulerJob.perform( Configuration.CONFIG_LOCATION, Configuration.AGENT_ID );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/SchedulerJobListener.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/SchedulerJobListener.java
index ad2e39a..8475b5c 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/SchedulerJobListener.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/SchedulerJobListener.java
@@ -28,53 +28,53 @@
* A global job listener.
*/
public class SchedulerJobListener
- implements JobListener
+ implements JobListener
{
- private final static transient Logger LOGGER = LoggerFactory.getLogger( SchedulerJobListener.class );
+ private final static transient Logger LOGGER = LoggerFactory.getLogger( SchedulerJobListener.class );
- public SchedulerJobListener()
- {
- }
-
- /**
- * Get the listener name.
- *
- * @return the listener name.
- */
- public String getName()
- {
- return "AgentJobListener";
- }
-
- /**
- * @see org.quartz.JobListener#jobToBeExecuted(org.quartz.JobExecutionContext)
- */
- public void jobToBeExecuted( JobExecutionContext jobExecutionContext )
- {
- LOGGER.info( "Executing scheduler job ..." );
- }
-
- /**
- * @see org.quartz.JobListener#jobExecutionVetoed(org.quartz.JobExecutionContext)
- */
- public void jobExecutionVetoed( JobExecutionContext jobExecutionContext )
- {
- }
-
- /**
- * @see org.quartz.JobListener#jobWasExecuted(org.quartz.JobExecutionContext, org.quartz.JobExecutionException)
- */
- public void jobWasExecuted( JobExecutionContext jobExecutionContext, JobExecutionException jobExecutionException )
- {
- if ( jobExecutionException != null )
+ public SchedulerJobListener()
{
- LOGGER.warn( "Scheduler job executed with error", jobExecutionException );
}
- else
+
+ /**
+ * Get the listener name.
+ *
+ * @return the listener name.
+ */
+ public String getName()
{
- LOGGER.info( "Scheduler job executed" );
+ return "AgentJobListener";
}
- }
+
+ /**
+ * @see org.quartz.JobListener#jobToBeExecuted(org.quartz.JobExecutionContext)
+ */
+ public void jobToBeExecuted( JobExecutionContext jobExecutionContext )
+ {
+ LOGGER.info( "Executing scheduler job ..." );
+ }
+
+ /**
+ * @see org.quartz.JobListener#jobExecutionVetoed(org.quartz.JobExecutionContext)
+ */
+ public void jobExecutionVetoed( JobExecutionContext jobExecutionContext )
+ {
+ }
+
+ /**
+ * @see org.quartz.JobListener#jobWasExecuted(org.quartz.JobExecutionContext, org.quartz.JobExecutionException)
+ */
+ public void jobWasExecuted( JobExecutionContext jobExecutionContext, JobExecutionException jobExecutionException )
+ {
+ if ( jobExecutionException != null )
+ {
+ LOGGER.warn( "Scheduler job executed with error", jobExecutionException );
+ }
+ else
+ {
+ LOGGER.info( "Scheduler job executed" );
+ }
+ }
}
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/WsServer.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/WsServer.java
index a2d4b8e..2d91a8b 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/WsServer.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/WsServer.java
@@ -35,71 +35,71 @@
public class WsServer
{
- private final static transient Logger LOGGER = LoggerFactory.getLogger( WsServer.class );
+ private final static transient Logger LOGGER = LoggerFactory.getLogger( WsServer.class );
- private final static int MAX_POOL_SIZE = 500;
+ private final static int MAX_POOL_SIZE = 500;
- private final static int MAX_SESSIONS_NUMBER = 500;
+ private final static int MAX_SESSIONS_NUMBER = 500;
- private SimpleAxisServer simpleAxisServer;
+ private SimpleAxisServer simpleAxisServer;
- /**
- * Create an embedded WS server.
- *
- * @param port the WS server listen port.
- * @param wsddFile the WebService Deployment Descriptor.
- * @throws KalumetException in case of WS server creation failure.
- */
- public WsServer( int port, String wsddFile )
- throws KalumetException
- {
- simpleAxisServer = new SimpleAxisServer( MAX_POOL_SIZE, MAX_SESSIONS_NUMBER );
- LOGGER.debug( "Creating WS server" );
- LOGGER.debug( " Max pool size: " + MAX_POOL_SIZE );
- LOGGER.debug( " Max sessions number: " + MAX_SESSIONS_NUMBER );
- try
+ /**
+ * Create an embedded WS server.
+ *
+ * @param port the WS server listen port.
+ * @param wsddFile the WebService Deployment Descriptor.
+ * @throws KalumetException in case of WS server creation failure.
+ */
+ public WsServer( int port, String wsddFile )
+ throws KalumetException
{
- simpleAxisServer.setServerSocket( new ServerSocket( port ) );
- LOGGER.debug( "WS server started on port {}", port );
+ simpleAxisServer = new SimpleAxisServer( MAX_POOL_SIZE, MAX_SESSIONS_NUMBER );
+ LOGGER.debug( "Creating WS server" );
+ LOGGER.debug( " Max pool size: " + MAX_POOL_SIZE );
+ LOGGER.debug( " Max sessions number: " + MAX_SESSIONS_NUMBER );
+ try
+ {
+ simpleAxisServer.setServerSocket( new ServerSocket( port ) );
+ LOGGER.debug( "WS server started on port {}", port );
+ }
+ catch ( IOException e )
+ {
+ LOGGER.error( "Can't create WS server on port {}", port, e );
+ throw new KalumetException( "Can't create WS server on port " + port, e );
+ }
}
- catch ( IOException e )
- {
- LOGGER.error( "Can't create WS server on port {}", port, e );
- throw new KalumetException( "Can't create WS server on port " + port, e );
- }
- }
- /**
- * Start the WS server.
- *
- * @throws KalumetException in case of WS server startup failure.
- */
- public void start()
- throws KalumetException
- {
- try
+ /**
+ * Start the WS server.
+ *
+ * @throws KalumetException in case of WS server startup failure.
+ */
+ public void start()
+ throws KalumetException
{
- LOGGER.debug( "Starting WS server in daemon mode" );
- simpleAxisServer.start( true );
+ try
+ {
+ LOGGER.debug( "Starting WS server in daemon mode" );
+ simpleAxisServer.start( true );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Can't start WS server", e );
+ throw new KalumetException( "Can't start WS server", e );
+ }
}
- catch ( Exception e )
- {
- LOGGER.error( "Can't start WS server", e );
- throw new KalumetException( "Can't start WS server", e );
- }
- }
- /**
- * Define the WS server configuration.
- *
- * @param wsddFile the WebService Deployment Descriptor file.
- * @return the engine configuration of the WS server.
- * @throws KalumetException in case of configuration failure.
- */
- private EngineConfiguration getEngineConfiguration( String wsddFile )
- throws KalumetException
- {
- return new FileProvider( getClass().getResourceAsStream( wsddFile ) );
- }
+ /**
+ * Define the WS server configuration.
+ *
+ * @param wsddFile the WebService Deployment Descriptor file.
+ * @return the engine configuration of the WS server.
+ * @throws KalumetException in case of configuration failure.
+ */
+ private EngineConfiguration getEngineConfiguration( String wsddFile )
+ throws KalumetException
+ {
+ return new FileProvider( getClass().getResourceAsStream( wsddFile ) );
+ }
}
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/ArchiveUpdater.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/ArchiveUpdater.java
index b374a81..0c66e19 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/ArchiveUpdater.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/ArchiveUpdater.java
@@ -25,8 +25,12 @@
import org.apache.kalumet.agent.utils.EventUtils;
import org.apache.kalumet.controller.core.JEEApplicationServerController;
import org.apache.kalumet.controller.core.JEEApplicationServerControllerFactory;
-import org.apache.kalumet.model.*;
+import org.apache.kalumet.model.Agent;
+import org.apache.kalumet.model.Archive;
+import org.apache.kalumet.model.Environment;
import org.apache.kalumet.model.JEEApplication;
+import org.apache.kalumet.model.JEEApplicationServer;
+import org.apache.kalumet.model.Kalumet;
import org.apache.kalumet.model.update.UpdateLog;
import org.apache.kalumet.model.update.UpdateMessage;
import org.apache.kalumet.utils.NotifierUtils;
@@ -43,434 +47,443 @@
public class ArchiveUpdater
{
- private static final transient Logger LOGGER = LoggerFactory.getLogger( ArchiveUpdater.class );
+ private static final transient Logger LOGGER = LoggerFactory.getLogger( ArchiveUpdater.class );
- /**
- * Wrapper method to update JEE application archive.
- *
- * @param environmentName the target environment name.
- * @param serverName the target JEE application server name.
- * @param applicationName the target JEE application name.
- * @param archiveName the target archive name.
- * @param delegation flag indicating if the update is a delegation from another agent (true), or a client call (false).
- * @throws UpdateException in case of update failure.
- */
- public static void update( String environmentName, String serverName, String applicationName, String archiveName,
- boolean delegation )
- throws KalumetException
- {
- LOGGER.info( "Archive {} update requested by WS", archiveName );
+ /**
+ * Wrapper method to update JEE application archive.
+ *
+ * @param environmentName the target environment name.
+ * @param serverName the target JEE application server name.
+ * @param applicationName the target JEE application name.
+ * @param archiveName the target archive name.
+ * @param delegation flag indicating if the update is a delegation from another agent (true), or a client call (false).
+ * @throws UpdateException in case of update failure.
+ */
+ public static void update( String environmentName, String serverName, String applicationName, String archiveName,
+ boolean delegation )
+ throws KalumetException
+ {
+ LOGGER.info( "Archive {} update requested by WS", archiveName );
- // load configuration.
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer server = environment.getJEEApplicationServers().getJEEApplicationServer(serverName);
- if ( server == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environmentName );
- throw new KalumetException(
- "JEE application server " + serverName + " is not found in environment " + environmentName );
- }
- JEEApplication application = server.getJEEApplication(applicationName);
- if ( application == null )
- {
- LOGGER.error( "JEE application {} is not found in JEE application server {}", applicationName, serverName );
- throw new KalumetException(
- "JEE application " + applicationName + " is not found in JEE application server " + serverName );
- }
- Archive archive = application.getArchive( archiveName );
- if ( archive == null )
- {
- LOGGER.error( "Archive {} is not found in JEE application {}", archiveName, applicationName );
- throw new KalumetException( "Archive " + archiveName + " is not found in JEE application " + applicationName );
- }
-
- // update configuration cache
- LOGGER.debug( "Updating configuration cache" );
- Configuration.CONFIG_CACHE = kalumet;
-
- // post journal event
- EventUtils.post( environment, "UPDATE", "Archive " + archiveName + " update requested by WS" );
- // create an update logger
- UpdateLog updateLog =
- new UpdateLog( "Archive " + archiveName + " update in progress ...", environment.getName(), environment );
-
- if ( !delegation )
- {
- // the update is a client call
- LOGGER.info( "Send a notification and waiting for the count down" );
- EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
- NotifierUtils.waitAndNotify( environment );
- }
-
- try
- {
- // call the updater method
- ArchiveUpdater.update( environment, server, application, archive, updateLog );
- }
- catch ( Exception e )
- {
- LOGGER.error( "Archive {} update failed", archiveName, e );
- EventUtils.post( environment, "ERROR", "Archive " + archiveName + " update failed: " + e.getMessage() );
- if ( !delegation )
- {
- updateLog.setStatus( "Archive " + archiveName + " update failed" );
- updateLog.addUpdateMessage(
- new UpdateMessage( "error", "Archive " + archiveName + " update failed: " + e.getMessage() ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
- }
- throw new UpdateException( "Archive " + archiveName + " update failed", e );
- }
-
- // update completed
- LOGGER.info( "Archive {} updated", archive.getName() );
- EventUtils.post( environment, "UPDATE", "Archive " + archive.getName() + " updated" );
-
- if ( !delegation )
- {
- if ( updateLog.isUpdated() )
- {
- updateLog.setStatus( "Archive " + archive.getName() + " updated" );
- }
- else
- {
- updateLog.setStatus( "Archive " + archive.getName() + " already up to date" );
- }
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Archive " + archive.getName() + " updated" ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
- }
- }
-
- /**
- * Updates a archive.
- *
- * @param environment the target <code>Environment</code>.
- * @param server the target <code>JEEApplicationServer</code>.
- * @param application the target JZEE <code>Application</code>.
- * @param archive the target <code>Archive</code>.
- * @param updateLog the <code>UpdateLog</code> to use.
- */
- public static void update( Environment environment, JEEApplicationServer server, JEEApplication application,
- Archive archive, UpdateLog updateLog )
- throws UpdateException
- {
- LOGGER.info( "Updating archive {}", archive.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Updating archive " + archive.getName() ) );
- EventUtils.post( environment, "UPDATE", "Updating archive " + archive.getName() );
-
- if ( !archive.isActive() )
- {
- LOGGER.info( "Archive {} is inactive, so not updated", archive.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Archive " + archive.getName() + " is inactive, so not updated" ) );
- EventUtils.post( environment, "UPDATE", "Archive " + archive.getName() + " is inactive, so not updated" );
- return;
- }
-
- // check to delegate the update
- if ( archive.getAgent() != null && archive.getAgent().trim().length() > 0 && !archive.getAgent().equals(
- Configuration.AGENT_ID ) )
- {
- LOGGER.info( "Delegating archive {} update to agent {}", archive.getName(), archive.getAgent() );
- EventUtils.post( environment, "UPDATE",
- "Delegating archive " + archive.getName() + " update to agent " + archive.getAgent() );
- updateLog.addUpdateMessage( new UpdateMessage( "info",
- "Delegating archive " + archive.getName() + " update to agent "
- + archive.getAgent() ) );
- Agent delegationAgent = Configuration.CONFIG_CACHE.getAgent( archive.getAgent() );
- if ( delegationAgent == null )
- {
- LOGGER.error( "Agent {} is not found in the configuration", archive.getAgent() );
- throw new UpdateException( "Agent " + archive.getAgent() + " is not found in the configuration" );
- }
- try
- {
- LOGGER.debug( "Call archive WS" );
- ArchiveClient client = new ArchiveClient( delegationAgent.getHostname(), delegationAgent.getPort() );
- client.update( environment.getName(), server.getName(), application.getName(), archive.getName(), true );
- }
- catch ( ClientException clientException )
- {
- LOGGER.error( "Archive " + archive.getName() + " update failed", clientException );
- throw new UpdateException( "Archive " + archive.getName() + " update failed", clientException );
- }
- return;
- }
-
- // construct the archiveUri
- String archiveUri = VariableUtils.replace( archive.getUri(), environment.getVariables() );
- if ( !FileManipulator.protocolExists( archiveUri ) )
- {
- // the archive URI is relative (no prefix protocol), use the
- // application URI to construct the VFS URI
- LOGGER.debug( "Archive URI is relative (no protocol prefix) to JEE application URI" );
- archiveUri =
- FileManipulator.format( VariableUtils.replace( application.getUri(), environment.getVariables() ) ) + "!/"
- + archiveUri;
- }
- // get the application cache directory
- String applicationCacheDir = null;
- // initialize the file manipulator instance
- FileManipulator fileManipulator = null;
- try
- {
- applicationCacheDir = FileManipulator.createJEEApplicationCacheDir(environment, application);
- fileManipulator = new FileManipulator();
- }
- catch ( FileManipulatorException e )
- {
- LOGGER.error( "Can't create JEE application {} cache directory", application.getName(), e );
- throw new UpdateException( "Can't create JEE application " + application.getName() + " cache directory", e );
- }
- finally
- {
- if ( fileManipulator != null )
- {
- fileManipulator.close();
- }
- }
- // define the archive cache location
- String archiveCache = applicationCacheDir + "/" + archive.getName();
- // define the archive installation URI
- String archiveInstallation = null;
- if ( archive.getPath() == null || archive.getPath().trim().length() < 1 )
- {
- LOGGER.error( "Archive {} path is not defined", archive.getName() );
- throw new UpdateException( "Archive " + archive.getName() + " path is not defined" );
- }
- // the archive path is defined, use it
- archiveInstallation = VariableUtils.replace( archive.getPath(), environment.getVariables() );
- // get the JEE application server controller
- LOGGER.debug( "Getting the JEE application server controller" );
- JEEApplicationServerController controller = null;
- try
- {
- controller = JEEApplicationServerControllerFactory.getController(environment, server);
- }
- catch ( KalumetException e )
- {
- LOGGER.error( "Can't get the JEE application server {} controller", server.getName(), e );
- throw new UpdateException( "Can't get the JEE application server " + server.getName() + " controller", e );
- }
- // check if the archive is already deployed
- try
- {
- if ( controller.isJEEApplicationDeployed(archiveInstallation, archive.getName()) )
- {
- // the archive is already deployed, check for update
- LOGGER.info( "Archive {} is already deployed, check for update", archive.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Archive " + archive.getName() + " is already deployed, check for update" ) );
- EventUtils.post( environment, "UPDATE",
- "Archive " + archive.getName() + " is already deployed, check for update" );
- if ( !fileManipulator.checksumEquals( archiveUri, archiveCache ) )
+ // load configuration.
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
{
- // the archive file is different from the copy in the
- // application directory, perform an update
- // update the cache
- fileManipulator.copy( archiveUri, archiveCache );
- LOGGER.info( "Archive {} (located {}) is different from the cache, performing update", archive.getName(),
- archiveUri );
- updateLog.addUpdateMessage( new UpdateMessage( "info",
- "Archive " + archive.getName() + " (located " + archiveUri
- + ") is different from the cache, performing update" ) );
- EventUtils.post( environment, "UPDATE", "Archive " + archive.getName() + " (located " + archiveUri
- + ") is different from the cache, performing update" );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Copy " + archiveUri + " to " + archiveInstallation ) );
- EventUtils.post( environment, "UPDATE", "Copy " + archiveUri + " to " + archiveInstallation );
- // update the archive path
- fileManipulator.copy( archiveUri, archiveInstallation );
- // undeploy the archive
- LOGGER.info( "Undeploying archive {}", archive.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Undeploying archive " + archive.getName() ) );
- EventUtils.post( environment, "UPDATE", "Undeploying archive " + archive.getName() );
- controller.undeployJEEApplication(archiveInstallation, archive.getName());
- // deploy the archive
- LOGGER.info( "Deploying archive {}", archive.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Deploying archive " + archive.getName() ) );
- EventUtils.post( environment, "UPDATE", "Deploying archive " + archive.getName() );
- controller.deployJEEApplication(archiveInstallation, archive.getName(), archive.getClassloaderorder(),
- archive.getClassloaderpolicy(),
- VariableUtils.replace(archive.getVhost(), environment.getVariables()));
- LOGGER.info( "Archive {} updated", archive.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Archive " + archive.getName() + " updated" ) );
- EventUtils.post( environment, "UPDATE", "Archive " + archive.getName() + " updated" );
- updateLog.setUpdated( true );
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
}
- }
- else
- {
- // the archive is not deployed
- LOGGER.info( "Archive {} is not deployed, deploying it", archive.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Archive " + archive.getName() + " is not deployed, deploying it" ) );
- EventUtils.post( environment, "UPDATE", "Archive " + archive.getName() + " is not deployed, deploying it" );
- // copy the archive agent locally
- fileManipulator.copy( archiveUri, archiveCache );
- // copy the archive to the destination path
- fileManipulator.copy( archiveUri, archiveInstallation );
- // deploy the archive
- LOGGER.info( "Deploying archive {}", archive.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Deploying archive " + archive.getName() ) );
- EventUtils.post( environment, "UPDATE", "Deploying archive " + archive.getName() );
- controller.deployJEEApplication(archiveInstallation, archive.getName(), archive.getClassloaderorder(),
- archive.getClassloaderpolicy(),
- VariableUtils.replace(archive.getVhost(), environment.getVariables()));
- updateLog.setUpdated( true );
- }
- // as some JEE application server (like IBM WebSphere) change the archive file during deployment, update
- // the local archive with a original copy (for next update)
- LOGGER.debug( "Restoring the original archive (before deployment) from {}", archiveUri );
- fileManipulator.copy( archiveUri, archiveCache );
- // check if the JEE application is deployed (it should be)
- if ( !controller.isJEEApplicationDeployed(archiveInstallation, archive.getName()) )
- {
- LOGGER.error( "Archive {} is not deployed whereas it should be. Please check the JEE application server logs",
- archive.getName() );
- throw new UpdateException( "Archive " + archive.getName()
- + " is not deployed whereas it should be. Please check the JEE application server logs" );
- }
- }
- catch ( Exception e )
- {
- // the archive update has failed
- LOGGER.error( "Archive {} update failed", archive.getName(), e );
- try
- {
- fileManipulator.delete( archiveCache );
- }
- catch ( FileManipulatorException fileManipulatorException )
- {
- LOGGER.warn( "Can't delete " + archiveCache, fileManipulatorException );
- }
- throw new UpdateException( "Archive " + archive.getName() + " update failed", e );
- }
- }
-
- /**
- * Wrapper method to check if a archive is up to date or not via WS.
- *
- * @param environmentName the target environment name.
- * @param serverName the target JEE application server name.
- * @param applicationName the target JEE application name.
- * @param archiveName the target archive name.
- * @return true if the archive is up to date, false else.
- * @throws KalumetException in case of status check failure
- */
- public static boolean check( String environmentName, String serverName, String applicationName, String archiveName )
- throws KalumetException
- {
- LOGGER.info( "Checking status of archive {} via WS", archiveName );
- // load configuration
- LOGGER.debug( "Load configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer applicationServer =
- environment.getJEEApplicationServers().getJEEApplicationServer(serverName);
- if ( applicationServer == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environmentName );
- throw new KalumetException(
- "JEE application server " + serverName + " is not found in environment " + environmentName );
- }
- JEEApplication application = applicationServer.getJEEApplication(applicationName);
- if ( application == null )
- {
- LOGGER.error( "JEE application {} is not found in JEE application server {}", applicationName, serverName );
- throw new KalumetException(
- "JEE application " + applicationName + " is not found in JEE application server " + serverName );
- }
- Archive archive = application.getArchive( archiveName );
- if ( archive == null )
- {
- LOGGER.error( "Archive {} is not found in JEE application {}", archiveName, applicationName );
- throw new KalumetException( "Archive " + archiveName + " is not found in JEE application " + applicationName );
- }
-
- // check if the check should be delegated to another agent
- if ( archive.getAgent() != null && archive.getAgent().trim().length() > 0 && !archive.getAgent().equals(
- Configuration.AGENT_ID ) )
- {
- // the check needs to be delegated to another agent
- LOGGER.info( "Delegating archive {} status check to agent {}", archive.getName(), archive.getAgent() );
- Agent agentDelegation = kalumet.getAgent( archive.getAgent() );
- if ( agentDelegation == null )
- {
- LOGGER.error( "Agent {} is not found in the configuration", archive.getName() );
- throw new KalumetException( "Agent " + archive.getAgent() + " is not found in the configuration" );
- }
- // call the service
- ArchiveClient client = new ArchiveClient( agentDelegation.getHostname(), agentDelegation.getPort() );
- return client.check( environmentName, serverName, applicationName, archiveName );
- }
-
- // get JEE application server controller
- LOGGER.debug( "Getting JEE application server controller" );
- JEEApplicationServerController controller =
- JEEApplicationServerControllerFactory.getController(environment, applicationServer);
-
- FileManipulator fileManipulator = null;
- try
- {
- fileManipulator = new FileManipulator();
-
- // get application cache directory
- LOGGER.debug( "Getting application cache directory" );
- String applicationCacheDirectory = FileManipulator.createJEEApplicationCacheDir(environment, application);
-
- // construct the archive URI
- String archiveUri = VariableUtils.replace( archive.getUri(), environment.getVariables() );
- if ( !FileManipulator.protocolExists( archiveUri ) )
- {
- // the archive URI is relative (doesn't contain the protocol prefix), construct the URI using the application URI
- archiveUri = VariableUtils.replace( application.getUri(), environment.getVariables() ) + "!/" + archiveUri;
- }
-
- // get the archive cache
- String archiveCache = applicationCacheDirectory + "/" + archive.getName();
-
- // get the archive installation path
- if ( archive.getPath() == null || archive.getPath().trim().length() < 1 )
- {
- LOGGER.error( "Archive {} path is not defined", archive.getName() );
- throw new KalumetException( "Archive " + archive.getName() + " path is not defined" );
- }
- String archiveInstallation = VariableUtils.replace( archive.getPath(), environment.getVariables() );
-
- if ( controller.isJEEApplicationDeployed(archiveInstallation, archive.getName()) )
- {
- // check if the archive is deployed or not
- if ( fileManipulator.checksumEquals( archiveUri, archiveCache ) )
+ JEEApplicationServer server = environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
+ if ( server == null )
{
- // archive URI and cache are the same
- LOGGER.debug( "Archive URI and agent cache are the same" );
- return true;
+ LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environmentName );
+ throw new KalumetException(
+ "JEE application server " + serverName + " is not found in environment " + environmentName );
}
- }
- }
- finally
- {
- if ( fileManipulator != null )
- {
- fileManipulator.close();
- }
+ JEEApplication application = server.getJEEApplication( applicationName );
+ if ( application == null )
+ {
+ LOGGER.error( "JEE application {} is not found in JEE application server {}", applicationName, serverName );
+ throw new KalumetException(
+ "JEE application " + applicationName + " is not found in JEE application server " + serverName );
+ }
+ Archive archive = application.getArchive( archiveName );
+ if ( archive == null )
+ {
+ LOGGER.error( "Archive {} is not found in JEE application {}", archiveName, applicationName );
+ throw new KalumetException(
+ "Archive " + archiveName + " is not found in JEE application " + applicationName );
+ }
+
+ // update configuration cache
+ LOGGER.debug( "Updating configuration cache" );
+ Configuration.CONFIG_CACHE = kalumet;
+
+ // post journal event
+ EventUtils.post( environment, "UPDATE", "Archive " + archiveName + " update requested by WS" );
+ // create an update logger
+ UpdateLog updateLog =
+ new UpdateLog( "Archive " + archiveName + " update in progress ...", environment.getName(), environment );
+
+ if ( !delegation )
+ {
+ // the update is a client call
+ LOGGER.info( "Send a notification and waiting for the count down" );
+ EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
+ NotifierUtils.waitAndNotify( environment );
+ }
+
+ try
+ {
+ // call the updater method
+ ArchiveUpdater.update( environment, server, application, archive, updateLog );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Archive {} update failed", archiveName, e );
+ EventUtils.post( environment, "ERROR", "Archive " + archiveName + " update failed: " + e.getMessage() );
+ if ( !delegation )
+ {
+ updateLog.setStatus( "Archive " + archiveName + " update failed" );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "error", "Archive " + archiveName + " update failed: " + e.getMessage() ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
+ }
+ throw new UpdateException( "Archive " + archiveName + " update failed", e );
+ }
+
+ // update completed
+ LOGGER.info( "Archive {} updated", archive.getName() );
+ EventUtils.post( environment, "UPDATE", "Archive " + archive.getName() + " updated" );
+
+ if ( !delegation )
+ {
+ if ( updateLog.isUpdated() )
+ {
+ updateLog.setStatus( "Archive " + archive.getName() + " updated" );
+ }
+ else
+ {
+ updateLog.setStatus( "Archive " + archive.getName() + " already up to date" );
+ }
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Archive " + archive.getName() + " updated" ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
+ }
}
- return false;
- }
+ /**
+ * Updates a archive.
+ *
+ * @param environment the target <code>Environment</code>.
+ * @param server the target <code>JEEApplicationServer</code>.
+ * @param application the target JZEE <code>Application</code>.
+ * @param archive the target <code>Archive</code>.
+ * @param updateLog the <code>UpdateLog</code> to use.
+ */
+ public static void update( Environment environment, JEEApplicationServer server, JEEApplication application,
+ Archive archive, UpdateLog updateLog )
+ throws UpdateException
+ {
+ LOGGER.info( "Updating archive {}", archive.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Updating archive " + archive.getName() ) );
+ EventUtils.post( environment, "UPDATE", "Updating archive " + archive.getName() );
+
+ if ( !archive.isActive() )
+ {
+ LOGGER.info( "Archive {} is inactive, so not updated", archive.getName() );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Archive " + archive.getName() + " is inactive, so not updated" ) );
+ EventUtils.post( environment, "UPDATE", "Archive " + archive.getName() + " is inactive, so not updated" );
+ return;
+ }
+
+ // check to delegate the update
+ if ( archive.getAgent() != null && archive.getAgent().trim().length() > 0 && !archive.getAgent().equals(
+ Configuration.AGENT_ID ) )
+ {
+ LOGGER.info( "Delegating archive {} update to agent {}", archive.getName(), archive.getAgent() );
+ EventUtils.post( environment, "UPDATE",
+ "Delegating archive " + archive.getName() + " update to agent " + archive.getAgent() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Delegating archive " + archive.getName()
+ + " update to agent " + archive.getAgent() ) );
+ Agent delegationAgent = Configuration.CONFIG_CACHE.getAgent( archive.getAgent() );
+ if ( delegationAgent == null )
+ {
+ LOGGER.error( "Agent {} is not found in the configuration", archive.getAgent() );
+ throw new UpdateException( "Agent " + archive.getAgent() + " is not found in the configuration" );
+ }
+ try
+ {
+ LOGGER.debug( "Call archive WS" );
+ ArchiveClient client = new ArchiveClient( delegationAgent.getHostname(), delegationAgent.getPort() );
+ client.update( environment.getName(), server.getName(), application.getName(), archive.getName(),
+ true );
+ }
+ catch ( ClientException clientException )
+ {
+ LOGGER.error( "Archive " + archive.getName() + " update failed", clientException );
+ throw new UpdateException( "Archive " + archive.getName() + " update failed", clientException );
+ }
+ return;
+ }
+
+ // construct the archiveUri
+ String archiveUri = VariableUtils.replace( archive.getUri(), environment.getVariables() );
+ if ( !FileManipulator.protocolExists( archiveUri ) )
+ {
+ // the archive URI is relative (no prefix protocol), use the
+ // application URI to construct the VFS URI
+ LOGGER.debug( "Archive URI is relative (no protocol prefix) to JEE application URI" );
+ archiveUri =
+ FileManipulator.format( VariableUtils.replace( application.getUri(), environment.getVariables() ) )
+ + "!/" + archiveUri;
+ }
+ // get the application cache directory
+ String applicationCacheDir = null;
+ // initialize the file manipulator instance
+ FileManipulator fileManipulator = null;
+ try
+ {
+ applicationCacheDir = FileManipulator.createJEEApplicationCacheDir( environment, application );
+ fileManipulator = new FileManipulator();
+ }
+ catch ( FileManipulatorException e )
+ {
+ LOGGER.error( "Can't create JEE application {} cache directory", application.getName(), e );
+ throw new UpdateException( "Can't create JEE application " + application.getName() + " cache directory",
+ e );
+ }
+ finally
+ {
+ if ( fileManipulator != null )
+ {
+ fileManipulator.close();
+ }
+ }
+ // define the archive cache location
+ String archiveCache = applicationCacheDir + "/" + archive.getName();
+ // define the archive installation URI
+ String archiveInstallation = null;
+ if ( archive.getPath() == null || archive.getPath().trim().length() < 1 )
+ {
+ LOGGER.error( "Archive {} path is not defined", archive.getName() );
+ throw new UpdateException( "Archive " + archive.getName() + " path is not defined" );
+ }
+ // the archive path is defined, use it
+ archiveInstallation = VariableUtils.replace( archive.getPath(), environment.getVariables() );
+ // get the JEE application server controller
+ LOGGER.debug( "Getting the JEE application server controller" );
+ JEEApplicationServerController controller = null;
+ try
+ {
+ controller = JEEApplicationServerControllerFactory.getController( environment, server );
+ }
+ catch ( KalumetException e )
+ {
+ LOGGER.error( "Can't get the JEE application server {} controller", server.getName(), e );
+ throw new UpdateException( "Can't get the JEE application server " + server.getName() + " controller", e );
+ }
+ // check if the archive is already deployed
+ try
+ {
+ if ( controller.isJEEApplicationDeployed( archiveInstallation, archive.getName() ) )
+ {
+ // the archive is already deployed, check for update
+ LOGGER.info( "Archive {} is already deployed, check for update", archive.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Archive " + archive.getName()
+ + " is already deployed, check for update" ) );
+ EventUtils.post( environment, "UPDATE",
+ "Archive " + archive.getName() + " is already deployed, check for update" );
+ if ( !fileManipulator.checksumEquals( archiveUri, archiveCache ) )
+ {
+ // the archive file is different from the copy in the
+ // application directory, perform an update
+ // update the cache
+ fileManipulator.copy( archiveUri, archiveCache );
+ LOGGER.info( "Archive {} (located {}) is different from the cache, performing update",
+ archive.getName(), archiveUri );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Archive " + archive.getName() + " (located "
+ + archiveUri + ") is different from the cache, performing update" ) );
+ EventUtils.post( environment, "UPDATE", "Archive " + archive.getName() + " (located " + archiveUri
+ + ") is different from the cache, performing update" );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Copy " + archiveUri + " to " + archiveInstallation ) );
+ EventUtils.post( environment, "UPDATE", "Copy " + archiveUri + " to " + archiveInstallation );
+ // update the archive path
+ fileManipulator.copy( archiveUri, archiveInstallation );
+ // undeploy the archive
+ LOGGER.info( "Undeploying archive {}", archive.getName() );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Undeploying archive " + archive.getName() ) );
+ EventUtils.post( environment, "UPDATE", "Undeploying archive " + archive.getName() );
+ controller.undeployJEEApplication( archiveInstallation, archive.getName() );
+ // deploy the archive
+ LOGGER.info( "Deploying archive {}", archive.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Deploying archive " + archive.getName() ) );
+ EventUtils.post( environment, "UPDATE", "Deploying archive " + archive.getName() );
+ controller.deployJEEApplication( archiveInstallation, archive.getName(),
+ archive.getClassloaderorder(), archive.getClassloaderpolicy(),
+ VariableUtils.replace( archive.getVhost(),
+ environment.getVariables() ) );
+ LOGGER.info( "Archive {} updated", archive.getName() );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Archive " + archive.getName() + " updated" ) );
+ EventUtils.post( environment, "UPDATE", "Archive " + archive.getName() + " updated" );
+ updateLog.setUpdated( true );
+ }
+ }
+ else
+ {
+ // the archive is not deployed
+ LOGGER.info( "Archive {} is not deployed, deploying it", archive.getName() );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Archive " + archive.getName() + " is not deployed, deploying it" ) );
+ EventUtils.post( environment, "UPDATE",
+ "Archive " + archive.getName() + " is not deployed, deploying it" );
+ // copy the archive agent locally
+ fileManipulator.copy( archiveUri, archiveCache );
+ // copy the archive to the destination path
+ fileManipulator.copy( archiveUri, archiveInstallation );
+ // deploy the archive
+ LOGGER.info( "Deploying archive {}", archive.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Deploying archive " + archive.getName() ) );
+ EventUtils.post( environment, "UPDATE", "Deploying archive " + archive.getName() );
+ controller.deployJEEApplication( archiveInstallation, archive.getName(), archive.getClassloaderorder(),
+ archive.getClassloaderpolicy(),
+ VariableUtils.replace( archive.getVhost(),
+ environment.getVariables() ) );
+ updateLog.setUpdated( true );
+ }
+ // as some JEE application server (like IBM WebSphere) change the archive file during deployment, update
+ // the local archive with a original copy (for next update)
+ LOGGER.debug( "Restoring the original archive (before deployment) from {}", archiveUri );
+ fileManipulator.copy( archiveUri, archiveCache );
+ // check if the JEE application is deployed (it should be)
+ if ( !controller.isJEEApplicationDeployed( archiveInstallation, archive.getName() ) )
+ {
+ LOGGER.error(
+ "Archive {} is not deployed whereas it should be. Please check the JEE application server logs",
+ archive.getName() );
+ throw new UpdateException( "Archive " + archive.getName()
+ + " is not deployed whereas it should be. Please check the JEE application server logs" );
+ }
+ }
+ catch ( Exception e )
+ {
+ // the archive update has failed
+ LOGGER.error( "Archive {} update failed", archive.getName(), e );
+ try
+ {
+ fileManipulator.delete( archiveCache );
+ }
+ catch ( FileManipulatorException fileManipulatorException )
+ {
+ LOGGER.warn( "Can't delete " + archiveCache, fileManipulatorException );
+ }
+ throw new UpdateException( "Archive " + archive.getName() + " update failed", e );
+ }
+ }
+
+ /**
+ * Wrapper method to check if a archive is up to date or not via WS.
+ *
+ * @param environmentName the target environment name.
+ * @param serverName the target JEE application server name.
+ * @param applicationName the target JEE application name.
+ * @param archiveName the target archive name.
+ * @return true if the archive is up to date, false else.
+ * @throws KalumetException in case of status check failure
+ */
+ public static boolean check( String environmentName, String serverName, String applicationName, String archiveName )
+ throws KalumetException
+ {
+ LOGGER.info( "Checking status of archive {} via WS", archiveName );
+ // load configuration
+ LOGGER.debug( "Load configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer applicationServer =
+ environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
+ if ( applicationServer == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environmentName );
+ throw new KalumetException(
+ "JEE application server " + serverName + " is not found in environment " + environmentName );
+ }
+ JEEApplication application = applicationServer.getJEEApplication( applicationName );
+ if ( application == null )
+ {
+ LOGGER.error( "JEE application {} is not found in JEE application server {}", applicationName, serverName );
+ throw new KalumetException(
+ "JEE application " + applicationName + " is not found in JEE application server " + serverName );
+ }
+ Archive archive = application.getArchive( archiveName );
+ if ( archive == null )
+ {
+ LOGGER.error( "Archive {} is not found in JEE application {}", archiveName, applicationName );
+ throw new KalumetException(
+ "Archive " + archiveName + " is not found in JEE application " + applicationName );
+ }
+
+ // check if the check should be delegated to another agent
+ if ( archive.getAgent() != null && archive.getAgent().trim().length() > 0 && !archive.getAgent().equals(
+ Configuration.AGENT_ID ) )
+ {
+ // the check needs to be delegated to another agent
+ LOGGER.info( "Delegating archive {} status check to agent {}", archive.getName(), archive.getAgent() );
+ Agent agentDelegation = kalumet.getAgent( archive.getAgent() );
+ if ( agentDelegation == null )
+ {
+ LOGGER.error( "Agent {} is not found in the configuration", archive.getName() );
+ throw new KalumetException( "Agent " + archive.getAgent() + " is not found in the configuration" );
+ }
+ // call the service
+ ArchiveClient client = new ArchiveClient( agentDelegation.getHostname(), agentDelegation.getPort() );
+ return client.check( environmentName, serverName, applicationName, archiveName );
+ }
+
+ // get JEE application server controller
+ LOGGER.debug( "Getting JEE application server controller" );
+ JEEApplicationServerController controller =
+ JEEApplicationServerControllerFactory.getController( environment, applicationServer );
+
+ FileManipulator fileManipulator = null;
+ try
+ {
+ fileManipulator = new FileManipulator();
+
+ // get application cache directory
+ LOGGER.debug( "Getting application cache directory" );
+ String applicationCacheDirectory = FileManipulator.createJEEApplicationCacheDir( environment, application );
+
+ // construct the archive URI
+ String archiveUri = VariableUtils.replace( archive.getUri(), environment.getVariables() );
+ if ( !FileManipulator.protocolExists( archiveUri ) )
+ {
+ // the archive URI is relative (doesn't contain the protocol prefix), construct the URI using the application URI
+ archiveUri =
+ VariableUtils.replace( application.getUri(), environment.getVariables() ) + "!/" + archiveUri;
+ }
+
+ // get the archive cache
+ String archiveCache = applicationCacheDirectory + "/" + archive.getName();
+
+ // get the archive installation path
+ if ( archive.getPath() == null || archive.getPath().trim().length() < 1 )
+ {
+ LOGGER.error( "Archive {} path is not defined", archive.getName() );
+ throw new KalumetException( "Archive " + archive.getName() + " path is not defined" );
+ }
+ String archiveInstallation = VariableUtils.replace( archive.getPath(), environment.getVariables() );
+
+ if ( controller.isJEEApplicationDeployed( archiveInstallation, archive.getName() ) )
+ {
+ // check if the archive is deployed or not
+ if ( fileManipulator.checksumEquals( archiveUri, archiveCache ) )
+ {
+ // archive URI and cache are the same
+ LOGGER.debug( "Archive URI and agent cache are the same" );
+ return true;
+ }
+ }
+ }
+ finally
+ {
+ if ( fileManipulator != null )
+ {
+ fileManipulator.close();
+ }
+ }
+
+ return false;
+ }
}
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/ConfigurationFileUpdater.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/ConfigurationFileUpdater.java
index 367aab0..9a0c94a 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/ConfigurationFileUpdater.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/ConfigurationFileUpdater.java
@@ -23,8 +23,13 @@
import org.apache.kalumet.KalumetException;
import org.apache.kalumet.agent.Configuration;
import org.apache.kalumet.agent.utils.EventUtils;
-import org.apache.kalumet.model.*;
+import org.apache.kalumet.model.Agent;
+import org.apache.kalumet.model.ConfigurationFile;
+import org.apache.kalumet.model.Environment;
+import org.apache.kalumet.model.JEEApplication;
import org.apache.kalumet.model.JEEApplicationServer;
+import org.apache.kalumet.model.Kalumet;
+import org.apache.kalumet.model.Mapping;
import org.apache.kalumet.model.update.UpdateLog;
import org.apache.kalumet.model.update.UpdateMessage;
import org.apache.kalumet.utils.NotifierUtils;
@@ -43,391 +48,400 @@
public class ConfigurationFileUpdater
{
- private static final transient Logger LOGGER = LoggerFactory.getLogger( ConfigurationFileUpdater.class );
+ private static final transient Logger LOGGER = LoggerFactory.getLogger( ConfigurationFileUpdater.class );
- /**
- * Updates a <code>ConfigurationFile</code>.
- *
- * @param environment the target <code>Environment</code>.
- * @param server the target <code>JEEApplicationServer</code>.
- * @param application the target <code>JEEApplication</code>.
- * @param configurationFile the target <code>ConfigurationFile</code>.
- * @param updateLog the <code>UpdateLog</code> to use.
- */
- public static void update( Environment environment, JEEApplicationServer server, JEEApplication application,
- ConfigurationFile configurationFile, UpdateLog updateLog )
- throws UpdateException
- {
- LOGGER.info( "Updating configuration file {}", configurationFile.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Updating configuration file " + configurationFile.getName() ) );
- EventUtils.post( environment, "UPDATE", "Updating configuration file " + configurationFile.getName() );
-
- if ( !configurationFile.isActive() )
+ /**
+ * Updates a <code>ConfigurationFile</code>.
+ *
+ * @param environment the target <code>Environment</code>.
+ * @param server the target <code>JEEApplicationServer</code>.
+ * @param application the target <code>JEEApplication</code>.
+ * @param configurationFile the target <code>ConfigurationFile</code>.
+ * @param updateLog the <code>UpdateLog</code> to use.
+ */
+ public static void update( Environment environment, JEEApplicationServer server, JEEApplication application,
+ ConfigurationFile configurationFile, UpdateLog updateLog )
+ throws UpdateException
{
- LOGGER.info( "Configuration file {} is inactive, so not updated", configurationFile.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Configuration file " + configurationFile.getName()
- + " is inactive, so not updated" ) );
- EventUtils.post( environment, "UPDATE",
- "Configuration file " + configurationFile.getName() + " is inactive, so not updated" );
- return;
- }
-
- // check for update delegation
- if ( configurationFile.getAgent() != null && configurationFile.getAgent().trim().length() > 0
- && !configurationFile.getAgent().equals( Configuration.AGENT_ID ) )
- {
- LOGGER.info( "Delegating the configuration file {} update to agent {}", configurationFile.getName(),
- configurationFile.getAgent() );
- updateLog.addUpdateMessage( new UpdateMessage( "info",
- "Delegating the configuration file " + configurationFile.getName()
- + " update to agent " + configurationFile.getAgent() ) );
- EventUtils.post( environment, "UPDATE",
- "Delegating the configuration file " + configurationFile.getName() + " update to agent "
- + configurationFile.getAgent() );
- Agent delegationAgent = Configuration.CONFIG_CACHE.getAgent( configurationFile.getAgent() );
- if ( delegationAgent == null )
- {
- // the delegation agent is not found
- LOGGER.error( "Agent {} is not found in the configuration", configurationFile.getAgent() );
- throw new UpdateException( "Agent " + configurationFile.getAgent() + " is not found in the configuration" );
- }
- try
- {
- LOGGER.debug( "Call the configuration file WS" );
- ConfigurationFileClient client =
- new ConfigurationFileClient( delegationAgent.getHostname(), delegationAgent.getPort() );
- client.update( environment.getName(), server.getName(), application.getName(), configurationFile.getName(),
- true );
- }
- catch ( ClientException clientException )
- {
- // delegation update has failed
- LOGGER.error( "Configuration file {} update failed", configurationFile.getName(), clientException );
- throw new UpdateException( "Configuration file " + configurationFile.getName() + " update failed",
- clientException );
- }
- return;
- }
-
- String configurationFileUri = VariableUtils.replace( configurationFile.getUri(), environment.getVariables() );
- if ( !FileManipulator.protocolExists( configurationFileUri ) )
- {
- // the configuration file URI is relative, construct the URI using the JEE application URI
- LOGGER.debug( "The configuration file URI is relative to the JEE application URI" );
- configurationFileUri =
- FileManipulator.format( VariableUtils.replace( application.getUri(), environment.getVariables() ) ) + "!/"
- + configurationFileUri;
- }
-
- // get a file manipulator
- FileManipulator fileManipulator = null;
- try
- {
- LOGGER.debug( "Initializing file manipulator" );
- fileManipulator = new FileManipulator();
- }
- catch ( FileManipulatorException fileManipulatorException )
- {
- LOGGER.error( "Can't initialize file manipulator", fileManipulatorException );
- throw new UpdateException( "Can't initialize file manipulator", fileManipulatorException );
- }
-
- // get the application working directory
- String applicationCacheDir = null;
- try
- {
- LOGGER.debug( "Initializing application cache directory" );
- applicationCacheDir = FileManipulator.createJEEApplicationCacheDir( environment, application );
- }
- catch ( FileManipulatorException fileManipulatorException )
- {
- LOGGER.error( "Can't create JEE application {} cache directory", application.getName(),
- fileManipulatorException );
- throw new UpdateException( "Can't create JEE application " + application.getName() + " cache directory",
- fileManipulatorException );
- }
-
- String configurationFileCache = applicationCacheDir + "/config/" + configurationFile.getName();
- try
- {
- // copy the configuration file in the application cache directory
- LOGGER.debug( "Copying the configuration file {} to the application cache directory",
- configurationFile.getName() );
- fileManipulator.copy( configurationFileUri, configurationFileCache );
- }
- catch ( FileManipulatorException fileManipulatorException )
- {
- LOGGER.error( "Can't copy {} to {}", new Object[]{ configurationFileUri, configurationFileCache },
- fileManipulatorException );
- throw new UpdateException( "Can't copy " + configurationFileUri + " to " + configurationFileCache,
- fileManipulatorException );
- }
-
- // change mappings in the configuration file
- LOGGER.debug( "Replacing mappings key/value" );
- for ( Iterator mappingIterator = configurationFile.getMappings().iterator(); mappingIterator.hasNext(); )
- {
- Mapping mapping = (Mapping) mappingIterator.next();
- FileManipulator.searchAndReplace( mapping.getKey(),
- VariableUtils.replace( mapping.getValue(), environment.getVariables() ),
- configurationFileCache );
- }
-
- // compare the configuration file with the target one
- try
- {
- if ( !fileManipulator.contentEquals( configurationFileCache, VariableUtils.replace( configurationFile.getPath(),
- environment.getVariables() ) ) )
- {
- // the configuration file has changed
- LOGGER.debug( "Configuration file {} has changed", configurationFile.getName() );
- fileManipulator.copy( configurationFileCache,
- VariableUtils.replace( configurationFile.getPath(), environment.getVariables() ) );
- updateLog.setStatus( "Update performed" );
- updateLog.setUpdated( true );
- LOGGER.info( "Configuration file {} updated", configurationFile.getName() );
+ LOGGER.info( "Updating configuration file {}", configurationFile.getName() );
updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Configuration file " + configurationFile.getName() + " updated" ) );
+ new UpdateMessage( "info", "Updating configuration file " + configurationFile.getName() ) );
+ EventUtils.post( environment, "UPDATE", "Updating configuration file " + configurationFile.getName() );
+
+ if ( !configurationFile.isActive() )
+ {
+ LOGGER.info( "Configuration file {} is inactive, so not updated", configurationFile.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Configuration file " + configurationFile.getName()
+ + " is inactive, so not updated" ) );
+ EventUtils.post( environment, "UPDATE",
+ "Configuration file " + configurationFile.getName() + " is inactive, so not updated" );
+ return;
+ }
+
+ // check for update delegation
+ if ( configurationFile.getAgent() != null && configurationFile.getAgent().trim().length() > 0
+ && !configurationFile.getAgent().equals( Configuration.AGENT_ID ) )
+ {
+ LOGGER.info( "Delegating the configuration file {} update to agent {}", configurationFile.getName(),
+ configurationFile.getAgent() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Delegating the configuration file "
+ + configurationFile.getName() + " update to agent " + configurationFile.getAgent() ) );
+ EventUtils.post( environment, "UPDATE",
+ "Delegating the configuration file " + configurationFile.getName() + " update to agent "
+ + configurationFile.getAgent() );
+ Agent delegationAgent = Configuration.CONFIG_CACHE.getAgent( configurationFile.getAgent() );
+ if ( delegationAgent == null )
+ {
+ // the delegation agent is not found
+ LOGGER.error( "Agent {} is not found in the configuration", configurationFile.getAgent() );
+ throw new UpdateException(
+ "Agent " + configurationFile.getAgent() + " is not found in the configuration" );
+ }
+ try
+ {
+ LOGGER.debug( "Call the configuration file WS" );
+ ConfigurationFileClient client =
+ new ConfigurationFileClient( delegationAgent.getHostname(), delegationAgent.getPort() );
+ client.update( environment.getName(), server.getName(), application.getName(),
+ configurationFile.getName(), true );
+ }
+ catch ( ClientException clientException )
+ {
+ // delegation update has failed
+ LOGGER.error( "Configuration file {} update failed", configurationFile.getName(), clientException );
+ throw new UpdateException( "Configuration file " + configurationFile.getName() + " update failed",
+ clientException );
+ }
+ return;
+ }
+
+ String configurationFileUri = VariableUtils.replace( configurationFile.getUri(), environment.getVariables() );
+ if ( !FileManipulator.protocolExists( configurationFileUri ) )
+ {
+ // the configuration file URI is relative, construct the URI using the JEE application URI
+ LOGGER.debug( "The configuration file URI is relative to the JEE application URI" );
+ configurationFileUri =
+ FileManipulator.format( VariableUtils.replace( application.getUri(), environment.getVariables() ) )
+ + "!/" + configurationFileUri;
+ }
+
+ // get a file manipulator
+ FileManipulator fileManipulator = null;
+ try
+ {
+ LOGGER.debug( "Initializing file manipulator" );
+ fileManipulator = new FileManipulator();
+ }
+ catch ( FileManipulatorException fileManipulatorException )
+ {
+ LOGGER.error( "Can't initialize file manipulator", fileManipulatorException );
+ throw new UpdateException( "Can't initialize file manipulator", fileManipulatorException );
+ }
+
+ // get the application working directory
+ String applicationCacheDir = null;
+ try
+ {
+ LOGGER.debug( "Initializing application cache directory" );
+ applicationCacheDir = FileManipulator.createJEEApplicationCacheDir( environment, application );
+ }
+ catch ( FileManipulatorException fileManipulatorException )
+ {
+ LOGGER.error( "Can't create JEE application {} cache directory", application.getName(),
+ fileManipulatorException );
+ throw new UpdateException( "Can't create JEE application " + application.getName() + " cache directory",
+ fileManipulatorException );
+ }
+
+ String configurationFileCache = applicationCacheDir + "/config/" + configurationFile.getName();
+ try
+ {
+ // copy the configuration file in the application cache directory
+ LOGGER.debug( "Copying the configuration file {} to the application cache directory",
+ configurationFile.getName() );
+ fileManipulator.copy( configurationFileUri, configurationFileCache );
+ }
+ catch ( FileManipulatorException fileManipulatorException )
+ {
+ LOGGER.error( "Can't copy {} to {}", new Object[]{ configurationFileUri, configurationFileCache },
+ fileManipulatorException );
+ throw new UpdateException( "Can't copy " + configurationFileUri + " to " + configurationFileCache,
+ fileManipulatorException );
+ }
+
+ // change mappings in the configuration file
+ LOGGER.debug( "Replacing mappings key/value" );
+ for ( Iterator mappingIterator = configurationFile.getMappings().iterator(); mappingIterator.hasNext(); )
+ {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ FileManipulator.searchAndReplace( mapping.getKey(),
+ VariableUtils.replace( mapping.getValue(), environment.getVariables() ),
+ configurationFileCache );
+ }
+
+ // compare the configuration file with the target one
+ try
+ {
+ if ( !fileManipulator.contentEquals( configurationFileCache,
+ VariableUtils.replace( configurationFile.getPath(),
+ environment.getVariables() ) ) )
+ {
+ // the configuration file has changed
+ LOGGER.debug( "Configuration file {} has changed", configurationFile.getName() );
+ fileManipulator.copy( configurationFileCache, VariableUtils.replace( configurationFile.getPath(),
+ environment.getVariables() ) );
+ updateLog.setStatus( "Update performed" );
+ updateLog.setUpdated( true );
+ LOGGER.info( "Configuration file {} updated", configurationFile.getName() );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Configuration file " + configurationFile.getName() + " updated" ) );
+ EventUtils.post( environment, "UPDATE",
+ "Configuration file " + configurationFile.getName() + " updated" );
+ }
+ }
+ catch ( Exception e )
+ {
+ // the configuration file update failed, delete from the cache
+ try
+ {
+ fileManipulator.delete( configurationFileCache );
+ }
+ catch ( FileManipulatorException fileManipulatorException )
+ {
+ LOGGER.warn( "Can't delete {}", configurationFile.getName(), fileManipulatorException );
+ }
+ LOGGER.error( "Configuration file {} update failed", configurationFile.getName(), e );
+ throw new UpdateException( "Configuration file " + configurationFile.getName() + " update failed", e );
+ }
+ }
+
+ /**
+ * Wrapper method to update a configuration file via WS.
+ *
+ * @param environmentName the target environment name.
+ * @param serverName the target JEE application server name.
+ * @param applicationName the target JEE application name.
+ * @param configurationFileName the target configuration file name.
+ * @param delegation flag indicating if the call is made by another agent (true), or by a client (false).
+ * @throws KalumetException in case of update error.
+ */
+ public static void update( String environmentName, String serverName, String applicationName,
+ String configurationFileName, boolean delegation )
+ throws KalumetException
+ {
+ LOGGER.info( "Configuration file {} update requested by WS", configurationFileName );
+
+ // load configuration
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer applicationServer =
+ environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
+ if ( applicationServer == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environmentName );
+ throw new KalumetException(
+ "JEE application server " + serverName + " is not found in environment " + environmentName );
+ }
+ JEEApplication application = applicationServer.getJEEApplication( applicationName );
+ if ( application == null )
+ {
+ LOGGER.error( "JEE application {} is not found in JEE application server {}", applicationName, serverName );
+ throw new KalumetException(
+ "JEE application " + applicationName + " is not found in JEE application server " + serverName );
+ }
+ ConfigurationFile configurationFile = application.getConfigurationFile( configurationFileName );
+ if ( configurationFile == null )
+ {
+ LOGGER.error( "Configuration file {} is not found in JEE application {}", configurationFileName,
+ applicationName );
+ throw new KalumetException(
+ "Configuration file " + configurationFileName + " is not found in JEE application " + applicationName );
+ }
+
+ // update cache
+ LOGGER.debug( "Updating configuration cache" );
+ Configuration.CONFIG_CACHE = kalumet;
+
+ // post event and create update logger
+ EventUtils.post( environment, "UPDATE",
+ "Configuration file " + configurationFile.getName() + " update requested by WS" );
+ UpdateLog updateLog =
+ new UpdateLog( "Configuration file " + configurationFile.getName() + " update in progress ...",
+ environment.getName(), environment );
+
+ // send and wait a notification if it's not a delegation
+ if ( !delegation )
+ {
+ // it's a client call
+ LOGGER.info( "Send a notification and waiting for the count down" );
+ EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
+ NotifierUtils.waitAndNotify( environment );
+ }
+
+ try
+ {
+ // call the updater method
+ LOGGER.debug( "Call configuration file updater" );
+ ConfigurationFileUpdater.update( environment, applicationServer, application, configurationFile,
+ updateLog );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Configuration file {} update failed", configurationFile.getName(), e );
+ EventUtils.post( environment, "ERROR",
+ "Configuration file " + configurationFile.getName() + " update failed: "
+ + e.getMessage() );
+ if ( !delegation )
+ {
+ // it's a client call, send a publisher
+ updateLog.setStatus( "Configuration file " + configurationFile.getName() + " update failed" );
+ updateLog.addUpdateMessage( new UpdateMessage( "error",
+ "Configuration file " + configurationFile.getName()
+ + " update failed: " + e.getMessage() ) );
+ PublisherUtils.publish( environment );
+ }
+ throw new UpdateException(
+ "Configuration file " + configurationFile.getName() + " update FAILED: " + e.getMessage(), e );
+ }
+
+ LOGGER.info( "Configuration file {} updated", configurationFile.getName() );
EventUtils.post( environment, "UPDATE", "Configuration file " + configurationFile.getName() + " updated" );
- }
+ if ( !delegation )
+ {
+ if ( updateLog.isUpdated() )
+ {
+ updateLog.setStatus( "Configuration file " + configurationFile.getName() + " updated" );
+ }
+ else
+ {
+ updateLog.setStatus( "Configuration file " + configurationFile.getName() + " already up to date" );
+ }
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Configuration file " + configurationFile.getName() + " updated" ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
+ }
}
- catch ( Exception e )
+
+ /**
+ * Wrapper method to check if a configuration file is update to date or not via WS.
+ *
+ * @param environmentName the target environment name.
+ * @param serverName the target JEE application server name.
+ * @param applicationName the target JEE application name.
+ * @param configurationFileName the target configuration file name.
+ * @return true if the configuration file is up to date, false else.
+ * @throws KalumetException in case of error during configuration file check.
+ */
+ public static boolean check( String environmentName, String serverName, String applicationName,
+ String configurationFileName )
+ throws KalumetException
{
- // the configuration file update failed, delete from the cache
- try
- {
- fileManipulator.delete( configurationFileCache );
- }
- catch ( FileManipulatorException fileManipulatorException )
- {
- LOGGER.warn( "Can't delete {}", configurationFile.getName(), fileManipulatorException );
- }
- LOGGER.error( "Configuration file {} update failed", configurationFile.getName(), e );
- throw new UpdateException( "Configuration file " + configurationFile.getName() + " update failed", e );
+ LOGGER.info( "Configuration file {} status check requested by WS", configurationFileName );
+
+ // load configuration.
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer applicationServer =
+ environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
+ if ( applicationServer == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environmentName );
+ throw new KalumetException(
+ "JEE application server " + serverName + " is not found in environment " + environmentName );
+ }
+ JEEApplication application = applicationServer.getJEEApplication( applicationName );
+ if ( application == null )
+ {
+ LOGGER.error( "JEE application {} is not found in JEE application server {}", applicationName, serverName );
+ throw new KalumetException(
+ "JEE application " + applicationName + " is not found in JEE application server " + serverName );
+ }
+ ConfigurationFile configurationFile = application.getConfigurationFile( configurationFileName );
+ if ( configurationFile == null )
+ {
+ LOGGER.error( "Configuration file {} is not found in JEE application {}", configurationFileName,
+ applicationName );
+ throw new KalumetException(
+ "Configuration file " + configurationFileName + " is not found in JEE application " + applicationName );
+ }
+
+ if ( configurationFile.getAgent() != null && configurationFile.getAgent().trim().length() > 0
+ && !configurationFile.getAgent().equals( Configuration.AGENT_ID ) )
+ {
+ // the check needs to be delegate to another agent
+ LOGGER.info( "Delegating configuration file {} check to agent {}", configurationFile.getName(),
+ configurationFile.getAgent() );
+ Agent agentDelegation = Configuration.CONFIG_CACHE.getAgent( configurationFile.getAgent() );
+ if ( agentDelegation == null )
+ {
+ LOGGER.error( "Agent {} is not found in the configuration", configurationFile.getAgent() );
+ throw new KalumetException(
+ "Agent " + configurationFile.getAgent() + " is not found in the configuration" );
+ }
+ // call the service
+ ConfigurationFileClient client =
+ new ConfigurationFileClient( agentDelegation.getHostname(), agentDelegation.getPort() );
+ return client.check( environmentName, serverName, applicationName, configurationFileName );
+ }
+
+ // initialize the file manipulator.
+ LOGGER.debug( "Initializing file manipulator" );
+ FileManipulator fileManipulator = new FileManipulator();
+
+ // constructs the configuration file URI.
+ String configurationFileUri = VariableUtils.replace( configurationFile.getUri(), environment.getVariables() );
+ if ( !FileManipulator.protocolExists( configurationFileUri ) )
+ {
+ // the configuration file URI doesn't contain protocol prefix,
+ // constructs the configuration file URI using the application URI
+ LOGGER.debug( "Configuration file {} URI is relative to the JEE application one",
+ configurationFile.getName() );
+ configurationFileUri =
+ FileManipulator.format( VariableUtils.replace( application.getUri(), environment.getVariables() ) )
+ + "!/" + configurationFileUri;
+ }
+
+ // get the application cache directory.
+ LOGGER.debug( "Creating the application cache directory" );
+ String applicationCacheDir = FileManipulator.createJEEApplicationCacheDir( environment, application );
+
+ // get the configuration file cache.
+ LOGGER.debug( "Creating the configuration file cache location" );
+ String configurationFileCache = applicationCacheDir + "/config/" + configurationFile.getName();
+
+ // copy the configuration file in the application cache directory
+ LOGGER.debug( "Copying the configuration file {} to the application cache directory",
+ configurationFile.getName() );
+ fileManipulator.copy( configurationFileUri, configurationFileCache );
+
+ // change mappings into the configuration file.
+ LOGGER.debug( "Replacing mappings key/value" );
+ for ( Iterator mappingIterator = configurationFile.getMappings().iterator(); mappingIterator.hasNext(); )
+ {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ FileManipulator.searchAndReplace( mapping.getKey(),
+ VariableUtils.replace( mapping.getValue(), environment.getVariables() ),
+ configurationFileCache );
+ }
+
+ // compare the configuration file with the target one.
+ return fileManipulator.contentEquals( configurationFileCache,
+ VariableUtils.replace( configurationFile.getPath(),
+ environment.getVariables() ) );
}
- }
-
- /**
- * Wrapper method to update a configuration file via WS.
- *
- * @param environmentName the target environment name.
- * @param serverName the target JEE application server name.
- * @param applicationName the target JEE application name.
- * @param configurationFileName the target configuration file name.
- * @param delegation flag indicating if the call is made by another agent (true), or by a client (false).
- * @throws KalumetException in case of update error.
- */
- public static void update( String environmentName, String serverName, String applicationName,
- String configurationFileName, boolean delegation )
- throws KalumetException
- {
- LOGGER.info( "Configuration file {} update requested by WS", configurationFileName );
-
- // load configuration
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer applicationServer =
- environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
- if ( applicationServer == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environmentName );
- throw new KalumetException(
- "JEE application server " + serverName + " is not found in environment " + environmentName );
- }
- JEEApplication application = applicationServer.getJEEApplication( applicationName );
- if ( application == null )
- {
- LOGGER.error( "JEE application {} is not found in JEE application server {}", applicationName, serverName );
- throw new KalumetException(
- "JEE application " + applicationName + " is not found in JEE application server " + serverName );
- }
- ConfigurationFile configurationFile = application.getConfigurationFile( configurationFileName );
- if ( configurationFile == null )
- {
- LOGGER.error( "Configuration file {} is not found in JEE application {}", configurationFileName,
- applicationName );
- throw new KalumetException(
- "Configuration file " + configurationFileName + " is not found in JEE application " + applicationName );
- }
-
- // update cache
- LOGGER.debug( "Updating configuration cache" );
- Configuration.CONFIG_CACHE = kalumet;
-
- // post event and create update logger
- EventUtils.post( environment, "UPDATE",
- "Configuration file " + configurationFile.getName() + " update requested by WS" );
- UpdateLog updateLog =
- new UpdateLog( "Configuration file " + configurationFile.getName() + " update in progress ...",
- environment.getName(), environment );
-
- // send and wait a notification if it's not a delegation
- if ( !delegation )
- {
- // it's a client call
- LOGGER.info( "Send a notification and waiting for the count down" );
- EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
- NotifierUtils.waitAndNotify( environment );
- }
-
- try
- {
- // call the updater method
- LOGGER.debug( "Call configuration file updater" );
- ConfigurationFileUpdater.update( environment, applicationServer, application, configurationFile, updateLog );
- }
- catch ( Exception e )
- {
- LOGGER.error( "Configuration file {} update failed", configurationFile.getName(), e );
- EventUtils.post( environment, "ERROR",
- "Configuration file " + configurationFile.getName() + " update failed: " + e.getMessage() );
- if ( !delegation )
- {
- // it's a client call, send a publisher
- updateLog.setStatus( "Configuration file " + configurationFile.getName() + " update failed" );
- updateLog.addUpdateMessage( new UpdateMessage( "error", "Configuration file " + configurationFile.getName()
- + " update failed: " + e.getMessage() ) );
- PublisherUtils.publish( environment );
- }
- throw new UpdateException(
- "Configuration file " + configurationFile.getName() + " update FAILED: " + e.getMessage(), e );
- }
-
- LOGGER.info( "Configuration file {} updated", configurationFile.getName() );
- EventUtils.post( environment, "UPDATE", "Configuration file " + configurationFile.getName() + " updated" );
- if ( !delegation )
- {
- if ( updateLog.isUpdated() )
- {
- updateLog.setStatus( "Configuration file " + configurationFile.getName() + " updated" );
- }
- else
- {
- updateLog.setStatus( "Configuration file " + configurationFile.getName() + " already up to date" );
- }
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Configuration file " + configurationFile.getName() + " updated" ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
- }
- }
-
- /**
- * Wrapper method to check if a configuration file is update to date or not via WS.
- *
- * @param environmentName the target environment name.
- * @param serverName the target JEE application server name.
- * @param applicationName the target JEE application name.
- * @param configurationFileName the target configuration file name.
- * @return true if the configuration file is up to date, false else.
- * @throws KalumetException in case of error during configuration file check.
- */
- public static boolean check( String environmentName, String serverName, String applicationName,
- String configurationFileName )
- throws KalumetException
- {
- LOGGER.info( "Configuration file {} status check requested by WS", configurationFileName );
-
- // load configuration.
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
-
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer applicationServer =
- environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
- if ( applicationServer == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environmentName );
- throw new KalumetException(
- "JEE application server " + serverName + " is not found in environment " + environmentName );
- }
- JEEApplication application = applicationServer.getJEEApplication( applicationName );
- if ( application == null )
- {
- LOGGER.error( "JEE application {} is not found in JEE application server {}", applicationName, serverName );
- throw new KalumetException(
- "JEE application " + applicationName + " is not found in JEE application server " + serverName );
- }
- ConfigurationFile configurationFile = application.getConfigurationFile( configurationFileName );
- if ( configurationFile == null )
- {
- LOGGER.error( "Configuration file {} is not found in JEE application {}", configurationFileName,
- applicationName );
- throw new KalumetException(
- "Configuration file " + configurationFileName + " is not found in JEE application " + applicationName );
- }
-
- if ( configurationFile.getAgent() != null && configurationFile.getAgent().trim().length() > 0
- && !configurationFile.getAgent().equals( Configuration.AGENT_ID ) )
- {
- // the check needs to be delegate to another agent
- LOGGER.info( "Delegating configuration file {} check to agent {}", configurationFile.getName(),
- configurationFile.getAgent() );
- Agent agentDelegation = Configuration.CONFIG_CACHE.getAgent( configurationFile.getAgent() );
- if ( agentDelegation == null )
- {
- LOGGER.error( "Agent {} is not found in the configuration", configurationFile.getAgent() );
- throw new KalumetException( "Agent " + configurationFile.getAgent() + " is not found in the configuration" );
- }
- // call the service
- ConfigurationFileClient client =
- new ConfigurationFileClient( agentDelegation.getHostname(), agentDelegation.getPort() );
- return client.check( environmentName, serverName, applicationName, configurationFileName );
- }
-
- // initialize the file manipulator.
- LOGGER.debug( "Initializing file manipulator" );
- FileManipulator fileManipulator = new FileManipulator();
-
- // constructs the configuration file URI.
- String configurationFileUri = VariableUtils.replace( configurationFile.getUri(), environment.getVariables() );
- if ( !FileManipulator.protocolExists( configurationFileUri ) )
- {
- // the configuration file URI doesn't contain protocol prefix,
- // constructs the configuration file URI using the application URI
- LOGGER.debug( "Configuration file {} URI is relative to the JEE application one", configurationFile.getName() );
- configurationFileUri =
- FileManipulator.format( VariableUtils.replace( application.getUri(), environment.getVariables() ) ) + "!/"
- + configurationFileUri;
- }
-
- // get the application cache directory.
- LOGGER.debug( "Creating the application cache directory" );
- String applicationCacheDir = FileManipulator.createJEEApplicationCacheDir( environment, application );
-
- // get the configuration file cache.
- LOGGER.debug( "Creating the configuration file cache location" );
- String configurationFileCache = applicationCacheDir + "/config/" + configurationFile.getName();
-
- // copy the configuration file in the application cache directory
- LOGGER.debug( "Copying the configuration file {} to the application cache directory", configurationFile.getName() );
- fileManipulator.copy( configurationFileUri, configurationFileCache );
-
- // change mappings into the configuration file.
- LOGGER.debug( "Replacing mappings key/value" );
- for ( Iterator mappingIterator = configurationFile.getMappings().iterator(); mappingIterator.hasNext(); )
- {
- Mapping mapping = (Mapping) mappingIterator.next();
- FileManipulator.searchAndReplace( mapping.getKey(),
- VariableUtils.replace( mapping.getValue(), environment.getVariables() ),
- configurationFileCache );
- }
-
- // compare the configuration file with the target one.
- return fileManipulator.contentEquals( configurationFileCache, VariableUtils.replace( configurationFile.getPath(),
- environment.getVariables() ) );
- }
}
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/ContentManagerUpdater.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/ContentManagerUpdater.java
index 9073b82..c8204cd 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/ContentManagerUpdater.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/ContentManagerUpdater.java
@@ -21,8 +21,13 @@
import org.apache.kalumet.KalumetException;
import org.apache.kalumet.agent.Configuration;
import org.apache.kalumet.agent.utils.EventUtils;
-import org.apache.kalumet.model.*;
+import org.apache.kalumet.model.Agent;
+import org.apache.kalumet.model.ContentManager;
+import org.apache.kalumet.model.Environment;
import org.apache.kalumet.model.JEEApplication;
+import org.apache.kalumet.model.JEEApplicationServer;
+import org.apache.kalumet.model.Kalumet;
+import org.apache.kalumet.model.Property;
import org.apache.kalumet.model.update.UpdateLog;
import org.apache.kalumet.model.update.UpdateMessage;
import org.apache.kalumet.utils.NotifierUtils;
@@ -42,215 +47,222 @@
public class ContentManagerUpdater
{
- private static final transient Logger LOGGER = LoggerFactory.getLogger( ContentManagerUpdater.class );
+ private static final transient Logger LOGGER = LoggerFactory.getLogger( ContentManagerUpdater.class );
- /**
- * Update a content manager.
- *
- * @param environment the target <code>Environment</code>.
- * @param server the target <code>JEEApplicationServer</code>.
- * @param application the target <code>JEEApplication</code>.
- * @param contentManager the target <code>ContentManager</code>.
- * @param updateLog the <code>UpdateLog</code> to use.
- * @throws UpdateException in case of update failure.
- */
- public static void update( Environment environment, JEEApplicationServer server, JEEApplication application,
- ContentManager contentManager, UpdateLog updateLog )
- throws UpdateException
- {
- LOGGER.info( "Updating content manager {}", contentManager.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Updating content manager " + contentManager.getName() ) );
- EventUtils.post( environment, "UPDATE", "Updating content manager " + contentManager.getName() );
-
- if ( !contentManager.isActive() )
+ /**
+ * Update a content manager.
+ *
+ * @param environment the target <code>Environment</code>.
+ * @param server the target <code>JEEApplicationServer</code>.
+ * @param application the target <code>JEEApplication</code>.
+ * @param contentManager the target <code>ContentManager</code>.
+ * @param updateLog the <code>UpdateLog</code> to use.
+ * @throws UpdateException in case of update failure.
+ */
+ public static void update( Environment environment, JEEApplicationServer server, JEEApplication application,
+ ContentManager contentManager, UpdateLog updateLog )
+ throws UpdateException
{
- // the content manager is not active
- LOGGER.info( "Content manager {} is inactive, so not updated", contentManager.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Content manager " + contentManager.getName() + " is inactive, so not updated" ) );
- EventUtils.post( environment, "UPDATE",
- "Content manager " + contentManager.getName() + " is inactive, so not updated" );
- return;
+ LOGGER.info( "Updating content manager {}", contentManager.getName() );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Updating content manager " + contentManager.getName() ) );
+ EventUtils.post( environment, "UPDATE", "Updating content manager " + contentManager.getName() );
+
+ if ( !contentManager.isActive() )
+ {
+ // the content manager is not active
+ LOGGER.info( "Content manager {} is inactive, so not updated", contentManager.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Content manager " + contentManager.getName()
+ + " is inactive, so not updated" ) );
+ EventUtils.post( environment, "UPDATE",
+ "Content manager " + contentManager.getName() + " is inactive, so not updated" );
+ return;
+ }
+
+ if ( contentManager.getAgent() != null && contentManager.getAgent().trim().length() > 0
+ && !contentManager.getAgent().equals( Configuration.AGENT_ID ) )
+ {
+ // the content manager update is delegated to another agent
+ LOGGER.info( "Delegating content manager {} update to agent {}", contentManager.getName(),
+ contentManager.getAgent() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info",
+ "Delegating content manager " + contentManager.getName()
+ + " update to agent " + contentManager.getAgent() ) );
+ EventUtils.post( environment, "UPDATE",
+ "Delegating content manager " + contentManager.getName() + " update to agent "
+ + contentManager.getAgent() );
+ Agent delegationAgent = Configuration.CONFIG_CACHE.getAgent( contentManager.getAgent() );
+ if ( delegationAgent == null )
+ {
+ // the content manager agent is not found in the configuration
+ LOGGER.error( "Agent {} is not found in the configuration", contentManager.getAgent() );
+ throw new UpdateException(
+ "Agent " + contentManager.getAgent() + " is not found in the configuration" );
+ }
+ try
+ {
+ // call agent WebService
+ LOGGER.debug( "Calling content manager WebService WS" );
+ ContentManagerClient client =
+ new ContentManagerClient( delegationAgent.getHostname(), delegationAgent.getPort() );
+ client.update( environment.getName(), server.getName(), application.getName(), contentManager.getName(),
+ true );
+ }
+ catch ( ClientException clientException )
+ {
+ LOGGER.error( "Content manager {} update failed", contentManager.getName(), clientException );
+ throw new UpdateException( "Content manager " + contentManager.getName() + " update failed",
+ clientException );
+ }
+ return;
+ }
+
+ try
+ {
+ LOGGER.debug( "Loading content manager class name" );
+ Class contentManagerClass =
+ Class.forName( VariableUtils.replace( contentManager.getClassname(), environment.getVariables() ) );
+ Object contentManagerObject = contentManagerClass.newInstance();
+ // call method properties
+ for ( Iterator propertyIterator = contentManager.getProperties().iterator(); propertyIterator.hasNext(); )
+ {
+ Property property = (Property) propertyIterator.next();
+ Method method = contentManagerClass.getMethod(
+ "set" + VariableUtils.replace( property.getName(), environment.getVariables() ),
+ new Class[]{ String.class } );
+ method.invoke( contentManagerObject, new Object[]{
+ VariableUtils.replace( property.getValue(), environment.getVariables() ) } );
+ }
+ // call main method
+ Method mainMethod = contentManagerClass.getMethod( "main", new Class[]{ } );
+ mainMethod.invoke( contentManagerObject, new Object[]{ } );
+ LOGGER.info( "Content manager {} updated", contentManager.getName() );
+ updateLog.setStatus( "update performed" );
+ updateLog.setUpdated( true );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Content manager " + contentManager.getName() + " updated" ) );
+ EventUtils.post( environment, "UPDATE", "Content manager " + contentManager.getName() + " updated" );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Content manager {} update failed", contentManager.getName(), e );
+ throw new UpdateException( "Content manager " + contentManager.getName() + " update failed", e );
+ }
}
- if ( contentManager.getAgent() != null && contentManager.getAgent().trim().length() > 0
- && !contentManager.getAgent().equals( Configuration.AGENT_ID ) )
+ /**
+ * Wrapper method to update a content manager via WS.
+ *
+ * @param environmentName the target environment name.
+ * @param serverName the target JEE application server name.
+ * @param applicationName the target JEE application name.
+ * @param contentManagerName the target content manager name.
+ * @param delegation flag indicating if the update is called by another agent (true) or by a client (false).
+ * @throws KalumetException in case of update failure.
+ */
+ public static void update( String environmentName, String serverName, String applicationName,
+ String contentManagerName, boolean delegation )
+ throws KalumetException
{
- // the content manager update is delegated to another agent
- LOGGER.info( "Delegating content manager {} update to agent {}", contentManager.getName(),
- contentManager.getAgent() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Delegating content manager " + contentManager.getName()
- + " update to agent " + contentManager.getAgent() ) );
- EventUtils.post( environment, "UPDATE",
- "Delegating content manager " + contentManager.getName() + " update to agent "
- + contentManager.getAgent() );
- Agent delegationAgent = Configuration.CONFIG_CACHE.getAgent( contentManager.getAgent() );
- if ( delegationAgent == null )
- {
- // the content manager agent is not found in the configuration
- LOGGER.error( "Agent {} is not found in the configuration", contentManager.getAgent() );
- throw new UpdateException( "Agent " + contentManager.getAgent() + " is not found in the configuration" );
- }
- try
- {
- // call agent WebService
- LOGGER.debug( "Calling content manager WebService WS" );
- ContentManagerClient client =
- new ContentManagerClient( delegationAgent.getHostname(), delegationAgent.getPort() );
- client.update( environment.getName(), server.getName(), application.getName(), contentManager.getName(), true );
- }
- catch ( ClientException clientException )
- {
- LOGGER.error( "Content manager {} update failed", contentManager.getName(), clientException );
- throw new UpdateException( "Content manager " + contentManager.getName() + " update failed", clientException );
- }
- return;
- }
+ LOGGER.info( "Content manager {} update requested by WS", contentManagerName );
- try
- {
- LOGGER.debug( "Loading content manager class name" );
- Class contentManagerClass =
- Class.forName( VariableUtils.replace( contentManager.getClassname(), environment.getVariables() ) );
- Object contentManagerObject = contentManagerClass.newInstance();
- // call method properties
- for ( Iterator propertyIterator = contentManager.getProperties().iterator(); propertyIterator.hasNext(); )
- {
- Property property = (Property) propertyIterator.next();
- Method method = contentManagerClass.getMethod(
- "set" + VariableUtils.replace( property.getName(), environment.getVariables() ),
- new Class[]{ String.class } );
- method.invoke( contentManagerObject,
- new Object[]{ VariableUtils.replace( property.getValue(), environment.getVariables() ) } );
- }
- // call main method
- Method mainMethod = contentManagerClass.getMethod( "main", new Class[]{ } );
- mainMethod.invoke( contentManagerObject, new Object[]{ } );
- LOGGER.info( "Content manager {} updated", contentManager.getName() );
- updateLog.setStatus( "update performed" );
- updateLog.setUpdated( true );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Content manager " + contentManager.getName() + " updated" ) );
- EventUtils.post( environment, "UPDATE", "Content manager " + contentManager.getName() + " updated" );
- }
- catch ( Exception e )
- {
- LOGGER.error( "Content manager {} update failed", contentManager.getName(), e );
- throw new UpdateException( "Content manager " + contentManager.getName() + " update failed", e );
- }
- }
+ // load configuration.
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- /**
- * Wrapper method to update a content manager via WS.
- *
- * @param environmentName the target environment name.
- * @param serverName the target JEE application server name.
- * @param applicationName the target JEE application name.
- * @param contentManagerName the target content manager name.
- * @param delegation flag indicating if the update is called by another agent (true) or by a client (false).
- * @throws KalumetException in case of update failure.
- */
- public static void update( String environmentName, String serverName, String applicationName,
- String contentManagerName, boolean delegation )
- throws KalumetException
- {
- LOGGER.info( "Content manager {} update requested by WS", contentManagerName );
+ // looking for component objects.
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer applicationServer =
+ environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
+ if ( applicationServer == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", serverName,
+ environment.getName() );
+ throw new KalumetException(
+ "JEE application server " + serverName + " is not found in environment " + environment.getName() );
+ }
+ JEEApplication application = applicationServer.getJEEApplication( applicationName );
+ if ( application == null )
+ {
+ LOGGER.error( "JEE application {} is not found in JEE application server {}", applicationName,
+ applicationServer.getName() );
+ throw new KalumetException(
+ "JEE application " + applicationName + " is not found in JEE application server "
+ + applicationServer.getName() );
+ }
+ ContentManager contentManager = application.getContentManager( contentManagerName );
+ if ( contentManager == null )
+ {
+ LOGGER.error( "Content manager {} is not found in JEE application {}", contentManagerName,
+ application.getName() );
+ throw new KalumetException(
+ "Content manager " + contentManagerName + " is not found in JEE application " + application.getName() );
+ }
- // load configuration.
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ // update configuration cache.
+ LOGGER.debug( "Updating configuration cache" );
+ Configuration.CONFIG_CACHE = kalumet;
- // looking for component objects.
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer applicationServer =
- environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
- if ( applicationServer == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environment.getName() );
- throw new KalumetException(
- "JEE application server " + serverName + " is not found in environment " + environment.getName() );
- }
- JEEApplication application = applicationServer.getJEEApplication( applicationName );
- if ( application == null )
- {
- LOGGER.error( "JEE application {} is not found in JEE application server {}", applicationName,
- applicationServer.getName() );
- throw new KalumetException( "JEE application " + applicationName + " is not found in JEE application server "
- + applicationServer.getName() );
- }
- ContentManager contentManager = application.getContentManager( contentManagerName );
- if ( contentManager == null )
- {
- LOGGER.error( "Content manager {} is not found in JEE application {}", contentManagerName,
- application.getName() );
- throw new KalumetException(
- "Content manager " + contentManagerName + " is not found in JEE application " + application.getName() );
- }
+ // post event and create an update log
+ EventUtils.post( environment, "UPDATE",
+ "Content manager " + contentManager.getName() + " update requested by WS" );
+ UpdateLog updateLog = new UpdateLog( "Content manager " + contentManager.getName() + " update in progress ...",
+ environment.getName(), environment );
- // update configuration cache.
- LOGGER.debug( "Updating configuration cache" );
- Configuration.CONFIG_CACHE = kalumet;
+ if ( !delegation )
+ {
+ // the update is a client call,
+ // send a notification and waiting for the count down
+ LOGGER.info( "Send a notification and waiting for the count down" );
+ EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
+ NotifierUtils.waitAndNotify( environment );
+ }
- // post event and create an update log
- EventUtils.post( environment, "UPDATE", "Content manager " + contentManager.getName() + " update requested by WS" );
- UpdateLog updateLog =
- new UpdateLog( "Content manager " + contentManager.getName() + " update in progress ...", environment.getName(),
- environment );
+ try
+ {
+ // call the content manager updater
+ LOGGER.debug( "Call content manager updater" );
+ ContentManagerUpdater.update( environment, applicationServer, application, contentManager, updateLog );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Content manager " + contentManager.getName() + " update failed", e );
+ EventUtils.post( environment, "ERROR",
+ "Content manager " + contentManager.getName() + " update failed: " + e.getMessage() );
+ if ( !delegation )
+ {
+ updateLog.setStatus( "Content manager " + contentManager.getName() + " update failed" );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "Content manager " + contentManager.getName()
+ + " update failed: " + e.getMessage() ) );
+ PublisherUtils.publish( environment );
+ }
+ throw new UpdateException( "Content manager " + contentManager.getName() + " update failed", e );
+ }
- if ( !delegation )
- {
- // the update is a client call,
- // send a notification and waiting for the count down
- LOGGER.info( "Send a notification and waiting for the count down" );
- EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
- NotifierUtils.waitAndNotify( environment );
+ // update completed
+ LOGGER.info( "Content manager {} updated", contentManager.getName() );
+ EventUtils.post( environment, "UPDATE", "Content manager " + contentManager.getName() + " updated" );
+ if ( !delegation )
+ {
+ if ( updateLog.isUpdated() )
+ {
+ updateLog.setStatus( "Content manager " + contentManager.getName() + " updated" );
+ }
+ else
+ {
+ updateLog.setStatus( "Content manager " + contentManager.getName() + " already up to date" );
+ }
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Content manager " + contentManager.getName() + " updated" ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
+ }
+
}
- try
- {
- // call the content manager updater
- LOGGER.debug( "Call content manager updater" );
- ContentManagerUpdater.update( environment, applicationServer, application, contentManager, updateLog );
- }
- catch ( Exception e )
- {
- LOGGER.error( "Content manager " + contentManager.getName() + " update failed", e );
- EventUtils.post( environment, "ERROR",
- "Content manager " + contentManager.getName() + " update failed: " + e.getMessage() );
- if ( !delegation )
- {
- updateLog.setStatus( "Content manager " + contentManager.getName() + " update failed" );
- updateLog.addUpdateMessage( new UpdateMessage( "error", "Content manager " + contentManager.getName()
- + " update failed: " + e.getMessage() ) );
- PublisherUtils.publish( environment );
- }
- throw new UpdateException( "Content manager " + contentManager.getName() + " update failed", e );
- }
-
- // update completed
- LOGGER.info( "Content manager {} updated", contentManager.getName() );
- EventUtils.post( environment, "UPDATE", "Content manager " + contentManager.getName() + " updated" );
- if ( !delegation )
- {
- if ( updateLog.isUpdated() )
- {
- updateLog.setStatus( "Content manager " + contentManager.getName() + " updated" );
- }
- else
- {
- updateLog.setStatus( "Content manager " + contentManager.getName() + " already up to date" );
- }
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Content manager " + contentManager.getName() + " updated" ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
- }
-
- }
-
}
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/DatabaseUpdater.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/DatabaseUpdater.java
index 0ba5249..e58528c 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/DatabaseUpdater.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/DatabaseUpdater.java
@@ -21,8 +21,13 @@
import org.apache.kalumet.KalumetException;
import org.apache.kalumet.agent.Configuration;
import org.apache.kalumet.agent.utils.EventUtils;
-import org.apache.kalumet.model.*;
+import org.apache.kalumet.model.Agent;
+import org.apache.kalumet.model.Database;
+import org.apache.kalumet.model.Environment;
import org.apache.kalumet.model.JEEApplication;
+import org.apache.kalumet.model.JEEApplicationServer;
+import org.apache.kalumet.model.Kalumet;
+import org.apache.kalumet.model.SqlScript;
import org.apache.kalumet.model.update.UpdateLog;
import org.apache.kalumet.model.update.UpdateMessage;
import org.apache.kalumet.utils.NotifierUtils;
@@ -40,215 +45,217 @@
public class DatabaseUpdater
{
- private static final transient Logger LOGGER = LoggerFactory.getLogger( DatabaseUpdater.class );
+ private static final transient Logger LOGGER = LoggerFactory.getLogger( DatabaseUpdater.class );
- /**
- * Updates a database.
- *
- * @param environment the target <code>Environment</code>.
- * @param server the target <code>JEEApplicationServer</code>.
- * @param application the target <code>JEEApplication</code>.
- * @param database the target <code>Database</code>.
- * @param updateLog the <code>UpdateLog</code> to use.
- */
- public static void update( Environment environment, JEEApplicationServer server, JEEApplication application,
- Database database, UpdateLog updateLog )
- throws UpdateException
- {
- LOGGER.info( "Updating database {}", database.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Updating database " + database.getName() ) );
- EventUtils.post( environment, "UPDATE", "Updating database " + database.getName() );
-
- if ( !database.isActive() )
+ /**
+ * Updates a database.
+ *
+ * @param environment the target <code>Environment</code>.
+ * @param server the target <code>JEEApplicationServer</code>.
+ * @param application the target <code>JEEApplication</code>.
+ * @param database the target <code>Database</code>.
+ * @param updateLog the <code>UpdateLog</code> to use.
+ */
+ public static void update( Environment environment, JEEApplicationServer server, JEEApplication application,
+ Database database, UpdateLog updateLog )
+ throws UpdateException
{
- // database is not active
- LOGGER.info( "Database {} is inactive, so not updated", database.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Database " + database.getName() + " is inactive, so not updated" ) );
- EventUtils.post( environment, "UPDATE", "Database " + database.getName() + " is inactive, so not updated" );
- return;
- }
+ LOGGER.info( "Updating database {}", database.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Updating database " + database.getName() ) );
+ EventUtils.post( environment, "UPDATE", "Updating database " + database.getName() );
- if ( database.getAgent() != null && database.getAgent().trim().length() > 0 && !database.getAgent().equals(
- Configuration.AGENT_ID ) )
- {
- // database update delegated to another agent
- LOGGER.info( "Delegating database {} update to agent {}", database.getName(), database.getAgent() );
- updateLog.addUpdateMessage( new UpdateMessage( "info",
- "Delegating database " + database.getName() + " update to agent "
- + database.getAgent() ) );
- EventUtils.post( environment, "UPDATE",
- "Delegating database " + database.getName() + " update to agent " + database.getAgent() );
- Agent delegationAgent = Configuration.CONFIG_CACHE.getAgent( database.getAgent() );
- if ( delegationAgent == null )
- {
- // database agent is not found in configuration
- LOGGER.error( "Agent {} is not found in the configuration", database.getAgent() );
- throw new UpdateException( "Agent " + database.getAgent() + " is not found in the configuration" );
- }
- try
- {
- // call WS
- LOGGER.debug( "Calling database WS" );
- DatabaseClient client = new DatabaseClient( delegationAgent.getHostname(), delegationAgent.getPort() );
- client.update( environment.getName(), server.getName(), application.getName(), database.getName(), true );
- }
- catch ( ClientException clientException )
- {
- LOGGER.error( "Database {} update failed", database.getName(), clientException );
- throw new UpdateException( "Database " + database.getName() + " update failed", clientException );
- }
- return;
- }
-
- // launch SQL scripts on the database
- LOGGER.debug( "Executing SQL scripts" );
- for ( Iterator sqlScriptIterator = database.getSqlScripts().iterator(); sqlScriptIterator.hasNext(); )
- {
- SqlScript sqlScript = (SqlScript) sqlScriptIterator.next();
- try
- {
- SqlScriptUpdater.execute( environment, server, application, database, sqlScript, updateLog );
- }
- catch ( UpdateException updateException )
- {
- // the SQL script execution failed
- if ( sqlScript.isBlocker() )
+ if ( !database.isActive() )
{
- // the SQL script is update blocker
- LOGGER.error( "SQL script {} execution failed", sqlScript.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "error",
- "SQL script " + sqlScript.getName() + " execution failed: "
- + updateException.getMessage() ) );
- EventUtils.post( environment, "ERROR",
- "SQL script " + sqlScript.getName() + " execution failed: " + updateException.getMessage() );
- throw new UpdateException( "SQL script " + sqlScript.getName() + " execution failed", updateException );
+ // database is not active
+ LOGGER.info( "Database {} is inactive, so not updated", database.getName() );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Database " + database.getName() + " is inactive, so not updated" ) );
+ EventUtils.post( environment, "UPDATE", "Database " + database.getName() + " is inactive, so not updated" );
+ return;
}
- else
+
+ if ( database.getAgent() != null && database.getAgent().trim().length() > 0 && !database.getAgent().equals(
+ Configuration.AGENT_ID ) )
{
- // the SQL script is not update blocker
- LOGGER.warn( "SQL script " + sqlScript.getName() + " execution failed", updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "warn",
- "SQL script " + sqlScript.getName() + " execution failed: "
- + updateException.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "SQL script " + sqlScript.getName()
- + " is not update blocker, update continues" ) );
- EventUtils.post( environment, "WARN",
- "SQL script " + sqlScript.getName() + " execution failed: " + updateException.getMessage() );
- EventUtils.post( environment, "UPDATE",
- "SQL script " + sqlScript.getName() + " is not update blocker, update continues" );
+ // database update delegated to another agent
+ LOGGER.info( "Delegating database {} update to agent {}", database.getName(), database.getAgent() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Delegating database " + database.getName()
+ + " update to agent " + database.getAgent() ) );
+ EventUtils.post( environment, "UPDATE",
+ "Delegating database " + database.getName() + " update to agent " + database.getAgent() );
+ Agent delegationAgent = Configuration.CONFIG_CACHE.getAgent( database.getAgent() );
+ if ( delegationAgent == null )
+ {
+ // database agent is not found in configuration
+ LOGGER.error( "Agent {} is not found in the configuration", database.getAgent() );
+ throw new UpdateException( "Agent " + database.getAgent() + " is not found in the configuration" );
+ }
+ try
+ {
+ // call WS
+ LOGGER.debug( "Calling database WS" );
+ DatabaseClient client = new DatabaseClient( delegationAgent.getHostname(), delegationAgent.getPort() );
+ client.update( environment.getName(), server.getName(), application.getName(), database.getName(),
+ true );
+ }
+ catch ( ClientException clientException )
+ {
+ LOGGER.error( "Database {} update failed", database.getName(), clientException );
+ throw new UpdateException( "Database " + database.getName() + " update failed", clientException );
+ }
+ return;
}
- }
+
+ // launch SQL scripts on the database
+ LOGGER.debug( "Executing SQL scripts" );
+ for ( Iterator sqlScriptIterator = database.getSqlScripts().iterator(); sqlScriptIterator.hasNext(); )
+ {
+ SqlScript sqlScript = (SqlScript) sqlScriptIterator.next();
+ try
+ {
+ SqlScriptUpdater.execute( environment, server, application, database, sqlScript, updateLog );
+ }
+ catch ( UpdateException updateException )
+ {
+ // the SQL script execution failed
+ if ( sqlScript.isBlocker() )
+ {
+ // the SQL script is update blocker
+ LOGGER.error( "SQL script {} execution failed", sqlScript.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "SQL script " + sqlScript.getName()
+ + " execution failed: " + updateException.getMessage() ) );
+ EventUtils.post( environment, "ERROR", "SQL script " + sqlScript.getName() + " execution failed: "
+ + updateException.getMessage() );
+ throw new UpdateException( "SQL script " + sqlScript.getName() + " execution failed",
+ updateException );
+ }
+ else
+ {
+ // the SQL script is not update blocker
+ LOGGER.warn( "SQL script " + sqlScript.getName() + " execution failed", updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn", "SQL script " + sqlScript.getName()
+ + " execution failed: " + updateException.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "SQL script " + sqlScript.getName()
+ + " is not update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN", "SQL script " + sqlScript.getName() + " execution failed: "
+ + updateException.getMessage() );
+ EventUtils.post( environment, "UPDATE",
+ "SQL script " + sqlScript.getName() + " is not update blocker, update continues" );
+ }
+ }
+ }
+
+ // update completed
+ LOGGER.info( "Database {} updated", database.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Database " + database.getName() + " updated" ) );
+ EventUtils.post( environment, "UPDATE", "Database " + database.getName() + " updated" );
}
- // update completed
- LOGGER.info( "Database {} updated", database.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Database " + database.getName() + " updated" ) );
- EventUtils.post( environment, "UPDATE", "Database " + database.getName() + " updated" );
- }
+ /**
+ * Wrapper method to update a database via WS.
+ *
+ * @param environmentName the target environment name.
+ * @param serverName the target JEE application server name.
+ * @param applicationName the target JEE application name.
+ * @param databaseName the target database name.
+ * @param delegation true if the call is made by another agent, false if the call is made by a client.
+ * @throws KalumetException in case of update failure.
+ */
+ public static void update( String environmentName, String serverName, String applicationName, String databaseName,
+ boolean delegation )
+ throws KalumetException
+ {
+ LOGGER.info( "Database {} update requested by WS", databaseName );
- /**
- * Wrapper method to update a database via WS.
- *
- * @param environmentName the target environment name.
- * @param serverName the target JEE application server name.
- * @param applicationName the target JEE application name.
- * @param databaseName the target database name.
- * @param delegation true if the call is made by another agent, false if the call is made by a client.
- * @throws KalumetException in case of update failure.
- */
- public static void update( String environmentName, String serverName, String applicationName, String databaseName,
- boolean delegation )
- throws KalumetException
- {
- LOGGER.info( "Database {} update requested by WS", databaseName );
+ // load configuration.
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer applicationServer =
+ environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
+ if ( applicationServer == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environmentName );
+ throw new KalumetException(
+ "JEE application server " + serverName + " is not found in environment " + environmentName );
+ }
+ JEEApplication application = applicationServer.getJEEApplication( applicationName );
+ if ( application == null )
+ {
+ LOGGER.error( "JEE application {} is not found in JEE application server {}", applicationName, serverName );
+ throw new KalumetException(
+ "JEE application " + applicationName + " is not found in JEE application server " + serverName );
+ }
+ Database database = application.getDatabase( databaseName );
+ if ( database == null )
+ {
+ LOGGER.error( "Database {} is not found in JEE application {}", databaseName, applicationName );
+ throw new KalumetException(
+ "Database " + databaseName + " is not found in JEE application " + applicationName );
+ }
- // load configuration.
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer applicationServer =
- environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
- if ( applicationServer == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environmentName );
- throw new KalumetException(
- "JEE application server " + serverName + " is not found in environment " + environmentName );
- }
- JEEApplication application = applicationServer.getJEEApplication( applicationName );
- if ( application == null )
- {
- LOGGER.error( "JEE application {} is not found in JEE application server {}", applicationName, serverName );
- throw new KalumetException(
- "JEE application " + applicationName + " is not found in JEE application server " + serverName );
- }
- Database database = application.getDatabase( databaseName );
- if ( database == null )
- {
- LOGGER.error( "Database {} is not found in JEE application {}", databaseName, applicationName );
- throw new KalumetException( "Database " + databaseName + " is not found in JEE application " + applicationName );
- }
+ // update configuration cache.
+ LOGGER.debug( "Updating configuration cache" );
+ Configuration.CONFIG_CACHE = kalumet;
- // update configuration cache.
- LOGGER.debug( "Updating configuration cache" );
- Configuration.CONFIG_CACHE = kalumet;
+ // post journal event
+ EventUtils.post( environment, "UPDATE", "Database " + databaseName + " update requested by WS" );
+ // create an update logger
+ UpdateLog updateLog =
+ new UpdateLog( "Database " + databaseName + " update in progress ...", environment.getName(), environment );
- // post journal event
- EventUtils.post( environment, "UPDATE", "Database " + databaseName + " update requested by WS" );
- // create an update logger
- UpdateLog updateLog =
- new UpdateLog( "Database " + databaseName + " update in progress ...", environment.getName(), environment );
+ if ( !delegation )
+ {
+ // the update is requested by a client
+ LOGGER.info( "Send a notification and waiting for the count down" );
+ EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
+ NotifierUtils.waitAndNotify( environment );
+ }
- if ( !delegation )
- {
- // the update is requested by a client
- LOGGER.info( "Send a notification and waiting for the count down" );
- EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
- NotifierUtils.waitAndNotify( environment );
- }
+ try
+ {
+ // call the updater
+ LOGGER.debug( "Call database updater" );
+ DatabaseUpdater.update( environment, applicationServer, application, database, updateLog );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Database {} update failed", database.getName(), e );
+ EventUtils.post( environment, "ERROR",
+ "Database " + database.getName() + " update failed: " + e.getMessage() );
+ if ( !delegation )
+ {
+ updateLog.setStatus( "Database " + database.getName() + " update failed" );
+ updateLog.addUpdateMessage( new UpdateMessage( "error",
+ "Database " + database.getName() + " update failed: "
+ + e.getMessage() ) );
+ PublisherUtils.publish( environment );
+ }
+ throw new UpdateException( "Database " + database.getName() + " update failed", e );
+ }
- try
- {
- // call the updater
- LOGGER.debug( "Call database updater" );
- DatabaseUpdater.update( environment, applicationServer, application, database, updateLog );
+ // update completed
+ LOGGER.info( "Database {} updated", database.getName() );
+ EventUtils.post( environment, "UPDATE", "Database " + database.getName() + " updated" );
+ if ( !delegation )
+ {
+ if ( updateLog.isUpdated() )
+ {
+ updateLog.setStatus( "Database " + database.getName() + " updated" );
+ }
+ else
+ {
+ updateLog.setStatus( "Database " + database.getName() + " already up to date" );
+ }
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Database " + database.getName() + " updated" ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
+ }
}
- catch ( Exception e )
- {
- LOGGER.error( "Database {} update failed", database.getName(), e );
- EventUtils.post( environment, "ERROR", "Database " + database.getName() + " update failed: " + e.getMessage() );
- if ( !delegation )
- {
- updateLog.setStatus( "Database " + database.getName() + " update failed" );
- updateLog.addUpdateMessage(
- new UpdateMessage( "error", "Database " + database.getName() + " update failed: " + e.getMessage() ) );
- PublisherUtils.publish( environment );
- }
- throw new UpdateException( "Database " + database.getName() + " update failed", e );
- }
-
- // update completed
- LOGGER.info( "Database {} updated", database.getName() );
- EventUtils.post( environment, "UPDATE", "Database " + database.getName() + " updated" );
- if ( !delegation )
- {
- if ( updateLog.isUpdated() )
- {
- updateLog.setStatus( "Database " + database.getName() + " updated" );
- }
- else
- {
- updateLog.setStatus( "Database " + database.getName() + " already up to date" );
- }
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Database " + database.getName() + " updated" ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
- }
- }
}
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/EnvironmentUpdater.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/EnvironmentUpdater.java
index 917c7e2..e3ce8a4 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/EnvironmentUpdater.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/EnvironmentUpdater.java
@@ -40,260 +40,256 @@
public class EnvironmentUpdater
{
- private final static transient Logger LOGGER = LoggerFactory.getLogger( EnvironmentUpdater.class );
+ private final static transient Logger LOGGER = LoggerFactory.getLogger( EnvironmentUpdater.class );
- /**
- * Updates an environment identified by a given name.
- * The update is forced even if the auto update flag is set to false.
- *
- * @param name the environment name.
- * @throws KalumetException
- */
- public static void update( String name )
- throws KalumetException
- {
- // load the Kalumet configuration
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- // get the environment
- Environment environment = kalumet.getEnvironment( name );
- if ( environment == null )
+ /**
+ * Updates an environment identified by a given name.
+ * The update is forced even if the auto update flag is set to false.
+ *
+ * @param name the environment name.
+ * @throws KalumetException
+ */
+ public static void update( String name )
+ throws KalumetException
{
- LOGGER.error( "Environment {} is not found in the configuration", name );
- throw new KalumetException( "Environment " + name + " is not found in the configuration" );
- }
- try
- {
- EnvironmentUpdater.update( environment, true );
- }
- catch ( Exception e )
- {
- throw new KalumetException( e );
- }
- }
-
- /**
- * Updates an environment.
- *
- * @param environment the environment to update.
- * @throws UpdateException in case of update failure.
- */
- public static void update( Environment environment )
- throws UpdateException
- {
- EnvironmentUpdater.update( environment, false );
- }
-
- /**
- * Updates an environment.
- *
- * @param environment the environment to update.
- * @param force true force the update (even if the autoupdate flag is false), false else
- * @throws UpdateException in case of update failure.
- */
- public static void update( Environment environment, boolean force )
- throws UpdateException
- {
- LOGGER.info( "Updating environment {}", environment.getName() );
-
- LOGGER.debug( "Loading configuration and updating the cache" );
- Kalumet kalumet = null;
- try
- {
- kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- Configuration.CONFIG_CACHE = kalumet;
- }
- catch ( Exception e )
- {
- LOGGER.error( "Can't load configuration", e );
- EventUtils.post( environment, "ERROR", "Can't load configuration: " + e.getMessage() );
- throw new UpdateException( "Can't load configuration", e );
- }
-
- if ( !force && !environment.isAutoupdate() )
- {
- LOGGER.info( "Update is not forced and environment {} is not auto update", environment.getName() );
- LOGGER.info( "Update is not performed" );
- return;
- }
-
- LOGGER.debug( "Creating a update logger" );
- UpdateLog updateLog = null;
- try
- {
- updateLog =
- new UpdateLog( "Environment " + environment.getName() + " update in progress ...", environment.getName(),
- environment );
- }
- catch ( Exception e )
- {
- LOGGER.error( "Can't create the update logger", e );
- EventUtils.post( environment, "ERROR", "Can't create the update logger: " + e.getMessage() );
- throw new UpdateException( "Can't create the update logger", e );
- }
-
- // posting start update event
- EventUtils.post( environment, "UPDATE", "Starting to update ..." );
-
- LOGGER.info( "Sending a notification and waiting for the update count down" );
- EventUtils.post( environment, "UPDATE", "Sending a notification and waiting for the update count donw" );
- NotifierUtils.waitAndNotify( environment );
-
- try
- {
- // update softwares flagged "before JEE"
- LOGGER.info( "Updating softwares flagged before JEE" );
- for ( Iterator softwareIterator = environment.getSoftwares().iterator(); softwareIterator.hasNext(); )
- {
- Software software = (Software) softwareIterator.next();
+ // load the Kalumet configuration
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ // get the environment
+ Environment environment = kalumet.getEnvironment( name );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", name );
+ throw new KalumetException( "Environment " + name + " is not found in the configuration" );
+ }
try
{
- if ( software.isBeforejee() )
- {
- SoftwareUpdater.update( environment, software, updateLog );
- }
+ EnvironmentUpdater.update( environment, true );
}
catch ( Exception e )
{
- if ( software.isBlocker() )
- {
- LOGGER.error( "Software {} update failed", software.getName() );
- EventUtils.post( environment, "ERROR",
- "Software " + software.getName() + " update failed: " + e.getMessage() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "error", "Software " + software.getName() + " update failed: " + e.getMessage() ) );
- updateLog.setStatus( "Environment " + environment.getName() + " update failed" );
- PublisherUtils.publish( environment );
- throw new UpdateException( "Software " + software.getName() + " update failed", e );
- }
- else
- {
- LOGGER.warn( "Software {} update failed", software.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "warn", "Software " + software.getName() + " update failed: " + e.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Software " + software.getName()
- + " is not an update blocker, update continues" ) );
- EventUtils.post( environment, "WARN",
- "Software " + software.getName() + " update failed: " + e.getMessage() );
- EventUtils.post( environment, "INFO",
- "Software " + software.getName() + " is not an update blocker, update continues" );
- }
+ throw new KalumetException( e );
}
- }
+ }
- // update JEE application servers
- LOGGER.info( "Updating JEE application servers" );
- for ( Iterator jeeApplicationServersIterator =
- environment.getJEEApplicationServers().getJEEApplicationServers().iterator();
- jeeApplicationServersIterator.hasNext(); )
- {
- JEEApplicationServer jeeApplicationServer = (JEEApplicationServer) jeeApplicationServersIterator.next();
+ /**
+ * Updates an environment.
+ *
+ * @param environment the environment to update.
+ * @throws UpdateException in case of update failure.
+ */
+ public static void update( Environment environment )
+ throws UpdateException
+ {
+ EnvironmentUpdater.update( environment, false );
+ }
+
+ /**
+ * Updates an environment.
+ *
+ * @param environment the environment to update.
+ * @param force true force the update (even if the autoupdate flag is false), false else
+ * @throws UpdateException in case of update failure.
+ */
+ public static void update( Environment environment, boolean force )
+ throws UpdateException
+ {
+ LOGGER.info( "Updating environment {}", environment.getName() );
+
+ LOGGER.debug( "Loading configuration and updating the cache" );
+ Kalumet kalumet = null;
try
{
- JEEApplicationServerUpdater.update(kalumet, environment, jeeApplicationServer, updateLog);
+ kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ Configuration.CONFIG_CACHE = kalumet;
}
catch ( Exception e )
{
- if ( jeeApplicationServer.isBlocker() )
- {
- LOGGER.error( "JEE application server {} update failed", e );
- EventUtils.post( environment, "ERROR",
- "JEE application server " + jeeApplicationServer.getName() + " update failed: "
- + e.getMessage() );
- updateLog.addUpdateMessage( new UpdateMessage( "error",
- "JEE application server " + jeeApplicationServer.getName()
- + " update failed: " + e.getMessage() ) );
- updateLog.setStatus( "Environment " + environment.getName() + " update failed" );
- PublisherUtils.publish( environment );
- throw new UpdateException( "JEE application server " + jeeApplicationServer.getName() + " update failed",
- e );
- }
- else
- {
- LOGGER.warn( "JEE application server {} update failed", e );
- updateLog.addUpdateMessage( new UpdateMessage( "warn",
- "JEE application server " + jeeApplicationServer.getName()
- + " update failed: " + e.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info",
- "JEE application server " + jeeApplicationServer.getName()
- + " is not an update blocker, update continues" ) );
- EventUtils.post( environment, "WARN",
- "JEE application server " + jeeApplicationServer.getName() + " update failed: "
- + e.getMessage() );
- EventUtils.post( environment, "INFO", "JEE application server " + jeeApplicationServer.getName()
- + " is not an update blocker, update continues" );
- }
+ LOGGER.error( "Can't load configuration", e );
+ EventUtils.post( environment, "ERROR", "Can't load configuration: " + e.getMessage() );
+ throw new UpdateException( "Can't load configuration", e );
}
- }
- // update softwares
- LOGGER.info( "Updating softwares" );
- for ( Iterator softwaresIterator = environment.getSoftwares().iterator(); softwaresIterator.hasNext(); )
- {
- Software software = (Software) softwaresIterator.next();
+ if ( !force && !environment.isAutoupdate() )
+ {
+ LOGGER.info( "Update is not forced and environment {} is not auto update", environment.getName() );
+ LOGGER.info( "Update is not performed" );
+ return;
+ }
+
+ LOGGER.debug( "Creating a update logger" );
+ UpdateLog updateLog = null;
try
{
- if ( !software.isBeforejee() )
- {
- SoftwareUpdater.update( environment, software, updateLog );
- }
+ updateLog = new UpdateLog( "Environment " + environment.getName() + " update in progress ...",
+ environment.getName(), environment );
}
catch ( Exception e )
{
- if ( software.isBlocker() )
- {
- LOGGER.error( "Software {} update failed", software.getName() );
- EventUtils.post( environment, "ERROR",
- "Software " + software.getName() + " update failed: " + e.getMessage() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "error", "Software " + software.getName() + " update failed: " + e.getMessage() ) );
- updateLog.setStatus( "Environment " + environment.getName() + " update failed" );
- PublisherUtils.publish( environment );
- throw new UpdateException( "Software " + software.getName() + " update failed", e );
- }
- else
- {
- LOGGER.warn( "Software {} update failed", software.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "warn", "Software " + software.getName() + " update failed: " + e.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Software " + software.getName()
- + " is not an update blocker, update continues" ) );
- EventUtils.post( environment, "WARN",
- "Software " + software.getName() + " update failed: " + e.getMessage() );
- EventUtils.post( environment, "INFO",
- "Software " + software.getName() + " is not an update blocker, update continues" );
- }
+ LOGGER.error( "Can't create the update logger", e );
+ EventUtils.post( environment, "ERROR", "Can't create the update logger: " + e.getMessage() );
+ throw new UpdateException( "Can't create the update logger", e );
}
- }
- }
- catch ( Exception e )
- {
- LOGGER.error( "Update failed", e );
- EventUtils.post( environment, "ERROR", "Update failed: " + e.getMessage() );
- updateLog.setStatus( "Environment " + environment.getName() + " update failed" );
- updateLog.addUpdateMessage( new UpdateMessage( "error", "Update failed: " + e.getMessage() ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
- throw new UpdateException( "Update failed", e );
- }
- // publish update result
- LOGGER.info( "Publishing update report" );
- if ( updateLog.isUpdated() )
- {
- updateLog.setStatus( "Environment " + environment.getName() + " updated" );
- }
- else
- {
- updateLog.setStatus( "Environment " + environment.getName() + " already up to date" );
- }
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Environment " + environment.getName() + " update completed" ) );
- EventUtils.post( environment, "UPDATE", "Environment " + environment.getName() + " update completed" );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
+ // posting start update event
+ EventUtils.post( environment, "UPDATE", "Starting to update ..." );
- LOGGER.info( "Update completed" );
- }
+ LOGGER.info( "Sending a notification and waiting for the update count down" );
+ EventUtils.post( environment, "UPDATE", "Sending a notification and waiting for the update count donw" );
+ NotifierUtils.waitAndNotify( environment );
+
+ try
+ {
+ // update softwares flagged "before JEE"
+ LOGGER.info( "Updating softwares flagged before JEE" );
+ for ( Iterator softwareIterator = environment.getSoftwares().iterator(); softwareIterator.hasNext(); )
+ {
+ Software software = (Software) softwareIterator.next();
+ try
+ {
+ if ( software.isBeforejee() )
+ {
+ SoftwareUpdater.update( environment, software, updateLog );
+ }
+ }
+ catch ( Exception e )
+ {
+ if ( software.isBlocker() )
+ {
+ LOGGER.error( "Software {} update failed", software.getName() );
+ EventUtils.post( environment, "ERROR",
+ "Software " + software.getName() + " update failed: " + e.getMessage() );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "Software " + software.getName()
+ + " update failed: " + e.getMessage() ) );
+ updateLog.setStatus( "Environment " + environment.getName() + " update failed" );
+ PublisherUtils.publish( environment );
+ throw new UpdateException( "Software " + software.getName() + " update failed", e );
+ }
+ else
+ {
+ LOGGER.warn( "Software {} update failed", software.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn", "Software " + software.getName()
+ + " update failed: " + e.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Software " + software.getName()
+ + " is not an update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN",
+ "Software " + software.getName() + " update failed: " + e.getMessage() );
+ EventUtils.post( environment, "INFO", "Software " + software.getName()
+ + " is not an update blocker, update continues" );
+ }
+ }
+ }
+
+ // update JEE application servers
+ LOGGER.info( "Updating JEE application servers" );
+ for ( Iterator jeeApplicationServersIterator =
+ environment.getJEEApplicationServers().getJEEApplicationServers().iterator();
+ jeeApplicationServersIterator.hasNext(); )
+ {
+ JEEApplicationServer jeeApplicationServer = (JEEApplicationServer) jeeApplicationServersIterator.next();
+ try
+ {
+ JEEApplicationServerUpdater.update( kalumet, environment, jeeApplicationServer, updateLog );
+ }
+ catch ( Exception e )
+ {
+ if ( jeeApplicationServer.isBlocker() )
+ {
+ LOGGER.error( "JEE application server {} update failed", e );
+ EventUtils.post( environment, "ERROR",
+ "JEE application server " + jeeApplicationServer.getName() + " update failed: "
+ + e.getMessage() );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "JEE application server "
+ + jeeApplicationServer.getName() + " update failed: " + e.getMessage() ) );
+ updateLog.setStatus( "Environment " + environment.getName() + " update failed" );
+ PublisherUtils.publish( environment );
+ throw new UpdateException(
+ "JEE application server " + jeeApplicationServer.getName() + " update failed", e );
+ }
+ else
+ {
+ LOGGER.warn( "JEE application server {} update failed", e );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn", "JEE application server "
+ + jeeApplicationServer.getName() + " update failed: " + e.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JEE application server "
+ + jeeApplicationServer.getName() + " is not an update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN",
+ "JEE application server " + jeeApplicationServer.getName() + " update failed: "
+ + e.getMessage() );
+ EventUtils.post( environment, "INFO", "JEE application server " + jeeApplicationServer.getName()
+ + " is not an update blocker, update continues" );
+ }
+ }
+ }
+
+ // update softwares
+ LOGGER.info( "Updating softwares" );
+ for ( Iterator softwaresIterator = environment.getSoftwares().iterator(); softwaresIterator.hasNext(); )
+ {
+ Software software = (Software) softwaresIterator.next();
+ try
+ {
+ if ( !software.isBeforejee() )
+ {
+ SoftwareUpdater.update( environment, software, updateLog );
+ }
+ }
+ catch ( Exception e )
+ {
+ if ( software.isBlocker() )
+ {
+ LOGGER.error( "Software {} update failed", software.getName() );
+ EventUtils.post( environment, "ERROR",
+ "Software " + software.getName() + " update failed: " + e.getMessage() );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "Software " + software.getName()
+ + " update failed: " + e.getMessage() ) );
+ updateLog.setStatus( "Environment " + environment.getName() + " update failed" );
+ PublisherUtils.publish( environment );
+ throw new UpdateException( "Software " + software.getName() + " update failed", e );
+ }
+ else
+ {
+ LOGGER.warn( "Software {} update failed", software.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn", "Software " + software.getName()
+ + " update failed: " + e.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Software " + software.getName()
+ + " is not an update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN",
+ "Software " + software.getName() + " update failed: " + e.getMessage() );
+ EventUtils.post( environment, "INFO", "Software " + software.getName()
+ + " is not an update blocker, update continues" );
+ }
+ }
+ }
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Update failed", e );
+ EventUtils.post( environment, "ERROR", "Update failed: " + e.getMessage() );
+ updateLog.setStatus( "Environment " + environment.getName() + " update failed" );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "Update failed: " + e.getMessage() ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
+ throw new UpdateException( "Update failed", e );
+ }
+
+ // publish update result
+ LOGGER.info( "Publishing update report" );
+ if ( updateLog.isUpdated() )
+ {
+ updateLog.setStatus( "Environment " + environment.getName() + " updated" );
+ }
+ else
+ {
+ updateLog.setStatus( "Environment " + environment.getName() + " already up to date" );
+ }
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Environment " + environment.getName() + " update completed" ) );
+ EventUtils.post( environment, "UPDATE", "Environment " + environment.getName() + " update completed" );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
+
+ LOGGER.info( "Update completed" );
+ }
}
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JDBCConnectionPoolUpdater.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JDBCConnectionPoolUpdater.java
index 9b260ff..312c92a 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JDBCConnectionPoolUpdater.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JDBCConnectionPoolUpdater.java
@@ -24,8 +24,8 @@
import org.apache.kalumet.controller.core.JEEApplicationServerController;
import org.apache.kalumet.controller.core.JEEApplicationServerControllerFactory;
import org.apache.kalumet.model.Environment;
-import org.apache.kalumet.model.JEEApplicationServer;
import org.apache.kalumet.model.JDBCConnectionPool;
+import org.apache.kalumet.model.JEEApplicationServer;
import org.apache.kalumet.model.Kalumet;
import org.apache.kalumet.model.update.UpdateLog;
import org.apache.kalumet.model.update.UpdateMessage;
@@ -41,256 +41,262 @@
public class JDBCConnectionPoolUpdater
{
- private static final transient Logger LOGGER = LoggerFactory.getLogger( JDBCConnectionPoolUpdater.class );
+ private static final transient Logger LOGGER = LoggerFactory.getLogger( JDBCConnectionPoolUpdater.class );
- /**
- * Update a JDBC connection pool.
- *
- * @param environment the target <code>Environment</code>.
- * @param server the target <code>JEEApplicationServer</code>.
- * @param connectionPool the target <code>JDBCConnectionPool</code>.
- * @param updateLog the target <code>UpdateLog</code> to use.
- */
- public static void update( Environment environment, JEEApplicationServer server, JDBCConnectionPool connectionPool,
- UpdateLog updateLog )
- throws UpdateException
- {
- LOGGER.info( "Updating JDBC connection pool {}", connectionPool.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Updating JDBC connection pool " + connectionPool.getName() ) );
- EventUtils.post( environment, "UPDATE", "Updating JDBC connection pool " + connectionPool.getName() );
-
- if ( !connectionPool.isActive() )
+ /**
+ * Update a JDBC connection pool.
+ *
+ * @param environment the target <code>Environment</code>.
+ * @param server the target <code>JEEApplicationServer</code>.
+ * @param connectionPool the target <code>JDBCConnectionPool</code>.
+ * @param updateLog the target <code>UpdateLog</code> to use.
+ */
+ public static void update( Environment environment, JEEApplicationServer server, JDBCConnectionPool connectionPool,
+ UpdateLog updateLog )
+ throws UpdateException
{
- LOGGER.info( "JDBC connection pool {} is inactive, so not updated", connectionPool.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "JDBC connection pool " + connectionPool.getName()
- + " is inactive, so not updated" ) );
- EventUtils.post( environment, "UPDATE",
- "JDBC connection pool " + connectionPool.getName() + " is inactive, so not updated" );
- return;
+ LOGGER.info( "Updating JDBC connection pool {}", connectionPool.getName() );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Updating JDBC connection pool " + connectionPool.getName() ) );
+ EventUtils.post( environment, "UPDATE", "Updating JDBC connection pool " + connectionPool.getName() );
+
+ if ( !connectionPool.isActive() )
+ {
+ LOGGER.info( "JDBC connection pool {} is inactive, so not updated", connectionPool.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JDBC connection pool " + connectionPool.getName()
+ + " is inactive, so not updated" ) );
+ EventUtils.post( environment, "UPDATE",
+ "JDBC connection pool " + connectionPool.getName() + " is inactive, so not updated" );
+ return;
+ }
+
+ // replace variables in connection pool data
+ LOGGER.debug( "Replacing variables in connection pool data" );
+ String jdbcDriver = VariableUtils.replace( connectionPool.getDriver(), environment.getVariables() );
+ String jdbcUser = VariableUtils.replace( connectionPool.getUser(), environment.getVariables() );
+ String jdbcPassword = VariableUtils.replace( connectionPool.getPassword(), environment.getVariables() );
+ String jdbcUrl = VariableUtils.replace( connectionPool.getUrl(), environment.getVariables() );
+ String jdbcClasspath = VariableUtils.replace( connectionPool.getClasspath(), environment.getVariables() );
+
+ try
+ {
+ // connect to JEE application server controller
+ JEEApplicationServerController controller =
+ JEEApplicationServerControllerFactory.getController( environment, server );
+ // test if the JDBC connection pool is already present in the JEE server
+ if ( controller.isJDBCConnectionPoolDeployed( connectionPool.getName() ) )
+ {
+ LOGGER.info( "JDBC connection pool {} already deployed, checking for update" );
+ if ( controller.updateJDBCConnectionPool( connectionPool.getName(), jdbcDriver,
+ connectionPool.getIncrement(), connectionPool.getInitial(),
+ connectionPool.getMaximal(), jdbcUser, jdbcPassword, jdbcUrl,
+ jdbcClasspath ) )
+ {
+ updateLog.setStatus( "Update performed" );
+ updateLog.setUpdated( true );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "JDBC connection pool " + connectionPool.getName() + " updated" ) );
+ EventUtils.post( environment, "UPDATE",
+ "JDBC connection pool " + connectionPool.getName() + " updated" );
+ LOGGER.info( "JDBC connection pool {} updated", connectionPool.getName() );
+ }
+ else
+ {
+ updateLog.addUpdateMessage( new UpdateMessage( "info",
+ "JDBC connection pool " + connectionPool.getName()
+ + " already up to date" ) );
+ EventUtils.post( environment, "UPDATE",
+ "JDBC connection pool " + connectionPool.getName() + " already up to date" );
+ LOGGER.info( "JDBC connection pool {} already up to date", connectionPool.getName() );
+ }
+ }
+ else
+ {
+ // deploy the JDBC connection pool
+ controller.deployJDBCConnectionPool( connectionPool.getName(), jdbcDriver,
+ connectionPool.getIncrement(), connectionPool.getInitial(),
+ connectionPool.getMaximal(), jdbcUser, jdbcPassword, jdbcUrl,
+ jdbcClasspath );
+ updateLog.setStatus( "Update performed" );
+ updateLog.setUpdated( true );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "JDBC connection pool " + connectionPool.getName() + " deployed" ) );
+ EventUtils.post( environment, "UPDATE",
+ "JDBC connection pool " + connectionPool.getName() + " deployed" );
+ LOGGER.info( "JDBC connection pool {} deployed", connectionPool.getName() );
+ }
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "JDBC connection pool {} update failed", connectionPool.getName(), e );
+ throw new UpdateException( "JDBC connection pool " + connectionPool.getName() + " update failed", e );
+ }
}
- // replace variables in connection pool data
- LOGGER.debug( "Replacing variables in connection pool data" );
- String jdbcDriver = VariableUtils.replace( connectionPool.getDriver(), environment.getVariables() );
- String jdbcUser = VariableUtils.replace( connectionPool.getUser(), environment.getVariables() );
- String jdbcPassword = VariableUtils.replace( connectionPool.getPassword(), environment.getVariables() );
- String jdbcUrl = VariableUtils.replace( connectionPool.getUrl(), environment.getVariables() );
- String jdbcClasspath = VariableUtils.replace( connectionPool.getClasspath(), environment.getVariables() );
-
- try
+ /**
+ * Wrapper method to update a JDBC connection pool via WS.
+ *
+ * @param environmentName the target environment name.
+ * @param serverName the target JEE application server name.
+ * @param connectionPoolName the target JDBC connection pool name.
+ * @throws KalumetException in case of update failure.
+ */
+ public static void update( String environmentName, String serverName, String connectionPoolName )
+ throws KalumetException
{
- // connect to JEE application server controller
- JEEApplicationServerController controller =
- JEEApplicationServerControllerFactory.getController(environment, server);
- // test if the JDBC connection pool is already present in the JEE server
- if ( controller.isJDBCConnectionPoolDeployed( connectionPool.getName() ) )
- {
- LOGGER.info( "JDBC connection pool {} already deployed, checking for update" );
- if ( controller.updateJDBCConnectionPool( connectionPool.getName(), jdbcDriver, connectionPool.getIncrement(),
- connectionPool.getInitial(), connectionPool.getMaximal(), jdbcUser,
- jdbcPassword, jdbcUrl, jdbcClasspath ) )
+ LOGGER.info( "JDBC connection pool {} update requested by WS", connectionPoolName );
+
+ // load configuration.
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+
+ // looking for component objects.
+ LOGGER.debug( "Looking for component objects" );
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
{
- updateLog.setStatus( "Update performed" );
- updateLog.setUpdated( true );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JDBC connection pool " + connectionPool.getName() + " updated" ) );
- EventUtils.post( environment, "UPDATE", "JDBC connection pool " + connectionPool.getName() + " updated" );
- LOGGER.info( "JDBC connection pool {} updated", connectionPool.getName() );
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer applicationServer =
+ environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
+ if ( applicationServer == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", serverName,
+ environment.getName() );
+ throw new KalumetException(
+ "JEE application server " + serverName + " is not found in environment " + environment.getName() );
+ }
+ JDBCConnectionPool connectionPool = applicationServer.getJDBCConnectionPool( connectionPoolName );
+ if ( connectionPool == null )
+ {
+ LOGGER.error( "JDBC connection pool {} is not found in JEE application server {}", connectionPoolName,
+ applicationServer.getName() );
+ throw new KalumetException(
+ "JDBC connection pool " + connectionPoolName + " is not found in JEE application server "
+ + applicationServer.getName() );
+ }
+
+ // post event and create update log
+ EventUtils.post( environment, "UPDATE",
+ "JDBC connection pool " + connectionPool.getName() + " update request by WS" );
+ UpdateLog updateLog = new UpdateLog( "JDBC connection pool " + connectionPool.getName() + " update in progress",
+ environment.getName(), environment );
+
+ // send a notification and waiting for the count down.
+ LOGGER.info( "Send a notification and waiting for the count down" );
+ EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
+ NotifierUtils.waitAndNotify( environment );
+
+ try
+ {
+ // call the JDBC connection pool updater.
+ LOGGER.debug( "Call connection pool updater" );
+ JDBCConnectionPoolUpdater.update( environment, applicationServer, connectionPool, updateLog );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "JDBC connection pool {} update failed", connectionPool.getName(), e );
+ EventUtils.post( environment, "ERROR",
+ "JDBC connection pool " + connectionPool.getName() + " update failed: " + e.getMessage() );
+ updateLog.setStatus( "JDBC connection pool " + connectionPool.getName() + " update failed" );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "JDBC connection pool " + connectionPool.getName()
+ + " update failed: " + e.getMessage() ) );
+ PublisherUtils.publish( environment );
+ throw new UpdateException( "JDBC connection pool " + connectionPool.getName() + " update failed", e );
+ }
+
+ // update completed.
+ LOGGER.info( "JDBC connection pool {} updated", connectionPool.getName() );
+ EventUtils.post( environment, "UPDATE", "JDBC connection pool " + connectionPool.getName() + " updated" );
+ if ( updateLog.isUpdated() )
+ {
+ updateLog.setStatus( "JDBC connection pool " + connectionPool.getName() + " updated" );
}
else
{
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JDBC connection pool " + connectionPool.getName() + " already up to date" ) );
- EventUtils.post( environment, "UPDATE",
- "JDBC connection pool " + connectionPool.getName() + " already up to date" );
- LOGGER.info( "JDBC connection pool {} already up to date", connectionPool.getName() );
+ updateLog.setStatus( "JDBC connection pool " + connectionPool.getName() + " is already up to date" );
}
- }
- else
- {
- // deploy the JDBC connection pool
- controller.deployJDBCConnectionPool( connectionPool.getName(), jdbcDriver, connectionPool.getIncrement(),
- connectionPool.getInitial(), connectionPool.getMaximal(), jdbcUser,
- jdbcPassword, jdbcUrl, jdbcClasspath );
- updateLog.setStatus( "Update performed" );
- updateLog.setUpdated( true );
updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JDBC connection pool " + connectionPool.getName() + " deployed" ) );
- EventUtils.post( environment, "UPDATE", "JDBC connection pool " + connectionPool.getName() + " deployed" );
- LOGGER.info( "JDBC connection pool {} deployed", connectionPool.getName() );
- }
- }
- catch ( Exception e )
- {
- LOGGER.error( "JDBC connection pool {} update failed", connectionPool.getName(), e );
- throw new UpdateException( "JDBC connection pool " + connectionPool.getName() + " update failed", e );
- }
- }
-
- /**
- * Wrapper method to update a JDBC connection pool via WS.
- *
- * @param environmentName the target environment name.
- * @param serverName the target JEE application server name.
- * @param connectionPoolName the target JDBC connection pool name.
- * @throws KalumetException in case of update failure.
- */
- public static void update( String environmentName, String serverName, String connectionPoolName )
- throws KalumetException
- {
- LOGGER.info( "JDBC connection pool {} update requested by WS", connectionPoolName );
-
- // load configuration.
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
-
- // looking for component objects.
- LOGGER.debug( "Looking for component objects" );
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer applicationServer =
- environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
- if ( applicationServer == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environment.getName() );
- throw new KalumetException(
- "JEE application server " + serverName + " is not found in environment " + environment.getName() );
- }
- JDBCConnectionPool connectionPool = applicationServer.getJDBCConnectionPool( connectionPoolName );
- if ( connectionPool == null )
- {
- LOGGER.error( "JDBC connection pool {} is not found in JEE application server {}", connectionPoolName,
- applicationServer.getName() );
- throw new KalumetException(
- "JDBC connection pool " + connectionPoolName + " is not found in JEE application server "
- + applicationServer.getName() );
+ new UpdateMessage( "info", "JDBC connection pool " + connectionPool.getName() + " updated" ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
}
- // post event and create update log
- EventUtils.post( environment, "UPDATE",
- "JDBC connection pool " + connectionPool.getName() + " update request by WS" );
- UpdateLog updateLog =
- new UpdateLog( "JDBC connection pool " + connectionPool.getName() + " update in progress", environment.getName(),
- environment );
+ /**
+ * Wrapper method to check if a JDBC connection pool is up to date via WS.
+ *
+ * @param environmentName the target environment name.
+ * @param serverName the target JEE application server name.
+ * @param connectionPoolName the target JDBC connection pool name.
+ * @return true if the JDBC connection pool is up to date, false else.
+ * @throws KalumetException in case of check failure.
+ */
+ public static boolean check( String environmentName, String serverName, String connectionPoolName )
+ throws KalumetException
+ {
+ LOGGER.info( "JDBC connection pool {} status check requested by WS", connectionPoolName );
- // send a notification and waiting for the count down.
- LOGGER.info( "Send a notification and waiting for the count down" );
- EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
- NotifierUtils.waitAndNotify( environment );
+ // load configuration.
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- try
- {
- // call the JDBC connection pool updater.
- LOGGER.debug( "Call connection pool updater" );
- JDBCConnectionPoolUpdater.update( environment, applicationServer, connectionPool, updateLog );
- }
- catch ( Exception e )
- {
- LOGGER.error( "JDBC connection pool {} update failed", connectionPool.getName(), e );
- EventUtils.post( environment, "ERROR",
- "JDBC connection pool " + connectionPool.getName() + " update failed: " + e.getMessage() );
- updateLog.setStatus( "JDBC connection pool " + connectionPool.getName() + " update failed" );
- updateLog.addUpdateMessage( new UpdateMessage( "error", "JDBC connection pool " + connectionPool.getName()
- + " update failed: " + e.getMessage() ) );
- PublisherUtils.publish( environment );
- throw new UpdateException( "JDBC connection pool " + connectionPool.getName() + " update failed", e );
- }
+ // looking for component objects
+ LOGGER.debug( "Looking for component objects." );
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer applicationServer =
+ environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
+ if ( applicationServer == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", serverName,
+ environment.getName() );
+ throw new KalumetException(
+ "JEE application server " + serverName + " is not found in environment " + environment.getName() );
+ }
+ JDBCConnectionPool connectionPool = applicationServer.getJDBCConnectionPool( connectionPoolName );
+ if ( connectionPool == null )
+ {
+ LOGGER.error( "JDBC connection pool {} is not found in JEE server {}", connectionPoolName,
+ applicationServer.getName() );
+ throw new KalumetException(
+ "JDBC connection pool " + connectionPoolName + " is not found in JEE application server "
+ + applicationServer.getName() );
+ }
- // update completed.
- LOGGER.info( "JDBC connection pool {} updated", connectionPool.getName() );
- EventUtils.post( environment, "UPDATE", "JDBC connection pool " + connectionPool.getName() + " updated" );
- if ( updateLog.isUpdated() )
- {
- updateLog.setStatus( "JDBC connection pool " + connectionPool.getName() + " updated" );
- }
- else
- {
- updateLog.setStatus( "JDBC connection pool " + connectionPool.getName() + " is already up to date" );
- }
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JDBC connection pool " + connectionPool.getName() + " updated" ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
- }
+ // post an event
+ EventUtils.post( environment, "INFO",
+ "JDBC connection pool " + connectionPool.getName() + " status check requested by WS" );
- /**
- * Wrapper method to check if a JDBC connection pool is up to date via WS.
- *
- * @param environmentName the target environment name.
- * @param serverName the target JEE application server name.
- * @param connectionPoolName the target JDBC connection pool name.
- * @return true if the JDBC connection pool is up to date, false else.
- * @throws KalumetException in case of check failure.
- */
- public static boolean check( String environmentName, String serverName, String connectionPoolName )
- throws KalumetException
- {
- LOGGER.info( "JDBC connection pool {} status check requested by WS", connectionPoolName );
-
- // load configuration.
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
-
- // looking for component objects
- LOGGER.debug( "Looking for component objects." );
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ try
+ {
+ // get the JEE server JMX controller.
+ LOGGER.debug( "Getting the JEE application server controller" );
+ JEEApplicationServerController controller =
+ JEEApplicationServerControllerFactory.getController( environment, applicationServer );
+ // replace values with environment variables
+ LOGGER.debug( "Replacing variables in connection pool data" );
+ String jdbcDriver = VariableUtils.replace( connectionPool.getDriver(), environment.getVariables() );
+ String jdbcUser = VariableUtils.replace( connectionPool.getUser(), environment.getVariables() );
+ String jdbcPassword = VariableUtils.replace( connectionPool.getPassword(), environment.getVariables() );
+ String jdbcUrl = VariableUtils.replace( connectionPool.getUrl(), environment.getVariables() );
+ String jdbcClasspath = VariableUtils.replace( connectionPool.getClasspath(), environment.getVariables() );
+ // check JDBC connection pool using JMX controller
+ LOGGER.debug( "Checking JDBC connection pool using JMX controller." );
+ return controller.isJDBCConnectionPoolUpToDate( connectionPool.getName(), jdbcDriver,
+ connectionPool.getIncrement(), connectionPool.getInitial(),
+ connectionPool.getMaximal(), jdbcUser, jdbcPassword,
+ jdbcUrl, jdbcClasspath );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "JDBC connection pool {} check failed", connectionPool.getName(), e );
+ throw new KalumetException( "JDBC connection pool " + connectionPool.getName() + " check failed", e );
+ }
}
- JEEApplicationServer applicationServer =
- environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
- if ( applicationServer == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environment.getName() );
- throw new KalumetException(
- "JEE application server " + serverName + " is not found in environment " + environment.getName() );
- }
- JDBCConnectionPool connectionPool = applicationServer.getJDBCConnectionPool( connectionPoolName );
- if ( connectionPool == null )
- {
- LOGGER.error( "JDBC connection pool {} is not found in JEE server {}", connectionPoolName,
- applicationServer.getName() );
- throw new KalumetException(
- "JDBC connection pool " + connectionPoolName + " is not found in JEE application server "
- + applicationServer.getName() );
- }
-
- // post an event
- EventUtils.post( environment, "INFO",
- "JDBC connection pool " + connectionPool.getName() + " status check requested by WS" );
-
- try
- {
- // get the JEE server JMX controller.
- LOGGER.debug( "Getting the JEE application server controller" );
- JEEApplicationServerController controller =
- JEEApplicationServerControllerFactory.getController(environment, applicationServer);
- // replace values with environment variables
- LOGGER.debug( "Replacing variables in connection pool data" );
- String jdbcDriver = VariableUtils.replace( connectionPool.getDriver(), environment.getVariables() );
- String jdbcUser = VariableUtils.replace( connectionPool.getUser(), environment.getVariables() );
- String jdbcPassword = VariableUtils.replace( connectionPool.getPassword(), environment.getVariables() );
- String jdbcUrl = VariableUtils.replace( connectionPool.getUrl(), environment.getVariables() );
- String jdbcClasspath = VariableUtils.replace( connectionPool.getClasspath(), environment.getVariables() );
- // check JDBC connection pool using JMX controller
- LOGGER.debug( "Checking JDBC connection pool using JMX controller." );
- return controller.isJDBCConnectionPoolUpToDate( connectionPool.getName(), jdbcDriver,
- connectionPool.getIncrement(), connectionPool.getInitial(),
- connectionPool.getMaximal(), jdbcUser, jdbcPassword, jdbcUrl,
- jdbcClasspath );
- }
- catch ( Exception e )
- {
- LOGGER.error( "JDBC connection pool {} check failed", connectionPool.getName(), e );
- throw new KalumetException( "JDBC connection pool " + connectionPool.getName() + " check failed", e );
- }
- }
}
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JDBCDataSourceUpdater.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JDBCDataSourceUpdater.java
index 9eb2816..c000612 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JDBCDataSourceUpdater.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JDBCDataSourceUpdater.java
@@ -23,8 +23,11 @@
import org.apache.kalumet.agent.utils.EventUtils;
import org.apache.kalumet.controller.core.JEEApplicationServerController;
import org.apache.kalumet.controller.core.JEEApplicationServerControllerFactory;
-import org.apache.kalumet.model.*;
+import org.apache.kalumet.model.Environment;
+import org.apache.kalumet.model.JDBCConnectionPool;
+import org.apache.kalumet.model.JDBCDataSource;
import org.apache.kalumet.model.JEEApplicationServer;
+import org.apache.kalumet.model.Kalumet;
import org.apache.kalumet.model.update.UpdateLog;
import org.apache.kalumet.model.update.UpdateMessage;
import org.apache.kalumet.utils.NotifierUtils;
@@ -39,257 +42,264 @@
public class JDBCDataSourceUpdater
{
- private static final transient Logger LOGGER = LoggerFactory.getLogger( JDBCDataSourceUpdater.class );
+ private static final transient Logger LOGGER = LoggerFactory.getLogger( JDBCDataSourceUpdater.class );
- /**
- * Update a JDBC dataSource.
- *
- * @param environment the target <code>Environment</code>.
- * @param server the target <code>JEEApplicationServer</code>.
- * @param dataSource the target <code>JDBCDataSource</code>.
- * @param updateLog the <code>UpdateLog</code> to use.
- */
- public static void update( Environment environment, JEEApplicationServer server, JDBCDataSource dataSource,
- UpdateLog updateLog )
- throws UpdateException
- {
- LOGGER.info( "Updating JDBC data source {}", dataSource.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Updating JDBC data source " + dataSource.getName() ) );
- EventUtils.post( environment, "UPDATE", "Updating JDBC data source " + dataSource.getName() );
+ /**
+ * Update a JDBC dataSource.
+ *
+ * @param environment the target <code>Environment</code>.
+ * @param server the target <code>JEEApplicationServer</code>.
+ * @param dataSource the target <code>JDBCDataSource</code>.
+ * @param updateLog the <code>UpdateLog</code> to use.
+ */
+ public static void update( Environment environment, JEEApplicationServer server, JDBCDataSource dataSource,
+ UpdateLog updateLog )
+ throws UpdateException
+ {
+ LOGGER.info( "Updating JDBC data source {}", dataSource.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Updating JDBC data source " + dataSource.getName() ) );
+ EventUtils.post( environment, "UPDATE", "Updating JDBC data source " + dataSource.getName() );
- if ( !dataSource.isActive() )
- {
- // the data source is not active
- LOGGER.info( "JDBC data source {} is inactive, so not updated", dataSource.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JDBC data source " + dataSource.getName() + " is inactive, so not updated" ) );
- EventUtils.post( environment, "UPDATE",
- "JDBC Data Source " + dataSource.getName() + " is inactive, so not updated" );
- return;
- }
-
- LOGGER.debug( "Getting the JDBC connection pool {}", dataSource.getPool() );
- JDBCConnectionPool connectionPool = server.getJDBCConnectionPool( dataSource.getPool() );
- if ( connectionPool == null )
- {
- LOGGER.error( "JDBC connection pool {} is not found in the configuration", dataSource.getPool() );
- throw new UpdateException(
- "JDBC connection pool " + dataSource.getPool() + " is not found in the configuration" );
- }
- JEEApplicationServerController controller = null;
- try
- {
- LOGGER.debug( "Connecting to JEE application server controller" );
- controller = JEEApplicationServerControllerFactory.getController(environment, server);
- }
- catch ( KalumetException e )
- {
- LOGGER.error( "Can't connect to JEE application server {} controller", server.getName(), e );
- throw new UpdateException( "Can't connect to JEE application server " + server.getName() + " controller", e );
- }
- // replace variables in the JDBC URL and helper class name
- LOGGER.debug( "Replacing variables in JDBC URL and helper class" );
- String jdbcUrl = VariableUtils.replace( connectionPool.getUrl(), environment.getVariables() );
- String helperClass = VariableUtils.replace( connectionPool.getHelperclass(), environment.getVariables() );
- try
- {
- if ( controller.isJDBCDataSourceDeployed( dataSource.getName() ) )
- {
- // JDBC data source already deployed in the JEE application server
- LOGGER.info( "JDBC data source " + dataSource.getName() + " already deployed, checking for update" );
- if ( controller.updateJDBCDataSource( dataSource.getName(), connectionPool.getName(), jdbcUrl, helperClass ) )
+ if ( !dataSource.isActive() )
{
- // JDBC data source has been updated
- LOGGER.info( "JDBC data source {} updated", dataSource.getName() );
- updateLog.setStatus( "Update performed" );
- updateLog.setUpdated( true );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JDBC data source " + dataSource.getName() + " updated" ) );
- EventUtils.post( environment, "UPDATE", "JDBC data source " + dataSource.getName() + " updated" );
+ // the data source is not active
+ LOGGER.info( "JDBC data source {} is inactive, so not updated", dataSource.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JDBC data source " + dataSource.getName()
+ + " is inactive, so not updated" ) );
+ EventUtils.post( environment, "UPDATE",
+ "JDBC Data Source " + dataSource.getName() + " is inactive, so not updated" );
+ return;
}
- }
- else
- {
- // JDBC data source is not deployed, deploy it
- LOGGER.debug( "JDBC data source {} is not deployed, deploying it", dataSource.getName() );
- controller.deployJDBCDataSource( dataSource.getName(), connectionPool.getName(), jdbcUrl, helperClass );
- updateLog.setStatus( "Update performed" );
- updateLog.setUpdated( true );
+
+ LOGGER.debug( "Getting the JDBC connection pool {}", dataSource.getPool() );
+ JDBCConnectionPool connectionPool = server.getJDBCConnectionPool( dataSource.getPool() );
+ if ( connectionPool == null )
+ {
+ LOGGER.error( "JDBC connection pool {} is not found in the configuration", dataSource.getPool() );
+ throw new UpdateException(
+ "JDBC connection pool " + dataSource.getPool() + " is not found in the configuration" );
+ }
+ JEEApplicationServerController controller = null;
+ try
+ {
+ LOGGER.debug( "Connecting to JEE application server controller" );
+ controller = JEEApplicationServerControllerFactory.getController( environment, server );
+ }
+ catch ( KalumetException e )
+ {
+ LOGGER.error( "Can't connect to JEE application server {} controller", server.getName(), e );
+ throw new UpdateException( "Can't connect to JEE application server " + server.getName() + " controller",
+ e );
+ }
+ // replace variables in the JDBC URL and helper class name
+ LOGGER.debug( "Replacing variables in JDBC URL and helper class" );
+ String jdbcUrl = VariableUtils.replace( connectionPool.getUrl(), environment.getVariables() );
+ String helperClass = VariableUtils.replace( connectionPool.getHelperclass(), environment.getVariables() );
+ try
+ {
+ if ( controller.isJDBCDataSourceDeployed( dataSource.getName() ) )
+ {
+ // JDBC data source already deployed in the JEE application server
+ LOGGER.info( "JDBC data source " + dataSource.getName() + " already deployed, checking for update" );
+ if ( controller.updateJDBCDataSource( dataSource.getName(), connectionPool.getName(), jdbcUrl,
+ helperClass ) )
+ {
+ // JDBC data source has been updated
+ LOGGER.info( "JDBC data source {} updated", dataSource.getName() );
+ updateLog.setStatus( "Update performed" );
+ updateLog.setUpdated( true );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "JDBC data source " + dataSource.getName() + " updated" ) );
+ EventUtils.post( environment, "UPDATE", "JDBC data source " + dataSource.getName() + " updated" );
+ }
+ }
+ else
+ {
+ // JDBC data source is not deployed, deploy it
+ LOGGER.debug( "JDBC data source {} is not deployed, deploying it", dataSource.getName() );
+ controller.deployJDBCDataSource( dataSource.getName(), connectionPool.getName(), jdbcUrl, helperClass );
+ updateLog.setStatus( "Update performed" );
+ updateLog.setUpdated( true );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "JDBC data source " + dataSource.getName() + " deployed" ) );
+ EventUtils.post( environment, "UPDATE", "JDBC data source " + dataSource.getName() + " deployed" );
+ LOGGER.info( "JDBC data source {} deployed", dataSource.getName() );
+ }
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "JDBC data source {} update failed", dataSource.getName(), e );
+ throw new UpdateException( "JDBC data source " + dataSource.getName() + " update failed", e );
+ }
+ }
+
+ /**
+ * Wrapper method to update a JDBC data source via WS.
+ *
+ * @param environmentName the target environment name.
+ * @param serverName the target JEE application server name.
+ * @param dataSourceName the target JDBC data source name.
+ * @throws KalumetException in case of update failure.
+ */
+ public static void update( String environmentName, String serverName, String dataSourceName )
+ throws KalumetException
+ {
+ LOGGER.info( "JDBC data source {} update requested by WS", dataSourceName );
+
+ // load configuration
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+
+ // looking for component objects
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer applicationServer =
+ environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
+ if ( applicationServer == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", serverName,
+ environment.getName() );
+ throw new KalumetException(
+ "JEE application server " + serverName + " is not found in environment " + environment.getName() );
+ }
+ JDBCDataSource dataSource = applicationServer.getJDBCDataSource( dataSourceName );
+ if ( dataSource == null )
+ {
+ LOGGER.error( "JDBC data source {} is not found in JEE application server {}", dataSourceName,
+ applicationServer.getName() );
+ throw new KalumetException(
+ "JDBC data source " + dataSourceName + " is not found in JEE application server "
+ + applicationServer.getName() );
+ }
+
+ // post event and create update log
+ EventUtils.post( environment, "UPDATE",
+ "JDBC data source " + dataSource.getName() + " update requested by WS" );
+ UpdateLog updateLog = new UpdateLog( "JDBC data source " + dataSource.getName() + " update in progress ...",
+ environment.getName(), environment );
+
+ // send a notification and waiting for the count down
+ EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
+ NotifierUtils.waitAndNotify( environment );
+
+ try
+ {
+ // call the updater
+ LOGGER.debug( "Call JDBC data source updater" );
+ JDBCDataSourceUpdater.update( environment, applicationServer, dataSource, updateLog );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "JDBC data source {} update failed", dataSource.getName(), e );
+ EventUtils.post( environment, "ERROR",
+ "JDBC data source " + dataSource.getName() + " update failed: " + e.getMessage() );
+ updateLog.setStatus( "JDBC data source " + dataSource.getName() + " update failed" );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "JDBC data source " + dataSource.getName()
+ + " update failed: " + e.getMessage() ) );
+ PublisherUtils.publish( environment );
+ throw new KalumetException( "JDBC data source " + dataSource.getName() + " update failed", e );
+ }
+
+ // update completed
+ LOGGER.info( "JDBC data source {} updated", dataSource.getName() );
+ EventUtils.post( environment, "UPDATE", "JDBC data source " + dataSource.getName() + " updated" );
+ if ( updateLog.isUpdated() )
+ {
+ updateLog.setStatus( "JDBC data source " + dataSource.getName() + " updated" );
+ }
+ else
+ {
+ updateLog.setStatus( "JDBC data source " + dataSource.getName() + " already up to date" );
+ }
updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JDBC data source " + dataSource.getName() + " deployed" ) );
- EventUtils.post( environment, "UPDATE", "JDBC data source " + dataSource.getName() + " deployed" );
- LOGGER.info( "JDBC data source {} deployed", dataSource.getName() );
- }
- }
- catch ( Exception e )
- {
- LOGGER.error( "JDBC data source {} update failed", dataSource.getName(), e );
- throw new UpdateException( "JDBC data source " + dataSource.getName() + " update failed", e );
- }
- }
-
- /**
- * Wrapper method to update a JDBC data source via WS.
- *
- * @param environmentName the target environment name.
- * @param serverName the target JEE application server name.
- * @param dataSourceName the target JDBC data source name.
- * @throws KalumetException in case of update failure.
- */
- public static void update( String environmentName, String serverName, String dataSourceName )
- throws KalumetException
- {
- LOGGER.info( "JDBC data source {} update requested by WS", dataSourceName );
-
- // load configuration
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
-
- // looking for component objects
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer applicationServer =
- environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
- if ( applicationServer == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environment.getName() );
- throw new KalumetException(
- "JEE application server " + serverName + " is not found in environment " + environment.getName() );
- }
- JDBCDataSource dataSource = applicationServer.getJDBCDataSource( dataSourceName );
- if ( dataSource == null )
- {
- LOGGER.error( "JDBC data source {} is not found in JEE application server {}", dataSourceName,
- applicationServer.getName() );
- throw new KalumetException( "JDBC data source " + dataSourceName + " is not found in JEE application server "
- + applicationServer.getName() );
+ new UpdateMessage( "info", "JMS data source " + dataSource.getName() + " updated" ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
}
- // post event and create update log
- EventUtils.post( environment, "UPDATE", "JDBC data source " + dataSource.getName() + " update requested by WS" );
- UpdateLog updateLog =
- new UpdateLog( "JDBC data source " + dataSource.getName() + " update in progress ...", environment.getName(),
- environment );
+ /**
+ * Wrapper method to check JDBC data source via WS.
+ *
+ * @param environmentName the target environment name.
+ * @param serverName the target JEE application server name.
+ * @param dataSourceName the target JDBC data source name.
+ * @return true if the JDBC data source is up to date, false else.
+ * @throws KalumetException in case of check failure.
+ */
+ public static boolean check( String environmentName, String serverName, String dataSourceName )
+ throws KalumetException
+ {
+ LOGGER.info( "JDBC data source {} status check requested by WS", dataSourceName );
- // send a notification and waiting for the count down
- EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
- NotifierUtils.waitAndNotify( environment );
+ // load configuration.
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- try
- {
- // call the updater
- LOGGER.debug( "Call JDBC data source updater" );
- JDBCDataSourceUpdater.update( environment, applicationServer, dataSource, updateLog );
- }
- catch ( Exception e )
- {
- LOGGER.error( "JDBC data source {} update failed", dataSource.getName(), e );
- EventUtils.post( environment, "ERROR",
- "JDBC data source " + dataSource.getName() + " update failed: " + e.getMessage() );
- updateLog.setStatus( "JDBC data source " + dataSource.getName() + " update failed" );
- updateLog.addUpdateMessage( new UpdateMessage( "error",
- "JDBC data source " + dataSource.getName() + " update failed: "
- + e.getMessage() ) );
- PublisherUtils.publish( environment );
- throw new KalumetException( "JDBC data source " + dataSource.getName() + " update failed", e );
- }
+ // looking for component objects
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer applicationServer =
+ environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
+ if ( applicationServer == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", serverName,
+ environment.getName() );
+ throw new KalumetException(
+ "JEE application server " + serverName + " is not found in environment " + environment.getName() );
+ }
+ JDBCDataSource dataSource = applicationServer.getJDBCDataSource( dataSourceName );
+ if ( dataSource == null )
+ {
+ LOGGER.error( "JDBC data source {} is not found in JEE application server {}", dataSourceName,
+ applicationServer.getName() );
+ throw new KalumetException(
+ "JDBC data source " + dataSourceName + " is not found in JEE application server "
+ + applicationServer.getName() );
+ }
- // update completed
- LOGGER.info( "JDBC data source {} updated", dataSource.getName() );
- EventUtils.post( environment, "UPDATE", "JDBC data source " + dataSource.getName() + " updated" );
- if ( updateLog.isUpdated() )
- {
- updateLog.setStatus( "JDBC data source " + dataSource.getName() + " updated" );
- }
- else
- {
- updateLog.setStatus( "JDBC data source " + dataSource.getName() + " already up to date" );
- }
- updateLog.addUpdateMessage( new UpdateMessage( "info", "JMS data source " + dataSource.getName() + " updated" ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
- }
+ // post an event
+ EventUtils.post( environment, "INFO",
+ "JDBC data source " + dataSource.getName() + " status check requested by WS" );
- /**
- * Wrapper method to check JDBC data source via WS.
- *
- * @param environmentName the target environment name.
- * @param serverName the target JEE application server name.
- * @param dataSourceName the target JDBC data source name.
- * @return true if the JDBC data source is up to date, false else.
- * @throws KalumetException in case of check failure.
- */
- public static boolean check( String environmentName, String serverName, String dataSourceName )
- throws KalumetException
- {
- LOGGER.info( "JDBC data source {} status check requested by WS", dataSourceName );
+ // Get JDBC data source connection pool.
+ LOGGER.debug( "Getting JDBC data source connection pool" );
+ JDBCConnectionPool connectionPool = applicationServer.getJDBCConnectionPool( dataSource.getPool() );
+ if ( connectionPool == null )
+ {
+ LOGGER.error( "JDBC connection pool {} is not found in JEE application server {}", dataSource.getPool(),
+ applicationServer.getName() );
+ throw new KalumetException(
+ "JDBC connection pool " + dataSource.getPool() + " is not found in JEE application server "
+ + applicationServer.getName() );
+ }
- // load configuration.
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
-
- // looking for component objects
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ try
+ {
+ // connecting to JEE application server controller
+ LOGGER.debug( "Connecting to JEE application server controller" );
+ JEEApplicationServerController controller =
+ JEEApplicationServerControllerFactory.getController( environment, applicationServer );
+ // replace variables in the JDBC URL and helper class name
+ LOGGER.debug( "Replacing variables in JDBC URL and helper class" );
+ String jdbcUrl = VariableUtils.replace( connectionPool.getUrl(), environment.getVariables() );
+ String helperClass = VariableUtils.replace( connectionPool.getHelperclass(), environment.getVariables() );
+ // check the data source
+ return controller.isJDBCDataSourceUpToDate( dataSource.getName(), dataSource.getPool(), jdbcUrl,
+ helperClass );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "JDBC data source {} check failed", dataSource.getName(), e );
+ throw new KalumetException( "JDBC data source " + dataSource.getName() + " check failed", e );
+ }
}
- JEEApplicationServer applicationServer =
- environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
- if ( applicationServer == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environment.getName() );
- throw new KalumetException(
- "JEE application server " + serverName + " is not found in environment " + environment.getName() );
- }
- JDBCDataSource dataSource = applicationServer.getJDBCDataSource( dataSourceName );
- if ( dataSource == null )
- {
- LOGGER.error( "JDBC data source {} is not found in JEE application server {}", dataSourceName,
- applicationServer.getName() );
- throw new KalumetException( "JDBC data source " + dataSourceName + " is not found in JEE application server "
- + applicationServer.getName() );
- }
-
- // post an event
- EventUtils.post( environment, "INFO",
- "JDBC data source " + dataSource.getName() + " status check requested by WS" );
-
- // Get JDBC data source connection pool.
- LOGGER.debug( "Getting JDBC data source connection pool" );
- JDBCConnectionPool connectionPool = applicationServer.getJDBCConnectionPool( dataSource.getPool() );
- if ( connectionPool == null )
- {
- LOGGER.error( "JDBC connection pool {} is not found in JEE application server {}", dataSource.getPool(),
- applicationServer.getName() );
- throw new KalumetException(
- "JDBC connection pool " + dataSource.getPool() + " is not found in JEE application server "
- + applicationServer.getName() );
- }
-
- try
- {
- // connecting to JEE application server controller
- LOGGER.debug( "Connecting to JEE application server controller" );
- JEEApplicationServerController controller =
- JEEApplicationServerControllerFactory.getController(environment, applicationServer);
- // replace variables in the JDBC URL and helper class name
- LOGGER.debug( "Replacing variables in JDBC URL and helper class" );
- String jdbcUrl = VariableUtils.replace( connectionPool.getUrl(), environment.getVariables() );
- String helperClass = VariableUtils.replace( connectionPool.getHelperclass(), environment.getVariables() );
- // check the data source
- return controller.isJDBCDataSourceUpToDate( dataSource.getName(), dataSource.getPool(), jdbcUrl, helperClass );
- }
- catch ( Exception e )
- {
- LOGGER.error( "JDBC data source {} check failed", dataSource.getName(), e );
- throw new KalumetException( "JDBC data source " + dataSource.getName() + " check failed", e );
- }
- }
}
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JEEApplicationServerUpdater.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JEEApplicationServerUpdater.java
index aa14bde..911bf24 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JEEApplicationServerUpdater.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JEEApplicationServerUpdater.java
@@ -24,8 +24,18 @@
import org.apache.kalumet.agent.utils.EventUtils;
import org.apache.kalumet.controller.core.JEEApplicationServerController;
import org.apache.kalumet.controller.core.JEEApplicationServerControllerFactory;
-import org.apache.kalumet.model.*;
+import org.apache.kalumet.model.Agent;
+import org.apache.kalumet.model.Cache;
+import org.apache.kalumet.model.Environment;
+import org.apache.kalumet.model.JDBCConnectionPool;
+import org.apache.kalumet.model.JDBCDataSource;
import org.apache.kalumet.model.JEEApplication;
+import org.apache.kalumet.model.JEEApplicationServer;
+import org.apache.kalumet.model.JMSConnectionFactory;
+import org.apache.kalumet.model.JMSServer;
+import org.apache.kalumet.model.JNDIBinding;
+import org.apache.kalumet.model.Kalumet;
+import org.apache.kalumet.model.SharedLibrary;
import org.apache.kalumet.model.update.UpdateLog;
import org.apache.kalumet.model.update.UpdateMessage;
import org.apache.kalumet.utils.CommandUtils;
@@ -46,947 +56,972 @@
public class JEEApplicationServerUpdater
{
- private static final transient Logger LOGGER = LoggerFactory.getLogger( JEEApplicationServerUpdater.class );
+ private static final transient Logger LOGGER = LoggerFactory.getLogger( JEEApplicationServerUpdater.class );
- /**
- * Wrapper class to update a JEE application server (via WS).
- *
- * @param environmentName the target environment name.
- * @param serverName the target JEE application server name.
- * @param delegation flag indicates if the update is a atomic call or part of an update launched by another agent.
- * @throws KalumetException if the JEE application server update fails.
- */
- public static void update( String environmentName, String serverName, boolean delegation )
- throws KalumetException
- {
- LOGGER.info( "JEE application server {} update requested by WS", serverName );
- // load configuration
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
+ /**
+ * Wrapper class to update a JEE application server (via WS).
+ *
+ * @param environmentName the target environment name.
+ * @param serverName the target JEE application server name.
+ * @param delegation flag indicates if the update is a atomic call or part of an update launched by another agent.
+ * @throws KalumetException if the JEE application server update fails.
+ */
+ public static void update( String environmentName, String serverName, boolean delegation )
+ throws KalumetException
{
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer applicationServer =
- environment.getJEEApplicationServers().getJEEApplicationServer(serverName);
- if ( applicationServer == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environmentName );
- throw new KalumetException(
- "JEE application server " + serverName + " is not found in environment " + environmentName );
- }
- // update configuration cache
- LOGGER.debug( "Updating configuration cache" );
- Configuration.CONFIG_CACHE = kalumet;
-
- EventUtils.post( environment, "UPDATE", "JEE application server " + serverName + " update requested by WS" );
- UpdateLog updateLog =
- new UpdateLog( "JEE application server " + serverName + " update in progress ...", environment.getName(),
- environment );
-
- if ( !delegation )
- {
- // it's not a delegation from another agent, send a notification and waiting for the count down
- LOGGER.info( "Send a notification and waiting for the count down" );
- EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
- NotifierUtils.waitAndNotify( environment );
- }
-
- try
- {
- // launch the update
- LOGGER.debug( "Call JEE application server updater" );
- JEEApplicationServerUpdater.update(kalumet, environment, applicationServer, updateLog);
- }
- catch ( Exception e )
- {
- // an error occurs
- LOGGER.error( "JEE application server {} update failed", serverName, e );
- EventUtils.post( environment, "ERROR",
- "JEE application server " + serverName + " update failed: " + e.getMessage() );
- if ( !delegation )
- {
- // it's not a delegation from another agent, publish update result
- updateLog.setStatus( "JEE application server " + serverName + " update failed" );
- updateLog.addUpdateMessage(
- new UpdateMessage( "error", "JEE application server " + serverName + " update failed: " + e.getMessage() ) );
- PublisherUtils.publish( environment );
- }
- throw new UpdateException( "JEE application server " + serverName + " update failed", e );
- }
-
- // update is completed
- LOGGER.info( "JEE application server {} updated", applicationServer.getName() );
- EventUtils.post( environment, "UPDATE", "JEE application server " + serverName + " updated" );
-
- if ( !delegation )
- {
- // it's not a delegation from another agent, publish update result
- if ( updateLog.isUpdated() )
- {
- updateLog.setStatus( "JEE application server " + serverName + " updated" );
- }
- else
- {
- updateLog.setStatus( "JEE application server " + serverName + " already up to date" );
- }
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Update completed" ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
- }
- }
-
- /**
- * Update a JEE application server.
- *
- * @param kalumet the main configuration.
- * @param environment the target <code>Environment</code>.
- * @param server the target <code>ApplicationServer</code> to update.
- * @param updateLog the <code>UpdateLog</code> to use.
- */
- public static void update( Kalumet kalumet, Environment environment, JEEApplicationServer server,
- UpdateLog updateLog )
- throws UpdateException
- {
- String applicationServerJmxUrl = VariableUtils.replace( server.getJmxurl(), environment.getVariables() );
- LOGGER.info( "Updating JEE application server {}", server.getName() );
-
- if ( !server.isActive() )
- {
- LOGGER.info( "JEE application server {} is inactive, so not updated", server.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JEE application server " + server.getName() + " is inactive, so not updated" ) );
- EventUtils.post( environment, "UPDATE",
- "JEE application server " + server.getName() + " is inactive, so not updated" );
- return;
- }
-
- if ( server.getAgent() != null && server.getAgent().trim().length() > 0 &&
- !server.getAgent().equals( Configuration.AGENT_ID ) )
- {
- // delegates the update to another agent
- LOGGER.info( "Delegating JEE application server {} update to agent {}", server.getName(), server.getAgent() );
- EventUtils.post( environment, "UPDATE",
- "Delegating JEE application server " + server.getName() + " update to agent "
- + server.getAgent() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Delegating JEE application server " + server.getName()
- + " update to agent " + server.getAgent() ) );
- Agent delegationAgent = Configuration.CONFIG_CACHE.getAgent( server.getAgent() );
- if ( delegationAgent == null )
- {
- // the target agent is not found in the configuration
- LOGGER.error( "Agent {} not found in the configuration", server.getAgent() );
- throw new UpdateException( "Agent " + server.getAgent() + " not found in the configuration" );
- }
- try
- {
- // request the update via WebService call
- LOGGER.debug( "Call JEE application server WS" );
- JEEApplicationServerClient client =
- new JEEApplicationServerClient( delegationAgent.getHostname(), delegationAgent.getPort() );
- client.update( environment.getName(), server.getName(), true );
- }
- catch ( ClientException e )
- {
- // an error occurs during the update on the remote agent
- LOGGER.error( "JEE application server {} update failed", server.getName(), e );
- throw new UpdateException( "JEE application server " + server.getName() + " update failed", e );
- }
- return;
- }
-
- EventUtils.post( environment, "UPDATE", "Updating JEE application server " + server.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "JEE application server " + server.getName() + " located "
- + applicationServerJmxUrl ) );
-
- // update JDBC connection pools
- LOGGER.info( "Updating JDBC connection pools" );
- for ( Iterator connectionPoolIterator = server.getJDBCConnectionPools().iterator();
- connectionPoolIterator.hasNext(); )
- {
- JDBCConnectionPool connectionPool = (JDBCConnectionPool) connectionPoolIterator.next();
- try
- {
- JDBCConnectionPoolUpdater.update( environment, server, connectionPool, updateLog );
- }
- catch ( UpdateException updateException )
- {
- // the JDBC connection pool update has failed
- if ( connectionPool.isBlocker() )
+ LOGGER.info( "JEE application server {} update requested by WS", serverName );
+ // load configuration
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
{
- // connection pool is update blocker
- LOGGER.error( "JDBC connection pool {} update failed", connectionPool.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "error", "JDBC connection pool " + connectionPool.getName()
- + " update failed: " + updateException.getMessage() ) );
- EventUtils.post( environment, "ERROR", "JDBC connection pool " + connectionPool.getName() + " update failed: "
- + updateException.getMessage() );
- throw new UpdateException( "JDBC connection ool " + connectionPool.getName() + " update failed",
- updateException );
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
}
- else
+ JEEApplicationServer applicationServer =
+ environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
+ if ( applicationServer == null )
{
- // connection pool is not update blocker
- LOGGER.warn( "JDBC connection pool {} update failed", connectionPool.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "warn", "JDBC connection pool " + connectionPool.getName()
- + " update failed: " + updateException.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "JDBC connection pool " + connectionPool.getName()
- + " is not update blocker, update continues" ) );
- EventUtils.post( environment, "WARN", "JDBC connection pool " + connectionPool.getName() + " update failed: "
- + updateException.getMessage() );
- EventUtils.post( environment, "UPDATE", "JDBC connection pool " + connectionPool.getName()
- + " is not update blocker, update continues" );
+ LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environmentName );
+ throw new KalumetException(
+ "JEE application server " + serverName + " is not found in environment " + environmentName );
}
- }
+ // update configuration cache
+ LOGGER.debug( "Updating configuration cache" );
+ Configuration.CONFIG_CACHE = kalumet;
+
+ EventUtils.post( environment, "UPDATE", "JEE application server " + serverName + " update requested by WS" );
+ UpdateLog updateLog =
+ new UpdateLog( "JEE application server " + serverName + " update in progress ...", environment.getName(),
+ environment );
+
+ if ( !delegation )
+ {
+ // it's not a delegation from another agent, send a notification and waiting for the count down
+ LOGGER.info( "Send a notification and waiting for the count down" );
+ EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
+ NotifierUtils.waitAndNotify( environment );
+ }
+
+ try
+ {
+ // launch the update
+ LOGGER.debug( "Call JEE application server updater" );
+ JEEApplicationServerUpdater.update( kalumet, environment, applicationServer, updateLog );
+ }
+ catch ( Exception e )
+ {
+ // an error occurs
+ LOGGER.error( "JEE application server {} update failed", serverName, e );
+ EventUtils.post( environment, "ERROR",
+ "JEE application server " + serverName + " update failed: " + e.getMessage() );
+ if ( !delegation )
+ {
+ // it's not a delegation from another agent, publish update result
+ updateLog.setStatus( "JEE application server " + serverName + " update failed" );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "JEE application server " + serverName
+ + " update failed: " + e.getMessage() ) );
+ PublisherUtils.publish( environment );
+ }
+ throw new UpdateException( "JEE application server " + serverName + " update failed", e );
+ }
+
+ // update is completed
+ LOGGER.info( "JEE application server {} updated", applicationServer.getName() );
+ EventUtils.post( environment, "UPDATE", "JEE application server " + serverName + " updated" );
+
+ if ( !delegation )
+ {
+ // it's not a delegation from another agent, publish update result
+ if ( updateLog.isUpdated() )
+ {
+ updateLog.setStatus( "JEE application server " + serverName + " updated" );
+ }
+ else
+ {
+ updateLog.setStatus( "JEE application server " + serverName + " already up to date" );
+ }
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Update completed" ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
+ }
}
- // update JDBC data sources
- LOGGER.info( "Updating JDBC data sources" );
- for ( Iterator dataSourceIterator = server.getJDBCDataSources().iterator(); dataSourceIterator.hasNext(); )
- {
- JDBCDataSource dataSource = (JDBCDataSource) dataSourceIterator.next();
- try
- {
- JDBCDataSourceUpdater.update( environment, server, dataSource, updateLog );
- }
- catch ( UpdateException updateException )
- {
- // the JDBC data source update has failed
- if ( dataSource.isBlocker() )
- {
- // data source is update blocker
- LOGGER.error( "JDBC data source {} udpate failed", dataSource.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "error",
- "JDBC data source " + dataSource.getName() + " update failed: "
- + updateException.getMessage() ) );
- EventUtils.post( environment, "ERROR", "JDBC data source " + dataSource.getName() + " update failed: "
- + updateException.getMessage() );
- throw new UpdateException( "JDBC data source " + dataSource.getName() + " update failed", updateException );
- }
- else
- {
- // data source is not update blocker
- LOGGER.warn( "JDBC data source {} update failed", dataSource.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "warn",
- "JDBC data source " + dataSource.getName() + " update failed: "
- + updateException.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "JDBC data source " + dataSource.getName()
- + " is not update blocker, update continues" ) );
- EventUtils.post( environment, "WARN", "JDBC data source " + dataSource.getName() + " update failed: "
- + updateException.getMessage() );
- EventUtils.post( environment, "UPDATE",
- "JDBC data source " + dataSource.getName() + " is not update blocker, update continues" );
- }
- }
- }
-
- // update JMS connection factories
- LOGGER.info( "Updating JMS connection factories" );
- for ( Iterator jmsConnectionFactoryIterator = server.getJMSConnectionFactories().iterator();
- jmsConnectionFactoryIterator.hasNext(); )
- {
- JMSConnectionFactory jmsConnectionFactory = (JMSConnectionFactory) jmsConnectionFactoryIterator.next();
- try
- {
- JMSConnectionFactoryUpdater.update( environment, server, jmsConnectionFactory, updateLog );
- }
- catch ( UpdateException updateException )
- {
- // the JMS connection factory update has failed
- if ( jmsConnectionFactory.isBlocker() )
- {
- // JMS connection factory is update blocker
- LOGGER.error( "JMS connection factory {} update failed", jmsConnectionFactory.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "error",
- "JMS connection factory " + jmsConnectionFactory.getName()
- + " update failed: " + updateException.getMessage() ) );
- EventUtils.post( environment, "ERROR",
- "JMS connection factory " + jmsConnectionFactory.getName() + " update failed: "
- + updateException.getMessage() );
- throw new UpdateException( "JMS connection factory " + jmsConnectionFactory.getName() + " update failed: "
- + updateException.getMessage(), updateException );
- }
- else
- {
- // JMS connection factory is not update blocker
- LOGGER.warn( "JMS connection factory {} update failed", jmsConnectionFactory.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "warn",
- "JMS connection factory " + jmsConnectionFactory.getName()
- + " update failed: " + updateException.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info",
- "JMS connection factory " + jmsConnectionFactory.getName()
- + " is not update blocker, update continues" ) );
- EventUtils.post( environment, "WARN",
- "JMS connection factory " + jmsConnectionFactory.getName() + " update failed: "
- + updateException.getMessage() );
- EventUtils.post( environment, "UPDATE", "JMS connection factory " + jmsConnectionFactory.getName()
- + " is not update blocker, update continues" );
- }
- }
- }
-
- // update JMS servers
- LOGGER.info( "Updating JMS servers" );
- for ( Iterator jmsServerIterator = server.getJMSServers().iterator(); jmsServerIterator.hasNext(); )
- {
- JMSServer jmsServer = (JMSServer) jmsServerIterator.next();
- try
- {
- JMSServerUpdater.update( environment, server, jmsServer, updateLog );
- }
- catch ( UpdateException updateException )
- {
- // the JMS server update has failed
- if ( jmsServer.isBlocker() )
- {
- // JMS server is update blocker
- LOGGER.error( "JMS server {} update failed", jmsServer.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "error",
- "JMS server " + jmsServer.getName() + " update failed: "
- + updateException.getMessage() ) );
- EventUtils.post( environment, "ERROR",
- "JMS server " + jmsServer.getName() + " update failed: " + updateException.getMessage() );
- throw new UpdateException( "JMS server " + jmsServer.getName() + " update failed", updateException );
- }
- else
- {
- // JMS server is not update blocker
- LOGGER.warn( "JMS server {} update failed", jmsServer.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "warn",
- "JMS server " + jmsServer.getName() + " update failed: "
- + updateException.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "JMS server " + jmsServer.getName()
- + " is not update blocker, update continues" ) );
- EventUtils.post( environment, "WARN",
- "JMS server " + jmsServer.getName() + " update failed: " + updateException.getMessage() );
- EventUtils.post( environment, "UPDATE",
- "JMS server " + jmsServer.getName() + " is not update blocker, update continues" );
- }
- }
- }
-
- // update JNDI name space bindings
- LOGGER.info( "Updating JNDIbindings" );
- for ( Iterator jndiBindingsIterator = server.getJNDIBindings().iterator(); jndiBindingsIterator.hasNext(); )
- {
- JNDIBinding jndiBinding = (JNDIBinding) jndiBindingsIterator.next();
- try
- {
- JNDIBindingUpdater.update( environment, server, jndiBinding, updateLog );
- }
- catch ( UpdateException updateException )
- {
- // the JNDI binding update has failed
- if ( jndiBinding.isBlocker() )
- {
- // JNDIbinding is update blocker
- LOGGER.error( "JNDI binding {} update failed", jndiBinding.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "error",
- "JNDI binding " + jndiBinding.getName() + " update failed: "
- + updateException.getMessage() ) );
- EventUtils.post( environment, "ERROR", "JNDI binding " + jndiBinding.getName() + " update failed: "
- + updateException.getMessage() );
- throw new UpdateException( "JNDI binding " + jndiBinding.getName() + " update failed", updateException );
- }
- else
- {
- // JNDI binding is not update blocker
- LOGGER.warn( "JNDI binding {} update failed", jndiBinding.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "warn",
- "JNDI binding " + jndiBinding.getName() + " update failed: "
- + updateException.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "JNDI binding " + jndiBinding.getName()
- + " is not update blocker, update continues" ) );
- EventUtils.post( environment, "WARN", "JNDI binding " + jndiBinding.getName() + " update failed: "
- + updateException.getMessage() );
- EventUtils.post( environment, "UPDATE",
- "JNDI binding " + jndiBinding.getName() + " is not update blocker, update continues" );
- }
- }
- }
-
- // update shared libraries
- LOGGER.info( "Updating shared libraries" );
- for ( Iterator sharedLibraryIterator = server.getSharedLibraries().iterator(); sharedLibraryIterator.hasNext(); )
- {
- SharedLibrary sharedLibrary = (SharedLibrary) sharedLibraryIterator.next();
- try
- {
- SharedLibraryUpdater.update( environment, server, sharedLibrary, updateLog );
- }
- catch ( UpdateException updateException )
- {
- // the shared library update has failed
- if ( sharedLibrary.isBlocker() )
- {
- // shared library is update blocker
- LOGGER.error( "Shared library {} update failed", sharedLibrary.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "error", "Shared library " + sharedLibrary.getName()
- + " update failed: " + updateException.getMessage() ) );
- EventUtils.post( environment, "ERROR", "Shared library " + sharedLibrary.getName() + " update failed: "
- + updateException.getMessage() );
- throw new UpdateException( "Shared library " + sharedLibrary.getName() + " update failed", updateException );
- }
- else
- {
- // shared library is not update blocker
- LOGGER.warn( "Shared library {} update failed", sharedLibrary.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "warn", "Shared library " + sharedLibrary.getName()
- + " update failed: " + updateException.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Shared library " + sharedLibrary.getName()
- + " is not update blocker, update continues" ) );
- EventUtils.post( environment, "WARN", "Shared library " + sharedLibrary.getName() + " update failed: "
- + updateException.getMessage() );
- EventUtils.post( environment, "UPDATE",
- "Shared library " + sharedLibrary.getName() + " is not update blocker, update continues" );
- }
- }
- }
-
- // update JEE applications
- LOGGER.info( "Updating JEE applications" );
- for ( Iterator applicationIterator = server.getJEEApplications().iterator(); applicationIterator.hasNext(); )
- {
- JEEApplication application = (JEEApplication) applicationIterator.next();
- try
- {
- JEEApplicationUpdater.update(environment, server, application, updateLog);
- }
- catch ( UpdateException updateException )
- {
- // the JEE application update has failed
- if ( application.isBlocker() )
- {
- // JEE application is update blocker
- LOGGER.error( "JEE application {} update failed", application.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "error", "JEE application " + application.getName()
- + " update failed: " + updateException.getMessage() ) );
- EventUtils.post( environment, "ERROR", "JEE application " + application.getName() + " update failed: "
- + updateException.getMessage() );
- throw new UpdateException( "JEE application " + application.getName() + " update failed", updateException );
- }
- else
- {
- // JEE application is not update blocker
- LOGGER.warn( "JEE application {} update failed", application.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "warn", "JEE application " + application.getName()
- + " update failed: " + updateException.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "JEE application " + application.getName()
- + " is not update blocker, update continues" ) );
- EventUtils.post( environment, "WARN", "JEE application " + application.getName() + " update failed: "
- + updateException.getMessage() );
- EventUtils.post( environment, "UPDATE",
- "JEE application " + application.getName() + " is not update blocker, update continues" );
- }
- }
- }
-
- // stop JEE server
- LOGGER.info( "Shutting down JEE application server" );
- try
- {
- JEEApplicationServerUpdater.stop(environment, server, updateLog);
- }
- catch ( UpdateException updateException )
- {
- // the JEE application server stop has failed
- if ( server.isBlocker() )
- {
- // JEE application server is update blocker
- LOGGER.error( "JEE application server {} shutdown failed", server.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "error", "JEE application server " + server.getName()
- + " shutdown failed: " + updateException.getMessage() ) );
- EventUtils.post( environment, "ERROR", "JEE application server " + server.getName() + " shutdown failed: "
- + updateException.getMessage() );
- throw new UpdateException(
- "JEE application server " + server.getName() + " shutdown failed: " + updateException.getMessage(),
- updateException );
- }
- else
- {
- // JEE application server is not update blocker
- LOGGER.warn( "JEE application server {} shutdown failed", server.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "warn", "JEE application server " + server.getName()
- + " shutdown failed: " + updateException.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "JEE application server " + server.getName()
- + " is not update blocker, update continues" ) );
- EventUtils.post( environment, "WARN", "JEE application server " + server.getName() + " shutdown failed: "
- + updateException.getMessage() );
- EventUtils.post( environment, "UPDATE",
- "JEE application server " + server.getName() + " is not update blocker, update continues" );
- }
- }
-
- // clean the JEE application server cache
- LOGGER.info( "Clean JEE application server cache directories" );
- try
- {
- JEEApplicationServerUpdater.cleanCaches(environment, server, updateLog);
- }
- catch ( UpdateException updateException )
- {
- // the JEE application server cache directories cleaning has failed
- if ( server.isBlocker() )
- {
- // JEE application server is update blocker
- LOGGER.error( "JEE application server {} cache directories cleanup failed", server.getName(),
- updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "error", "JEE application server " + server.getName()
- + " cache directories cleanup failed: " + updateException.getMessage() ) );
- EventUtils.post( environment, "ERROR",
- "JEE application server " + server.getName() + " cache directories cleanup failed: "
- + updateException.getMessage() );
- throw new UpdateException( "JEE application server " + server.getName() + " cache directories cleanup failed",
- updateException );
- }
- else
- {
- // JEE application server is not update blocker
- LOGGER.warn( "JEE application server {} cache directories cleanup failed", server.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "warn", "JEE application server " + server.getName()
- + " cache directories cleanup failed: " + updateException.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "JEE application server " + server.getName()
- + " is not update blocker, update continues" ) );
- EventUtils.post( environment, "WARN",
- "JEE application server " + server.getName() + " cache directories cleanup failed: "
- + updateException.getMessage() );
- EventUtils.post( environment, "UPDATE",
- "JEE application server " + server.getName() + " is not update blocker, update continues" );
- }
- }
-
- // start JEE application server
- LOGGER.info( "Starting JEE application server" );
- try
- {
- JEEApplicationServerUpdater.start(kalumet, environment, server, updateLog);
- }
- catch ( UpdateException updateException )
- {
- // the JEE application server start has failed
- if ( server.isBlocker() )
- {
- // JEE application server is update blocker
- LOGGER.error( "JEE application server {} start failed", server.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "error",
- "JEE application server " + server.getName() + " start failed: "
- + updateException.getMessage() ) );
- EventUtils.post( environment, "ERROR", "JEE application server " + server.getName() + " start failed: "
- + updateException.getMessage() );
- throw new UpdateException( "JEE application server " + server.getName() + " start failed", updateException );
- }
- else
- {
- // JEE application server is not update blocker
- LOGGER.warn( "JEE application server " + server.getName() + " start failed", updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "warn",
- "JEE application server " + server.getName() + " start failed: "
- + updateException.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "JEE application server " + server.getName()
- + " is not update blocker, update continues" ) );
- EventUtils.post( environment, "WARN", "JEE application server " + server.getName() + " start failed: "
- + updateException.getMessage() );
- EventUtils.post( environment, "UPDATE",
- "JEE application server " + server.getName() + " is not update blocker, update continues" );
- }
- }
-
- // update completed
- EventUtils.post( environment, "UPDATE", "JEE application server updated" );
- }
-
- /**
- * Shutdown a JEE server.
- *
- * @param environment the target <code>Environment</code>.
- * @param server the <code>JEEApplicationServer</code> to stop.
- * @param updateLog the <code>UpdateLog</code> to use.
- */
- protected static void stop( Environment environment, JEEApplicationServer server, UpdateLog updateLog )
- throws UpdateException
- {
- // TODO delegate the JEE server stop to another agent is required
- try
- {
- if ( !server.isUpdateRequireRestart() || !updateLog.isUpdated() )
- {
- LOGGER.info( "JEE application server {} shutdown is not required", server.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JEE application server " + server.getName() + " shutdown is not required" ) );
- EventUtils.post( environment, "UPDATE",
- "JEE application server " + server.getName() + " shutdown is not required" );
- return;
- }
- // the server restart is required
- LOGGER.info( "JEE application server {} shutdown is required", server.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JEE application server " + server.getName() + " shutdown is required" ) );
- EventUtils.post( environment, "UPDATE", "JEE application server " + server.getName() + " shutdown is required" );
- if ( server.isUsejmxstop() )
- {
- LOGGER.debug( "JEE application server shutdown is performed using JMX controller" );
- LOGGER.debug( "Getting JEE application server JMX controller" );
- JEEApplicationServerController controller =
- JEEApplicationServerControllerFactory.getController(environment, server);
- controller.shutdown();
- LOGGER.info( "JEE application server {} shutdown completed", server.getName() );
- EventUtils.post( environment, "UPDATE", "JEE server " + server.getName() + " shutdown completed" );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JEE server " + server.getName() + " shutdown completed" ) );
- return;
- }
- LOGGER.debug( "JEE application server shutdown is performed using system command" );
- String output =
- CommandUtils.execute( VariableUtils.replace( server.getShutdowncommand(), environment.getVariables() ) );
- LOGGER.info( "JEE application server " + server.getName() + " shutdown completed: " + output );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JEE application server " + server.getName() + " shutdown completed: " + output ) );
- EventUtils.post( environment, "UPDATE", "JEE server " + server.getName() + " shutdown completed: " + output );
- }
- catch ( Exception exception )
- {
- LOGGER.error( "JEE application server " + server.getName() + " shutdown failed", exception );
- updateLog.addUpdateMessage( new UpdateMessage( "error", "JEE server " + server.getName() + " shutdown failed: "
- + exception.getMessage() ) );
- EventUtils.post( environment, "ERROR",
- "JEE application server " + server.getName() + " shutdown failed: " + exception.getMessage() );
- throw new UpdateException( "JEE application server " + server.getName() + " shutdown failed", exception );
- }
- }
-
- /**
- * Start a JEE application server.
- *
- * @param kalumet the configuration.
- * @param environment the target <code>Environment</code>.
- * @param server the <code>JEEApplicationServer</code> to start.
- * @param updateLog the <code>UpdateLog</code> to use.
- */
- protected static void start( Kalumet kalumet, Environment environment, JEEApplicationServer server,
+ /**
+ * Update a JEE application server.
+ *
+ * @param kalumet the main configuration.
+ * @param environment the target <code>Environment</code>.
+ * @param server the target <code>ApplicationServer</code> to update.
+ * @param updateLog the <code>UpdateLog</code> to use.
+ */
+ public static void update( Kalumet kalumet, Environment environment, JEEApplicationServer server,
UpdateLog updateLog )
- throws UpdateException
- {
- // TODO delegate the JEE server start to another agent is required
- try
+ throws UpdateException
{
- if ( !server.isUpdateRequireRestart() || !updateLog.isUpdated() )
- {
- LOGGER.info( "JEE application server {} start is not required", server.getName() );
- EventUtils.post( environment, "UPDATE",
- "JEE application server " + server.getName() + " start is not required" );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JEE application server " + server.getName() + " start is required" ) );
- return;
- }
+ String applicationServerJmxUrl = VariableUtils.replace( server.getJmxurl(), environment.getVariables() );
+ LOGGER.info( "Updating JEE application server {}", server.getName() );
- LOGGER.info( "JEE application server {} start is required", server.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JEE application server " + server.getName() + " start is required" ) );
- EventUtils.post( environment, "UPDATE", "JEE application server " + server.getName() + " start is required" );
-
- // get the agent configuration
- Agent agent = kalumet.getAgent( Configuration.AGENT_ID );
-
- // check the agent max environment active
- if ( agent.getMaxjeeapplicationserversstarted() > 0 )
- {
- // get the environments managed by the agent
- List agentEnvironments = kalumet.getEnvironmentsByAgent( Configuration.AGENT_ID );
- int applicationServersStarted = 0;
- for ( Iterator agentEnvironmentsIterator = agentEnvironments.iterator(); agentEnvironmentsIterator.hasNext(); )
+ if ( !server.isActive() )
{
- Environment agentEnvironment = (Environment) agentEnvironmentsIterator.next();
- // check if the application server started into the environment
- for ( Iterator agentEnvironmentApplicationServersIterator =
- agentEnvironment.getJEEApplicationServers().getJEEApplicationServers().iterator();
- agentEnvironmentApplicationServersIterator.hasNext(); )
- {
- JEEApplicationServer agentEnvironmentApplicationServer =
- (JEEApplicationServer) agentEnvironmentApplicationServersIterator.next();
+ LOGGER.info( "JEE application server {} is inactive, so not updated", server.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JEE application server " + server.getName()
+ + " is inactive, so not updated" ) );
+ EventUtils.post( environment, "UPDATE",
+ "JEE application server " + server.getName() + " is inactive, so not updated" );
+ return;
+ }
+
+ if ( server.getAgent() != null && server.getAgent().trim().length() > 0 &&
+ !server.getAgent().equals( Configuration.AGENT_ID ) )
+ {
+ // delegates the update to another agent
+ LOGGER.info( "Delegating JEE application server {} update to agent {}", server.getName(),
+ server.getAgent() );
+ EventUtils.post( environment, "UPDATE",
+ "Delegating JEE application server " + server.getName() + " update to agent "
+ + server.getAgent() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info",
+ "Delegating JEE application server " + server.getName()
+ + " update to agent " + server.getAgent() ) );
+ Agent delegationAgent = Configuration.CONFIG_CACHE.getAgent( server.getAgent() );
+ if ( delegationAgent == null )
+ {
+ // the target agent is not found in the configuration
+ LOGGER.error( "Agent {} not found in the configuration", server.getAgent() );
+ throw new UpdateException( "Agent " + server.getAgent() + " not found in the configuration" );
+ }
+ try
+ {
+ // request the update via WebService call
+ LOGGER.debug( "Call JEE application server WS" );
+ JEEApplicationServerClient client =
+ new JEEApplicationServerClient( delegationAgent.getHostname(), delegationAgent.getPort() );
+ client.update( environment.getName(), server.getName(), true );
+ }
+ catch ( ClientException e )
+ {
+ // an error occurs during the update on the remote agent
+ LOGGER.error( "JEE application server {} update failed", server.getName(), e );
+ throw new UpdateException( "JEE application server " + server.getName() + " update failed", e );
+ }
+ return;
+ }
+
+ EventUtils.post( environment, "UPDATE", "Updating JEE application server " + server.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info",
+ "JEE application server " + server.getName() + " located "
+ + applicationServerJmxUrl ) );
+
+ // update JDBC connection pools
+ LOGGER.info( "Updating JDBC connection pools" );
+ for ( Iterator connectionPoolIterator = server.getJDBCConnectionPools().iterator();
+ connectionPoolIterator.hasNext(); )
+ {
+ JDBCConnectionPool connectionPool = (JDBCConnectionPool) connectionPoolIterator.next();
+ try
+ {
+ JDBCConnectionPoolUpdater.update( environment, server, connectionPool, updateLog );
+ }
+ catch ( UpdateException updateException )
+ {
+ // the JDBC connection pool update has failed
+ if ( connectionPool.isBlocker() )
+ {
+ // connection pool is update blocker
+ LOGGER.error( "JDBC connection pool {} update failed", connectionPool.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "error",
+ "JDBC connection pool " + connectionPool.getName()
+ + " update failed: "
+ + updateException.getMessage() ) );
+ EventUtils.post( environment, "ERROR",
+ "JDBC connection pool " + connectionPool.getName() + " update failed: "
+ + updateException.getMessage() );
+ throw new UpdateException( "JDBC connection ool " + connectionPool.getName() + " update failed",
+ updateException );
+ }
+ else
+ {
+ // connection pool is not update blocker
+ LOGGER.warn( "JDBC connection pool {} update failed", connectionPool.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn",
+ "JDBC connection pool " + connectionPool.getName()
+ + " update failed: "
+ + updateException.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info",
+ "JDBC connection pool " + connectionPool.getName()
+ + " is not update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN",
+ "JDBC connection pool " + connectionPool.getName() + " update failed: "
+ + updateException.getMessage() );
+ EventUtils.post( environment, "UPDATE", "JDBC connection pool " + connectionPool.getName()
+ + " is not update blocker, update continues" );
+ }
+ }
+ }
+
+ // update JDBC data sources
+ LOGGER.info( "Updating JDBC data sources" );
+ for ( Iterator dataSourceIterator = server.getJDBCDataSources().iterator(); dataSourceIterator.hasNext(); )
+ {
+ JDBCDataSource dataSource = (JDBCDataSource) dataSourceIterator.next();
+ try
+ {
+ JDBCDataSourceUpdater.update( environment, server, dataSource, updateLog );
+ }
+ catch ( UpdateException updateException )
+ {
+ // the JDBC data source update has failed
+ if ( dataSource.isBlocker() )
+ {
+ // data source is update blocker
+ LOGGER.error( "JDBC data source {} udpate failed", dataSource.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "JDBC data source " + dataSource.getName()
+ + " update failed: " + updateException.getMessage() ) );
+ EventUtils.post( environment, "ERROR",
+ "JDBC data source " + dataSource.getName() + " update failed: "
+ + updateException.getMessage() );
+ throw new UpdateException( "JDBC data source " + dataSource.getName() + " update failed",
+ updateException );
+ }
+ else
+ {
+ // data source is not update blocker
+ LOGGER.warn( "JDBC data source {} update failed", dataSource.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn", "JDBC data source " + dataSource.getName()
+ + " update failed: " + updateException.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JDBC data source " + dataSource.getName()
+ + " is not update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN",
+ "JDBC data source " + dataSource.getName() + " update failed: "
+ + updateException.getMessage() );
+ EventUtils.post( environment, "UPDATE", "JDBC data source " + dataSource.getName()
+ + " is not update blocker, update continues" );
+ }
+ }
+ }
+
+ // update JMS connection factories
+ LOGGER.info( "Updating JMS connection factories" );
+ for ( Iterator jmsConnectionFactoryIterator = server.getJMSConnectionFactories().iterator();
+ jmsConnectionFactoryIterator.hasNext(); )
+ {
+ JMSConnectionFactory jmsConnectionFactory = (JMSConnectionFactory) jmsConnectionFactoryIterator.next();
+ try
+ {
+ JMSConnectionFactoryUpdater.update( environment, server, jmsConnectionFactory, updateLog );
+ }
+ catch ( UpdateException updateException )
+ {
+ // the JMS connection factory update has failed
+ if ( jmsConnectionFactory.isBlocker() )
+ {
+ // JMS connection factory is update blocker
+ LOGGER.error( "JMS connection factory {} update failed", jmsConnectionFactory.getName(),
+ updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "JMS connection factory "
+ + jmsConnectionFactory.getName() + " update failed: " + updateException.getMessage() ) );
+ EventUtils.post( environment, "ERROR",
+ "JMS connection factory " + jmsConnectionFactory.getName() + " update failed: "
+ + updateException.getMessage() );
+ throw new UpdateException(
+ "JMS connection factory " + jmsConnectionFactory.getName() + " update failed: "
+ + updateException.getMessage(), updateException );
+ }
+ else
+ {
+ // JMS connection factory is not update blocker
+ LOGGER.warn( "JMS connection factory {} update failed", jmsConnectionFactory.getName(),
+ updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn", "JMS connection factory "
+ + jmsConnectionFactory.getName() + " update failed: " + updateException.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JMS connection factory "
+ + jmsConnectionFactory.getName() + " is not update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN",
+ "JMS connection factory " + jmsConnectionFactory.getName() + " update failed: "
+ + updateException.getMessage() );
+ EventUtils.post( environment, "UPDATE", "JMS connection factory " + jmsConnectionFactory.getName()
+ + " is not update blocker, update continues" );
+ }
+ }
+ }
+
+ // update JMS servers
+ LOGGER.info( "Updating JMS servers" );
+ for ( Iterator jmsServerIterator = server.getJMSServers().iterator(); jmsServerIterator.hasNext(); )
+ {
+ JMSServer jmsServer = (JMSServer) jmsServerIterator.next();
+ try
+ {
+ JMSServerUpdater.update( environment, server, jmsServer, updateLog );
+ }
+ catch ( UpdateException updateException )
+ {
+ // the JMS server update has failed
+ if ( jmsServer.isBlocker() )
+ {
+ // JMS server is update blocker
+ LOGGER.error( "JMS server {} update failed", jmsServer.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "JMS server " + jmsServer.getName()
+ + " update failed: " + updateException.getMessage() ) );
+ EventUtils.post( environment, "ERROR", "JMS server " + jmsServer.getName() + " update failed: "
+ + updateException.getMessage() );
+ throw new UpdateException( "JMS server " + jmsServer.getName() + " update failed",
+ updateException );
+ }
+ else
+ {
+ // JMS server is not update blocker
+ LOGGER.warn( "JMS server {} update failed", jmsServer.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn", "JMS server " + jmsServer.getName()
+ + " update failed: " + updateException.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JMS server " + jmsServer.getName()
+ + " is not update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN", "JMS server " + jmsServer.getName() + " update failed: "
+ + updateException.getMessage() );
+ EventUtils.post( environment, "UPDATE",
+ "JMS server " + jmsServer.getName() + " is not update blocker, update continues" );
+ }
+ }
+ }
+
+ // update JNDI name space bindings
+ LOGGER.info( "Updating JNDIbindings" );
+ for ( Iterator jndiBindingsIterator = server.getJNDIBindings().iterator(); jndiBindingsIterator.hasNext(); )
+ {
+ JNDIBinding jndiBinding = (JNDIBinding) jndiBindingsIterator.next();
+ try
+ {
+ JNDIBindingUpdater.update( environment, server, jndiBinding, updateLog );
+ }
+ catch ( UpdateException updateException )
+ {
+ // the JNDI binding update has failed
+ if ( jndiBinding.isBlocker() )
+ {
+ // JNDIbinding is update blocker
+ LOGGER.error( "JNDI binding {} update failed", jndiBinding.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "JNDI binding " + jndiBinding.getName()
+ + " update failed: " + updateException.getMessage() ) );
+ EventUtils.post( environment, "ERROR", "JNDI binding " + jndiBinding.getName() + " update failed: "
+ + updateException.getMessage() );
+ throw new UpdateException( "JNDI binding " + jndiBinding.getName() + " update failed",
+ updateException );
+ }
+ else
+ {
+ // JNDI binding is not update blocker
+ LOGGER.warn( "JNDI binding {} update failed", jndiBinding.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn", "JNDI binding " + jndiBinding.getName()
+ + " update failed: " + updateException.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JNDI binding " + jndiBinding.getName()
+ + " is not update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN", "JNDI binding " + jndiBinding.getName() + " update failed: "
+ + updateException.getMessage() );
+ EventUtils.post( environment, "UPDATE", "JNDI binding " + jndiBinding.getName()
+ + " is not update blocker, update continues" );
+ }
+ }
+ }
+
+ // update shared libraries
+ LOGGER.info( "Updating shared libraries" );
+ for ( Iterator sharedLibraryIterator = server.getSharedLibraries().iterator();
+ sharedLibraryIterator.hasNext(); )
+ {
+ SharedLibrary sharedLibrary = (SharedLibrary) sharedLibraryIterator.next();
+ try
+ {
+ SharedLibraryUpdater.update( environment, server, sharedLibrary, updateLog );
+ }
+ catch ( UpdateException updateException )
+ {
+ // the shared library update has failed
+ if ( sharedLibrary.isBlocker() )
+ {
+ // shared library is update blocker
+ LOGGER.error( "Shared library {} update failed", sharedLibrary.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "Shared library " + sharedLibrary.getName()
+ + " update failed: " + updateException.getMessage() ) );
+ EventUtils.post( environment, "ERROR",
+ "Shared library " + sharedLibrary.getName() + " update failed: "
+ + updateException.getMessage() );
+ throw new UpdateException( "Shared library " + sharedLibrary.getName() + " update failed",
+ updateException );
+ }
+ else
+ {
+ // shared library is not update blocker
+ LOGGER.warn( "Shared library {} update failed", sharedLibrary.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn", "Shared library " + sharedLibrary.getName()
+ + " update failed: " + updateException.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Shared library " + sharedLibrary.getName()
+ + " is not update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN",
+ "Shared library " + sharedLibrary.getName() + " update failed: "
+ + updateException.getMessage() );
+ EventUtils.post( environment, "UPDATE", "Shared library " + sharedLibrary.getName()
+ + " is not update blocker, update continues" );
+ }
+ }
+ }
+
+ // update JEE applications
+ LOGGER.info( "Updating JEE applications" );
+ for ( Iterator applicationIterator = server.getJEEApplications().iterator(); applicationIterator.hasNext(); )
+ {
+ JEEApplication application = (JEEApplication) applicationIterator.next();
+ try
+ {
+ JEEApplicationUpdater.update( environment, server, application, updateLog );
+ }
+ catch ( UpdateException updateException )
+ {
+ // the JEE application update has failed
+ if ( application.isBlocker() )
+ {
+ // JEE application is update blocker
+ LOGGER.error( "JEE application {} update failed", application.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "JEE application " + application.getName()
+ + " update failed: " + updateException.getMessage() ) );
+ EventUtils.post( environment, "ERROR",
+ "JEE application " + application.getName() + " update failed: "
+ + updateException.getMessage() );
+ throw new UpdateException( "JEE application " + application.getName() + " update failed",
+ updateException );
+ }
+ else
+ {
+ // JEE application is not update blocker
+ LOGGER.warn( "JEE application {} update failed", application.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn", "JEE application " + application.getName()
+ + " update failed: " + updateException.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JEE application " + application.getName()
+ + " is not update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN",
+ "JEE application " + application.getName() + " update failed: "
+ + updateException.getMessage() );
+ EventUtils.post( environment, "UPDATE", "JEE application " + application.getName()
+ + " is not update blocker, update continues" );
+ }
+ }
+ }
+
+ // stop JEE server
+ LOGGER.info( "Shutting down JEE application server" );
+ try
+ {
+ JEEApplicationServerUpdater.stop( environment, server, updateLog );
+ }
+ catch ( UpdateException updateException )
+ {
+ // the JEE application server stop has failed
+ if ( server.isBlocker() )
+ {
+ // JEE application server is update blocker
+ LOGGER.error( "JEE application server {} shutdown failed", server.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "JEE application server " + server.getName()
+ + " shutdown failed: " + updateException.getMessage() ) );
+ EventUtils.post( environment, "ERROR",
+ "JEE application server " + server.getName() + " shutdown failed: "
+ + updateException.getMessage() );
+ throw new UpdateException(
+ "JEE application server " + server.getName() + " shutdown failed: " + updateException.getMessage(),
+ updateException );
+ }
+ else
+ {
+ // JEE application server is not update blocker
+ LOGGER.warn( "JEE application server {} shutdown failed", server.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn", "JEE application server " + server.getName()
+ + " shutdown failed: " + updateException.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JEE application server " + server.getName()
+ + " is not update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN",
+ "JEE application server " + server.getName() + " shutdown failed: "
+ + updateException.getMessage() );
+ EventUtils.post( environment, "UPDATE", "JEE application server " + server.getName()
+ + " is not update blocker, update continues" );
+ }
+ }
+
+ // clean the JEE application server cache
+ LOGGER.info( "Clean JEE application server cache directories" );
+ try
+ {
+ JEEApplicationServerUpdater.cleanCaches( environment, server, updateLog );
+ }
+ catch ( UpdateException updateException )
+ {
+ // the JEE application server cache directories cleaning has failed
+ if ( server.isBlocker() )
+ {
+ // JEE application server is update blocker
+ LOGGER.error( "JEE application server {} cache directories cleanup failed", server.getName(),
+ updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "JEE application server " + server.getName()
+ + " cache directories cleanup failed: " + updateException.getMessage() ) );
+ EventUtils.post( environment, "ERROR",
+ "JEE application server " + server.getName() + " cache directories cleanup failed: "
+ + updateException.getMessage() );
+ throw new UpdateException(
+ "JEE application server " + server.getName() + " cache directories cleanup failed",
+ updateException );
+ }
+ else
+ {
+ // JEE application server is not update blocker
+ LOGGER.warn( "JEE application server {} cache directories cleanup failed", server.getName(),
+ updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn", "JEE application server " + server.getName()
+ + " cache directories cleanup failed: " + updateException.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JEE application server " + server.getName()
+ + " is not update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN",
+ "JEE application server " + server.getName() + " cache directories cleanup failed: "
+ + updateException.getMessage() );
+ EventUtils.post( environment, "UPDATE", "JEE application server " + server.getName()
+ + " is not update blocker, update continues" );
+ }
+ }
+
+ // start JEE application server
+ LOGGER.info( "Starting JEE application server" );
+ try
+ {
+ JEEApplicationServerUpdater.start( kalumet, environment, server, updateLog );
+ }
+ catch ( UpdateException updateException )
+ {
+ // the JEE application server start has failed
+ if ( server.isBlocker() )
+ {
+ // JEE application server is update blocker
+ LOGGER.error( "JEE application server {} start failed", server.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "JEE application server " + server.getName()
+ + " start failed: " + updateException.getMessage() ) );
+ EventUtils.post( environment, "ERROR", "JEE application server " + server.getName() + " start failed: "
+ + updateException.getMessage() );
+ throw new UpdateException( "JEE application server " + server.getName() + " start failed",
+ updateException );
+ }
+ else
+ {
+ // JEE application server is not update blocker
+ LOGGER.warn( "JEE application server " + server.getName() + " start failed", updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn", "JEE application server " + server.getName()
+ + " start failed: " + updateException.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JEE application server " + server.getName()
+ + " is not update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN", "JEE application server " + server.getName() + " start failed: "
+ + updateException.getMessage() );
+ EventUtils.post( environment, "UPDATE", "JEE application server " + server.getName()
+ + " is not update blocker, update continues" );
+ }
+ }
+
+ // update completed
+ EventUtils.post( environment, "UPDATE", "JEE application server updated" );
+ }
+
+ /**
+ * Shutdown a JEE server.
+ *
+ * @param environment the target <code>Environment</code>.
+ * @param server the <code>JEEApplicationServer</code> to stop.
+ * @param updateLog the <code>UpdateLog</code> to use.
+ */
+ protected static void stop( Environment environment, JEEApplicationServer server, UpdateLog updateLog )
+ throws UpdateException
+ {
+ // TODO delegate the JEE server stop to another agent is required
+ try
+ {
+ if ( !server.isUpdateRequireRestart() || !updateLog.isUpdated() )
+ {
+ LOGGER.info( "JEE application server {} shutdown is not required", server.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JEE application server " + server.getName()
+ + " shutdown is not required" ) );
+ EventUtils.post( environment, "UPDATE",
+ "JEE application server " + server.getName() + " shutdown is not required" );
+ return;
+ }
+ // the server restart is required
+ LOGGER.info( "JEE application server {} shutdown is required", server.getName() );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "JEE application server " + server.getName() + " shutdown is required" ) );
+ EventUtils.post( environment, "UPDATE",
+ "JEE application server " + server.getName() + " shutdown is required" );
+ if ( server.isUsejmxstop() )
+ {
+ LOGGER.debug( "JEE application server shutdown is performed using JMX controller" );
+ LOGGER.debug( "Getting JEE application server JMX controller" );
+ JEEApplicationServerController controller =
+ JEEApplicationServerControllerFactory.getController( environment, server );
+ controller.shutdown();
+ LOGGER.info( "JEE application server {} shutdown completed", server.getName() );
+ EventUtils.post( environment, "UPDATE", "JEE server " + server.getName() + " shutdown completed" );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "JEE server " + server.getName() + " shutdown completed" ) );
+ return;
+ }
+ LOGGER.debug( "JEE application server shutdown is performed using system command" );
+ String output = CommandUtils.execute(
+ VariableUtils.replace( server.getShutdowncommand(), environment.getVariables() ) );
+ LOGGER.info( "JEE application server " + server.getName() + " shutdown completed: " + output );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JEE application server " + server.getName()
+ + " shutdown completed: " + output ) );
+ EventUtils.post( environment, "UPDATE",
+ "JEE server " + server.getName() + " shutdown completed: " + output );
+ }
+ catch ( Exception exception )
+ {
+ LOGGER.error( "JEE application server " + server.getName() + " shutdown failed", exception );
+ updateLog.addUpdateMessage( new UpdateMessage( "error",
+ "JEE server " + server.getName() + " shutdown failed: "
+ + exception.getMessage() ) );
+ EventUtils.post( environment, "ERROR", "JEE application server " + server.getName() + " shutdown failed: "
+ + exception.getMessage() );
+ throw new UpdateException( "JEE application server " + server.getName() + " shutdown failed", exception );
+ }
+ }
+
+ /**
+ * Start a JEE application server.
+ *
+ * @param kalumet the configuration.
+ * @param environment the target <code>Environment</code>.
+ * @param server the <code>JEEApplicationServer</code> to start.
+ * @param updateLog the <code>UpdateLog</code> to use.
+ */
+ protected static void start( Kalumet kalumet, Environment environment, JEEApplicationServer server,
+ UpdateLog updateLog )
+ throws UpdateException
+ {
+ // TODO delegate the JEE server start to another agent is required
+ try
+ {
+ if ( !server.isUpdateRequireRestart() || !updateLog.isUpdated() )
+ {
+ LOGGER.info( "JEE application server {} start is not required", server.getName() );
+ EventUtils.post( environment, "UPDATE",
+ "JEE application server " + server.getName() + " start is not required" );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "JEE application server " + server.getName() + " start is required" ) );
+ return;
+ }
+
+ LOGGER.info( "JEE application server {} start is required", server.getName() );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "JEE application server " + server.getName() + " start is required" ) );
+ EventUtils.post( environment, "UPDATE",
+ "JEE application server " + server.getName() + " start is required" );
+
+ // get the agent configuration
+ Agent agent = kalumet.getAgent( Configuration.AGENT_ID );
+
+ // check the agent max environment active
+ if ( agent.getMaxjeeapplicationserversstarted() > 0 )
+ {
+ // get the environments managed by the agent
+ List agentEnvironments = kalumet.getEnvironmentsByAgent( Configuration.AGENT_ID );
+ int applicationServersStarted = 0;
+ for ( Iterator agentEnvironmentsIterator = agentEnvironments.iterator();
+ agentEnvironmentsIterator.hasNext(); )
+ {
+ Environment agentEnvironment = (Environment) agentEnvironmentsIterator.next();
+ // check if the application server started into the environment
+ for ( Iterator agentEnvironmentApplicationServersIterator =
+ agentEnvironment.getJEEApplicationServers().getJEEApplicationServers().iterator();
+ agentEnvironmentApplicationServersIterator.hasNext(); )
+ {
+ JEEApplicationServer agentEnvironmentApplicationServer =
+ (JEEApplicationServer) agentEnvironmentApplicationServersIterator.next();
+ // get the controller
+ JEEApplicationServerController controller =
+ JEEApplicationServerControllerFactory.getController( environment, server );
+ if ( !controller.isStopped() )
+ {
+ applicationServersStarted++;
+ if ( applicationServersStarted >= agent.getMaxjeeapplicationserversstarted() )
+ {
+ // the max number of application servers started is raised
+ throw new UpdateException(
+ "The maximum number of started JEE application servers has been raised for the agent" );
+ }
+ }
+ }
+ }
+ }
+
+ // the start is performed using system command
+ String output =
+ CommandUtils.execute( VariableUtils.replace( server.getStartupcommand(), environment.getVariables() ) );
+ // application server start has been performed
+ LOGGER.info( "JEE application server {} start completed: {}", server.getName(), output );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JEE application server " + server.getName()
+ + " start completed: " + output ) );
+ EventUtils.post( environment, "UPDATE",
+ "JEE application server " + server.getName() + " start completed: " + output );
+ }
+ catch ( Exception exception )
+ {
+ LOGGER.error( "JEE application server {} start failed", server.getName(), exception );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "JEE application server " + server.getName()
+ + " start failed: " + exception.getMessage() ) );
+ EventUtils.post( environment, "ERROR", "JEE application server " + server.getName() + " start failed: "
+ + exception.getMessage() );
+ throw new UpdateException( "JEE application server " + server.getName() + " start failed", exception );
+ }
+ }
+
+ /**
+ * Cleanup JEE application server caches.
+ *
+ * @param environment the <code>Environment</code>.
+ * @param server the target <code>JEEApplicationServer</code>.
+ * @param updateLog the <code>UpdateLog</code> to use.
+ */
+ protected static void cleanCaches( Environment environment, JEEApplicationServer server, UpdateLog updateLog )
+ throws UpdateException
+ {
+ try
+ {
+ if ( !server.isUpdateRequireCacheCleaning() || !updateLog.isUpdated() )
+ {
+ LOGGER.info( "JEE application server {} caches cleaning is not required", server.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JEE application server " + server.getName()
+ + " caches cleaning is not required" ) );
+ EventUtils.post( environment, "UPDATE",
+ "JEE application server " + server.getName() + " caches cleaning is not required" );
+ return;
+ }
+ // the application server caches cleaning is required
+ LOGGER.info( "JEE application server {} caches cleaning is required", server.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JEE application server " + server.getName()
+ + " caches cleaning is required" ) );
+ EventUtils.post( environment, "UPDATE",
+ "JEE application server " + server.getName() + " caches cleaning is required" );
+ // initializes the file manipulator instance
+ FileManipulator fileManipulator = new FileManipulator();
+ for ( Iterator cacheIterator = server.getCaches().iterator(); cacheIterator.hasNext(); )
+ {
+ Cache cache = (Cache) cacheIterator.next();
+ String path = VariableUtils.replace( cache.getPath(), environment.getVariables() );
+ fileManipulator.delete( path );
+ }
+ }
+ catch ( Exception exception )
+ {
+ LOGGER.error( "JEE application server {} cache directories cleanup failed", server.getName(), exception );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "JEE application server" + server.getName()
+ + " cache directories cleanup failed: " + exception.getMessage() ) );
+ EventUtils.post( environment, "ERROR",
+ "JEE application server " + server.getName() + " cache directories cleanup failed: "
+ + exception.getMessage() );
+ throw new UpdateException( "JEE application server " + server.getName() + " caches cleanup failed",
+ exception );
+ }
+ }
+
+ /**
+ * Wrapper method to start JEE application server (via WS).
+ *
+ * @param environmentName the target environment name.
+ * @param serverName the target JEE application server name.
+ */
+ public static void start( String environmentName, String serverName )
+ throws KalumetException
+ {
+ LOGGER.info( "JEE application server {} start requested by WS", serverName );
+
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new UpdateException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer server = environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
+ if ( server == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environmentName );
+ throw new UpdateException(
+ "JEE application server " + serverName + " is not found in environment " + environmentName );
+ }
+
+ // get the agent configuration
+ Agent agent = kalumet.getAgent( Configuration.AGENT_ID );
+
+ // check the agent max environment active
+ if ( agent.getMaxjeeapplicationserversstarted() > 0 )
+ {
+ // get the environments managed by the agent
+ List agentEnvironments = kalumet.getEnvironmentsByAgent( Configuration.AGENT_ID );
+ int applicationServersStarted = 0;
+ for ( Iterator agentEnvironmentsIterator = agentEnvironments.iterator();
+ agentEnvironmentsIterator.hasNext(); )
+ {
+ Environment agentEnvironment = (Environment) agentEnvironmentsIterator.next();
+ // check if the application server started into the environment
+ for ( Iterator agentEnvironmentApplicationServersIterator =
+ agentEnvironment.getJEEApplicationServers().getJEEApplicationServers().iterator();
+ agentEnvironmentApplicationServersIterator.hasNext(); )
+ {
+ JEEApplicationServer agentEnvironmentApplicationServer =
+ (JEEApplicationServer) agentEnvironmentApplicationServersIterator.next();
+ // get the controller
+ JEEApplicationServerController controller =
+ JEEApplicationServerControllerFactory.getController( environment, server );
+ if ( !controller.isStopped() )
+ {
+ applicationServersStarted++;
+ if ( applicationServersStarted >= agent.getMaxjeeapplicationserversstarted() )
+ {
+ // the max number of application servers started is raised
+ throw new KalumetException(
+ "The maximum number of started JEE application servers has been raised for the agent" );
+ }
+ }
+ }
+ }
+ }
+
+ EventUtils.post( environment, "INFO", "JEE application server " + serverName + " start requested by WS" );
+ // the start is performed using system command
+ String output =
+ CommandUtils.execute( VariableUtils.replace( server.getStartupcommand(), environment.getVariables() ) );
+ // application server start has been performed
+ LOGGER.info( "JEE application server {} STARTED: {}", serverName, output );
+ EventUtils.post( environment, "INFO", "JEE application server " + serverName + " started: " + output );
+ }
+
+ /**
+ * Wrapper method to stop JEE application server (via WS).
+ *
+ * @param environmentName the environment name.
+ * @param serverName the JEE application server name.
+ */
+ public static void stop( String environmentName, String serverName )
+ throws UpdateException
+ {
+ LOGGER.info( "JEE application server {} shutdown requested by WS", serverName );
+ Kalumet kalumet;
+ try
+ {
+ kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ }
+ catch ( KalumetException e )
+ {
+ LOGGER.error( "Can't load configuration", e );
+ throw new UpdateException( "Can't load configuration", e );
+ }
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new UpdateException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer server = environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
+ if ( server == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environmentName );
+ throw new UpdateException(
+ "JEE application server " + serverName + " is not found in environment " + environmentName );
+ }
+ EventUtils.post( environment, "INFO", "JEE application server " + serverName + " shutdown requested by WS" );
+ // check if the stop is made using JMX
+ try
+ {
+ if ( server.isUsejmxstop() )
+ {
+ JEEApplicationServerController controller =
+ JEEApplicationServerControllerFactory.getController( environment, server );
+ controller.shutdown();
+ LOGGER.info( "JEE application server {} shutdown using the controller", serverName );
+ EventUtils.post( environment, "INFO",
+ "JEE application server " + serverName + " shutdown using the controller" );
+ return;
+ }
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "JEE application server {} shutdown failed", serverName, e );
+ throw new UpdateException( "JEE application server " + serverName + " shutdown failed", e );
+ }
+ // no JMX stop, use system command call
+ String shutdownCommand = VariableUtils.replace( server.getShutdowncommand(), environment.getVariables() );
+ String output = null;
+ try
+ {
+ output = CommandUtils.execute( shutdownCommand );
+ }
+ catch ( KalumetException e )
+ {
+ LOGGER.error( "JEE application server {} shutdown FAILED.", serverName, e );
+ throw new UpdateException( "JEE application server " + serverName + " shutdown failed", e );
+ }
+ LOGGER.info( "JEE application server {} shutdown using system command: {}", serverName, output );
+ EventUtils.post( environment, "INFO",
+ "JEE application server " + serverName + " shutdown using system command: " + output );
+ }
+
+ /**
+ * Wrapper method to get JEE application server status (via WS).
+ *
+ * @param environmentName the environment name.
+ * @param applicationServerName the JEE application server name.
+ * @return the JEE application server current status.
+ */
+ public static String status( String environmentName, String applicationServerName )
+ throws UpdateException
+ {
+ // TODO delegate the JEE server status to another agent if required
+ LOGGER.info( "JEE application server {} status check requested by WS", applicationServerName );
+
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet;
+ try
+ {
+ kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ }
+ catch ( KalumetException e )
+ {
+ LOGGER.error( "Can't load configuration", e );
+ throw new UpdateException( "Can't load configuration", e );
+ }
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new UpdateException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer server =
+ environment.getJEEApplicationServers().getJEEApplicationServer( applicationServerName );
+ if ( server == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", applicationServerName,
+ environmentName );
+ throw new UpdateException(
+ "JEE application server " + applicationServerName + " is not found in environment " + environmentName );
+ }
+ EventUtils.post( environment, "INFO",
+ "JEE application server " + applicationServerName + " status requested by WS" );
+ try
+ {
// get the controller
JEEApplicationServerController controller =
- JEEApplicationServerControllerFactory.getController(environment, server);
- if ( !controller.isStopped() )
- {
- applicationServersStarted++;
- if ( applicationServersStarted >= agent.getMaxjeeapplicationserversstarted() )
- {
- // the max number of application servers started is raised
- throw new UpdateException(
- "The maximum number of started JEE application servers has been raised for the agent" );
- }
- }
- }
+ JEEApplicationServerControllerFactory.getController( environment, server );
+ // get the application server status
+ return controller.status();
}
- }
-
- // the start is performed using system command
- String output =
- CommandUtils.execute( VariableUtils.replace( server.getStartupcommand(), environment.getVariables() ) );
- // application server start has been performed
- LOGGER.info( "JEE application server {} start completed: {}", server.getName(), output );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JEE application server " + server.getName() + " start completed: " + output ) );
- EventUtils.post( environment, "UPDATE",
- "JEE application server " + server.getName() + " start completed: " + output );
- }
- catch ( Exception exception )
- {
- LOGGER.error( "JEE application server {} start failed", server.getName(), exception );
- updateLog.addUpdateMessage( new UpdateMessage( "error",
- "JEE application server " + server.getName() + " start failed: "
- + exception.getMessage() ) );
- EventUtils.post( environment, "ERROR",
- "JEE application server " + server.getName() + " start failed: " + exception.getMessage() );
- throw new UpdateException( "JEE application server " + server.getName() + " start failed", exception );
- }
- }
-
- /**
- * Cleanup JEE application server caches.
- *
- * @param environment the <code>Environment</code>.
- * @param server the target <code>JEEApplicationServer</code>.
- * @param updateLog the <code>UpdateLog</code> to use.
- */
- protected static void cleanCaches( Environment environment, JEEApplicationServer server, UpdateLog updateLog )
- throws UpdateException
- {
- try
- {
- if ( !server.isUpdateRequireCacheCleaning() || !updateLog.isUpdated() )
- {
- LOGGER.info( "JEE application server {} caches cleaning is not required", server.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "JEE application server " + server.getName()
- + " caches cleaning is not required" ) );
- EventUtils.post( environment, "UPDATE",
- "JEE application server " + server.getName() + " caches cleaning is not required" );
- return;
- }
- // the application server caches cleaning is required
- LOGGER.info( "JEE application server {} caches cleaning is required", server.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JEE application server " + server.getName() + " caches cleaning is required" ) );
- EventUtils.post( environment, "UPDATE",
- "JEE application server " + server.getName() + " caches cleaning is required" );
- // initializes the file manipulator instance
- FileManipulator fileManipulator = new FileManipulator();
- for ( Iterator cacheIterator = server.getCaches().iterator(); cacheIterator.hasNext(); )
- {
- Cache cache = (Cache) cacheIterator.next();
- String path = VariableUtils.replace( cache.getPath(), environment.getVariables() );
- fileManipulator.delete( path );
- }
- }
- catch ( Exception exception )
- {
- LOGGER.error( "JEE application server {} cache directories cleanup failed", server.getName(), exception );
- updateLog.addUpdateMessage( new UpdateMessage( "error", "JEE application server" + server.getName()
- + " cache directories cleanup failed: " + exception.getMessage() ) );
- EventUtils.post( environment, "ERROR",
- "JEE application server " + server.getName() + " cache directories cleanup failed: "
- + exception.getMessage() );
- throw new UpdateException( "JEE application server " + server.getName() + " caches cleanup failed", exception );
- }
- }
-
- /**
- * Wrapper method to start JEE application server (via WS).
- *
- * @param environmentName the target environment name.
- * @param serverName the target JEE application server name.
- */
- public static void start( String environmentName, String serverName )
- throws KalumetException
- {
- LOGGER.info( "JEE application server {} start requested by WS", serverName );
-
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new UpdateException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer server = environment.getJEEApplicationServers().getJEEApplicationServer(serverName);
- if ( server == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environmentName );
- throw new UpdateException(
- "JEE application server " + serverName + " is not found in environment " + environmentName );
- }
-
- // get the agent configuration
- Agent agent = kalumet.getAgent( Configuration.AGENT_ID );
-
- // check the agent max environment active
- if ( agent.getMaxjeeapplicationserversstarted() > 0 )
- {
- // get the environments managed by the agent
- List agentEnvironments = kalumet.getEnvironmentsByAgent( Configuration.AGENT_ID );
- int applicationServersStarted = 0;
- for ( Iterator agentEnvironmentsIterator = agentEnvironments.iterator(); agentEnvironmentsIterator.hasNext(); )
- {
- Environment agentEnvironment = (Environment) agentEnvironmentsIterator.next();
- // check if the application server started into the environment
- for ( Iterator agentEnvironmentApplicationServersIterator =
- agentEnvironment.getJEEApplicationServers().getJEEApplicationServers().iterator();
- agentEnvironmentApplicationServersIterator.hasNext(); )
+ catch ( Exception e )
{
- JEEApplicationServer agentEnvironmentApplicationServer =
- (JEEApplicationServer) agentEnvironmentApplicationServersIterator.next();
- // get the controller
- JEEApplicationServerController controller =
- JEEApplicationServerControllerFactory.getController(environment, server);
- if ( !controller.isStopped() )
- {
- applicationServersStarted++;
- if ( applicationServersStarted >= agent.getMaxjeeapplicationserversstarted() )
- {
- // the max number of application servers started is raised
- throw new KalumetException(
- "The maximum number of started JEE application servers has been raised for the agent" );
- }
- }
+ LOGGER.error( "JEE application server {} status check failed", applicationServerName, e );
+ throw new UpdateException( "JEE application server " + applicationServerName + " status check failed", e );
}
- }
}
- EventUtils.post( environment, "INFO", "JEE application server " + serverName + " start requested by WS" );
- // the start is performed using system command
- String output =
- CommandUtils.execute( VariableUtils.replace( server.getStartupcommand(), environment.getVariables() ) );
- // application server start has been performed
- LOGGER.info( "JEE application server {} STARTED: {}", serverName, output );
- EventUtils.post( environment, "INFO", "JEE application server " + serverName + " started: " + output );
- }
-
- /**
- * Wrapper method to stop JEE application server (via WS).
- *
- * @param environmentName the environment name.
- * @param serverName the JEE application server name.
- */
- public static void stop( String environmentName, String serverName )
- throws UpdateException
- {
- LOGGER.info( "JEE application server {} shutdown requested by WS", serverName );
- Kalumet kalumet;
- try
- {
- kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- }
- catch ( KalumetException e )
- {
- LOGGER.error( "Can't load configuration", e );
- throw new UpdateException( "Can't load configuration", e );
- }
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new UpdateException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer server = environment.getJEEApplicationServers().getJEEApplicationServer(serverName);
- if ( server == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environmentName );
- throw new UpdateException(
- "JEE application server " + serverName + " is not found in environment " + environmentName );
- }
- EventUtils.post( environment, "INFO", "JEE application server " + serverName + " shutdown requested by WS" );
- // check if the stop is made using JMX
- try
- {
- if ( server.isUsejmxstop() )
- {
- JEEApplicationServerController controller =
- JEEApplicationServerControllerFactory.getController(environment, server);
- controller.shutdown();
- LOGGER.info( "JEE application server {} shutdown using the controller", serverName );
- EventUtils.post( environment, "INFO",
- "JEE application server " + serverName + " shutdown using the controller" );
- return;
- }
- }
- catch ( Exception e )
- {
- LOGGER.error( "JEE application server {} shutdown failed", serverName, e );
- throw new UpdateException( "JEE application server " + serverName + " shutdown failed", e );
- }
- // no JMX stop, use system command call
- String shutdownCommand = VariableUtils.replace( server.getShutdowncommand(), environment.getVariables() );
- String output = null;
- try
- {
- output = CommandUtils.execute( shutdownCommand );
- }
- catch ( KalumetException e )
- {
- LOGGER.error( "JEE application server {} shutdown FAILED.", serverName, e );
- throw new UpdateException( "JEE application server " + serverName + " shutdown failed", e );
- }
- LOGGER.info( "JEE application server {} shutdown using system command: {}", serverName, output );
- EventUtils.post( environment, "INFO",
- "JEE application server " + serverName + " shutdown using system command: " + output );
- }
-
- /**
- * Wrapper method to get JEE application server status (via WS).
- *
- * @param environmentName the environment name.
- * @param applicationServerName the JEE application server name.
- * @return the JEE application server current status.
- */
- public static String status( String environmentName, String applicationServerName )
- throws UpdateException
- {
- // TODO delegate the JEE server status to another agent if required
- LOGGER.info( "JEE application server {} status check requested by WS", applicationServerName );
-
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet;
- try
- {
- kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- }
- catch ( KalumetException e )
- {
- LOGGER.error( "Can't load configuration", e );
- throw new UpdateException( "Can't load configuration", e );
- }
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new UpdateException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer server =
- environment.getJEEApplicationServers().getJEEApplicationServer(applicationServerName);
- if ( server == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", applicationServerName,
- environmentName );
- throw new UpdateException(
- "JEE application server " + applicationServerName + " is not found in environment " + environmentName );
- }
- EventUtils.post( environment, "INFO",
- "JEE application server " + applicationServerName + " status requested by WS" );
- try
- {
- // get the controller
- JEEApplicationServerController controller =
- JEEApplicationServerControllerFactory.getController(environment, server);
- // get the application server status
- return controller.status();
- }
- catch ( Exception e )
- {
- LOGGER.error( "JEE application server {} status check failed", applicationServerName, e );
- throw new UpdateException( "JEE application server " + applicationServerName + " status check failed", e );
- }
- }
-
}
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JEEApplicationUpdater.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JEEApplicationUpdater.java
index 3577d56..66dd727 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JEEApplicationUpdater.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JEEApplicationUpdater.java
@@ -50,341 +50,362 @@
public class JEEApplicationUpdater
{
- private static final transient Logger LOGGER = LoggerFactory.getLogger( JEEApplicationUpdater.class );
+ private static final transient Logger LOGGER = LoggerFactory.getLogger( JEEApplicationUpdater.class );
- /**
- * Update a JEE application.
- *
- * @param environment the target <code>Environment</code>.
- * @param server the target <code>JEEApplicationServer</code>.
- * @param application the target <code>JEEApplication</code>.
- * @param updateLog the <code>UpdateLog</code> to use.
- * @throws UpdateException if the update failed.
- */
- public static void update( Environment environment, JEEApplicationServer server, JEEApplication application,
- UpdateLog updateLog )
- throws UpdateException
- {
- LOGGER.info( "Updating JEE application {}", application.getName() );
-
- String applicationUri = VariableUtils.replace( application.getUri(), environment.getVariables() );
-
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Updating JEE application " + application.getName() ) );
- updateLog.addUpdateMessage(
- new UpdateMessage( "summary", "JEE application " + application.getName() + " located " + applicationUri ) );
- EventUtils.post( environment, "UPDATE", "Updating JEE application " + application.getName() );
-
- if ( !application.isActive() )
+ /**
+ * Update a JEE application.
+ *
+ * @param environment the target <code>Environment</code>.
+ * @param server the target <code>JEEApplicationServer</code>.
+ * @param application the target <code>JEEApplication</code>.
+ * @param updateLog the <code>UpdateLog</code> to use.
+ * @throws UpdateException if the update failed.
+ */
+ public static void update( Environment environment, JEEApplicationServer server, JEEApplication application,
+ UpdateLog updateLog )
+ throws UpdateException
{
- // the application is inactive, not updated
- LOGGER.info( "JEE application {} is inactive, so not updated", application.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JEE application " + application.getName() + " is inactive, not updated" ) );
- EventUtils.post( environment, "UPDATE",
- "JEE application " + application.getName() + " is inactive, not updated" );
- return;
- }
+ LOGGER.info( "Updating JEE application {}", application.getName() );
- if ( application.getAgent() != null && application.getAgent().trim().length() > 0 && !application.getAgent().equals(
- Configuration.AGENT_ID ) )
- {
- // delegates the application update to another agent
- LOGGER.info( "Delegating JEE application {} update to agent {}", application.getName(), application.getAgent() );
- Agent delegationAgent = Configuration.CONFIG_CACHE.getAgent( application.getAgent() );
- EventUtils.post( environment, "UPDATE",
- "Delegating JEE application " + application.getName() + " update to agent "
- + application.getAgent() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Delegating JEE application " + application.getName()
- + " update to agent " + application.getAgent() ) );
- if ( delegationAgent == null )
- {
- LOGGER.error( "Agent " + application.getAgent() + " is not found in the configuration" );
- throw new UpdateException( "Agent " + application.getAgent() + " is not found in the configuration" );
- }
- try
- {
- LOGGER.debug( "Call JEE application WS" );
- JEEApplicationClient webServiceClient =
- new JEEApplicationClient( delegationAgent.getHostname(), delegationAgent.getPort() );
- webServiceClient.update( environment.getName(), server.getName(), application.getName(), true );
- }
- catch ( ClientException clientException )
- {
- LOGGER.error( "JEE application {} update failed", application.getName(), clientException );
- throw new UpdateException( "JEE application " + application.getName() + " update failed", clientException );
- }
- return;
- }
+ String applicationUri = VariableUtils.replace( application.getUri(), environment.getVariables() );
- try
- {
- // create the application directory in the environment working directory
- // (if needed)
- LOGGER.debug( "Creating the JEE application directory" );
- String applicationCacheDir = FileManipulator.createJEEApplicationCacheDir( environment, application );
- }
- catch ( FileManipulatorException e )
- {
- LOGGER.error( "Can't create JEE application cache directory", e );
- throw new UpdateException( "Can't create JEE application cache directory", e );
- }
-
- // update configuration files
- LOGGER.info( "Updating JEE application configuration files" );
- for ( Iterator configurationFileIterator = application.getConfigurationFiles().iterator();
- configurationFileIterator.hasNext(); )
- {
- ConfigurationFile configurationFile = (ConfigurationFile) configurationFileIterator.next();
- try
- {
- ConfigurationFileUpdater.update( environment, server, application, configurationFile, updateLog );
- }
- catch ( UpdateException updateException )
- {
- // the configuration file update has failed
- if ( configurationFile.isBlocker() )
- {
- // the configuration file is update blocker
- LOGGER.error( "Configuration file {} update failed", configurationFile.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "error", "Configuration file " + configurationFile.getName()
- + " update failed: " + updateException.getMessage() ) );
- EventUtils.post( environment, "ERROR",
- "Configuration file " + configurationFile.getName() + " update failed: "
- + updateException.getMessage() );
- throw new UpdateException( "Configuration file " + configurationFile.getName() + " update failed",
- updateException );
- }
- else
- {
- // the configuration file is not update blocker
- LOGGER.warn( "Configuration file {} update failed", configurationFile.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "warn", "Configuration file " + configurationFile.getName()
- + " update failed: " + updateException.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Configuration file " + configurationFile.getName()
- + " is not update blocker, update continues" ) );
- EventUtils.post( environment, "WARN", "Configuration file " + configurationFile.getName() + " update failed: "
- + updateException.getMessage() );
- EventUtils.post( environment, "UPDATE", "Configuration file " + configurationFile.getName()
- + " is not update blocker, update continues" );
- }
- }
- }
-
- // update database
- LOGGER.info( "Updating JEE application databases" );
- for ( Iterator databaseIterator = application.getDatabases().iterator(); databaseIterator.hasNext(); )
- {
- Database database = (Database) databaseIterator.next();
- try
- {
- DatabaseUpdater.update( environment, server, application, database, updateLog );
- }
- catch ( UpdateException updateException )
- {
- // the database update has failed
- if ( database.isBlocker() )
- {
- // the database is update blocker
- LOGGER.error( "Database {} update failed", database.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "error", "Database " + database.getName() + " update failed: "
- + updateException.getMessage() ) );
- EventUtils.post( environment, "ERROR",
- "Database " + database.getName() + " update failed: " + updateException.getMessage() );
- throw new UpdateException( "Database " + database.getName() + " update failed", updateException );
- }
- else
- {
- // the database is not update blocker
- LOGGER.warn( "Database {} update failed", database.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "warn", "Database " + database.getName() + " update failed: "
- + updateException.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Database " + database.getName()
- + " is not update blocker, update continues" ) );
- EventUtils.post( environment, "WARN",
- "Database " + database.getName() + " update failed: " + updateException.getMessage() );
- EventUtils.post( environment, "UPDATE",
- "Database " + database.getName() + " is not update blocker, update continues" );
- }
- }
- }
-
- // update content managers
- LOGGER.info( "Updating JEE application content managers" );
- for ( Iterator contentManagerIterator = application.getContentManagers().iterator();
- contentManagerIterator.hasNext(); )
- {
- ContentManager contentManager = (ContentManager) contentManagerIterator.next();
- try
- {
- ContentManagerUpdater.update( environment, server, application, contentManager, updateLog );
- }
- catch ( UpdateException updateException )
- {
- // the content manager update has failed
- if ( contentManager.isBlocker() )
- {
- // the content manager is update blocker
- LOGGER.error( "Content manager {} update failed", contentManager.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "error", "Content manager " + contentManager.getName()
- + " update failed: " + updateException.getMessage() ) );
- EventUtils.post( environment, "ERROR", "Content manager " + contentManager.getName() + " update failed: "
- + updateException.getMessage() );
- throw new UpdateException( "Content manager " + contentManager.getName() + " update failed",
- updateException );
- }
- else
- {
- // the content manager is not update blocker
- LOGGER.warn( "Content manager {} update failed", contentManager.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "warn", "Content manager " + contentManager.getName()
- + " update failed: " + updateException.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Content manager " + contentManager.getName()
- + " is not update blocker, update continues" ) );
- EventUtils.post( environment, "WARN", "Content manager " + contentManager.getName() + " update failed: "
- + updateException.getMessage() );
- EventUtils.post( environment, "UPDATE",
- "Content manager " + contentManager.getName() + " is not update blocker, update continues" );
- }
- }
- }
-
- // update archives
- LOGGER.info( "Updating JEE application archives" );
- for ( Iterator archiveIterator = application.getArchives().iterator(); archiveIterator.hasNext(); )
- {
- Archive archive = (Archive) archiveIterator.next();
- try
- {
- ArchiveUpdater.update( environment, server, application, archive, updateLog );
- }
- catch ( UpdateException updateException )
- {
- // the archive update has failed
- if ( archive.isBlocker() )
- {
- // the archive is update blocker
- LOGGER.error( "Archive {} update failed", archive.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "error", "Archive " + archive.getName() + " update failed: "
- + updateException.getMessage() ) );
- EventUtils.post( environment, "ERROR",
- "Archive " + archive.getName() + " update failed: " + updateException.getMessage() );
- throw new UpdateException( "Archive " + archive.getName() + " update failed", updateException );
- }
- else
- {
- // the archive is not update blocker
- LOGGER.warn( "Archive {} update failed", archive.getName(), updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "warn", "Archive " + archive.getName() + " update failed: "
- + updateException.getMessage() ) );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Archive " + archive.getName() + " is not update blocker, update continues" ) );
- EventUtils.post( environment, "WARN",
- "Archive " + archive.getName() + " update failed: " + updateException.getMessage() );
- EventUtils.post( environment, "UPDATE",
- "Archive " + archive.getName() + " is not update blocker, update continues" );
- }
- }
- }
-
- // JEE application update is completed
- LOGGER.info( "JEE application {} updated", application.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "JEE application " + application.getName() + " updated" ) );
- EventUtils.post( environment, "UPDATE", "JEE application " + application.getName() + " updated" );
- }
-
- /**
- * Wrapper method to update a JEE application (via WS).
- *
- * @param environmentName the target environment name.
- * @param serverName the target JEE application server name.
- * @param applicationName the target JEE application name.
- * @param delegation flag indicating if the update is a delegation from another agent (true), or a client call (false).
- * @throws KalumetException in case of update error.
- */
- public static void update( String environmentName, String serverName, String applicationName, boolean delegation )
- throws KalumetException
- {
- LOGGER.info( "JEE application {} update requested by WS", applicationName );
-
- LOGGER.debug( "Loading the configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "The environment {} is not found in the the configuration", environmentName );
- throw new KalumetException( "The environment " + environmentName + " is not found in the the configuration" );
- }
- JEEApplicationServer applicationServer =
- environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
- if ( applicationServer == null )
- {
- LOGGER.error( "The JEE application server {} is not found in the environment {}", serverName, environmentName );
- throw new KalumetException(
- "The JEE application server " + serverName + " is not found in the environment " + environmentName );
- }
- JEEApplication application = applicationServer.getJEEApplication( applicationName );
- if ( application == null )
- {
- LOGGER.error( "The JEE application {} is not found in the JEE application server {}", applicationName,
- serverName );
- throw new KalumetException(
- "The JEE application " + applicationName + " is not found in the JEE application server " + serverName );
- }
-
- // update the agent cache
- LOGGER.debug( "Updating configuration cache" );
- Configuration.CONFIG_CACHE = kalumet;
-
- EventUtils.post( environment, "UPDATE", "JEE application {} update requested by WS", applicationName );
- UpdateLog updateLog =
- new UpdateLog( "JEE application " + applicationName + " update in progress ...", environment.getName(),
- environment );
-
- if ( !delegation )
- {
- // it's a client call
- LOGGER.info( "Send a notification and waiting for the count down" );
- EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
- NotifierUtils.waitAndNotify( environment );
- }
- try
- {
- LOGGER.debug( "Call JEE application updater" );
- JEEApplicationUpdater.update(environment, applicationServer, application, updateLog);
- }
- catch ( Exception e )
- {
- LOGGER.error( "JEE application {} update failed", applicationName, e );
- EventUtils.post( environment, "ERROR",
- "JEE application " + applicationName + " udpate failed: " + e.getMessage() );
- if ( !delegation )
- {
- updateLog.setStatus( "JEE application " + applicationName + " update failed" );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Updating JEE application " + application.getName() ) );
updateLog.addUpdateMessage(
- new UpdateMessage( "error", "JEE application " + applicationName + " update failed: " + e.getMessage() ) );
- PublisherUtils.publish( environment );
- }
- throw new UpdateException( "JEE application " + applicationName + " update failed", e );
+ new UpdateMessage( "summary", "JEE application " + application.getName() + " located " + applicationUri ) );
+ EventUtils.post( environment, "UPDATE", "Updating JEE application " + application.getName() );
+
+ if ( !application.isActive() )
+ {
+ // the application is inactive, not updated
+ LOGGER.info( "JEE application {} is inactive, so not updated", application.getName() );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "JEE application " + application.getName() + " is inactive, not updated" ) );
+ EventUtils.post( environment, "UPDATE",
+ "JEE application " + application.getName() + " is inactive, not updated" );
+ return;
+ }
+
+ if ( application.getAgent() != null && application.getAgent().trim().length() > 0
+ && !application.getAgent().equals( Configuration.AGENT_ID ) )
+ {
+ // delegates the application update to another agent
+ LOGGER.info( "Delegating JEE application {} update to agent {}", application.getName(),
+ application.getAgent() );
+ Agent delegationAgent = Configuration.CONFIG_CACHE.getAgent( application.getAgent() );
+ EventUtils.post( environment, "UPDATE",
+ "Delegating JEE application " + application.getName() + " update to agent "
+ + application.getAgent() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Delegating JEE application " + application.getName()
+ + " update to agent " + application.getAgent() ) );
+ if ( delegationAgent == null )
+ {
+ LOGGER.error( "Agent " + application.getAgent() + " is not found in the configuration" );
+ throw new UpdateException( "Agent " + application.getAgent() + " is not found in the configuration" );
+ }
+ try
+ {
+ LOGGER.debug( "Call JEE application WS" );
+ JEEApplicationClient webServiceClient =
+ new JEEApplicationClient( delegationAgent.getHostname(), delegationAgent.getPort() );
+ webServiceClient.update( environment.getName(), server.getName(), application.getName(), true );
+ }
+ catch ( ClientException clientException )
+ {
+ LOGGER.error( "JEE application {} update failed", application.getName(), clientException );
+ throw new UpdateException( "JEE application " + application.getName() + " update failed",
+ clientException );
+ }
+ return;
+ }
+
+ try
+ {
+ // create the application directory in the environment working directory
+ // (if needed)
+ LOGGER.debug( "Creating the JEE application directory" );
+ String applicationCacheDir = FileManipulator.createJEEApplicationCacheDir( environment, application );
+ }
+ catch ( FileManipulatorException e )
+ {
+ LOGGER.error( "Can't create JEE application cache directory", e );
+ throw new UpdateException( "Can't create JEE application cache directory", e );
+ }
+
+ // update configuration files
+ LOGGER.info( "Updating JEE application configuration files" );
+ for ( Iterator configurationFileIterator = application.getConfigurationFiles().iterator();
+ configurationFileIterator.hasNext(); )
+ {
+ ConfigurationFile configurationFile = (ConfigurationFile) configurationFileIterator.next();
+ try
+ {
+ ConfigurationFileUpdater.update( environment, server, application, configurationFile, updateLog );
+ }
+ catch ( UpdateException updateException )
+ {
+ // the configuration file update has failed
+ if ( configurationFile.isBlocker() )
+ {
+ // the configuration file is update blocker
+ LOGGER.error( "Configuration file {} update failed", configurationFile.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "error",
+ "Configuration file " + configurationFile.getName()
+ + " update failed: "
+ + updateException.getMessage() ) );
+ EventUtils.post( environment, "ERROR",
+ "Configuration file " + configurationFile.getName() + " update failed: "
+ + updateException.getMessage() );
+ throw new UpdateException( "Configuration file " + configurationFile.getName() + " update failed",
+ updateException );
+ }
+ else
+ {
+ // the configuration file is not update blocker
+ LOGGER.warn( "Configuration file {} update failed", configurationFile.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn",
+ "Configuration file " + configurationFile.getName()
+ + " update failed: "
+ + updateException.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info",
+ "Configuration file " + configurationFile.getName()
+ + " is not update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN",
+ "Configuration file " + configurationFile.getName() + " update failed: "
+ + updateException.getMessage() );
+ EventUtils.post( environment, "UPDATE", "Configuration file " + configurationFile.getName()
+ + " is not update blocker, update continues" );
+ }
+ }
+ }
+
+ // update database
+ LOGGER.info( "Updating JEE application databases" );
+ for ( Iterator databaseIterator = application.getDatabases().iterator(); databaseIterator.hasNext(); )
+ {
+ Database database = (Database) databaseIterator.next();
+ try
+ {
+ DatabaseUpdater.update( environment, server, application, database, updateLog );
+ }
+ catch ( UpdateException updateException )
+ {
+ // the database update has failed
+ if ( database.isBlocker() )
+ {
+ // the database is update blocker
+ LOGGER.error( "Database {} update failed", database.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "error",
+ "Database " + database.getName() + " update failed: "
+ + updateException.getMessage() ) );
+ EventUtils.post( environment, "ERROR", "Database " + database.getName() + " update failed: "
+ + updateException.getMessage() );
+ throw new UpdateException( "Database " + database.getName() + " update failed", updateException );
+ }
+ else
+ {
+ // the database is not update blocker
+ LOGGER.warn( "Database {} update failed", database.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn",
+ "Database " + database.getName() + " update failed: "
+ + updateException.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Database " + database.getName()
+ + " is not update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN", "Database " + database.getName() + " update failed: "
+ + updateException.getMessage() );
+ EventUtils.post( environment, "UPDATE",
+ "Database " + database.getName() + " is not update blocker, update continues" );
+ }
+ }
+ }
+
+ // update content managers
+ LOGGER.info( "Updating JEE application content managers" );
+ for ( Iterator contentManagerIterator = application.getContentManagers().iterator();
+ contentManagerIterator.hasNext(); )
+ {
+ ContentManager contentManager = (ContentManager) contentManagerIterator.next();
+ try
+ {
+ ContentManagerUpdater.update( environment, server, application, contentManager, updateLog );
+ }
+ catch ( UpdateException updateException )
+ {
+ // the content manager update has failed
+ if ( contentManager.isBlocker() )
+ {
+ // the content manager is update blocker
+ LOGGER.error( "Content manager {} update failed", contentManager.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "error",
+ "Content manager " + contentManager.getName()
+ + " update failed: "
+ + updateException.getMessage() ) );
+ EventUtils.post( environment, "ERROR",
+ "Content manager " + contentManager.getName() + " update failed: "
+ + updateException.getMessage() );
+ throw new UpdateException( "Content manager " + contentManager.getName() + " update failed",
+ updateException );
+ }
+ else
+ {
+ // the content manager is not update blocker
+ LOGGER.warn( "Content manager {} update failed", contentManager.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn", "Content manager " + contentManager.getName()
+ + " update failed: " + updateException.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Content manager " + contentManager.getName()
+ + " is not update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN",
+ "Content manager " + contentManager.getName() + " update failed: "
+ + updateException.getMessage() );
+ EventUtils.post( environment, "UPDATE", "Content manager " + contentManager.getName()
+ + " is not update blocker, update continues" );
+ }
+ }
+ }
+
+ // update archives
+ LOGGER.info( "Updating JEE application archives" );
+ for ( Iterator archiveIterator = application.getArchives().iterator(); archiveIterator.hasNext(); )
+ {
+ Archive archive = (Archive) archiveIterator.next();
+ try
+ {
+ ArchiveUpdater.update( environment, server, application, archive, updateLog );
+ }
+ catch ( UpdateException updateException )
+ {
+ // the archive update has failed
+ if ( archive.isBlocker() )
+ {
+ // the archive is update blocker
+ LOGGER.error( "Archive {} update failed", archive.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "error",
+ "Archive " + archive.getName() + " update failed: "
+ + updateException.getMessage() ) );
+ EventUtils.post( environment, "ERROR", "Archive " + archive.getName() + " update failed: "
+ + updateException.getMessage() );
+ throw new UpdateException( "Archive " + archive.getName() + " update failed", updateException );
+ }
+ else
+ {
+ // the archive is not update blocker
+ LOGGER.warn( "Archive {} update failed", archive.getName(), updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn",
+ "Archive " + archive.getName() + " update failed: "
+ + updateException.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Archive " + archive.getName()
+ + " is not update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN", "Archive " + archive.getName() + " update failed: "
+ + updateException.getMessage() );
+ EventUtils.post( environment, "UPDATE",
+ "Archive " + archive.getName() + " is not update blocker, update continues" );
+ }
+ }
+ }
+
+ // JEE application update is completed
+ LOGGER.info( "JEE application {} updated", application.getName() );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "JEE application " + application.getName() + " updated" ) );
+ EventUtils.post( environment, "UPDATE", "JEE application " + application.getName() + " updated" );
}
- // update completed
- LOGGER.info( "JEE application {} updated", application.getName() );
- EventUtils.post( environment, "UPDATE", "JEE application " + application.getName() + " updated" );
- if ( !delegation )
+ /**
+ * Wrapper method to update a JEE application (via WS).
+ *
+ * @param environmentName the target environment name.
+ * @param serverName the target JEE application server name.
+ * @param applicationName the target JEE application name.
+ * @param delegation flag indicating if the update is a delegation from another agent (true), or a client call (false).
+ * @throws KalumetException in case of update error.
+ */
+ public static void update( String environmentName, String serverName, String applicationName, boolean delegation )
+ throws KalumetException
{
- if ( updateLog.isUpdated() )
- {
- updateLog.setStatus( "JEE application " + application.getName() + " updated" );
- }
- else
- {
- updateLog.setStatus( "JEE application " + application.getName() + " already up to date" );
- }
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JEE application " + application.getName() + " updated" ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
+ LOGGER.info( "JEE application {} update requested by WS", applicationName );
+
+ LOGGER.debug( "Loading the configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "The environment {} is not found in the the configuration", environmentName );
+ throw new KalumetException(
+ "The environment " + environmentName + " is not found in the the configuration" );
+ }
+ JEEApplicationServer applicationServer =
+ environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
+ if ( applicationServer == null )
+ {
+ LOGGER.error( "The JEE application server {} is not found in the environment {}", serverName,
+ environmentName );
+ throw new KalumetException(
+ "The JEE application server " + serverName + " is not found in the environment " + environmentName );
+ }
+ JEEApplication application = applicationServer.getJEEApplication( applicationName );
+ if ( application == null )
+ {
+ LOGGER.error( "The JEE application {} is not found in the JEE application server {}", applicationName,
+ serverName );
+ throw new KalumetException(
+ "The JEE application " + applicationName + " is not found in the JEE application server "
+ + serverName );
+ }
+
+ // update the agent cache
+ LOGGER.debug( "Updating configuration cache" );
+ Configuration.CONFIG_CACHE = kalumet;
+
+ EventUtils.post( environment, "UPDATE", "JEE application {} update requested by WS", applicationName );
+ UpdateLog updateLog =
+ new UpdateLog( "JEE application " + applicationName + " update in progress ...", environment.getName(),
+ environment );
+
+ if ( !delegation )
+ {
+ // it's a client call
+ LOGGER.info( "Send a notification and waiting for the count down" );
+ EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
+ NotifierUtils.waitAndNotify( environment );
+ }
+ try
+ {
+ LOGGER.debug( "Call JEE application updater" );
+ JEEApplicationUpdater.update( environment, applicationServer, application, updateLog );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "JEE application {} update failed", applicationName, e );
+ EventUtils.post( environment, "ERROR",
+ "JEE application " + applicationName + " udpate failed: " + e.getMessage() );
+ if ( !delegation )
+ {
+ updateLog.setStatus( "JEE application " + applicationName + " update failed" );
+ updateLog.addUpdateMessage( new UpdateMessage( "error",
+ "JEE application " + applicationName + " update failed: "
+ + e.getMessage() ) );
+ PublisherUtils.publish( environment );
+ }
+ throw new UpdateException( "JEE application " + applicationName + " update failed", e );
+ }
+
+ // update completed
+ LOGGER.info( "JEE application {} updated", application.getName() );
+ EventUtils.post( environment, "UPDATE", "JEE application " + application.getName() + " updated" );
+ if ( !delegation )
+ {
+ if ( updateLog.isUpdated() )
+ {
+ updateLog.setStatus( "JEE application " + application.getName() + " updated" );
+ }
+ else
+ {
+ updateLog.setStatus( "JEE application " + application.getName() + " already up to date" );
+ }
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "JEE application " + application.getName() + " updated" ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
+ }
}
- }
}
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JMSConnectionFactoryUpdater.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JMSConnectionFactoryUpdater.java
index 19381f1..18a9614 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JMSConnectionFactoryUpdater.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JMSConnectionFactoryUpdater.java
@@ -41,232 +41,240 @@
public class JMSConnectionFactoryUpdater
{
- private static final transient Logger LOGGER = LoggerFactory.getLogger( JMSConnectionFactoryUpdater.class );
+ private static final transient Logger LOGGER = LoggerFactory.getLogger( JMSConnectionFactoryUpdater.class );
- /**
- * Updates a JMS connection factory.
- *
- * @param environment the target <code>Environment</code>.
- * @param server the target <code>JEEApplicationServer</code>.
- * @param jmsConnectionFactory the target <code>JMSConnectionFactory</code>.
- * @param updateLog the <code>UpdateLog</code> to use.
- */
- public static void update( Environment environment, JEEApplicationServer server,
- JMSConnectionFactory jmsConnectionFactory, UpdateLog updateLog )
- throws UpdateException
- {
- LOGGER.info( "Updating JMS connection factory {}", jmsConnectionFactory.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Updating JMS connection factory " + jmsConnectionFactory.getName() ) );
- EventUtils.post( environment, "UPDATE", "Updating JMS connection factory " + jmsConnectionFactory.getName() );
- if ( !jmsConnectionFactory.isActive() )
+ /**
+ * Updates a JMS connection factory.
+ *
+ * @param environment the target <code>Environment</code>.
+ * @param server the target <code>JEEApplicationServer</code>.
+ * @param jmsConnectionFactory the target <code>JMSConnectionFactory</code>.
+ * @param updateLog the <code>UpdateLog</code> to use.
+ */
+ public static void update( Environment environment, JEEApplicationServer server,
+ JMSConnectionFactory jmsConnectionFactory, UpdateLog updateLog )
+ throws UpdateException
{
- // the JMS connection factory is not active
- LOGGER.info( "JMS connection factory {} is inactive, so not updated", jmsConnectionFactory.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "JMS connection factory " + jmsConnectionFactory.getName()
- + " is inactive, so not updated" ) );
- EventUtils.post( environment, "UPDATE",
- "JMS Connection Factory " + jmsConnectionFactory.getName() + " is inactive, so not updated" );
- return;
- }
- JEEApplicationServerController controller = null;
- try
- {
- // connect controller to JEE application server
- LOGGER.debug( "Connecting to JEE application server controller" );
- controller = JEEApplicationServerControllerFactory.getController(environment, server);
- }
- catch ( KalumetException e )
- {
- LOGGER.error( "Can't connect to JEE application server {} controller", server.getName(), e );
- throw new UpdateException( "Can't connect to JEE application server " + server.getName() + " controller", e );
- }
- try
- {
- if ( controller.isJMSConnectionFactoryDeployed( jmsConnectionFactory.getName() ) )
- {
- // JMS connection factory already deployed in the JEE application server
- LOGGER.info( "JMS connection factory {} already deployed", jmsConnectionFactory.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info",
- "JMS connection factory " + jmsConnectionFactory.getName()
- + " already deployed" ) );
- EventUtils.post( environment, "UPDATE",
- "JMS connection factory " + jmsConnectionFactory.getName() + " already deployed" );
- }
- else
- {
- // deploy the JMS connection factory
- controller.deployJMSConnectionFactory( jmsConnectionFactory.getName() );
- updateLog.setStatus( "Update performed" );
- updateLog.setUpdated( true );
+ LOGGER.info( "Updating JMS connection factory {}", jmsConnectionFactory.getName() );
updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JMS connection factory " + jmsConnectionFactory.getName() + " deployed" ) );
+ new UpdateMessage( "info", "Updating JMS connection factory " + jmsConnectionFactory.getName() ) );
+ EventUtils.post( environment, "UPDATE", "Updating JMS connection factory " + jmsConnectionFactory.getName() );
+ if ( !jmsConnectionFactory.isActive() )
+ {
+ // the JMS connection factory is not active
+ LOGGER.info( "JMS connection factory {} is inactive, so not updated", jmsConnectionFactory.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info",
+ "JMS connection factory " + jmsConnectionFactory.getName()
+ + " is inactive, so not updated" ) );
+ EventUtils.post( environment, "UPDATE", "JMS Connection Factory " + jmsConnectionFactory.getName()
+ + " is inactive, so not updated" );
+ return;
+ }
+ JEEApplicationServerController controller = null;
+ try
+ {
+ // connect controller to JEE application server
+ LOGGER.debug( "Connecting to JEE application server controller" );
+ controller = JEEApplicationServerControllerFactory.getController( environment, server );
+ }
+ catch ( KalumetException e )
+ {
+ LOGGER.error( "Can't connect to JEE application server {} controller", server.getName(), e );
+ throw new UpdateException( "Can't connect to JEE application server " + server.getName() + " controller",
+ e );
+ }
+ try
+ {
+ if ( controller.isJMSConnectionFactoryDeployed( jmsConnectionFactory.getName() ) )
+ {
+ // JMS connection factory already deployed in the JEE application server
+ LOGGER.info( "JMS connection factory {} already deployed", jmsConnectionFactory.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JMS connection factory "
+ + jmsConnectionFactory.getName() + " already deployed" ) );
+ EventUtils.post( environment, "UPDATE",
+ "JMS connection factory " + jmsConnectionFactory.getName() + " already deployed" );
+ }
+ else
+ {
+ // deploy the JMS connection factory
+ controller.deployJMSConnectionFactory( jmsConnectionFactory.getName() );
+ updateLog.setStatus( "Update performed" );
+ updateLog.setUpdated( true );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JMS connection factory "
+ + jmsConnectionFactory.getName() + " deployed" ) );
+ EventUtils.post( environment, "UPDATE",
+ "JMS connection factory " + jmsConnectionFactory.getName() + " deployed" );
+ LOGGER.info( "JMS connection factory {} deployed", jmsConnectionFactory.getName() );
+ }
+ }
+ catch ( ControllerException e )
+ {
+ LOGGER.error( "JMS connection factory {} update failed", jmsConnectionFactory.getName(), e );
+ throw new UpdateException( "JMS connection factory " + jmsConnectionFactory.getName() + " update failed",
+ e );
+ }
+ }
+
+ /**
+ * Wrapper method to update a JMS connection factory via WS.
+ *
+ * @param environmentName the target environment name.
+ * @param serverName the target JEE application server name.
+ * @param jmsConnectionFactoryName the target JMS connection factory name.
+ * @throws KalumetException in case of update failure.
+ */
+ public static void update( String environmentName, String serverName, String jmsConnectionFactoryName )
+ throws KalumetException
+ {
+ LOGGER.info( "JMS connection factory {} update requested by WS", jmsConnectionFactoryName );
+
+ // load configuration.
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+
+ // looking for component objects
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer server = environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
+ if ( server == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", serverName,
+ environment.getName() );
+ throw new KalumetException(
+ "JEE application server " + serverName + " is not found in environment " + environment.getName() );
+ }
+ JMSConnectionFactory jmsConnectionFactory = server.getJMSConnectionFactory( jmsConnectionFactoryName );
+ if ( jmsConnectionFactory == null )
+ {
+ LOGGER.error( "JMS connection factory {} is not found in JEE application server {}",
+ jmsConnectionFactoryName, server.getName() );
+ throw new KalumetException(
+ "JMS connection factory " + jmsConnectionFactoryName + " is not found in JEE application server "
+ + server.getName() );
+ }
+
+ // post event and create update log
+ LOGGER.debug( "Posting event and creating update log" );
EventUtils.post( environment, "UPDATE",
- "JMS connection factory " + jmsConnectionFactory.getName() + " deployed" );
- LOGGER.info( "JMS connection factory {} deployed", jmsConnectionFactory.getName() );
- }
- }
- catch ( ControllerException e )
- {
- LOGGER.error( "JMS connection factory {} update failed", jmsConnectionFactory.getName(), e );
- throw new UpdateException( "JMS connection factory " + jmsConnectionFactory.getName() + " update failed", e );
- }
- }
+ "JMS connection factory " + jmsConnectionFactory.getName() + " update requested by WS" );
+ UpdateLog updateLog =
+ new UpdateLog( "JMS connection factory " + jmsConnectionFactory.getName() + " update in progress ...",
+ environment.getName(), environment );
- /**
- * Wrapper method to update a JMS connection factory via WS.
- *
- * @param environmentName the target environment name.
- * @param serverName the target JEE application server name.
- * @param jmsConnectionFactoryName the target JMS connection factory name.
- * @throws KalumetException in case of update failure.
- */
- public static void update( String environmentName, String serverName, String jmsConnectionFactoryName )
- throws KalumetException
- {
- LOGGER.info( "JMS connection factory {} update requested by WS", jmsConnectionFactoryName );
+ // send a notification and waiting for the count down
+ LOGGER.debug( "Send a notification and waiting for the count down" );
+ EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
+ NotifierUtils.waitAndNotify( environment );
- // load configuration.
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ try
+ {
+ // call update
+ LOGGER.debug( "Call JMS connection factory updater" );
+ JMSConnectionFactoryUpdater.update( environment, server, jmsConnectionFactory, updateLog );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "JMS connection factory {} update failed", jmsConnectionFactory.getName(), e );
+ EventUtils.post( environment, "ERROR",
+ "JMS connection factory " + jmsConnectionFactory.getName() + " update failed: "
+ + e.getMessage() );
+ updateLog.setStatus( "JMS connection factory " + jmsConnectionFactory.getName() + " update failed" );
+ updateLog.addUpdateMessage( new UpdateMessage( "error",
+ "JMS connection factory " + jmsConnectionFactory.getName()
+ + " update failed: " + e.getMessage() ) );
+ PublisherUtils.publish( environment );
+ throw new UpdateException( "JMS connection factory " + jmsConnectionFactory.getName() + " update failed",
+ e );
+ }
- // looking for component objects
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer server = environment.getJEEApplicationServers().getJEEApplicationServer(serverName);
- if ( server == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environment.getName() );
- throw new KalumetException(
- "JEE application server " + serverName + " is not found in environment " + environment.getName() );
- }
- JMSConnectionFactory jmsConnectionFactory = server.getJMSConnectionFactory( jmsConnectionFactoryName );
- if ( jmsConnectionFactory == null )
- {
- LOGGER.error( "JMS connection factory {} is not found in JEE application server {}", jmsConnectionFactoryName,
- server.getName() );
- throw new KalumetException(
- "JMS connection factory " + jmsConnectionFactoryName + " is not found in JEE application server "
- + server.getName() );
+ // update completed.
+ LOGGER.info( "JMS connection factory {} updated", jmsConnectionFactory.getName() );
+ EventUtils.post( environment, "UPDATE",
+ "JMS connection factory " + jmsConnectionFactory.getName() + " updated" );
+ if ( updateLog.isUpdated() )
+ {
+ updateLog.setStatus( "JMS connection factory " + jmsConnectionFactory.getName() + " updated" );
+ }
+ else
+ {
+ updateLog.setStatus(
+ "JMS connection factory " + jmsConnectionFactory.getName() + " is already up to date" );
+ }
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "JMS connection factory " + jmsConnectionFactory.getName() + " updated" ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
}
- // post event and create update log
- LOGGER.debug( "Posting event and creating update log" );
- EventUtils.post( environment, "UPDATE",
- "JMS connection factory " + jmsConnectionFactory.getName() + " update requested by WS" );
- UpdateLog updateLog =
- new UpdateLog( "JMS connection factory " + jmsConnectionFactory.getName() + " update in progress ...",
- environment.getName(), environment );
+ /**
+ * Check a JMS connection factory via WS.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param jmsConnectionFactoryName the target JMS connection factory name.
+ * @return true if the JMS connection factory is up to date, false else.
+ * @throws KalumetException in case of check failure.
+ */
+ public static boolean check( String environmentName, String applicationServerName, String jmsConnectionFactoryName )
+ throws KalumetException
+ {
+ LOGGER.info( "JMS connection factory {} status check requested by WS", jmsConnectionFactoryName );
- // send a notification and waiting for the count down
- LOGGER.debug( "Send a notification and waiting for the count down" );
- EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
- NotifierUtils.waitAndNotify( environment );
+ // load configuration.
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- try
- {
- // call update
- LOGGER.debug( "Call JMS connection factory updater" );
- JMSConnectionFactoryUpdater.update( environment, server, jmsConnectionFactory, updateLog );
- }
- catch ( Exception e )
- {
- LOGGER.error( "JMS connection factory {} update failed", jmsConnectionFactory.getName(), e );
- EventUtils.post( environment, "ERROR",
- "JMS connection factory " + jmsConnectionFactory.getName() + " update failed: "
- + e.getMessage() );
- updateLog.setStatus( "JMS connection factory " + jmsConnectionFactory.getName() + " update failed" );
- updateLog.addUpdateMessage( new UpdateMessage( "error", "JMS connection factory " + jmsConnectionFactory.getName()
- + " update failed: " + e.getMessage() ) );
- PublisherUtils.publish( environment );
- throw new UpdateException( "JMS connection factory " + jmsConnectionFactory.getName() + " update failed", e );
- }
+ // looking for component objects
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer server =
+ environment.getJEEApplicationServers().getJEEApplicationServer( applicationServerName );
+ if ( server == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", applicationServerName,
+ environment.getName() );
+ throw new KalumetException(
+ "JEE application server " + applicationServerName + " is not found in environment "
+ + environment.getName() );
+ }
+ JMSConnectionFactory jmsConnectionFactory = server.getJMSConnectionFactory( jmsConnectionFactoryName );
+ if ( jmsConnectionFactory == null )
+ {
+ LOGGER.error( "JMS connection factory {} is not found in the JEE application server {}",
+ jmsConnectionFactoryName, server.getName() );
+ throw new KalumetException(
+ "JMS connection factory " + jmsConnectionFactoryName + " is not found in the JEE application server "
+ + server.getName() );
+ }
- // update completed.
- LOGGER.info( "JMS connection factory {} updated", jmsConnectionFactory.getName() );
- EventUtils.post( environment, "UPDATE", "JMS connection factory " + jmsConnectionFactory.getName() + " updated" );
- if ( updateLog.isUpdated() )
- {
- updateLog.setStatus( "JMS connection factory " + jmsConnectionFactory.getName() + " updated" );
- }
- else
- {
- updateLog.setStatus( "JMS connection factory " + jmsConnectionFactory.getName() + " is already up to date" );
- }
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JMS connection factory " + jmsConnectionFactory.getName() + " updated" ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
- }
+ // post an event
+ EventUtils.post( environment, "INFO",
+ "JMS connection factory " + jmsConnectionFactory.getName() + " status check requested by WS" );
- /**
- * Check a JMS connection factory via WS.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param jmsConnectionFactoryName the target JMS connection factory name.
- * @return true if the JMS connection factory is up to date, false else.
- * @throws KalumetException in case of check failure.
- */
- public static boolean check( String environmentName, String applicationServerName, String jmsConnectionFactoryName )
- throws KalumetException
- {
- LOGGER.info( "JMS connection factory {} status check requested by WS", jmsConnectionFactoryName );
-
- // load configuration.
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
-
- // looking for component objects
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ try
+ {
+ // get JEE application server controller.
+ LOGGER.debug( "Getting JEE application server controller" );
+ JEEApplicationServerController controller =
+ JEEApplicationServerControllerFactory.getController( environment, server );
+ // check if the JMS connection factory is deployed
+ LOGGER.debug( "Check the status of the JMS connection factory " + jmsConnectionFactory.getName() );
+ return controller.isJMSConnectionFactoryDeployed( jmsConnectionFactory.getName() );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "JMS connection factory {} status check failed", jmsConnectionFactory.getName(), e );
+ throw new KalumetException(
+ "JMS connection factory " + jmsConnectionFactory.getName() + " status check failed", e );
+ }
}
- JEEApplicationServer server =
- environment.getJEEApplicationServers().getJEEApplicationServer(applicationServerName);
- if ( server == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", applicationServerName,
- environment.getName() );
- throw new KalumetException(
- "JEE application server " + applicationServerName + " is not found in environment " + environment.getName() );
- }
- JMSConnectionFactory jmsConnectionFactory = server.getJMSConnectionFactory( jmsConnectionFactoryName );
- if ( jmsConnectionFactory == null )
- {
- LOGGER.error( "JMS connection factory {} is not found in the JEE application server {}",
- jmsConnectionFactoryName, server.getName() );
- throw new KalumetException(
- "JMS connection factory " + jmsConnectionFactoryName + " is not found in the JEE application server "
- + server.getName() );
- }
-
- // post an event
- EventUtils.post( environment, "INFO",
- "JMS connection factory " + jmsConnectionFactory.getName() + " status check requested by WS" );
-
- try
- {
- // get JEE application server controller.
- LOGGER.debug( "Getting JEE application server controller" );
- JEEApplicationServerController controller =
- JEEApplicationServerControllerFactory.getController(environment, server);
- // check if the JMS connection factory is deployed
- LOGGER.debug( "Check the status of the JMS connection factory " + jmsConnectionFactory.getName() );
- return controller.isJMSConnectionFactoryDeployed( jmsConnectionFactory.getName() );
- }
- catch ( Exception e )
- {
- LOGGER.error( "JMS connection factory {} status check failed", jmsConnectionFactory.getName(), e );
- throw new KalumetException( "JMS connection factory " + jmsConnectionFactory.getName() + " status check failed",
- e );
- }
- }
}
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JMSServerUpdater.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JMSServerUpdater.java
index 4b95a1d..944ab14 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JMSServerUpdater.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JMSServerUpdater.java
@@ -24,8 +24,12 @@
import org.apache.kalumet.controller.core.ControllerException;
import org.apache.kalumet.controller.core.JEEApplicationServerController;
import org.apache.kalumet.controller.core.JEEApplicationServerControllerFactory;
-import org.apache.kalumet.model.*;
+import org.apache.kalumet.model.Environment;
import org.apache.kalumet.model.JEEApplicationServer;
+import org.apache.kalumet.model.JMSQueue;
+import org.apache.kalumet.model.JMSServer;
+import org.apache.kalumet.model.JMSTopic;
+import org.apache.kalumet.model.Kalumet;
import org.apache.kalumet.model.update.UpdateLog;
import org.apache.kalumet.model.update.UpdateMessage;
import org.apache.kalumet.utils.NotifierUtils;
@@ -43,260 +47,267 @@
public class JMSServerUpdater
{
- private static final transient Logger LOGGER = LoggerFactory.getLogger( JMSServerUpdater.class );
+ private static final transient Logger LOGGER = LoggerFactory.getLogger( JMSServerUpdater.class );
- /**
- * Update a JMS server.
- *
- * @param environment the target <code>Environment</code>.
- * @param server the target <code>JEEApplicationServer</code>.
- * @param jmsServer the target <code>JMSServer</code>.
- * @param updateLog the <code>UpdateLog</code> to use.
- * @thorws UpdateException in case of update failure.
- */
- public static void update( Environment environment, JEEApplicationServer server, JMSServer jmsServer,
- UpdateLog updateLog )
- throws UpdateException
- {
- LOGGER.info( "Updating JMS server {}", jmsServer.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Updating JMS server " + jmsServer.getName() ) );
- EventUtils.post( environment, "UPDATE", "Updating JMS server " + jmsServer.getName() );
- if ( !jmsServer.isActive() )
+ /**
+ * Update a JMS server.
+ *
+ * @param environment the target <code>Environment</code>.
+ * @param server the target <code>JEEApplicationServer</code>.
+ * @param jmsServer the target <code>JMSServer</code>.
+ * @param updateLog the <code>UpdateLog</code> to use.
+ * @thorws UpdateException in case of update failure.
+ */
+ public static void update( Environment environment, JEEApplicationServer server, JMSServer jmsServer,
+ UpdateLog updateLog )
+ throws UpdateException
{
- // JMS server is not active
- LOGGER.info( "JMS server {} is inactive, so not updated", jmsServer.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JMS server " + jmsServer.getName() + " is inactive, so not updated" ) );
- EventUtils.post( environment, "UPDATE", "JMS server " + jmsServer.getName() + " is inactive, so not updated" );
- return;
- }
- // construct the queues and topics list
- LinkedList queues = new LinkedList();
- LinkedList topics = new LinkedList();
- // construct the queues
- for ( Iterator queueIterator = jmsServer.getJMSQueues().iterator(); queueIterator.hasNext(); )
- {
- JMSQueue jmsQueue = (JMSQueue) queueIterator.next();
- queues.add( VariableUtils.replace( jmsQueue.getName(), environment.getVariables() ) );
- }
- // construct the topics
- for ( Iterator topicIterator = jmsServer.getJMSTopics().iterator(); topicIterator.hasNext(); )
- {
- JMSTopic jmsTopic = (JMSTopic) topicIterator.next();
- topics.add( VariableUtils.replace( jmsTopic.getName(), environment.getVariables() ) );
- }
- JEEApplicationServerController controller = null;
- try
- {
- // connect JMX controller to JEE application server
- LOGGER.debug( "Connecting to JEE application server {} controller", server.getName() );
- controller = JEEApplicationServerControllerFactory.getController(environment, server);
- }
- catch ( KalumetException e )
- {
- LOGGER.error( "Can't connect to JEE application server {} controller", server.getName(), e );
- throw new UpdateException( "Can't connect to JEE application server " + server.getName() + " controller", e );
- }
- try
- {
- if ( controller.isJMSServerDeployed( jmsServer.getName() ) )
- {
- // JMS server already deployed, check for update
- LOGGER.info( "JMS server {} already deployed, checking for update", jmsServer.getName() );
- if ( controller.updateJMSServer( jmsServer.getName(), queues, topics ) )
+ LOGGER.info( "Updating JMS server {}", jmsServer.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Updating JMS server " + jmsServer.getName() ) );
+ EventUtils.post( environment, "UPDATE", "Updating JMS server " + jmsServer.getName() );
+ if ( !jmsServer.isActive() )
{
- updateLog.setStatus( "Update performed" );
- updateLog.setUpdated( true );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "JMS server " + jmsServer.getName() + " updated" ) );
- EventUtils.post( environment, "UPDATE", "JMS server " + jmsServer.getName() + " updated" );
- LOGGER.info( "JMS server {} updated", jmsServer.getName() );
+ // JMS server is not active
+ LOGGER.info( "JMS server {} is inactive, so not updated", jmsServer.getName() );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "JMS server " + jmsServer.getName() + " is inactive, so not updated" ) );
+ EventUtils.post( environment, "UPDATE",
+ "JMS server " + jmsServer.getName() + " is inactive, so not updated" );
+ return;
}
- }
- else
- {
- // JMS server is not deployed, deploy it
- controller.deployJMSServer( jmsServer.getName(), queues, topics );
- updateLog.setStatus( "Update performed" );
- updateLog.setUpdated( true );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "JMS server " + jmsServer.getName() + " deployed" ) );
- EventUtils.post( environment, "UPDATE", "JMS server " + jmsServer.getName() + " deployed" );
- LOGGER.info( "JMS server {} deployed" );
- }
- }
- catch ( ControllerException e )
- {
- LOGGER.error( "JMS server {} update failed", jmsServer.getName(), e );
- throw new UpdateException( "JMS server " + jmsServer.getName() + " update failed", e );
- }
- }
-
- /**
- * Wrapper method to update a JMS server via WS.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param jmsServerName the target JMS server name.
- * @throws KalumetException if case of update failure.
- */
- public static void update( String environmentName, String applicationServerName, String jmsServerName )
- throws KalumetException
- {
- LOGGER.info( "JMS server {} update requested by WS", jmsServerName );
-
- // load configuration.
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
-
- // looking for component objects
- LOGGER.debug( "Looking for component objects" );
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer applicationServer =
- environment.getJEEApplicationServers().getJEEApplicationServer(applicationServerName);
- if ( applicationServer == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", applicationServerName,
- environment.getName() );
- throw new KalumetException(
- "JEE application server " + applicationServerName + " is not found in environment " + environment.getName() );
- }
- JMSServer jmsServer = applicationServer.getJMSServer( jmsServerName );
- if ( jmsServer == null )
- {
- LOGGER.error( "JMS server {} is not found in JEE application server {}", jmsServerName,
- applicationServer.getName() );
- throw new KalumetException(
- "JMS server " + jmsServerName + " is not found in JEE application server " + applicationServer.getName() );
+ // construct the queues and topics list
+ LinkedList queues = new LinkedList();
+ LinkedList topics = new LinkedList();
+ // construct the queues
+ for ( Iterator queueIterator = jmsServer.getJMSQueues().iterator(); queueIterator.hasNext(); )
+ {
+ JMSQueue jmsQueue = (JMSQueue) queueIterator.next();
+ queues.add( VariableUtils.replace( jmsQueue.getName(), environment.getVariables() ) );
+ }
+ // construct the topics
+ for ( Iterator topicIterator = jmsServer.getJMSTopics().iterator(); topicIterator.hasNext(); )
+ {
+ JMSTopic jmsTopic = (JMSTopic) topicIterator.next();
+ topics.add( VariableUtils.replace( jmsTopic.getName(), environment.getVariables() ) );
+ }
+ JEEApplicationServerController controller = null;
+ try
+ {
+ // connect JMX controller to JEE application server
+ LOGGER.debug( "Connecting to JEE application server {} controller", server.getName() );
+ controller = JEEApplicationServerControllerFactory.getController( environment, server );
+ }
+ catch ( KalumetException e )
+ {
+ LOGGER.error( "Can't connect to JEE application server {} controller", server.getName(), e );
+ throw new UpdateException( "Can't connect to JEE application server " + server.getName() + " controller",
+ e );
+ }
+ try
+ {
+ if ( controller.isJMSServerDeployed( jmsServer.getName() ) )
+ {
+ // JMS server already deployed, check for update
+ LOGGER.info( "JMS server {} already deployed, checking for update", jmsServer.getName() );
+ if ( controller.updateJMSServer( jmsServer.getName(), queues, topics ) )
+ {
+ updateLog.setStatus( "Update performed" );
+ updateLog.setUpdated( true );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "JMS server " + jmsServer.getName() + " updated" ) );
+ EventUtils.post( environment, "UPDATE", "JMS server " + jmsServer.getName() + " updated" );
+ LOGGER.info( "JMS server {} updated", jmsServer.getName() );
+ }
+ }
+ else
+ {
+ // JMS server is not deployed, deploy it
+ controller.deployJMSServer( jmsServer.getName(), queues, topics );
+ updateLog.setStatus( "Update performed" );
+ updateLog.setUpdated( true );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "JMS server " + jmsServer.getName() + " deployed" ) );
+ EventUtils.post( environment, "UPDATE", "JMS server " + jmsServer.getName() + " deployed" );
+ LOGGER.info( "JMS server {} deployed" );
+ }
+ }
+ catch ( ControllerException e )
+ {
+ LOGGER.error( "JMS server {} update failed", jmsServer.getName(), e );
+ throw new UpdateException( "JMS server " + jmsServer.getName() + " update failed", e );
+ }
}
- // post an event and create update log.
- LOGGER.debug( "Posting an event and creating update log" );
- EventUtils.post( environment, "UPDATE", "JMS server " + jmsServer.getName() + " update requested by WS" );
- UpdateLog updateLog =
- new UpdateLog( "JMS server " + jmsServer.getName() + " update in progress ...", environment.getName(),
- environment );
-
- // send a notification and waiting for the count down.
- LOGGER.info( "Send a notification and waiting for the count down" );
- EventUtils.post( environment, "UPDATE", "Post an event and waiting for the count down" );
- NotifierUtils.waitAndNotify( environment );
-
- try
+ /**
+ * Wrapper method to update a JMS server via WS.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param jmsServerName the target JMS server name.
+ * @throws KalumetException if case of update failure.
+ */
+ public static void update( String environmentName, String applicationServerName, String jmsServerName )
+ throws KalumetException
{
- // call update
- LOGGER.debug( "Call JMS server updater" );
- JMSServerUpdater.update( environment, applicationServer, jmsServer, updateLog );
- }
- catch ( Exception e )
- {
- LOGGER.error( "JMS server {} update failed", jmsServer.getName(), e );
- EventUtils.post( environment, "ERROR",
- "JMS server " + jmsServer.getName() + " update failed: " + e.getMessage() );
- updateLog.setStatus( "JMS server " + jmsServer.getName() + " update failed" );
- updateLog.addUpdateMessage(
- new UpdateMessage( "error", "JMS server " + jmsServer.getName() + " update failed: " + e.getMessage() ) );
- PublisherUtils.publish( environment );
- throw new KalumetException( "JMS server " + jmsServer.getName() + " update failed", e );
+ LOGGER.info( "JMS server {} update requested by WS", jmsServerName );
+
+ // load configuration.
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+
+ // looking for component objects
+ LOGGER.debug( "Looking for component objects" );
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer applicationServer =
+ environment.getJEEApplicationServers().getJEEApplicationServer( applicationServerName );
+ if ( applicationServer == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", applicationServerName,
+ environment.getName() );
+ throw new KalumetException(
+ "JEE application server " + applicationServerName + " is not found in environment "
+ + environment.getName() );
+ }
+ JMSServer jmsServer = applicationServer.getJMSServer( jmsServerName );
+ if ( jmsServer == null )
+ {
+ LOGGER.error( "JMS server {} is not found in JEE application server {}", jmsServerName,
+ applicationServer.getName() );
+ throw new KalumetException( "JMS server " + jmsServerName + " is not found in JEE application server "
+ + applicationServer.getName() );
+ }
+
+ // post an event and create update log.
+ LOGGER.debug( "Posting an event and creating update log" );
+ EventUtils.post( environment, "UPDATE", "JMS server " + jmsServer.getName() + " update requested by WS" );
+ UpdateLog updateLog =
+ new UpdateLog( "JMS server " + jmsServer.getName() + " update in progress ...", environment.getName(),
+ environment );
+
+ // send a notification and waiting for the count down.
+ LOGGER.info( "Send a notification and waiting for the count down" );
+ EventUtils.post( environment, "UPDATE", "Post an event and waiting for the count down" );
+ NotifierUtils.waitAndNotify( environment );
+
+ try
+ {
+ // call update
+ LOGGER.debug( "Call JMS server updater" );
+ JMSServerUpdater.update( environment, applicationServer, jmsServer, updateLog );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "JMS server {} update failed", jmsServer.getName(), e );
+ EventUtils.post( environment, "ERROR",
+ "JMS server " + jmsServer.getName() + " update failed: " + e.getMessage() );
+ updateLog.setStatus( "JMS server " + jmsServer.getName() + " update failed" );
+ updateLog.addUpdateMessage( new UpdateMessage( "error",
+ "JMS server " + jmsServer.getName() + " update failed: "
+ + e.getMessage() ) );
+ PublisherUtils.publish( environment );
+ throw new KalumetException( "JMS server " + jmsServer.getName() + " update failed", e );
+ }
+
+ // update completed
+ LOGGER.info( "JMS server {} updated", jmsServer.getName() );
+ EventUtils.post( environment, "UPDATE", "JMS server " + jmsServer.getName() + " updated" );
+ if ( updateLog.isUpdated() )
+ {
+ updateLog.setStatus( "JMS server " + jmsServer.getName() + " updated" );
+ }
+ else
+ {
+ updateLog.setStatus( "JMS server " + jmsServer.getName() + " already up to date" );
+ }
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JMS server " + jmsServer.getName() + " updated" ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
}
- // update completed
- LOGGER.info( "JMS server {} updated", jmsServer.getName() );
- EventUtils.post( environment, "UPDATE", "JMS server " + jmsServer.getName() + " updated" );
- if ( updateLog.isUpdated() )
+ /**
+ * Check a JMS server via WS.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param jmsServerName the target JMS server name.
+ * @return true if the JMS server is up to date, false else.
+ * @throws KalumetException in case of check failure.
+ */
+ public static boolean check( String environmentName, String applicationServerName, String jmsServerName )
+ throws KalumetException
{
- updateLog.setStatus( "JMS server " + jmsServer.getName() + " updated" );
- }
- else
- {
- updateLog.setStatus( "JMS server " + jmsServer.getName() + " already up to date" );
- }
- updateLog.addUpdateMessage( new UpdateMessage( "info", "JMS server " + jmsServer.getName() + " updated" ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
- }
+ LOGGER.info( "JMS server {} status check requested by WS", jmsServerName );
- /**
- * Check a JMS server via WS.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param jmsServerName the target JMS server name.
- * @return true if the JMS server is up to date, false else.
- * @throws KalumetException in case of check failure.
- */
- public static boolean check( String environmentName, String applicationServerName, String jmsServerName )
- throws KalumetException
- {
- LOGGER.info( "JMS server {} status check requested by WS", jmsServerName );
+ // load configuration.
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- // load configuration.
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ // load component objects
+ LOGGER.debug( "Loading component objects" );
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer applicationServer =
+ environment.getJEEApplicationServers().getJEEApplicationServer( applicationServerName );
+ if ( applicationServer == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", applicationServerName,
+ environment.getName() );
+ throw new KalumetException(
+ "JEE application server " + applicationServerName + " is not found in environment "
+ + environment.getName() );
+ }
+ JMSServer jmsServer = applicationServer.getJMSServer( jmsServerName );
+ if ( jmsServer == null )
+ {
+ LOGGER.error( "JMS server {} is not found in JEE application server {}", jmsServerName,
+ applicationServer.getName() );
+ throw new KalumetException( "JMS server " + jmsServerName + " is not found in JEE application server "
+ + applicationServer.getName() );
+ }
- // load component objects
- LOGGER.debug( "Loading component objects" );
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer applicationServer =
- environment.getJEEApplicationServers().getJEEApplicationServer(applicationServerName);
- if ( applicationServer == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", applicationServerName,
- environment.getName() );
- throw new KalumetException(
- "JEE application server " + applicationServerName + " is not found in environment " + environment.getName() );
- }
- JMSServer jmsServer = applicationServer.getJMSServer( jmsServerName );
- if ( jmsServer == null )
- {
- LOGGER.error( "JMS server {} is not found in JEE application server {}", jmsServerName,
- applicationServer.getName() );
- throw new KalumetException(
- "JMS server " + jmsServerName + " is not found in JEE application server " + applicationServer.getName() );
- }
+ // post an event.
+ EventUtils.post( environment, "INFO", "JMS server " + jmsServer.getName() + " status check requested by WS" );
- // post an event.
- EventUtils.post( environment, "INFO", "JMS server " + jmsServer.getName() + " status check requested by WS" );
-
- try
- {
- // get JEE application server controller.
- LOGGER.debug( "Getting JEE application server controller" );
- JEEApplicationServerController controller =
- JEEApplicationServerControllerFactory.getController(environment, applicationServer);
- // construct the queue list.
- LOGGER.debug( "Constructing the queue list" );
- LinkedList queues = new LinkedList();
- for ( Iterator queueIterator = jmsServer.getJMSQueues().iterator(); queueIterator.hasNext(); )
- {
- JMSQueue queue = (JMSQueue) queueIterator.next();
- queues.add( queue );
- }
- // construct the topic list.
- LOGGER.debug( "Constructing the topic list" );
- LinkedList topics = new LinkedList();
- for ( Iterator topicIterator = jmsServer.getJMSTopics().iterator(); topicIterator.hasNext(); )
- {
- JMSTopic topic = (JMSTopic) topicIterator.next();
- topics.add( topic );
- }
- // check if the JMS server is up to date.
- LOGGER.debug( "Checking if JMS server {} is up to date", jmsServer.getName() );
- return controller.isJMSServerUpToDate( jmsServer.getName(), queues, topics );
+ try
+ {
+ // get JEE application server controller.
+ LOGGER.debug( "Getting JEE application server controller" );
+ JEEApplicationServerController controller =
+ JEEApplicationServerControllerFactory.getController( environment, applicationServer );
+ // construct the queue list.
+ LOGGER.debug( "Constructing the queue list" );
+ LinkedList queues = new LinkedList();
+ for ( Iterator queueIterator = jmsServer.getJMSQueues().iterator(); queueIterator.hasNext(); )
+ {
+ JMSQueue queue = (JMSQueue) queueIterator.next();
+ queues.add( queue );
+ }
+ // construct the topic list.
+ LOGGER.debug( "Constructing the topic list" );
+ LinkedList topics = new LinkedList();
+ for ( Iterator topicIterator = jmsServer.getJMSTopics().iterator(); topicIterator.hasNext(); )
+ {
+ JMSTopic topic = (JMSTopic) topicIterator.next();
+ topics.add( topic );
+ }
+ // check if the JMS server is up to date.
+ LOGGER.debug( "Checking if JMS server {} is up to date", jmsServer.getName() );
+ return controller.isJMSServerUpToDate( jmsServer.getName(), queues, topics );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "JMS server {} check failed", jmsServer.getName(), e );
+ throw new KalumetException( "JMS server " + jmsServer.getName() + " check failed", e );
+ }
}
- catch ( Exception e )
- {
- LOGGER.error( "JMS server {} check failed", jmsServer.getName(), e );
- throw new KalumetException( "JMS server " + jmsServer.getName() + " check failed", e );
- }
- }
}
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JNDIBindingUpdater.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JNDIBindingUpdater.java
index 017c0ca..fa4e974 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JNDIBindingUpdater.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/JNDIBindingUpdater.java
@@ -42,238 +42,244 @@
public class JNDIBindingUpdater
{
- private static final transient Logger LOGGER = LoggerFactory.getLogger( JNDIBindingUpdater.class );
+ private static final transient Logger LOGGER = LoggerFactory.getLogger( JNDIBindingUpdater.class );
- /**
- * Update a JNDI binding..
- *
- * @param environment the target <code>Environment</code>.
- * @param server the target <code>JEEApplicationServer</code>.
- * @param jndiBinding the target <code>JNDIBinding</code>.
- * @param updateLog the <code>UpdateLog</code> to use.
- * @throws UpdateException in case of update failure.
- */
- public static void update( Environment environment, JEEApplicationServer server, JNDIBinding jndiBinding,
- UpdateLog updateLog )
- throws UpdateException
- {
- LOGGER.info( "Updating JNDI binding {}", jndiBinding.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Updating JNDI binding " + jndiBinding.getName() ) );
- EventUtils.post( environment, "UPDATE", "Updating JNDI binding " + jndiBinding.getName() );
- if ( !jndiBinding.isActive() )
+ /**
+ * Update a JNDI binding..
+ *
+ * @param environment the target <code>Environment</code>.
+ * @param server the target <code>JEEApplicationServer</code>.
+ * @param jndiBinding the target <code>JNDIBinding</code>.
+ * @param updateLog the <code>UpdateLog</code> to use.
+ * @throws UpdateException in case of update failure.
+ */
+ public static void update( Environment environment, JEEApplicationServer server, JNDIBinding jndiBinding,
+ UpdateLog updateLog )
+ throws UpdateException
{
- // the JNDI binding is not active
- LOGGER.info( "JNDI binding {} is inactive, so not updated", jndiBinding.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JNDI binding " + jndiBinding.getName() + " is inactive, so not updated" ) );
- EventUtils.post( environment, "UPDATE",
- "JNDI binding " + jndiBinding.getName() + " is inactive, so not updated" );
- return;
- }
- JEEApplicationServerController controller = null;
- try
- {
- // connect controller to JEE application server
- LOGGER.debug( "Connecting to JEE application server {} controller", server.getName() );
- controller = JEEApplicationServerControllerFactory.getController(environment, server);
- }
- catch ( KalumetException e )
- {
- LOGGER.error( "Can't connect to JEE application server {} controller", server.getName(), e );
- throw new UpdateException( "Can't connect to JEE application server " + server.getName() + " controller", e );
- }
- // replaces variables in name space binding data
- LOGGER.debug( "Replacing variables in name space binding data" );
- String mapJndiName = VariableUtils.replace( jndiBinding.getJndiname(), environment.getVariables() );
- String mapJndiAlias = VariableUtils.replace( jndiBinding.getJndialias(), environment.getVariables() );
- String mapJndiProviderUrl = VariableUtils.replace( jndiBinding.getProviderurl(), environment.getVariables() );
- try
- {
- if ( controller.isJNDIBindingDeployed( jndiBinding.getName() ) )
- {
- // the JNDI binding is already deployed, check for update
- LOGGER.info( "JNDI binding {} already deployed, checking for update", jndiBinding.getName() );
- if ( controller.updateJNDIBinding( jndiBinding.getName(), mapJndiName, mapJndiAlias, mapJndiProviderUrl ) )
+ LOGGER.info( "Updating JNDI binding {}", jndiBinding.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Updating JNDI binding " + jndiBinding.getName() ) );
+ EventUtils.post( environment, "UPDATE", "Updating JNDI binding " + jndiBinding.getName() );
+ if ( !jndiBinding.isActive() )
{
- // the JNDI binding has been updated
- updateLog.setStatus( "Update performed" );
- updateLog.setUpdated( true );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JNDI binding " + jndiBinding.getName() + " updated" ) );
- EventUtils.post( environment, "UPDATE", "JNDI binding " + jndiBinding.getName() + " updated" );
- LOGGER.info( "JNDI binding {} updated", jndiBinding.getName() );
+ // the JNDI binding is not active
+ LOGGER.info( "JNDI binding {} is inactive, so not updated", jndiBinding.getName() );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "JNDI binding " + jndiBinding.getName() + " is inactive, so not updated" ) );
+ EventUtils.post( environment, "UPDATE",
+ "JNDI binding " + jndiBinding.getName() + " is inactive, so not updated" );
+ return;
}
- }
- else
- {
- // JNDI binding is not deployed, deploy it
- controller.deployJNDIBinding( jndiBinding.getName(), mapJndiName, mapJndiAlias, mapJndiProviderUrl );
- updateLog.setStatus( "Update performed" );
- updateLog.setUpdated( true );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "JNDI binding " + jndiBinding.getName() + " deployed" ) );
- EventUtils.post( environment, "UPDATE", "JNDI binding " + jndiBinding.getName() + " deployed" );
- LOGGER.info( "JNDI binding {} deployed", jndiBinding.getName() );
- }
- }
- catch ( ControllerException e )
- {
- LOGGER.error( "JNDI binding {} update failed", jndiBinding.getName(), e );
- throw new UpdateException( "JNDI binding " + jndiBinding.getName() + " update failed", e );
- }
- }
-
- /**
- * Wrapper method to JNDI binding update via WS.
- *
- * @param environmentName the target environment name.
- * @param serverName the target JEE application server name.
- * @param bindingName the target JNDI binding name.
- * @throws KalumetException in case of update failure.
- */
- public static void update( String environmentName, String serverName, String bindingName )
- throws KalumetException
- {
- LOGGER.info( "JNDI binding {} update requested by WS", bindingName );
-
- // load configuration
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
-
- // looking for component objects.
- LOGGER.debug( "Looking for component objects" );
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer server = environment.getJEEApplicationServers().getJEEApplicationServer(serverName);
- if ( server == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environment.getName() );
- throw new KalumetException(
- "JEE application server " + serverName + " is not found in environment " + environment.getName() );
- }
- JNDIBinding jndiBinding = server.getJNDIBinding( bindingName );
- if ( jndiBinding == null )
- {
- LOGGER.error( "JNDI binding {} is not found in JEE application server {}", bindingName, server.getName() );
- throw new KalumetException(
- "JNDI binding " + bindingName + " is not found in JEE application server " + server.getName() );
+ JEEApplicationServerController controller = null;
+ try
+ {
+ // connect controller to JEE application server
+ LOGGER.debug( "Connecting to JEE application server {} controller", server.getName() );
+ controller = JEEApplicationServerControllerFactory.getController( environment, server );
+ }
+ catch ( KalumetException e )
+ {
+ LOGGER.error( "Can't connect to JEE application server {} controller", server.getName(), e );
+ throw new UpdateException( "Can't connect to JEE application server " + server.getName() + " controller",
+ e );
+ }
+ // replaces variables in name space binding data
+ LOGGER.debug( "Replacing variables in name space binding data" );
+ String mapJndiName = VariableUtils.replace( jndiBinding.getJndiname(), environment.getVariables() );
+ String mapJndiAlias = VariableUtils.replace( jndiBinding.getJndialias(), environment.getVariables() );
+ String mapJndiProviderUrl = VariableUtils.replace( jndiBinding.getProviderurl(), environment.getVariables() );
+ try
+ {
+ if ( controller.isJNDIBindingDeployed( jndiBinding.getName() ) )
+ {
+ // the JNDI binding is already deployed, check for update
+ LOGGER.info( "JNDI binding {} already deployed, checking for update", jndiBinding.getName() );
+ if ( controller.updateJNDIBinding( jndiBinding.getName(), mapJndiName, mapJndiAlias,
+ mapJndiProviderUrl ) )
+ {
+ // the JNDI binding has been updated
+ updateLog.setStatus( "Update performed" );
+ updateLog.setUpdated( true );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "JNDI binding " + jndiBinding.getName() + " updated" ) );
+ EventUtils.post( environment, "UPDATE", "JNDI binding " + jndiBinding.getName() + " updated" );
+ LOGGER.info( "JNDI binding {} updated", jndiBinding.getName() );
+ }
+ }
+ else
+ {
+ // JNDI binding is not deployed, deploy it
+ controller.deployJNDIBinding( jndiBinding.getName(), mapJndiName, mapJndiAlias, mapJndiProviderUrl );
+ updateLog.setStatus( "Update performed" );
+ updateLog.setUpdated( true );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "JNDI binding " + jndiBinding.getName() + " deployed" ) );
+ EventUtils.post( environment, "UPDATE", "JNDI binding " + jndiBinding.getName() + " deployed" );
+ LOGGER.info( "JNDI binding {} deployed", jndiBinding.getName() );
+ }
+ }
+ catch ( ControllerException e )
+ {
+ LOGGER.error( "JNDI binding {} update failed", jndiBinding.getName(), e );
+ throw new UpdateException( "JNDI binding " + jndiBinding.getName() + " update failed", e );
+ }
}
- // post an event and create the update log.
- LOGGER.debug( "Posting an event and creating the update log" );
- EventUtils.post( environment, "UPDATE", "JNDI binding " + jndiBinding.getName() + " update requested by WS" );
- UpdateLog updateLog =
- new UpdateLog( "JNDI binding " + jndiBinding.getName() + " update in progress ...", jndiBinding.getName(),
- environment );
-
- // send a notification and waiting for the count down.
- LOGGER.info( "Send a notification and waiting for the count down" );
- EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
- NotifierUtils.waitAndNotify( environment );
-
- try
+ /**
+ * Wrapper method to JNDI binding update via WS.
+ *
+ * @param environmentName the target environment name.
+ * @param serverName the target JEE application server name.
+ * @param bindingName the target JNDI binding name.
+ * @throws KalumetException in case of update failure.
+ */
+ public static void update( String environmentName, String serverName, String bindingName )
+ throws KalumetException
{
- // call update.
- LOGGER.debug( "Call JNDI binding updater" );
- JNDIBindingUpdater.update( environment, server, jndiBinding, updateLog );
- }
- catch ( Exception e )
- {
- LOGGER.error( "JNDI binding {} update failed", jndiBinding.getName(), e );
- EventUtils.post( environment, "ERROR",
- "JNDI binding " + jndiBinding.getName() + " update failed: " + e.getMessage() );
- updateLog.setStatus( "JNDI binding " + jndiBinding.getName() + " update failed" );
- updateLog.addUpdateMessage(
- new UpdateMessage( "error", "JNDI binding " + jndiBinding.getName() + " update failed: " + e.getMessage() ) );
- PublisherUtils.publish( environment );
- throw new UpdateException( "JNDI binding " + jndiBinding.getName() + " update failed", e );
+ LOGGER.info( "JNDI binding {} update requested by WS", bindingName );
+
+ // load configuration
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+
+ // looking for component objects.
+ LOGGER.debug( "Looking for component objects" );
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer server = environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
+ if ( server == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", serverName,
+ environment.getName() );
+ throw new KalumetException(
+ "JEE application server " + serverName + " is not found in environment " + environment.getName() );
+ }
+ JNDIBinding jndiBinding = server.getJNDIBinding( bindingName );
+ if ( jndiBinding == null )
+ {
+ LOGGER.error( "JNDI binding {} is not found in JEE application server {}", bindingName, server.getName() );
+ throw new KalumetException(
+ "JNDI binding " + bindingName + " is not found in JEE application server " + server.getName() );
+ }
+
+ // post an event and create the update log.
+ LOGGER.debug( "Posting an event and creating the update log" );
+ EventUtils.post( environment, "UPDATE", "JNDI binding " + jndiBinding.getName() + " update requested by WS" );
+ UpdateLog updateLog =
+ new UpdateLog( "JNDI binding " + jndiBinding.getName() + " update in progress ...", jndiBinding.getName(),
+ environment );
+
+ // send a notification and waiting for the count down.
+ LOGGER.info( "Send a notification and waiting for the count down" );
+ EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
+ NotifierUtils.waitAndNotify( environment );
+
+ try
+ {
+ // call update.
+ LOGGER.debug( "Call JNDI binding updater" );
+ JNDIBindingUpdater.update( environment, server, jndiBinding, updateLog );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "JNDI binding {} update failed", jndiBinding.getName(), e );
+ EventUtils.post( environment, "ERROR",
+ "JNDI binding " + jndiBinding.getName() + " update failed: " + e.getMessage() );
+ updateLog.setStatus( "JNDI binding " + jndiBinding.getName() + " update failed" );
+ updateLog.addUpdateMessage( new UpdateMessage( "error",
+ "JNDI binding " + jndiBinding.getName() + " update failed: "
+ + e.getMessage() ) );
+ PublisherUtils.publish( environment );
+ throw new UpdateException( "JNDI binding " + jndiBinding.getName() + " update failed", e );
+ }
+
+ // update completed
+ LOGGER.info( "JNDI binding {} updated", jndiBinding.getName() );
+ EventUtils.post( environment, "UPDATE", "JNDI binding " + jndiBinding.getName() + " updated" );
+ if ( updateLog.isUpdated() )
+ {
+ updateLog.setStatus( "JNDI binding " + jndiBinding.getName() + " updated" );
+ }
+ else
+ {
+ updateLog.setStatus( "JNDI binding " + jndiBinding.getName() + " already up to date" );
+ }
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "JNDI binding " + jndiBinding.getName() + " updated" ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
}
- // update completed
- LOGGER.info( "JNDI binding {} updated", jndiBinding.getName() );
- EventUtils.post( environment, "UPDATE", "JNDI binding " + jndiBinding.getName() + " updated" );
- if ( updateLog.isUpdated() )
+ /**
+ * Check if a JNDI name space binding is up to date or not via WS.
+ *
+ * @param environmentName the target environment name.
+ * @param serverName the target JEE application server name.
+ * @param jndiBindingName the target JNDI binding name.
+ * @return true if the JNDI name space binding is up to date, false else.
+ * @throws KalumetException in case of JNDI name space binding check failure.
+ */
+ public static boolean check( String environmentName, String serverName, String jndiBindingName )
+ throws KalumetException
{
- updateLog.setStatus( "JNDI binding " + jndiBinding.getName() + " updated" );
- }
- else
- {
- updateLog.setStatus( "JNDI binding " + jndiBinding.getName() + " already up to date" );
- }
- updateLog.addUpdateMessage( new UpdateMessage( "info", "JNDI binding " + jndiBinding.getName() + " updated" ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
- }
+ LOGGER.info( "JNDI binding {} status check requested by WS", jndiBindingName );
- /**
- * Check if a JNDI name space binding is up to date or not via WS.
- *
- * @param environmentName the target environment name.
- * @param serverName the target JEE application server name.
- * @param jndiBindingName the target JNDI binding name.
- * @return true if the JNDI name space binding is up to date, false else.
- * @throws KalumetException in case of JNDI name space binding check failure.
- */
- public static boolean check( String environmentName, String serverName, String jndiBindingName )
- throws KalumetException
- {
- LOGGER.info( "JNDI binding {} status check requested by WS", jndiBindingName );
+ // load configuration.
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- // load configuration.
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ // looking for component objects
+ LOGGER.debug( "Looking for component objects" );
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer applicationServer =
+ environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
+ if ( applicationServer == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", serverName,
+ environment.getName() );
+ throw new KalumetException(
+ "JEE application server " + serverName + " is not found in environment " + environment.getName() );
+ }
+ JNDIBinding jndiBinding = applicationServer.getJNDIBinding( jndiBindingName );
+ if ( jndiBinding == null )
+ {
+ LOGGER.error( "JNDI binding {} is not found in JEE application server {}", jndiBindingName,
+ applicationServer.getName() );
+ throw new KalumetException( "JNDI binding " + jndiBindingName + " is not found in JEE application server "
+ + applicationServer.getName() );
+ }
- // looking for component objects
- LOGGER.debug( "Looking for component objects" );
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer applicationServer =
- environment.getJEEApplicationServers().getJEEApplicationServer(serverName);
- if ( applicationServer == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environment.getName() );
- throw new KalumetException(
- "JEE application server " + serverName + " is not found in environment " + environment.getName() );
- }
- JNDIBinding jndiBinding = applicationServer.getJNDIBinding( jndiBindingName );
- if ( jndiBinding == null )
- {
- LOGGER.error( "JNDI binding {} is not found in JEE application server {}", jndiBindingName,
- applicationServer.getName() );
- throw new KalumetException(
- "JNDI binding " + jndiBindingName + " is not found in JEE application server " + applicationServer.getName() );
- }
+ // post an event
+ EventUtils.post( environment, "INFO",
+ "JNDI binding " + jndiBinding.getName() + " status check requested by WS" );
- // post an event
- EventUtils.post( environment, "INFO", "JNDI binding " + jndiBinding.getName() + " status check requested by WS" );
-
- try
- {
- // get JEE application server controller
- LOGGER.debug( "Getting JEE aplication server controller" );
- JEEApplicationServerController controller =
- JEEApplicationServerControllerFactory.getController(environment, applicationServer);
- // replace JNDI binding data with environment variables.
- LOGGER.debug( "Replaces variables in JNDI binding data" );
- String jndiName = VariableUtils.replace( jndiBinding.getJndiname(), environment.getVariables() );
- String jndiAlias = VariableUtils.replace( jndiBinding.getJndialias(), environment.getVariables() );
- String jndiProviderUrl = VariableUtils.replace( jndiBinding.getProviderurl(), environment.getVariables() );
- // check if the JNDI binding is up to date.
- return controller.isJNDIBindingUpToDate( jndiBinding.getName(), jndiName, jndiAlias, jndiProviderUrl );
+ try
+ {
+ // get JEE application server controller
+ LOGGER.debug( "Getting JEE aplication server controller" );
+ JEEApplicationServerController controller =
+ JEEApplicationServerControllerFactory.getController( environment, applicationServer );
+ // replace JNDI binding data with environment variables.
+ LOGGER.debug( "Replaces variables in JNDI binding data" );
+ String jndiName = VariableUtils.replace( jndiBinding.getJndiname(), environment.getVariables() );
+ String jndiAlias = VariableUtils.replace( jndiBinding.getJndialias(), environment.getVariables() );
+ String jndiProviderUrl = VariableUtils.replace( jndiBinding.getProviderurl(), environment.getVariables() );
+ // check if the JNDI binding is up to date.
+ return controller.isJNDIBindingUpToDate( jndiBinding.getName(), jndiName, jndiAlias, jndiProviderUrl );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "JNDI binding {} status check failed", jndiBinding.getName(), e );
+ throw new KalumetException( "JNDI binding " + jndiBinding.getName() + " status check failed", e );
+ }
}
- catch ( Exception e )
- {
- LOGGER.error( "JNDI binding {} status check failed", jndiBinding.getName(), e );
- throw new KalumetException( "JNDI binding " + jndiBinding.getName() + " status check failed", e );
- }
- }
}
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/SharedLibraryUpdater.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/SharedLibraryUpdater.java
index 85f5d4e..3ad108b 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/SharedLibraryUpdater.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/SharedLibraryUpdater.java
@@ -42,235 +42,240 @@
public class SharedLibraryUpdater
{
- private static final transient Logger LOGGER = LoggerFactory.getLogger( SharedLibraryUpdater.class );
+ private static final transient Logger LOGGER = LoggerFactory.getLogger( SharedLibraryUpdater.class );
- /**
- * Updates a shared library.
- *
- * @param environment the target <code>Environment</code>.
- * @param server the target <code>JEEApplicationServer</code>.
- * @param sharedLibrary the target <code>SharedLibrary</code>.
- * @param updateLog the <code>UpdateLog</code> to use.
- * @throws UpdateException in case of update failure.
- */
- public static void update( Environment environment, JEEApplicationServer server, SharedLibrary sharedLibrary,
- UpdateLog updateLog )
- throws UpdateException
- {
- LOGGER.info( "Updating shared library {}", sharedLibrary.getName() );
+ /**
+ * Updates a shared library.
+ *
+ * @param environment the target <code>Environment</code>.
+ * @param server the target <code>JEEApplicationServer</code>.
+ * @param sharedLibrary the target <code>SharedLibrary</code>.
+ * @param updateLog the <code>UpdateLog</code> to use.
+ * @throws UpdateException in case of update failure.
+ */
+ public static void update( Environment environment, JEEApplicationServer server, SharedLibrary sharedLibrary,
+ UpdateLog updateLog )
+ throws UpdateException
+ {
+ LOGGER.info( "Updating shared library {}", sharedLibrary.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Updating shared library " + sharedLibrary.getName() ) );
- EventUtils.post( environment, "UPDATE", "Updating shared library " + sharedLibrary.getName() );
- if ( !sharedLibrary.isActive() )
- {
- // the shared library is not active
- LOGGER.info( "Shared library {} is inactive, so not updated", sharedLibrary.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Shared library " + sharedLibrary.getName() + " is inactive, so not updated" ) );
- EventUtils.post( environment, "UPDATE",
- "Shared library " + sharedLibrary.getName() + " is inactive, so not updated" );
- return;
- }
- JEEApplicationServerController controller = null;
- try
- {
- // connect JMX controller to JEE application server
- LOGGER.debug( "Connecting to JEE application server {} controller", server.getName() );
- controller = JEEApplicationServerControllerFactory.getController(environment, server);
- }
- catch ( KalumetException e )
- {
- LOGGER.error( "Can't connect to JEE application server {} controller", server.getName(), e );
- throw new UpdateException( "Can't connect to JEE application server " + server.getName() + " controller", e );
- }
- // replaces variables in shared library class path.
- LOGGER.debug( "Replacing variables into the shared library classpath" );
- String mapClasspath = VariableUtils.replace( sharedLibrary.getClasspath(), environment.getVariables() );
- try
- {
- if ( controller.isSharedLibraryDeployed( sharedLibrary.getName() ) )
- {
- // the shared library is already deployed, check for update
- LOGGER.info( "Shared library {} already deployed, checking for update", sharedLibrary.getName() );
- if ( controller.updateSharedLibrary( sharedLibrary.getName(), mapClasspath ) )
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Updating shared library " + sharedLibrary.getName() ) );
+ EventUtils.post( environment, "UPDATE", "Updating shared library " + sharedLibrary.getName() );
+ if ( !sharedLibrary.isActive() )
{
- // the shared library has been updated
- updateLog.setStatus( "Update performed" );
- updateLog.setUpdated( true );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Shared library " + sharedLibrary.getName() + " updated" ) );
- EventUtils.post( environment, "UPDATE", "Shared library " + sharedLibrary.getName() + " updated" );
- LOGGER.info( "Shared library " + sharedLibrary.getName() + " udpated" );
+ // the shared library is not active
+ LOGGER.info( "Shared library {} is inactive, so not updated", sharedLibrary.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Shared library " + sharedLibrary.getName()
+ + " is inactive, so not updated" ) );
+ EventUtils.post( environment, "UPDATE",
+ "Shared library " + sharedLibrary.getName() + " is inactive, so not updated" );
+ return;
}
- }
- else
- {
- // the shared library is not deployed, deploy it
- controller.deploySharedLibrary( sharedLibrary.getName(), mapClasspath );
- updateLog.setStatus( "Update performed" );
- updateLog.setUpdated( true );
+ JEEApplicationServerController controller = null;
+ try
+ {
+ // connect JMX controller to JEE application server
+ LOGGER.debug( "Connecting to JEE application server {} controller", server.getName() );
+ controller = JEEApplicationServerControllerFactory.getController( environment, server );
+ }
+ catch ( KalumetException e )
+ {
+ LOGGER.error( "Can't connect to JEE application server {} controller", server.getName(), e );
+ throw new UpdateException( "Can't connect to JEE application server " + server.getName() + " controller",
+ e );
+ }
+ // replaces variables in shared library class path.
+ LOGGER.debug( "Replacing variables into the shared library classpath" );
+ String mapClasspath = VariableUtils.replace( sharedLibrary.getClasspath(), environment.getVariables() );
+ try
+ {
+ if ( controller.isSharedLibraryDeployed( sharedLibrary.getName() ) )
+ {
+ // the shared library is already deployed, check for update
+ LOGGER.info( "Shared library {} already deployed, checking for update", sharedLibrary.getName() );
+ if ( controller.updateSharedLibrary( sharedLibrary.getName(), mapClasspath ) )
+ {
+ // the shared library has been updated
+ updateLog.setStatus( "Update performed" );
+ updateLog.setUpdated( true );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Shared library " + sharedLibrary.getName() + " updated" ) );
+ EventUtils.post( environment, "UPDATE", "Shared library " + sharedLibrary.getName() + " updated" );
+ LOGGER.info( "Shared library " + sharedLibrary.getName() + " udpated" );
+ }
+ }
+ else
+ {
+ // the shared library is not deployed, deploy it
+ controller.deploySharedLibrary( sharedLibrary.getName(), mapClasspath );
+ updateLog.setStatus( "Update performed" );
+ updateLog.setUpdated( true );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Shared library " + sharedLibrary.getName() + " deployed" ) );
+ EventUtils.post( environment, "UPDATE", "Shared library " + sharedLibrary.getName() + " deployed" );
+ LOGGER.info( "Shared library " + sharedLibrary.getName() + " deployed" );
+ }
+ }
+ catch ( ControllerException exception )
+ {
+ LOGGER.error( "Shared library {} update failed", sharedLibrary.getName(), exception );
+ throw new UpdateException( "Shared library " + sharedLibrary.getName() + " update failed", exception );
+ }
+ }
+
+ /**
+ * Wrapper method to update shared library via WS.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param sharedLibraryName the target shared library name.
+ * @throws KalumetException in case of update failure.
+ */
+ public static void update( String environmentName, String applicationServerName, String sharedLibraryName )
+ throws KalumetException
+ {
+ LOGGER.info( "Shared library {} update requested by WS", sharedLibraryName );
+
+ // load configuration.
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+
+ // looking for component objects.
+ LOGGER.debug( "Looking for component objects" );
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer applicationServer =
+ environment.getJEEApplicationServers().getJEEApplicationServer( applicationServerName );
+ if ( applicationServer == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", applicationServerName,
+ environment.getName() );
+ throw new KalumetException(
+ "JEE application server " + applicationServerName + " is not found in environment "
+ + environment.getName() );
+ }
+ SharedLibrary sharedLibrary = applicationServer.getSharedLibrary( sharedLibraryName );
+ if ( sharedLibrary == null )
+ {
+ LOGGER.error( "Shared library {} is not found in JEE application server {}", sharedLibraryName,
+ applicationServer.getName() );
+ throw new KalumetException(
+ "Shared library " + sharedLibraryName + " is not found in JEE application server "
+ + applicationServer.getName() );
+ }
+
+ // post an event and create update log
+ LOGGER.debug( "Posting an event and creating update log" );
+ EventUtils.post( environment, "UPDATE",
+ "Shared library " + sharedLibrary.getName() + " update requested by WS" );
+ UpdateLog updateLog = new UpdateLog( "Shared library " + sharedLibrary.getName() + " update in progress ...",
+ environment.getName(), environment );
+
+ // send a notification and waiting for the count down
+ LOGGER.info( "Send a notification and waiting for the count down" );
+ NotifierUtils.waitAndNotify( environment );
+
+ try
+ {
+ // call updater
+ LOGGER.debug( "Call shared library updater" );
+ SharedLibraryUpdater.update( environment, applicationServer, sharedLibrary, updateLog );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Shared library {} update failed", sharedLibrary.getName(), e );
+ EventUtils.post( environment, "ERROR",
+ "Shared library " + sharedLibrary.getName() + " update failed: " + e.getMessage() );
+ updateLog.setStatus( "Shared library " + sharedLibrary.getName() + " update failed" );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "Shared library " + sharedLibrary.getName()
+ + " update failed: " + e.getMessage() ) );
+ PublisherUtils.publish( environment );
+ throw new UpdateException( "Shared library " + sharedLibrary.getName() + " update failed", e );
+ }
+
+ // update completed.
+ LOGGER.info( "Shared library {} updated", sharedLibrary.getName() );
+ if ( updateLog.isUpdated() )
+ {
+ updateLog.setStatus( "Shared library " + sharedLibrary.getName() + " updated" );
+ }
+ else
+ {
+ updateLog.setStatus( "Shared library " + sharedLibrary.getName() + " already up to date" );
+ }
updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Shared library " + sharedLibrary.getName() + " deployed" ) );
- EventUtils.post( environment, "UPDATE", "Shared library " + sharedLibrary.getName() + " deployed" );
- LOGGER.info( "Shared library " + sharedLibrary.getName() + " deployed" );
- }
- }
- catch ( ControllerException exception )
- {
- LOGGER.error( "Shared library {} update failed", sharedLibrary.getName(), exception );
- throw new UpdateException( "Shared library " + sharedLibrary.getName() + " update failed", exception );
- }
- }
-
- /**
- * Wrapper method to update shared library via WS.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param sharedLibraryName the target shared library name.
- * @throws KalumetException in case of update failure.
- */
- public static void update( String environmentName, String applicationServerName, String sharedLibraryName )
- throws KalumetException
- {
- LOGGER.info( "Shared library {} update requested by WS", sharedLibraryName );
-
- // load configuration.
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
-
- // looking for component objects.
- LOGGER.debug( "Looking for component objects" );
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer applicationServer =
- environment.getJEEApplicationServers().getJEEApplicationServer(applicationServerName);
- if ( applicationServer == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", applicationServerName,
- environment.getName() );
- throw new KalumetException(
- "JEE application server " + applicationServerName + " is not found in environment " + environment.getName() );
- }
- SharedLibrary sharedLibrary = applicationServer.getSharedLibrary( sharedLibraryName );
- if ( sharedLibrary == null )
- {
- LOGGER.error( "Shared library {} is not found in JEE application server {}", sharedLibraryName,
- applicationServer.getName() );
- throw new KalumetException( "Shared library " + sharedLibraryName + " is not found in JEE application server "
- + applicationServer.getName() );
+ new UpdateMessage( "info", "Shared library " + sharedLibrary.getName() + " updated" ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
}
- // post an event and create update log
- LOGGER.debug( "Posting an event and creating update log" );
- EventUtils.post( environment, "UPDATE", "Shared library " + sharedLibrary.getName() + " update requested by WS" );
- UpdateLog updateLog =
- new UpdateLog( "Shared library " + sharedLibrary.getName() + " update in progress ...", environment.getName(),
- environment );
+ /**
+ * Check if a shared library is up to date or not via WS.
+ *
+ * @param environmentName the target environment name.
+ * @param serverName the target JEE application server name.
+ * @param sharedLibraryName the target shared library name.
+ * @return true if the shared library is up to date, false else.
+ * @throws KalumetException in case of check failure.
+ */
+ public static boolean check( String environmentName, String serverName, String sharedLibraryName )
+ throws KalumetException
+ {
+ LOGGER.info( "Shared library {} status check requested by WS", sharedLibraryName );
- // send a notification and waiting for the count down
- LOGGER.info( "Send a notification and waiting for the count down" );
- NotifierUtils.waitAndNotify( environment );
+ // load configuration
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- try
- {
- // call updater
- LOGGER.debug( "Call shared library updater" );
- SharedLibraryUpdater.update( environment, applicationServer, sharedLibrary, updateLog );
- }
- catch ( Exception e )
- {
- LOGGER.error( "Shared library {} update failed", sharedLibrary.getName(), e );
- EventUtils.post( environment, "ERROR",
- "Shared library " + sharedLibrary.getName() + " update failed: " + e.getMessage() );
- updateLog.setStatus( "Shared library " + sharedLibrary.getName() + " update failed" );
- updateLog.addUpdateMessage( new UpdateMessage( "error",
- "Shared library " + sharedLibrary.getName() + " update failed: "
- + e.getMessage() ) );
- PublisherUtils.publish( environment );
- throw new UpdateException( "Shared library " + sharedLibrary.getName() + " update failed", e );
- }
+ // looking for component objects
+ LOGGER.debug( "Looking for component objects" );
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer applicationServer =
+ environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
+ if ( applicationServer == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", serverName,
+ environment.getName() );
+ throw new KalumetException(
+ "JEE application server " + serverName + " is not found in environment " + environment.getName() );
+ }
+ SharedLibrary sharedLibrary = applicationServer.getSharedLibrary( sharedLibraryName );
+ if ( sharedLibrary == null )
+ {
+ LOGGER.error( "Shared library {} is not found in JEE application server {}", sharedLibraryName,
+ applicationServer.getName() );
+ throw new KalumetException(
+ "Shared library " + sharedLibraryName + " is not found in JEE application server "
+ + applicationServer.getName() );
+ }
- // update completed.
- LOGGER.info( "Shared library {} updated", sharedLibrary.getName() );
- if ( updateLog.isUpdated() )
- {
- updateLog.setStatus( "Shared library " + sharedLibrary.getName() + " updated" );
+ try
+ {
+ // get JEE application server controller
+ LOGGER.debug( "Getting JEE application server controller" );
+ JEEApplicationServerController controller =
+ JEEApplicationServerControllerFactory.getController( environment, applicationServer );
+ // replaces variables in shared library class path.
+ LOGGER.debug( "Replacing variables into the shared library classpath" );
+ String classpath = VariableUtils.replace( sharedLibrary.getClasspath(), environment.getVariables() );
+ // check shared library using controller.
+ LOGGER.debug( "Checking status of the shared library using controller" );
+ return controller.isSharedLibraryUpToDate( sharedLibrary.getName(), classpath );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Shared library {} status check failed", sharedLibrary.getName(), e );
+ throw new KalumetException( "Shared library " + sharedLibrary.getName() + " status check failed", e );
+ }
}
- else
- {
- updateLog.setStatus( "Shared library " + sharedLibrary.getName() + " already up to date" );
- }
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Shared library " + sharedLibrary.getName() + " updated" ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
- }
-
- /**
- * Check if a shared library is up to date or not via WS.
- *
- * @param environmentName the target environment name.
- * @param serverName the target JEE application server name.
- * @param sharedLibraryName the target shared library name.
- * @return true if the shared library is up to date, false else.
- * @throws KalumetException in case of check failure.
- */
- public static boolean check( String environmentName, String serverName, String sharedLibraryName )
- throws KalumetException
- {
- LOGGER.info( "Shared library {} status check requested by WS", sharedLibraryName );
-
- // load configuration
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
-
- // looking for component objects
- LOGGER.debug( "Looking for component objects" );
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer applicationServer =
- environment.getJEEApplicationServers().getJEEApplicationServer(serverName);
- if ( applicationServer == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environment.getName() );
- throw new KalumetException(
- "JEE application server " + serverName + " is not found in environment " + environment.getName() );
- }
- SharedLibrary sharedLibrary = applicationServer.getSharedLibrary( sharedLibraryName );
- if ( sharedLibrary == null )
- {
- LOGGER.error( "Shared library {} is not found in JEE application server {}", sharedLibraryName,
- applicationServer.getName() );
- throw new KalumetException( "Shared library " + sharedLibraryName + " is not found in JEE application server "
- + applicationServer.getName() );
- }
-
- try
- {
- // get JEE application server controller
- LOGGER.debug( "Getting JEE application server controller" );
- JEEApplicationServerController controller =
- JEEApplicationServerControllerFactory.getController(environment, applicationServer);
- // replaces variables in shared library class path.
- LOGGER.debug( "Replacing variables into the shared library classpath" );
- String classpath = VariableUtils.replace( sharedLibrary.getClasspath(), environment.getVariables() );
- // check shared library using controller.
- LOGGER.debug( "Checking status of the shared library using controller" );
- return controller.isSharedLibraryUpToDate( sharedLibrary.getName(), classpath );
- }
- catch ( Exception e )
- {
- LOGGER.error( "Shared library {} status check failed", sharedLibrary.getName(), e );
- throw new KalumetException( "Shared library " + sharedLibrary.getName() + " status check failed", e );
- }
- }
}
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/SoftwareUpdater.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/SoftwareUpdater.java
index 9d8ebd1..ca477ab 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/SoftwareUpdater.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/SoftwareUpdater.java
@@ -24,8 +24,18 @@
import org.apache.kalumet.KalumetException;
import org.apache.kalumet.agent.Configuration;
import org.apache.kalumet.agent.utils.EventUtils;
-import org.apache.kalumet.model.*;
+import org.apache.kalumet.model.Agent;
+import org.apache.kalumet.model.Command;
+import org.apache.kalumet.model.ConfigurationFile;
+import org.apache.kalumet.model.Database;
+import org.apache.kalumet.model.Environment;
+import org.apache.kalumet.model.JDBCConnectionPool;
import org.apache.kalumet.model.JEEApplicationServer;
+import org.apache.kalumet.model.Kalumet;
+import org.apache.kalumet.model.Location;
+import org.apache.kalumet.model.Mapping;
+import org.apache.kalumet.model.Software;
+import org.apache.kalumet.model.SqlScript;
import org.apache.kalumet.model.update.UpdateLog;
import org.apache.kalumet.model.update.UpdateMessage;
import org.apache.kalumet.utils.CommandUtils;
@@ -46,1362 +56,1393 @@
public class SoftwareUpdater
{
- private static final transient Logger LOGGER = LoggerFactory.getLogger( SoftwareUpdater.class );
+ private static final transient Logger LOGGER = LoggerFactory.getLogger( SoftwareUpdater.class );
- /**
- * Updates a software.
- *
- * @param environment the target <code>Environment</code>.
- * @param software the target <code>Software</code>.
- * @param updateLog the <code>UpdateLog</code> to use.
- */
- public static void update( Environment environment, Software software, UpdateLog updateLog )
- throws UpdateException
- {
- LOGGER.info( "Updating software {}", software.getName() );
-
- if ( !software.isActive() )
+ /**
+ * Updates a software.
+ *
+ * @param environment the target <code>Environment</code>.
+ * @param software the target <code>Software</code>.
+ * @param updateLog the <code>UpdateLog</code> to use.
+ */
+ public static void update( Environment environment, Software software, UpdateLog updateLog )
+ throws UpdateException
{
- LOGGER.info( "Software {} is inactive, so not updated", software.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Software " + software.getName() + " is inactive, so not updated" ) );
- EventUtils.post( environment, "UPDATE", "Software " + software.getName() + " is inactive, so not updated" );
- return;
+ LOGGER.info( "Updating software {}", software.getName() );
+
+ if ( !software.isActive() )
+ {
+ LOGGER.info( "Software {} is inactive, so not updated", software.getName() );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Software " + software.getName() + " is inactive, so not updated" ) );
+ EventUtils.post( environment, "UPDATE", "Software " + software.getName() + " is inactive, so not updated" );
+ return;
+ }
+
+ if ( software.getAgent() != null && software.getAgent().trim().length() > 0 && !software.getAgent().equals(
+ Configuration.AGENT_ID ) )
+ {
+ LOGGER.info( "Delegating software {} update to agent {}", software.getName(), software.getAgent() );
+ EventUtils.post( environment, "UPDATE",
+ "Delegating software " + software.getName() + " update to agent " + software.getAgent() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Delegating software " + software.getName()
+ + " update to agent " + software.getAgent() ) );
+ Agent delegationAgent = Configuration.CONFIG_CACHE.getAgent( software.getAgent() );
+ if ( delegationAgent == null )
+ {
+ LOGGER.error( "Agent {} is not found in the configuration", software.getAgent() );
+ throw new UpdateException( "Agent " + software.getAgent() + " is not found in the configuration" );
+ }
+ try
+ {
+ LOGGER.debug( "Call software WS" );
+ SoftwareClient client = new SoftwareClient( delegationAgent.getHostname(), delegationAgent.getPort() );
+ client.update( environment.getName(), software.getName(), true );
+ }
+ catch ( ClientException clientException )
+ {
+ LOGGER.error( "Software {} update failed", software.getName(), clientException );
+ throw new UpdateException( "Software " + software.getName() + " update failed", clientException );
+ }
+ return;
+ }
+
+ // add an update message
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Updating software " + software.getName() ) );
+ // post an event
+ EventUtils.post( environment, "UPDATE", "Updating software " + software.getName() );
+
+ // iterate in the software update plan
+ for ( Iterator updatePlanIterator = software.getUpdatePlan().iterator(); updatePlanIterator.hasNext(); )
+ {
+ Object item = updatePlanIterator.next();
+
+ // command update
+ if ( item instanceof Command )
+ {
+ Command command = (Command) item;
+ try
+ {
+ SoftwareUpdater.executeCommand( environment, software, command, updateLog );
+ }
+ catch ( Exception e )
+ {
+ if ( command.isBlocker() )
+ {
+ LOGGER.error( "Command {} execution failed", command.getName(), e );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "Command " + command.getName()
+ + " execution failed: " + e.getMessage() ) );
+ EventUtils.post( environment, "ERROR",
+ "Command " + command.getName() + " execution failed: " + e.getMessage() );
+ throw new UpdateException( "Command " + command.getName() + " execution failed", e );
+ }
+ else
+ {
+ LOGGER.warn( "Command {} execution failed", command.getName(), e );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn", "Command " + command.getName()
+ + " execution failed: " + e.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Command " + command.getName()
+ + " is not an update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN",
+ "Command " + command.getName() + " execution failed: " + e.getMessage() );
+ EventUtils.post( environment, "UPDATE", "Command " + command.getName()
+ + " is not an update blocker, update continues" );
+ }
+ }
+ }
+
+ // location update
+ if ( item instanceof Location )
+ {
+ Location location = (Location) item;
+ try
+ {
+ SoftwareUpdater.updateLocation( environment, software, location, updateLog );
+ }
+ catch ( Exception e )
+ {
+ if ( location.isBlocker() )
+ {
+ LOGGER.error( "Location {} update failed", location.getName(), e );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "Location " + location.getName()
+ + " update failed: " + e.getMessage() ) );
+ EventUtils.post( environment, "ERROR",
+ "Location " + location.getName() + " update failed: " + e.getMessage() );
+ throw new UpdateException( "Location " + location.getName() + " update failed", e );
+ }
+ else
+ {
+ LOGGER.warn( "Location " + location.getName() + " update failed", e );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn", "Location " + location.getName()
+ + " update failed: " + e.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Location " + location.getName()
+ + " is not an update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN",
+ "Location " + location.getName() + " execution failed: " + e.getMessage() );
+ EventUtils.post( environment, "UPDATE", "Location " + location.getName()
+ + " is not an update blocker, update continues" );
+ }
+ }
+ }
+
+ // configuration update
+ if ( item instanceof ConfigurationFile )
+ {
+ ConfigurationFile configurationFile = (ConfigurationFile) item;
+ try
+ {
+ SoftwareUpdater.updateConfigurationFile( environment, software, configurationFile, updateLog );
+ }
+ catch ( Exception e )
+ {
+ if ( configurationFile.isBlocker() )
+ {
+ LOGGER.error( "Configuration file {} update failed", configurationFile.getName(), e );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "Configuration file "
+ + configurationFile.getName() + " update failed: " + e.getMessage() ) );
+ EventUtils.post( environment, "ERROR",
+ "Configuration file " + configurationFile.getName() + " update failed: "
+ + e.getMessage() );
+ throw new UpdateException(
+ "Configuration file " + configurationFile.getName() + " update failed", e );
+ }
+ else
+ {
+ LOGGER.warn( "Configuration file {} update failed", configurationFile.getName(), e );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn", "Configuration file "
+ + configurationFile.getName() + " update failed: " + e.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Configuration file "
+ + configurationFile.getName() + " is not an update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN",
+ "Configuration file " + configurationFile.getName() + " update failed: "
+ + e.getMessage() );
+ EventUtils.post( environment, "UPDATE", "Configuration file " + configurationFile.getName()
+ + " is not an update blocker, update continues" );
+ }
+ }
+ }
+
+ // database update
+ if ( item instanceof Database )
+ {
+ Database database = (Database) item;
+ try
+ {
+ SoftwareUpdater.updateDatabase( environment, software, database, updateLog );
+ }
+ catch ( Exception e )
+ {
+ if ( database.isBlocker() )
+ {
+ LOGGER.error( "Database {} update failed", database.getName(), e );
+ updateLog.addUpdateMessage( new UpdateMessage( "error", "Database " + database.getName()
+ + " update failed: " + e.getMessage() ) );
+ EventUtils.post( environment, "ERROR",
+ "Database " + database.getName() + " update failed: " + e.getMessage() );
+ throw new UpdateException( "Database " + database.getName() + " update failed", e );
+ }
+ else
+ {
+ LOGGER.warn( "Database {} update failed", database.getName(), e );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn", "Database " + database.getName()
+ + " update failed: " + e.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Database " + database.getName()
+ + " is not an update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN",
+ "Database " + database.getName() + " update failed: " + e.getMessage() );
+ EventUtils.post( environment, "UPDATE", "Database " + database.getName()
+ + " is not an update blocker, update continues" );
+ }
+ }
+ }
+ }
}
- if ( software.getAgent() != null && software.getAgent().trim().length() > 0 && !software.getAgent().equals(
- Configuration.AGENT_ID ) )
+ /**
+ * Wrapper method to update a software (via WebService).
+ *
+ * @param environmentName the target environment name.
+ * @param softwareName the target software name.
+ * @param delegation flag indicating if the update is a delegation from another agent (true), or a client call (false).
+ */
+ public static void update( String environmentName, String softwareName, boolean delegation )
+ throws KalumetException
{
- LOGGER.info( "Delegating software {} update to agent {}", software.getName(), software.getAgent() );
- EventUtils.post( environment, "UPDATE",
- "Delegating software " + software.getName() + " update to agent " + software.getAgent() );
- updateLog.addUpdateMessage( new UpdateMessage( "info",
- "Delegating software " + software.getName() + " update to agent "
- + software.getAgent() ) );
- Agent delegationAgent = Configuration.CONFIG_CACHE.getAgent( software.getAgent() );
- if ( delegationAgent == null )
- {
- LOGGER.error( "Agent {} is not found in the configuration", software.getAgent() );
- throw new UpdateException( "Agent " + software.getAgent() + " is not found in the configuration" );
- }
- try
- {
- LOGGER.debug( "Call software WS" );
- SoftwareClient client = new SoftwareClient( delegationAgent.getHostname(), delegationAgent.getPort() );
- client.update( environment.getName(), software.getName(), true );
- }
- catch ( ClientException clientException )
- {
- LOGGER.error( "Software {} update failed", software.getName(), clientException );
- throw new UpdateException( "Software " + software.getName() + " update failed", clientException );
- }
- return;
- }
+ LOGGER.info( "Software {} update requested by WS", softwareName );
- // add an update message
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Updating software " + software.getName() ) );
- // post an event
- EventUtils.post( environment, "UPDATE", "Updating software " + software.getName() );
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- // iterate in the software update plan
- for ( Iterator updatePlanIterator = software.getUpdatePlan().iterator(); updatePlanIterator.hasNext(); )
- {
- Object item = updatePlanIterator.next();
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ Software software = environment.getSoftware( softwareName );
+ if ( software == null )
+ {
+ LOGGER.error( "Software {} is not found in environment {}", softwareName, environment.getName() );
+ throw new KalumetException(
+ "Software " + softwareName + " is not found in environment " + environment.getName() );
+ }
- // command update
- if ( item instanceof Command )
- {
- Command command = (Command) item;
+ LOGGER.debug( "Creating an update log" );
+ UpdateLog updateLog =
+ new UpdateLog( "Software " + software.getName() + " update in progress ...", environment.getName(),
+ environment );
+ EventUtils.post( environment, "UPDATE", "Software " + software.getName() + " update requested by WS" );
+
+ if ( !delegation )
+ {
+ LOGGER.info( "Send a notification and waiting for the count down" );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Send a notification and waiting for the count down" ) );
+ EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
+ NotifierUtils.waitAndNotify( environment );
+ }
try
{
- SoftwareUpdater.executeCommand( environment, software, command, updateLog );
+ LOGGER.debug( "Call the software updater" );
+ SoftwareUpdater.update( environment, software, updateLog );
}
catch ( Exception e )
{
- if ( command.isBlocker() )
- {
+ LOGGER.error( "Software {} update failed", software.getName(), e );
+ EventUtils.post( environment, "ERROR",
+ "Software " + software.getName() + " update failed: " + e.getMessage() );
+ if ( !delegation )
+ {
+ updateLog.setStatus( "Software " + software.getName() + " update failed" );
+ updateLog.addUpdateMessage( new UpdateMessage( "error",
+ "Software " + software.getName() + " update failed: "
+ + e.getMessage() ) );
+ PublisherUtils.publish( environment );
+ }
+ throw new KalumetException( "Software " + software.getName() + " update failed", e );
+ }
+
+ LOGGER.info( "Software {} updated", software.getName() );
+ EventUtils.post( environment, "UPDATE", "Software " + software.getName() + " updated" );
+ if ( !delegation )
+ {
+ LOGGER.debug( "The update is a client call, publish result" );
+ EventUtils.post( environment, "UPDATE", "Update completed" );
+ if ( updateLog.isUpdated() )
+ {
+ updateLog.setStatus( "Software " + software.getName() + " updated" );
+ }
+ else
+ {
+ updateLog.setStatus( "Software " + software.getName() + " already up to date" );
+ }
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Update completed" ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
+ }
+ }
+
+ /**
+ * Execute a software command.
+ *
+ * @param environment the target environment.
+ * @param software the target software.
+ * @param command the target command.
+ * @param updateLog the <code>UpdateLog</code> to use.
+ * @throws UpdateException in case of error during the command execution.
+ */
+ public static void executeCommand( Environment environment, Software software, Command command,
+ UpdateLog updateLog )
+ throws UpdateException
+ {
+ LOGGER.info( "Executing software {} command {}", software.getName(), command.getName() );
+
+ if ( !command.isActive() )
+ {
+ LOGGER.info( "Software {} command {} is inactive, so not executed", software.getName(), command.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Software " + software.getName() + " command "
+ + command.getName() + " is inactive, so not executed" ) );
+ EventUtils.post( environment, "UPDATE", "Software " + software.getName() + " command " + command.getName()
+ + " is inactive, so not executed" );
+ return;
+ }
+
+ if ( command.getAgent() != null && command.getAgent().trim().length() > 0 && !command.getAgent().equals(
+ Configuration.AGENT_ID ) )
+ {
+ // delegates the command execution to another agent
+ LOGGER.info( "Delegating command {} execution to agent {}", command.getName(), command.getAgent() );
+ Agent agentDelegation = Configuration.CONFIG_CACHE.getAgent( command.getAgent() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Delegating command " + command.getName()
+ + " execution to agent " + command.getAgent() ) );
+ EventUtils.post( environment, "UPDATE",
+ "Delegating command " + command.getName() + " execution to agent " + command );
+ if ( agentDelegation == null )
+ {
+ LOGGER.error( "Agent {} is not found in the configuration", command.getAgent() );
+ throw new UpdateException( "Agent " + command.getAgent() + " is not found in the configuration" );
+ }
+ try
+ {
+ LOGGER.debug( "Call software WS" );
+ SoftwareClient client = new SoftwareClient( agentDelegation.getHostname(), agentDelegation.getPort() );
+ client.executeCommand( environment.getName(), software.getName(), command.getName(), true );
+ }
+ catch ( ClientException clientException )
+ {
+ LOGGER.error( "Command {} execution failed", command.getName(), clientException );
+ throw new UpdateException(
+ "Command " + command.getName() + " execution failed: " + clientException.getMessage(),
+ clientException );
+ }
+ return;
+ }
+
+ String commandExec = VariableUtils.replace( command.getCommand(), environment.getVariables() );
+ String output = null;
+ try
+ {
+ output = CommandUtils.execute( commandExec );
+ }
+ catch ( KalumetException kalumetException )
+ {
+ LOGGER.error( "Command {} execution failed", command.getName(), kalumetException );
+ throw new UpdateException( "Command " + command.getName() + " execution failed", kalumetException );
+ }
+
+ LOGGER.info( "Software {} command {} executed: {}",
+ new Object[]{ software.getName(), command.getName(), output } );
+ // add an update message
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Software " + software.getName() + " command "
+ + command.getName() + " executed: " + output ) );
+ // post an event
+ EventUtils.post( environment, "UPDATE",
+ "Software " + software.getName() + " command " + command.getName() + " executed: " + output );
+ }
+
+ /**
+ * Wrapper method to execute a software command (via WS).
+ *
+ * @param environmentName the target environment name.
+ * @param softwareName the target software name.
+ * @param commandName the target command name.
+ * @param delegation flag indicating if the execution is a delegation from another agent (true), or a client call (false).
+ */
+ public static void executeCommand( String environmentName, String softwareName, String commandName,
+ boolean delegation )
+ throws KalumetException
+ {
+ LOGGER.info( "Software {} command {} execution requested by WS", softwareName, commandName );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ Software software = environment.getSoftware( softwareName );
+ if ( software == null )
+ {
+ LOGGER.error( "Software {} is not found in environment {}", softwareName, environmentName );
+ throw new KalumetException(
+ "Software " + softwareName + " is not found in environment " + environmentName );
+ }
+ Command command = software.getCommand( commandName );
+ if ( command == null )
+ {
+ LOGGER.error( "Command {} is not found in software {}", commandName, softwareName );
+ throw new KalumetException( "Command " + commandName + " is not found in software " + softwareName );
+ }
+ // update the agent configuration cache
+ LOGGER.debug( "Updating agent configuration cache" );
+ Configuration.CONFIG_CACHE = kalumet;
+ // post a journal event
+ EventUtils.post( environment, "UPDATE",
+ "Software " + softwareName + " command " + commandName + " execution requested by WS" );
+ // create an update logger
+ UpdateLog updateLog =
+ new UpdateLog( "Software " + softwareName + " command " + commandName + " execution in progress ...",
+ environment.getName(), environment );
+ if ( !delegation )
+ {
+ // the call is not a delegation from another agent
+ LOGGER.info( "Send a notification and waiting for the count down" );
+ EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
+ NotifierUtils.waitAndNotify( environment );
+ }
+ try
+ {
+ // call the updater
+ LOGGER.debug( "Call the software updater" );
+ SoftwareUpdater.executeCommand( environment, software, command, updateLog );
+ }
+ catch ( Exception e )
+ {
LOGGER.error( "Command {} execution failed", command.getName(), e );
- updateLog.addUpdateMessage(
- new UpdateMessage( "error", "Command " + command.getName() + " execution failed: " + e.getMessage() ) );
EventUtils.post( environment, "ERROR",
"Command " + command.getName() + " execution failed: " + e.getMessage() );
+ if ( !delegation )
+ {
+ updateLog.setStatus( "Command " + command.getName() + " execution failed" );
+ updateLog.addUpdateMessage( new UpdateMessage( "error",
+ "Command " + command.getName() + " execution failed: "
+ + e.getMessage() ) );
+ PublisherUtils.publish( environment );
+ }
throw new UpdateException( "Command " + command.getName() + " execution failed", e );
- }
- else
- {
- LOGGER.warn( "Command {} execution failed", command.getName(), e );
- updateLog.addUpdateMessage(
- new UpdateMessage( "warn", "Command " + command.getName() + " execution failed: " + e.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Command " + command.getName()
- + " is not an update blocker, update continues" ) );
- EventUtils.post( environment, "WARN",
- "Command " + command.getName() + " execution failed: " + e.getMessage() );
- EventUtils.post( environment, "UPDATE",
- "Command " + command.getName() + " is not an update blocker, update continues" );
- }
}
- }
- // location update
- if ( item instanceof Location )
- {
- Location location = (Location) item;
+ // command execution is completed
+ LOGGER.info( "Command {} has been executed successfully", command.getName() );
+ EventUtils.post( environment, "UPDATE", "Command " + command.getName() + " has been executed successfully" );
+ if ( !delegation )
+ {
+ updateLog.setStatus( "Command " + command.getName() + " has been executed successfully" );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Command " + command.getName() + " has been executed successfully" ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
+ }
+ }
+
+ /**
+ * Wrapper method to update a location (via WS).
+ *
+ * @param environmentName the target environment name.
+ * @param softwareName the target software name.
+ * @param locationName the target location name.
+ * @param delegation true if the call is performed by another agent, false else.
+ * @throws UpdateException in case of location update failure.
+ */
+ public static void updateLocation( String environmentName, String softwareName, String locationName,
+ boolean delegation )
+ throws KalumetException
+ {
+ LOGGER.info( "Software {} location {} update requested by WS", softwareName, locationName );
+
+ // loading configuration
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ Software software = environment.getSoftware( softwareName );
+ if ( software == null )
+ {
+ LOGGER.error( "Software {} is not found in environment {}", softwareName, environmentName );
+ throw new KalumetException(
+ "Software " + softwareName + " is not found in environment " + environmentName );
+ }
+ Location location = software.getLocation( locationName );
+ if ( location == null )
+ {
+ LOGGER.error( "Location {} is not found in software {}", locationName, softwareName );
+ throw new KalumetException( "Location " + locationName + " is not found in software " + softwareName );
+ }
+
+ // update configuration cache
+ LOGGER.debug( "Updating configuration cache" );
+ Configuration.CONFIG_CACHE = kalumet;
+
+ // post journal event
+ EventUtils.post( environment, "UPDATE", "Software " + software.getName() + " location " + location.getName()
+ + " update requested by WS" );
+ // create an update logger
+ UpdateLog updateLog = new UpdateLog(
+ "Software " + software.getName() + " location " + location.getName() + " update in progress ....",
+ environment.getName(), environment );
+
+ if ( !delegation )
+ {
+ // the call is not a delegation from another agent, it's an atomic update
+ LOGGER.info( "Send a notification and waiting for the count down" );
+ EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
+ NotifierUtils.waitAndNotify( environment );
+ }
try
{
- SoftwareUpdater.updateLocation( environment, software, location, updateLog );
+ // call software updater
+ LOGGER.debug( "Call software updater" );
+ SoftwareUpdater.updateLocation( environment, software, location, updateLog );
}
catch ( Exception e )
{
- if ( location.isBlocker() )
- {
LOGGER.error( "Location {} update failed", location.getName(), e );
- updateLog.addUpdateMessage(
- new UpdateMessage( "error", "Location " + location.getName() + " update failed: " + e.getMessage() ) );
EventUtils.post( environment, "ERROR",
"Location " + location.getName() + " update failed: " + e.getMessage() );
+ if ( !delegation )
+ {
+ updateLog.setStatus( "Location " + locationName + " update failed" );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "error", "Location " + locationName + " update failed: " + e.getMessage() ) );
+ PublisherUtils.publish( environment );
+ }
throw new UpdateException( "Location " + location.getName() + " update failed", e );
- }
- else
- {
- LOGGER.warn( "Location " + location.getName() + " update failed", e );
- updateLog.addUpdateMessage(
- new UpdateMessage( "warn", "Location " + location.getName() + " update failed: " + e.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Location " + location.getName()
- + " is not an update blocker, update continues" ) );
- EventUtils.post( environment, "WARN",
- "Location " + location.getName() + " execution failed: " + e.getMessage() );
+ }
+
+ // location updated
+ LOGGER.info( "Location {} updated", location.getName() );
+ EventUtils.post( environment, "UPDATE", "Location " + location.getName() + " updated" );
+ if ( !delegation )
+ {
+ updateLog.setStatus( "Location " + location.getName() + " updated" );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Location " + location.getName() + " updated" ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
+ }
+ }
+
+ /**
+ * Updates an <code>Software</code> <code>Location</code>.
+ *
+ * @param environment the target <code>Environment</code>.
+ * @param software the target <code>Software</code>.
+ * @param location the target <code>Location</code>.
+ * @param updateLog the <code>UpdateLog</code> to use.
+ * @throws UpdateException in case of error during the location update.
+ */
+ public static void updateLocation( Environment environment, Software software, Location location,
+ UpdateLog updateLog )
+ throws UpdateException
+ {
+ LOGGER.info( "Updating software {} location {}", software.getName(), location.getName() );
+
+ if ( !location.isActive() )
+ {
+ LOGGER.info( "Software {} location {} is inactive, so not updated", software.getName(),
+ location.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Software " + software.getName() + " location "
+ + location.getName() + " is inactive, so not updated" ) );
+ EventUtils.post( environment, "UPDATE", "Software " + software.getName() + " location " + location.getName()
+ + "is inactive, so not updated" );
+ return;
+ }
+
+ if ( location.getAgent() != null && location.getAgent().trim().length() > 0 && !location.getAgent().equals(
+ Configuration.AGENT_ID ) )
+ {
+ // delegates the location update to another agent
+ LOGGER.info( "Delegating location {} update to agent {}", location.getName(), location.getAgent() );
+ Agent agentDelegation = Configuration.CONFIG_CACHE.getAgent( location.getAgent() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Delegating location " + location.getName()
+ + " update to agent " + location.getAgent() ) );
EventUtils.post( environment, "UPDATE",
- "Location " + location.getName() + " is not an update blocker, update continues" );
- }
- }
- }
-
- // configuration update
- if ( item instanceof ConfigurationFile )
- {
- ConfigurationFile configurationFile = (ConfigurationFile) item;
- try
- {
- SoftwareUpdater.updateConfigurationFile( environment, software, configurationFile, updateLog );
- }
- catch ( Exception e )
- {
- if ( configurationFile.isBlocker() )
- {
- LOGGER.error( "Configuration file {} update failed", configurationFile.getName(), e );
- updateLog.addUpdateMessage( new UpdateMessage( "error", "Configuration file " + configurationFile.getName()
- + " update failed: " + e.getMessage() ) );
- EventUtils.post( environment, "ERROR",
- "Configuration file " + configurationFile.getName() + " update failed: "
- + e.getMessage() );
- throw new UpdateException( "Configuration file " + configurationFile.getName() + " update failed", e );
- }
- else
- {
- LOGGER.warn( "Configuration file {} update failed", configurationFile.getName(), e );
- updateLog.addUpdateMessage( new UpdateMessage( "warn", "Configuration file " + configurationFile.getName()
- + " update failed: " + e.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Configuration file " + configurationFile.getName()
- + " is not an update blocker, update continues" ) );
- EventUtils.post( environment, "WARN",
- "Configuration file " + configurationFile.getName() + " update failed: "
- + e.getMessage() );
- EventUtils.post( environment, "UPDATE", "Configuration file " + configurationFile.getName()
- + " is not an update blocker, update continues" );
- }
- }
- }
-
- // database update
- if ( item instanceof Database )
- {
- Database database = (Database) item;
- try
- {
- SoftwareUpdater.updateDatabase( environment, software, database, updateLog );
- }
- catch ( Exception e )
- {
- if ( database.isBlocker() )
- {
- LOGGER.error( "Database {} update failed", database.getName(), e );
- updateLog.addUpdateMessage(
- new UpdateMessage( "error", "Database " + database.getName() + " update failed: " + e.getMessage() ) );
- EventUtils.post( environment, "ERROR",
- "Database " + database.getName() + " update failed: " + e.getMessage() );
- throw new UpdateException( "Database " + database.getName() + " update failed", e );
- }
- else
- {
- LOGGER.warn( "Database {} update failed", database.getName(), e );
- updateLog.addUpdateMessage(
- new UpdateMessage( "warn", "Database " + database.getName() + " update failed: " + e.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Database " + database.getName()
- + " is not an update blocker, update continues" ) );
- EventUtils.post( environment, "WARN",
- "Database " + database.getName() + " update failed: " + e.getMessage() );
- EventUtils.post( environment, "UPDATE",
- "Database " + database.getName() + " is not an update blocker, update continues" );
- }
- }
- }
- }
- }
-
- /**
- * Wrapper method to update a software (via WebService).
- *
- * @param environmentName the target environment name.
- * @param softwareName the target software name.
- * @param delegation flag indicating if the update is a delegation from another agent (true), or a client call (false).
- */
- public static void update( String environmentName, String softwareName, boolean delegation )
- throws KalumetException
- {
- LOGGER.info( "Software {} update requested by WS", softwareName );
-
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
-
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- Software software = environment.getSoftware( softwareName );
- if ( software == null )
- {
- LOGGER.error( "Software {} is not found in environment {}", softwareName, environment.getName() );
- throw new KalumetException(
- "Software " + softwareName + " is not found in environment " + environment.getName() );
- }
-
- LOGGER.debug( "Creating an update log" );
- UpdateLog updateLog =
- new UpdateLog( "Software " + software.getName() + " update in progress ...", environment.getName(), environment );
- EventUtils.post( environment, "UPDATE", "Software " + software.getName() + " update requested by WS" );
-
- if ( !delegation )
- {
- LOGGER.info( "Send a notification and waiting for the count down" );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Send a notification and waiting for the count down" ) );
- EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
- NotifierUtils.waitAndNotify( environment );
- }
- try
- {
- LOGGER.debug( "Call the software updater" );
- SoftwareUpdater.update( environment, software, updateLog );
- }
- catch ( Exception e )
- {
- LOGGER.error( "Software {} update failed", software.getName(), e );
- EventUtils.post( environment, "ERROR", "Software " + software.getName() + " update failed: " + e.getMessage() );
- if ( !delegation )
- {
- updateLog.setStatus( "Software " + software.getName() + " update failed" );
- updateLog.addUpdateMessage(
- new UpdateMessage( "error", "Software " + software.getName() + " update failed: " + e.getMessage() ) );
- PublisherUtils.publish( environment );
- }
- throw new KalumetException( "Software " + software.getName() + " update failed", e );
- }
-
- LOGGER.info( "Software {} updated", software.getName() );
- EventUtils.post( environment, "UPDATE", "Software " + software.getName() + " updated" );
- if ( !delegation )
- {
- LOGGER.debug( "The update is a client call, publish result" );
- EventUtils.post( environment, "UPDATE", "Update completed" );
- if ( updateLog.isUpdated() )
- {
- updateLog.setStatus( "Software " + software.getName() + " updated" );
- }
- else
- {
- updateLog.setStatus( "Software " + software.getName() + " already up to date" );
- }
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Update completed" ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
- }
- }
-
- /**
- * Execute a software command.
- *
- * @param environment the target environment.
- * @param software the target software.
- * @param command the target command.
- * @param updateLog the <code>UpdateLog</code> to use.
- * @throws UpdateException in case of error during the command execution.
- */
- public static void executeCommand( Environment environment, Software software, Command command, UpdateLog updateLog )
- throws UpdateException
- {
- LOGGER.info( "Executing software {} command {}", software.getName(), command.getName() );
-
- if ( !command.isActive() )
- {
- LOGGER.info( "Software {} command {} is inactive, so not executed", software.getName(), command.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info",
- "Software " + software.getName() + " command " + command.getName()
- + " is inactive, so not executed" ) );
- EventUtils.post( environment, "UPDATE", "Software " + software.getName() + " command " + command.getName()
- + " is inactive, so not executed" );
- return;
- }
-
- if ( command.getAgent() != null && command.getAgent().trim().length() > 0 && !command.getAgent().equals(
- Configuration.AGENT_ID ) )
- {
- // delegates the command execution to another agent
- LOGGER.info( "Delegating command {} execution to agent {}", command.getName(), command.getAgent() );
- Agent agentDelegation = Configuration.CONFIG_CACHE.getAgent( command.getAgent() );
- updateLog.addUpdateMessage( new UpdateMessage( "info",
- "Delegating command " + command.getName() + " execution to agent "
- + command.getAgent() ) );
- EventUtils.post( environment, "UPDATE",
- "Delegating command " + command.getName() + " execution to agent " + command );
- if ( agentDelegation == null )
- {
- LOGGER.error( "Agent {} is not found in the configuration", command.getAgent() );
- throw new UpdateException( "Agent " + command.getAgent() + " is not found in the configuration" );
- }
- try
- {
- LOGGER.debug( "Call software WS" );
- SoftwareClient client = new SoftwareClient( agentDelegation.getHostname(), agentDelegation.getPort() );
- client.executeCommand( environment.getName(), software.getName(), command.getName(), true );
- }
- catch ( ClientException clientException )
- {
- LOGGER.error( "Command {} execution failed", command.getName(), clientException );
- throw new UpdateException(
- "Command " + command.getName() + " execution failed: " + clientException.getMessage(), clientException );
- }
- return;
- }
-
- String commandExec = VariableUtils.replace( command.getCommand(), environment.getVariables() );
- String output = null;
- try
- {
- output = CommandUtils.execute( commandExec );
- }
- catch ( KalumetException kalumetException )
- {
- LOGGER.error( "Command {} execution failed", command.getName(), kalumetException );
- throw new UpdateException( "Command " + command.getName() + " execution failed", kalumetException );
- }
-
- LOGGER.info( "Software {} command {} executed: {}", new Object[]{ software.getName(), command.getName(), output } );
- // add an update message
- updateLog.addUpdateMessage( new UpdateMessage( "info",
- "Software " + software.getName() + " command " + command.getName()
- + " executed: " + output ) );
- // post an event
- EventUtils.post( environment, "UPDATE",
- "Software " + software.getName() + " command " + command.getName() + " executed: " + output );
- }
-
- /**
- * Wrapper method to execute a software command (via WS).
- *
- * @param environmentName the target environment name.
- * @param softwareName the target software name.
- * @param commandName the target command name.
- * @param delegation flag indicating if the execution is a delegation from another agent (true), or a client call (false).
- */
- public static void executeCommand( String environmentName, String softwareName, String commandName,
- boolean delegation )
- throws KalumetException
- {
- LOGGER.info( "Software {} command {} execution requested by WS", softwareName, commandName );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- Software software = environment.getSoftware( softwareName );
- if ( software == null )
- {
- LOGGER.error( "Software {} is not found in environment {}", softwareName, environmentName );
- throw new KalumetException( "Software " + softwareName + " is not found in environment " + environmentName );
- }
- Command command = software.getCommand( commandName );
- if ( command == null )
- {
- LOGGER.error( "Command {} is not found in software {}", commandName, softwareName );
- throw new KalumetException( "Command " + commandName + " is not found in software " + softwareName );
- }
- // update the agent configuration cache
- LOGGER.debug( "Updating agent configuration cache" );
- Configuration.CONFIG_CACHE = kalumet;
- // post a journal event
- EventUtils.post( environment, "UPDATE",
- "Software " + softwareName + " command " + commandName + " execution requested by WS" );
- // create an update logger
- UpdateLog updateLog =
- new UpdateLog( "Software " + softwareName + " command " + commandName + " execution in progress ...",
- environment.getName(), environment );
- if ( !delegation )
- {
- // the call is not a delegation from another agent
- LOGGER.info( "Send a notification and waiting for the count down" );
- EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
- NotifierUtils.waitAndNotify( environment );
- }
- try
- {
- // call the updater
- LOGGER.debug( "Call the software updater" );
- SoftwareUpdater.executeCommand( environment, software, command, updateLog );
- }
- catch ( Exception e )
- {
- LOGGER.error( "Command {} execution failed", command.getName(), e );
- EventUtils.post( environment, "ERROR", "Command " + command.getName() + " execution failed: " + e.getMessage() );
- if ( !delegation )
- {
- updateLog.setStatus( "Command " + command.getName() + " execution failed" );
- updateLog.addUpdateMessage(
- new UpdateMessage( "error", "Command " + command.getName() + " execution failed: " + e.getMessage() ) );
- PublisherUtils.publish( environment );
- }
- throw new UpdateException( "Command " + command.getName() + " execution failed", e );
- }
-
- // command execution is completed
- LOGGER.info( "Command {} has been executed successfully", command.getName() );
- EventUtils.post( environment, "UPDATE", "Command " + command.getName() + " has been executed successfully" );
- if ( !delegation )
- {
- updateLog.setStatus( "Command " + command.getName() + " has been executed successfully" );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Command " + command.getName() + " has been executed successfully" ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
- }
- }
-
- /**
- * Wrapper method to update a location (via WS).
- *
- * @param environmentName the target environment name.
- * @param softwareName the target software name.
- * @param locationName the target location name.
- * @param delegation true if the call is performed by another agent, false else.
- * @throws UpdateException in case of location update failure.
- */
- public static void updateLocation( String environmentName, String softwareName, String locationName,
- boolean delegation )
- throws KalumetException
- {
- LOGGER.info( "Software {} location {} update requested by WS", softwareName, locationName );
-
- // loading configuration
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- Software software = environment.getSoftware( softwareName );
- if ( software == null )
- {
- LOGGER.error( "Software {} is not found in environment {}", softwareName, environmentName );
- throw new KalumetException( "Software " + softwareName + " is not found in environment " + environmentName );
- }
- Location location = software.getLocation( locationName );
- if ( location == null )
- {
- LOGGER.error( "Location {} is not found in software {}", locationName, softwareName );
- throw new KalumetException( "Location " + locationName + " is not found in software " + softwareName );
- }
-
- // update configuration cache
- LOGGER.debug( "Updating configuration cache" );
- Configuration.CONFIG_CACHE = kalumet;
-
- // post journal event
- EventUtils.post( environment, "UPDATE",
- "Software " + software.getName() + " location " + location.getName() + " update requested by WS" );
- // create an update logger
- UpdateLog updateLog =
- new UpdateLog( "Software " + software.getName() + " location " + location.getName() + " update in progress ....",
- environment.getName(), environment );
-
- if ( !delegation )
- {
- // the call is not a delegation from another agent, it's an atomic update
- LOGGER.info( "Send a notification and waiting for the count down" );
- EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
- NotifierUtils.waitAndNotify( environment );
- }
- try
- {
- // call software updater
- LOGGER.debug( "Call software updater" );
- SoftwareUpdater.updateLocation( environment, software, location, updateLog );
- }
- catch ( Exception e )
- {
- LOGGER.error( "Location {} update failed", location.getName(), e );
- EventUtils.post( environment, "ERROR", "Location " + location.getName() + " update failed: " + e.getMessage() );
- if ( !delegation )
- {
- updateLog.setStatus( "Location " + locationName + " update failed" );
- updateLog.addUpdateMessage(
- new UpdateMessage( "error", "Location " + locationName + " update failed: " + e.getMessage() ) );
- PublisherUtils.publish( environment );
- }
- throw new UpdateException( "Location " + location.getName() + " update failed", e );
- }
-
- // location updated
- LOGGER.info( "Location {} updated", location.getName() );
- EventUtils.post( environment, "UPDATE", "Location " + location.getName() + " updated" );
- if ( !delegation )
- {
- updateLog.setStatus( "Location " + location.getName() + " updated" );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Location " + location.getName() + " updated" ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
- }
- }
-
- /**
- * Updates an <code>Software</code> <code>Location</code>.
- *
- * @param environment the target <code>Environment</code>.
- * @param software the target <code>Software</code>.
- * @param location the target <code>Location</code>.
- * @param updateLog the <code>UpdateLog</code> to use.
- * @throws UpdateException in case of error during the location update.
- */
- public static void updateLocation( Environment environment, Software software, Location location,
- UpdateLog updateLog )
- throws UpdateException
- {
- LOGGER.info( "Updating software {} location {}", software.getName(), location.getName() );
-
- if ( !location.isActive() )
- {
- LOGGER.info( "Software {} location {} is inactive, so not updated", software.getName(), location.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Software " + software.getName() + " location "
- + location.getName() + " is inactive, so not updated" ) );
- EventUtils.post( environment, "UPDATE", "Software " + software.getName() + " location " + location.getName()
- + "is inactive, so not updated" );
- return;
- }
-
- if ( location.getAgent() != null && location.getAgent().trim().length() > 0 && !location.getAgent().equals(
- Configuration.AGENT_ID ) )
- {
- // delegates the location update to another agent
- LOGGER.info( "Delegating location {} update to agent {}", location.getName(), location.getAgent() );
- Agent agentDelegation = Configuration.CONFIG_CACHE.getAgent( location.getAgent() );
- updateLog.addUpdateMessage( new UpdateMessage( "info",
- "Delegating location " + location.getName() + " update to agent "
- + location.getAgent() ) );
- EventUtils.post( environment, "UPDATE",
- "Delegating location " + location.getName() + " update to agent " + location.getAgent() );
- if ( agentDelegation == null )
- {
- LOGGER.error( "Agent {} is not found in the configuration", location.getAgent() );
- throw new UpdateException( "Agent " + location.getAgent() + " is not found in the configuration" );
- }
- try
- {
- // call the WebService
- LOGGER.debug( "Call software WS" );
- SoftwareClient client = new SoftwareClient( agentDelegation.getHostname(), agentDelegation.getPort() );
- client.updateLocation( environment.getName(), software.getName(), location.getName(), true );
- }
- catch ( ClientException clientException )
- {
- LOGGER.error( "Location {} update failed", location.getName(), clientException );
- throw new UpdateException( "Location " + location.getName() + " update failed: " + clientException.getMessage(),
- clientException );
- }
- return;
- }
-
- // constructs the location URI
- String locationUri = VariableUtils.replace( location.getUri(), environment.getVariables() );
- if ( !FileManipulator.protocolExists( locationUri ) )
- {
- LOGGER.debug( "The location URI is relative to the software URI" );
- locationUri =
- FileManipulator.format( VariableUtils.replace( software.getUri(), environment.getVariables() ) ) + "!/"
- + locationUri;
- }
- // constructs the location destination path
- String locationPath = VariableUtils.replace( location.getPath(), environment.getVariables() );
- // get a file manipulator
- FileManipulator fileManipulator = null;
- try
- {
- fileManipulator = new FileManipulator();
- }
- catch ( FileManipulatorException fileManipulatorException )
- {
- LOGGER.error( "Can't initialize file manipulator", fileManipulatorException );
- throw new UpdateException( "Can't initialize file manipulator", fileManipulatorException );
- }
- try
- {
- LOGGER.debug( "Copying {} to {}", locationUri, locationPath );
- fileManipulator.copy( locationUri, locationPath );
- updateLog.setUpdated( true );
- }
- catch ( FileManipulatorException fileManipulatorException )
- {
- LOGGER.error( "Location {} update failed", location.getName(), fileManipulatorException );
- throw new UpdateException( "Location " + location.getName() + " update failed", fileManipulatorException );
- }
- LOGGER.info( "Software {} location {} updated", software.getName(), location.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Software " + software.getName() + " location " + location.getName() + " updated" ) );
- EventUtils.post( environment, "UPDATE",
- "Software " + software.getName() + " location " + location.getName() + " updated" );
- }
-
- /**
- * Wrapper method to update a configuration file (via WS).
- *
- * @param environmentName the target environment name.
- * @param softwareName the target software name.
- * @param configurationFileName the target configuration file name.
- * @param delegation true if the call is made by another agent (delegation), false if the call is made by a client.
- * @throws KalumetException in case of update failure.
- */
- public static void updateConfigurationFile( String environmentName, String softwareName, String configurationFileName,
- boolean delegation )
- throws KalumetException
- {
- LOGGER.info( "Software {} configuration file {} update requested by WS", softwareName, configurationFileName );
-
- // loading configuration
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
-
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- Software software = environment.getSoftware( softwareName );
- if ( software == null )
- {
- LOGGER.error( "Software {} is not found in environment {}", softwareName, environmentName );
- throw new KalumetException( "Software " + softwareName + " is not found in environment " + environmentName );
- }
- ConfigurationFile configurationFile = software.getConfigurationFile( configurationFileName );
- if ( configurationFile == null )
- {
- LOGGER.error( "Configuration file {} is not found in software {}", configurationFileName, softwareName );
- throw new KalumetException(
- "Configuration file " + configurationFileName + " is not found in software " + softwareName );
- }
-
- // update agent configuration cache
- LOGGER.debug( "Updating agent configuration cache" );
- Configuration.CONFIG_CACHE = kalumet;
-
- // post journal event
- EventUtils.post( environment, "UPDATE",
- "Software " + software.getName() + " configuration file " + configurationFile.getName()
- + " update requested by WS" );
- // create update log
- UpdateLog updateLog = new UpdateLog(
- "Software " + software.getName() + " configuration file " + configurationFile.getName()
- + " update in progress ...", environment.getName(), environment );
-
- if ( !delegation )
- {
- // the update is not call by another agent, it's an atomic update
- LOGGER.info( "Send a notification and waiting for the count down" );
- EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
- NotifierUtils.waitAndNotify( environment );
- }
-
- try
- {
- // call software updater
- LOGGER.debug( "Call software updater" );
- SoftwareUpdater.updateConfigurationFile( environment, software, configurationFile, updateLog );
- }
- catch ( Exception e )
- {
- LOGGER.error( "Configuration file {} update failed", configurationFile.getName(), e );
- EventUtils.post( environment, "ERROR",
- "Configuration file " + configurationFile.getName() + " update failed: " + e.getMessage() );
- if ( !delegation )
- {
- updateLog.setStatus( "Configuration file " + configurationFile.getName() + " update failed" );
- updateLog.addUpdateMessage( new UpdateMessage( "error", "Configuration file " + configurationFile.getName()
- + " update failed: " + e.getMessage() ) );
- PublisherUtils.publish( environment );
- }
- throw new UpdateException( "Configuration file " + configurationFile.getName() + " update failed", e );
- }
-
- // configuration file updated
- LOGGER.info( "Configuration file {} updated", configurationFile.getName() );
- EventUtils.post( environment, "UPDATE", "Configuration file " + configurationFile.getName() + " updated" );
- if ( !delegation )
- {
- updateLog.setStatus( "Configuration file " + configurationFile.getName() + " updated" );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Configuration file " + configurationFile.getName() + " updated" ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
- }
- }
-
- /**
- * Update an <code>Software</code> <code>ConfigurationFile</code>.
- *
- * @param environment the target <code>Environment</code>.
- * @param software the target <code>Software</code>.
- * @param configurationFile the target <code>ConfigurationFile</code>.
- * @param updateLog the <code>UpdateLog</code> to use.
- * @throws UpdateException in case of error during the configuration file update.
- */
- public static void updateConfigurationFile( Environment environment, Software software,
- ConfigurationFile configurationFile, UpdateLog updateLog )
- throws UpdateException
- {
- LOGGER.info( "Updating software {} configuration file {}", software.getName(), configurationFile.getName() );
-
- if ( !configurationFile.isActive() )
- {
- LOGGER.info( "Software {} configuration file {} is inactive, so not updated", software.getName(),
- configurationFile.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Software " + software.getName() + " configuration file "
- + configurationFile.getName() + " is inactive, so not updated" ) );
- EventUtils.post( environment, "UPDATE",
- "Software " + software.getName() + " configuration file " + configurationFile.getName()
- + " is inactive, so not updated" );
- return;
- }
-
- if ( configurationFile.getAgent() != null && configurationFile.getAgent().trim().length() > 0
- && !configurationFile.getAgent().equals( Configuration.AGENT_ID ) )
- {
- // delegates configuration file update to another agent
- LOGGER.info( "Delegating configuration file {} update to agent {}", configurationFile.getName(),
- configurationFile.getAgent() );
- Agent agentDelegation = Configuration.CONFIG_CACHE.getAgent( configurationFile.getAgent() );
- updateLog.addUpdateMessage( new UpdateMessage( "info",
- "Delegating configuration file " + configurationFile.getName()
- + " update to agent " + configurationFile.getAgent() ) );
- EventUtils.post( environment, "UPDATE",
- "Delegating configuration file " + configurationFile.getName() + " update to agent "
- + configurationFile.getAgent() );
- if ( agentDelegation == null )
- {
- LOGGER.error( "Agent {} is not found in the configuration", configurationFile.getAgent() );
- throw new UpdateException( "Agent " + configurationFile.getAgent() + " is not found in the configuration" );
- }
- try
- {
- // call WS
- LOGGER.debug( "Call software WS" );
- SoftwareClient client = new SoftwareClient( agentDelegation.getHostname(), agentDelegation.getPort() );
- client.updateConfigurationFile( environment.getName(), software.getName(), configurationFile.getName(), true );
- }
- catch ( ClientException clientException )
- {
- LOGGER.error( "Configuration file {} update failed", configurationFile.getName(), clientException );
- throw new UpdateException( "Configuration file " + configurationFile.getName() + " update failed",
- clientException );
- }
- return;
- }
-
- // defines the configuration file URI
- LOGGER.debug( "Getting configuration file URI" );
- String configurationFileUri = VariableUtils.replace( configurationFile.getUri(), environment.getVariables() );
- if ( !FileManipulator.protocolExists( configurationFileUri ) )
- {
- LOGGER.debug( "The configuration file URI is relative to the software URI" );
- configurationFileUri =
- FileManipulator.format( VariableUtils.replace( software.getUri(), environment.getVariables() ) ) + "!/"
- + configurationFileUri;
- }
-
- // defines the software cache directory
- LOGGER.debug( "Getting software cache directory" );
- String softwareCacheDir = null;
- try
- {
- softwareCacheDir = FileManipulator.createSoftwareCacheDir( environment, software );
- }
- catch ( FileManipulatorException fileManipulatorException )
- {
- LOGGER.error( "Can't initialize software cache directory", fileManipulatorException );
- throw new UpdateException( "Can't initialize software cache directory", fileManipulatorException );
- }
-
- // initializes file manipulator
- LOGGER.debug( "Initializing file manipulator" );
- FileManipulator fileManipulator = null;
- try
- {
- fileManipulator = new FileManipulator();
- }
- catch ( FileManipulatorException fileManipulatorException )
- {
- LOGGER.error( "Can't initialize file manipulator", fileManipulatorException );
- throw new UpdateException( "Can't initialize file manipulator", fileManipulatorException );
- }
-
- // copy configuration file into cache
- String configurationFileCacheLocation = softwareCacheDir + "/config/" + configurationFile.getName();
- LOGGER.debug( "Copying configuration file {} into cache", configurationFile.getName() );
- try
- {
- fileManipulator.copy( configurationFileUri, configurationFileCacheLocation );
- }
- catch ( FileManipulatorException fileManipulatorException )
- {
- LOGGER.error( "Can't copy configuration file {} into cache", configurationFile.getName(),
- fileManipulatorException );
- throw new UpdateException( "Can't copy configuration file " + configurationFile.getName() + " into cache",
- fileManipulatorException );
- }
-
- // change mappings into the configuration file cache
- LOGGER.debug( "Replacing mappings key/value" );
- for ( Iterator mappingIterator = configurationFile.getMappings().iterator(); mappingIterator.hasNext(); )
- {
- Mapping mapping = (Mapping) mappingIterator.next();
- FileManipulator.searchAndReplace( mapping.getKey(),
- VariableUtils.replace( mapping.getValue(), environment.getVariables() ),
- configurationFileCacheLocation );
- }
-
- // compare configuration file cache with target
- LOGGER.debug( "Comparing the configuration file cache with the target location" );
- String configurationFileDestinationPath =
- VariableUtils.replace( configurationFile.getPath(), environment.getVariables() );
- try
- {
- if ( !fileManipulator.contentEquals( configurationFileCacheLocation, configurationFileDestinationPath ) )
- {
- // the configuration file needs to be updated
- LOGGER.debug( "Configuration file {} needs to be updated", configurationFile.getName() );
- fileManipulator.copy( configurationFileCacheLocation, configurationFileDestinationPath );
- updateLog.setStatus( "UPDATE PERFORMED" );
- updateLog.setUpdated( true );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "Configuration file " + configurationFile.getName() + " updated" ) );
- EventUtils.post( environment, "UPDATE", "Configuration file " + configurationFile.getName() + " updated" );
- LOGGER.info( "Configuration file {} updated", configurationFile.getName() );
- }
- }
- catch ( FileManipulatorException fileManipulatorException )
- {
- LOGGER.error( "Configuration file {} update failed", configurationFile.getName(), fileManipulatorException );
- throw new UpdateException( "Configuration file " + configurationFile.getName() + " update failed: "
- + fileManipulatorException.getMessage(), fileManipulatorException );
- }
- }
-
- /**
- * Wrapper method to update a software database (via WS).
- *
- * @param environmentName the target environment name.
- * @param softwareName the target software name.
- * @param databaseName the target database name.
- * @param delegation true if the call is made by another agent (delegation), false if the call is made by a client.
- * @throws KalumetException in case of update failure.
- */
- public static void updateDatabase( String environmentName, String softwareName, String databaseName,
- boolean delegation )
- throws KalumetException
- {
- LOGGER.info( "Software {} database {} update requested by WS", softwareName, databaseName );
-
- // load configuration
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- Software software = environment.getSoftware( softwareName );
- if ( software == null )
- {
- LOGGER.error( "Software {} is not found in environment {}", softwareName, environmentName );
- throw new KalumetException( "Software " + softwareName + " is not found in environment " + environmentName );
- }
- Database database = software.getDatabase( databaseName );
- if ( database == null )
- {
- LOGGER.error( "Database {} is not found in software {}", databaseName, softwareName );
- throw new KalumetException( "Database " + databaseName + " is not found in software " + softwareName );
- }
-
- // updating configuration cache
- LOGGER.debug( "Updating configuration cache" );
- Configuration.CONFIG_CACHE = kalumet;
-
- // post journal event
- EventUtils.post( environment, "UPDATE",
- "Software " + software.getName() + " database " + database.getName() + " update requested by WS" );
- // create update log
- UpdateLog updateLog =
- new UpdateLog( "Software " + software.getName() + " database " + database.getName() + " update in progress ...",
- environment.getName(), environment );
-
- if ( !delegation )
- {
- // the call is not a delegation from another agent, it's an atomic update
- LOGGER.info( "Send a notification and waiting for the count down" );
- EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
- NotifierUtils.waitAndNotify( environment );
- }
-
- try
- {
- // call software updater
- LOGGER.debug( "Call software updater" );
- SoftwareUpdater.updateDatabase( environment, software, database, updateLog );
- }
- catch ( Exception e )
- {
- LOGGER.error( "Database {} update failed", database.getName(), e );
- EventUtils.post( environment, "ERROR", "Database " + database.getName() + " update failed: " + e.getMessage() );
- if ( !delegation )
- {
- updateLog.setStatus( "Database " + database.getName() + " update failed" );
- updateLog.addUpdateMessage(
- new UpdateMessage( "error", "Database " + database.getName() + " update failed: " + e.getMessage() ) );
- PublisherUtils.publish( environment );
- }
- throw new UpdateException( "Database " + database.getName() + " update failed", e );
- }
-
- // database updated
- LOGGER.info( "Database {} updated", database.getName() );
- EventUtils.post( environment, "UPDATE", "Database " + database.getName() + " updated" );
- if ( !delegation )
- {
- updateLog.setStatus( "Database " + database.getName() + " updated" );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Database " + database.getName() + " updated" ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
- }
- }
-
- /**
- * Update a software database.
- *
- * @param environment the target <code>Environment</code>.
- * @param software the target <code>Software</code>.
- * @param database the target <code>Database</code>.
- * @param updateLog the update logger to use.
- */
- public static void updateDatabase( Environment environment, Software software, Database database,
- UpdateLog updateLog )
- throws UpdateException
- {
- LOGGER.info( "Update software {} database {}", software.getName(), database.getName() );
-
- if ( !database.isActive() )
- {
- LOGGER.info( "Software {} database {} (environment {}) is inactive, so not updated",
- new Object[]{ software.getName(), database.getName(), environment.getName() } );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Software " + software.getName() + " database "
- + database.getName() + " is inactive, so not updated" ) );
- EventUtils.post( environment, "UPDATE", "Software " + software.getName() + " database " + database.getName()
- + " is inactive, so not updated" );
- return;
- }
-
- if ( database.getAgent() != null && database.getAgent().trim().length() > 0 && !database.getAgent().equals(
- Configuration.AGENT_ID ) )
- {
- // the database update is delegated to another agent
- LOGGER.info( "Delegating software {} database {} update to agent {}",
- new Object[]{ software.getName(), database.getName(), database.getAgent() } );
- Agent delegationAgent = Configuration.CONFIG_CACHE.getAgent( database.getAgent() );
- updateLog.addUpdateMessage( new UpdateMessage( "info",
- "Delegating database " + database.getName() + " update to agent "
- + database.getAgent() ) );
- EventUtils.post( environment, "UPDATE",
- "Delegating database " + database.getName() + " update to agent " + database.getAgent() );
- if ( delegationAgent == null )
- {
- // the database agent is not found in the configuration
- LOGGER.error( "Agent {} is not found in the configuration", database.getAgent() );
- throw new UpdateException( "Agent " + database.getAgent() + " is not found in the configuration" );
- }
- try
- {
- // call the WebService
- LOGGER.debug( "Call software WS" );
- SoftwareClient client = new SoftwareClient( delegationAgent.getHostname(), delegationAgent.getPort() );
- client.updateDatabase( environment.getName(), software.getName(), database.getName(), true );
- }
- catch ( ClientException clientException )
- {
- LOGGER.error( "Database {} update failed", database.getName(), clientException );
- throw new UpdateException( "Database " + database.getName() + " update failed", clientException );
- }
- return;
- }
-
- // launch SQL scripts of the database
- LOGGER.debug( "Executing SQL scripts" );
- for ( Iterator sqlScriptIterator = database.getSqlScripts().iterator(); sqlScriptIterator.hasNext(); )
- {
- SqlScript sqlScript = (SqlScript) sqlScriptIterator.next();
- try
- {
- SoftwareUpdater.executeSqlScript( environment, software, database, sqlScript, updateLog );
- }
- catch ( UpdateException updateException )
- {
- // SQL script execution has failed
- if ( sqlScript.isBlocker() )
- {
- // the SQL script is update blocker
- LOGGER.error( "SQL script {} execution failed", updateException );
- throw new UpdateException( "SQL script " + sqlScript.getName() + " execution failed", updateException );
- }
- else
- {
- // the SQL script is not update blocker
- LOGGER.warn( "SQL script {} execution failed", updateException );
- updateLog.addUpdateMessage( new UpdateMessage( "warn",
- "SQL script " + sqlScript.getName() + " execution failed: "
- + updateException.getMessage() ) );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "SQL script " + sqlScript.getName()
- + " is not update blocker, update continues" ) );
- EventUtils.post( environment, "WARN",
- "SQL script " + sqlScript.getName() + " execution failed: " + updateException.getMessage() );
- EventUtils.post( environment, "UPDATE",
- "SQL script " + sqlScript.getName() + " is not update blocker, update continues" );
- }
- }
- }
- }
-
- /**
- * Executes SQL script.
- *
- * @param environment the target <code>Environment</code>.
- * @param software the target <code>Software</code>.
- * @param database the target <code>Database</code>.
- * @param sqlScript the target <code>SqlScript</code>.
- * @param updateLog the update log to use.
- * @throws UpdateException in case of error during the SQL script execution.
- */
- public static void executeSqlScript( Environment environment, Software software, Database database,
- SqlScript sqlScript, UpdateLog updateLog )
- throws UpdateException
- {
- LOGGER.info( "Executing SQL script {}", sqlScript.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Executing SQL script " + sqlScript.getName() ) );
- EventUtils.post( environment, "UPDATE", "Executing SQL script " + sqlScript.getName() );
-
- if ( !sqlScript.isActive() )
- {
- // the SQL script is not active
- LOGGER.info( "SQL script {} is inactive, so not executed", sqlScript.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "SQL script " + sqlScript.getName() + " is inactive, so not executed" ) );
- EventUtils.post( environment, "UPDATE", "SQL script " + sqlScript.getName() + " is inactive, so not executed" );
- return;
- }
-
- // construct the SQL script URI
- String sqlScriptUri = VariableUtils.replace( sqlScript.getUri(), environment.getVariables() );
- if ( !FileManipulator.protocolExists( sqlScriptUri ) )
- {
- // the SQL script URI is relative, constructs using the software URI
- LOGGER.debug( "The SQL script URI is relative to the software URI" );
- sqlScriptUri =
- FileManipulator.format( VariableUtils.replace( software.getUri(), environment.getVariables() ) ) + "!/"
- + sqlScriptUri;
- }
-
- // get the cache directory
- LOGGER.debug( "Getting software cache directory" );
- String softwareCacheDir = null;
- try
- {
- softwareCacheDir = FileManipulator.createSoftwareCacheDir( environment, software );
- }
- catch ( FileManipulatorException fileManipulatorException )
- {
- LOGGER.error( "Can't initialize software cache directory", fileManipulatorException );
- throw new UpdateException( "Can't initialize software cache directory", fileManipulatorException );
- }
-
- // get file manipulator instance
- LOGGER.debug( "Initializing file manipulator" );
- FileManipulator fileManipulator = null;
- try
- {
- fileManipulator = new FileManipulator();
- }
- catch ( FileManipulatorException fileManipulatorException )
- {
- LOGGER.error( "Can't initialize file manipulator", fileManipulatorException );
- throw new UpdateException( "Can't initialize file manipulator", fileManipulatorException );
- }
-
- // copy the SQL script into the software cache directory
- LOGGER.debug( "Copying the SQL script into the software cache directory" );
- String sqlScriptCache = softwareCacheDir + "/sql/" + sqlScript.getName() + ".cache";
- String sqlScriptRuntime = softwareCacheDir + "/sql/" + sqlScript.getName();
- try
- {
- fileManipulator.copy( sqlScriptUri, sqlScriptCache );
- }
- catch ( FileManipulatorException fileManipulatorException )
- {
- LOGGER.error( "Can't copy SQL script from {} to {}", new Object[]{ sqlScriptUri, sqlScriptCache },
- fileManipulatorException );
- throw new UpdateException( "Can't copy SQL script " + sqlScriptUri + " to " + sqlScriptCache,
- fileManipulatorException );
- }
-
- if ( fileManipulator.isFolder( sqlScriptCache ) )
- {
- // TODO add a generic method to reuse in the case of directory
-
- // the user provided a directory
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", sqlScript.getName() + "is a folder, iterate in the SQL scripts" ) );
- EventUtils.post( environment, "UPDATE", sqlScript.getName() + " is a folder, iterate in the SQL scripts" );
- LOGGER.info( "{} is a folder, iterate in the SQL scripts", sqlScript.getName() );
- FileObject[] children = fileManipulator.browse( sqlScriptCache );
- for ( int i = 0; i < children.length; i++ )
- {
- FileObject current = children[i];
- String name = current.getName().getBaseName();
- String singleSqlScriptCache = sqlScriptCache + "/" + name;
- String singleSqlScriptRuntime = sqlScriptRuntime + "/" + name;
- // change mappings in the current SQL script
- for ( Iterator mappingIterator = sqlScript.getMappings().iterator(); mappingIterator.hasNext(); )
- {
- Mapping mapping = (Mapping) mappingIterator.next();
- FileManipulator.searchAndReplace( mapping.getKey(),
- VariableUtils.replace( mapping.getValue(), environment.getVariables() ),
- singleSqlScriptCache );
- }
- try
- {
- if ( sqlScript.isForce() || ( !fileManipulator.contentEquals( singleSqlScriptCache,
- singleSqlScriptRuntime ) ) )
- {
- fileManipulator.copy( singleSqlScriptCache, singleSqlScriptRuntime );
-
- if ( database.getSqlCommand() != null && database.getSqlCommand().trim().length() > 0 )
+ "Delegating location " + location.getName() + " update to agent " + location.getAgent() );
+ if ( agentDelegation == null )
{
- // execute SQL script using system command
- String command = VariableUtils.replace( database.getSqlCommand(), environment.getVariables() );
- String output = SqlScriptUtils.executeUsingCommand( singleSqlScriptRuntime, command );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "SQL script " + name + " executed: " + output ) );
- EventUtils.post( environment, "UPDATE", "SQL script " + name + " executed: " + output );
- LOGGER.info( "SQL script {} executed succesfully", name );
+ LOGGER.error( "Agent {} is not found in the configuration", location.getAgent() );
+ throw new UpdateException( "Agent " + location.getAgent() + " is not found in the configuration" );
}
- else
+ try
{
- // execute SQL script using JDBC
- String user = null;
- String password = null;
- String driver = null;
- String url = null;
- if ( database.getConnectionPool() != null && database.getConnectionPool().trim().length() > 0 )
- {
- // the database is linked to a connection pool
- // looking for the connection pool (from the cache)
- LOGGER.debug( "Database has a reference to a connection pool" );
- // looking for the connection pool definition
- String connectionPoolName =
- VariableUtils.replace( database.getConnectionPool(), environment.getVariables() );
- JDBCConnectionPool connectionPool = null;
- for ( Iterator applicationServerIterator =
- environment.getJEEApplicationServers().getJEEApplicationServers().iterator();
- applicationServerIterator.hasNext(); )
- {
- JEEApplicationServer applicationServer = (JEEApplicationServer) applicationServerIterator.next();
- connectionPool = applicationServer.getJDBCConnectionPool( connectionPoolName );
- if ( connectionPool != null )
- {
- break;
- }
- }
- if ( connectionPool == null )
- {
- LOGGER.error( "JDBC connection pool {} is not found in any JEE application servers",
- connectionPoolName );
- throw new UpdateException(
- "JDBC connection pool " + connectionPoolName + " is not found in any JEE application servers" );
- }
- user = VariableUtils.replace( connectionPool.getUser(), environment.getVariables() );
- password = VariableUtils.replace( connectionPool.getPassword(), environment.getVariables() );
- driver = VariableUtils.replace( connectionPool.getDriver(), environment.getVariables() );
- url = VariableUtils.replace( connectionPool.getUrl(), environment.getVariables() );
- }
- else
- {
- // use the database connection data
- user = VariableUtils.replace( database.getUser(), environment.getVariables() );
- password = VariableUtils.replace( database.getPassword(), environment.getVariables() );
- driver = VariableUtils.replace( database.getDriver(), environment.getVariables() );
- url = VariableUtils.replace( database.getJdbcurl(), environment.getVariables() );
- }
- // execute SQL script using JDBC
- SqlScriptUtils.executeUsingJdbc( singleSqlScriptRuntime, driver, user, password, url );
+ // call the WebService
+ LOGGER.debug( "Call software WS" );
+ SoftwareClient client = new SoftwareClient( agentDelegation.getHostname(), agentDelegation.getPort() );
+ client.updateLocation( environment.getName(), software.getName(), location.getName(), true );
}
- // add message
- updateLog.setStatus( "Update performed" );
- updateLog.setUpdated( true );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "SQL script " + sqlScript.getName() + " executed" ) );
- EventUtils.post( environment, "UPDATE", "SQL script " + sqlScript.getName() + " executed" );
- LOGGER.info( "SQL script " + sqlScript.getName() + " executed" );
- }
- }
- catch ( Exception e )
- {
- // SQL script execution failed, delete the SQL script from the cache
- try
- {
- fileManipulator.delete( sqlScriptRuntime );
- }
- catch ( FileManipulatorException fileManipulatorException )
- {
- LOGGER.warn( "Can't delete SQL script cache", fileManipulatorException );
- }
- LOGGER.error( "SQL script {} execution failed", sqlScript.getName(), e );
- throw new UpdateException( "SQL script " + sqlScript.getName() + " execution failed", e );
- }
- }
- }
- else
- {
- // the user provided a single SQL script
-
- // change mappings into the SQL script
- LOGGER.debug( "Replacing mappings into the SQL script {}", sqlScript.getName() );
- for ( Iterator mappingIterator = sqlScript.getMappings().iterator(); mappingIterator.hasNext(); )
- {
- Mapping mapping = (Mapping) mappingIterator.next();
- FileManipulator.searchAndReplace( mapping.getKey(), mapping.getValue(), sqlScriptCache );
- }
-
- // compare the SQL script origin with the runtime one
- try
- {
- if ( !fileManipulator.contentEquals( sqlScriptCache, sqlScriptRuntime ) )
- {
- // the SQL script needs to be executed
- LOGGER.debug( "The SQL script {} needs to be executed", sqlScript.getName() );
- // copy the SQL script cache to the runtime
- LOGGER.debug( "Copy the SQL script cache to the runtime" );
- fileManipulator.copy( sqlScriptCache, sqlScriptRuntime );
- if ( database.getSqlCommand() != null && database.getSqlCommand().trim().length() > 0 )
- {
- // execute the SQL script using a command
- LOGGER.info( "Executing the SQL script using a system command" );
- String command = VariableUtils.replace( database.getSqlCommand(), environment.getVariables() );
- String output = SqlScriptUtils.executeUsingCommand( sqlScriptRuntime, command );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "SQL script " + sqlScript.getName() + " executed: " + output ) );
- EventUtils.post( environment, "UPDATE", "SQL script " + sqlScript.getName() + " executed: " + output );
- LOGGER.info( "SQL script {} executed successfully", sqlScript.getName() );
- }
- else
- {
- // execute SQL script using JDBC
- LOGGER.info( "Executing SQL script using JDBC" );
- String user = null;
- String password = null;
- String driver = null;
- String url = null;
- if ( database.getConnectionPool() != null && database.getConnectionPool().trim().length() > 0 )
+ catch ( ClientException clientException )
{
- // the database has a reference to an existing connection pool
- LOGGER.debug( "Database has a reference to a connection pool" );
- // looking for the connection pool definition
- String connectionPoolName =
- VariableUtils.replace( database.getConnectionPool(), environment.getVariables() );
- JDBCConnectionPool connectionPool = null;
- for ( Iterator applicationServerIterator =
- environment.getJEEApplicationServers().getJEEApplicationServers().iterator();
- applicationServerIterator.hasNext(); )
- {
- JEEApplicationServer applicationServer = (JEEApplicationServer) applicationServerIterator.next();
- connectionPool = applicationServer.getJDBCConnectionPool( connectionPoolName );
- if ( connectionPool != null )
- {
- break;
- }
- }
- if ( connectionPool == null )
- {
- LOGGER.error( "JDBC connection pool {} is not found in any JEE application servers",
- connectionPoolName );
+ LOGGER.error( "Location {} update failed", location.getName(), clientException );
throw new UpdateException(
- "JDBC connection pool " + connectionPoolName + " is not found in any JEE application servers" );
- }
- user = VariableUtils.replace( connectionPool.getUser(), environment.getVariables() );
- password = VariableUtils.replace( connectionPool.getPassword(), environment.getVariables() );
- driver = VariableUtils.replace( connectionPool.getDriver(), environment.getVariables() );
- url = VariableUtils.replace( connectionPool.getUrl(), environment.getVariables() );
+ "Location " + location.getName() + " update failed: " + clientException.getMessage(),
+ clientException );
}
- else
- {
- // use the database data
- LOGGER.debug( "Use database data definition" );
- user = VariableUtils.replace( database.getUser(), environment.getVariables() );
- password = VariableUtils.replace( database.getPassword(), environment.getVariables() );
- driver = VariableUtils.replace( database.getDriver(), environment.getVariables() );
- url = VariableUtils.replace( database.getJdbcurl(), environment.getVariables() );
- }
- // execute SQL script
- SqlScriptUtils.executeUsingJdbc( sqlScriptRuntime, driver, user, password, url );
- }
- // add log messages
- updateLog.setStatus( "Update performed" );
- updateLog.setUpdated( true );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "SQL script " + sqlScript.getName() + " executed" ) );
- EventUtils.post( environment, "UPDATE", "SQL script " + sqlScript.getName() + " executed" );
- LOGGER.info( "SQL script {} executed sucessfully", sqlScript.getName() );
+ return;
}
- }
- catch ( Exception e )
- {
- // SQL script execution failed, delete SQL script from the cache
+
+ // constructs the location URI
+ String locationUri = VariableUtils.replace( location.getUri(), environment.getVariables() );
+ if ( !FileManipulator.protocolExists( locationUri ) )
+ {
+ LOGGER.debug( "The location URI is relative to the software URI" );
+ locationUri =
+ FileManipulator.format( VariableUtils.replace( software.getUri(), environment.getVariables() ) ) + "!/"
+ + locationUri;
+ }
+ // constructs the location destination path
+ String locationPath = VariableUtils.replace( location.getPath(), environment.getVariables() );
+ // get a file manipulator
+ FileManipulator fileManipulator = null;
try
{
- fileManipulator.delete( sqlScriptRuntime );
+ fileManipulator = new FileManipulator();
}
catch ( FileManipulatorException fileManipulatorException )
{
- LOGGER.warn( "Can't delete SQL script cache", fileManipulatorException );
+ LOGGER.error( "Can't initialize file manipulator", fileManipulatorException );
+ throw new UpdateException( "Can't initialize file manipulator", fileManipulatorException );
}
- LOGGER.error( "SQL script {} execution failed", sqlScript.getName(), e );
- throw new UpdateException( "SQL script " + sqlScript.getName() + " execution failed", e );
- }
+ try
+ {
+ LOGGER.debug( "Copying {} to {}", locationUri, locationPath );
+ fileManipulator.copy( locationUri, locationPath );
+ updateLog.setUpdated( true );
+ }
+ catch ( FileManipulatorException fileManipulatorException )
+ {
+ LOGGER.error( "Location {} update failed", location.getName(), fileManipulatorException );
+ throw new UpdateException( "Location " + location.getName() + " update failed", fileManipulatorException );
+ }
+ LOGGER.info( "Software {} location {} updated", software.getName(), location.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Software " + software.getName() + " location "
+ + location.getName() + " updated" ) );
+ EventUtils.post( environment, "UPDATE",
+ "Software " + software.getName() + " location " + location.getName() + " updated" );
}
- }
+
+ /**
+ * Wrapper method to update a configuration file (via WS).
+ *
+ * @param environmentName the target environment name.
+ * @param softwareName the target software name.
+ * @param configurationFileName the target configuration file name.
+ * @param delegation true if the call is made by another agent (delegation), false if the call is made by a client.
+ * @throws KalumetException in case of update failure.
+ */
+ public static void updateConfigurationFile( String environmentName, String softwareName,
+ String configurationFileName, boolean delegation )
+ throws KalumetException
+ {
+ LOGGER.info( "Software {} configuration file {} update requested by WS", softwareName, configurationFileName );
+
+ // loading configuration
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ Software software = environment.getSoftware( softwareName );
+ if ( software == null )
+ {
+ LOGGER.error( "Software {} is not found in environment {}", softwareName, environmentName );
+ throw new KalumetException(
+ "Software " + softwareName + " is not found in environment " + environmentName );
+ }
+ ConfigurationFile configurationFile = software.getConfigurationFile( configurationFileName );
+ if ( configurationFile == null )
+ {
+ LOGGER.error( "Configuration file {} is not found in software {}", configurationFileName, softwareName );
+ throw new KalumetException(
+ "Configuration file " + configurationFileName + " is not found in software " + softwareName );
+ }
+
+ // update agent configuration cache
+ LOGGER.debug( "Updating agent configuration cache" );
+ Configuration.CONFIG_CACHE = kalumet;
+
+ // post journal event
+ EventUtils.post( environment, "UPDATE",
+ "Software " + software.getName() + " configuration file " + configurationFile.getName()
+ + " update requested by WS" );
+ // create update log
+ UpdateLog updateLog = new UpdateLog(
+ "Software " + software.getName() + " configuration file " + configurationFile.getName()
+ + " update in progress ...", environment.getName(), environment );
+
+ if ( !delegation )
+ {
+ // the update is not call by another agent, it's an atomic update
+ LOGGER.info( "Send a notification and waiting for the count down" );
+ EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
+ NotifierUtils.waitAndNotify( environment );
+ }
+
+ try
+ {
+ // call software updater
+ LOGGER.debug( "Call software updater" );
+ SoftwareUpdater.updateConfigurationFile( environment, software, configurationFile, updateLog );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Configuration file {} update failed", configurationFile.getName(), e );
+ EventUtils.post( environment, "ERROR",
+ "Configuration file " + configurationFile.getName() + " update failed: "
+ + e.getMessage() );
+ if ( !delegation )
+ {
+ updateLog.setStatus( "Configuration file " + configurationFile.getName() + " update failed" );
+ updateLog.addUpdateMessage( new UpdateMessage( "error",
+ "Configuration file " + configurationFile.getName()
+ + " update failed: " + e.getMessage() ) );
+ PublisherUtils.publish( environment );
+ }
+ throw new UpdateException( "Configuration file " + configurationFile.getName() + " update failed", e );
+ }
+
+ // configuration file updated
+ LOGGER.info( "Configuration file {} updated", configurationFile.getName() );
+ EventUtils.post( environment, "UPDATE", "Configuration file " + configurationFile.getName() + " updated" );
+ if ( !delegation )
+ {
+ updateLog.setStatus( "Configuration file " + configurationFile.getName() + " updated" );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Configuration file " + configurationFile.getName() + " updated" ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
+ }
+ }
+
+ /**
+ * Update an <code>Software</code> <code>ConfigurationFile</code>.
+ *
+ * @param environment the target <code>Environment</code>.
+ * @param software the target <code>Software</code>.
+ * @param configurationFile the target <code>ConfigurationFile</code>.
+ * @param updateLog the <code>UpdateLog</code> to use.
+ * @throws UpdateException in case of error during the configuration file update.
+ */
+ public static void updateConfigurationFile( Environment environment, Software software,
+ ConfigurationFile configurationFile, UpdateLog updateLog )
+ throws UpdateException
+ {
+ LOGGER.info( "Updating software {} configuration file {}", software.getName(), configurationFile.getName() );
+
+ if ( !configurationFile.isActive() )
+ {
+ LOGGER.info( "Software {} configuration file {} is inactive, so not updated", software.getName(),
+ configurationFile.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info",
+ "Software " + software.getName() + " configuration file "
+ + configurationFile.getName()
+ + " is inactive, so not updated" ) );
+ EventUtils.post( environment, "UPDATE",
+ "Software " + software.getName() + " configuration file " + configurationFile.getName()
+ + " is inactive, so not updated" );
+ return;
+ }
+
+ if ( configurationFile.getAgent() != null && configurationFile.getAgent().trim().length() > 0
+ && !configurationFile.getAgent().equals( Configuration.AGENT_ID ) )
+ {
+ // delegates configuration file update to another agent
+ LOGGER.info( "Delegating configuration file {} update to agent {}", configurationFile.getName(),
+ configurationFile.getAgent() );
+ Agent agentDelegation = Configuration.CONFIG_CACHE.getAgent( configurationFile.getAgent() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Delegating configuration file "
+ + configurationFile.getName() + " update to agent " + configurationFile.getAgent() ) );
+ EventUtils.post( environment, "UPDATE",
+ "Delegating configuration file " + configurationFile.getName() + " update to agent "
+ + configurationFile.getAgent() );
+ if ( agentDelegation == null )
+ {
+ LOGGER.error( "Agent {} is not found in the configuration", configurationFile.getAgent() );
+ throw new UpdateException(
+ "Agent " + configurationFile.getAgent() + " is not found in the configuration" );
+ }
+ try
+ {
+ // call WS
+ LOGGER.debug( "Call software WS" );
+ SoftwareClient client = new SoftwareClient( agentDelegation.getHostname(), agentDelegation.getPort() );
+ client.updateConfigurationFile( environment.getName(), software.getName(), configurationFile.getName(),
+ true );
+ }
+ catch ( ClientException clientException )
+ {
+ LOGGER.error( "Configuration file {} update failed", configurationFile.getName(), clientException );
+ throw new UpdateException( "Configuration file " + configurationFile.getName() + " update failed",
+ clientException );
+ }
+ return;
+ }
+
+ // defines the configuration file URI
+ LOGGER.debug( "Getting configuration file URI" );
+ String configurationFileUri = VariableUtils.replace( configurationFile.getUri(), environment.getVariables() );
+ if ( !FileManipulator.protocolExists( configurationFileUri ) )
+ {
+ LOGGER.debug( "The configuration file URI is relative to the software URI" );
+ configurationFileUri =
+ FileManipulator.format( VariableUtils.replace( software.getUri(), environment.getVariables() ) ) + "!/"
+ + configurationFileUri;
+ }
+
+ // defines the software cache directory
+ LOGGER.debug( "Getting software cache directory" );
+ String softwareCacheDir = null;
+ try
+ {
+ softwareCacheDir = FileManipulator.createSoftwareCacheDir( environment, software );
+ }
+ catch ( FileManipulatorException fileManipulatorException )
+ {
+ LOGGER.error( "Can't initialize software cache directory", fileManipulatorException );
+ throw new UpdateException( "Can't initialize software cache directory", fileManipulatorException );
+ }
+
+ // initializes file manipulator
+ LOGGER.debug( "Initializing file manipulator" );
+ FileManipulator fileManipulator = null;
+ try
+ {
+ fileManipulator = new FileManipulator();
+ }
+ catch ( FileManipulatorException fileManipulatorException )
+ {
+ LOGGER.error( "Can't initialize file manipulator", fileManipulatorException );
+ throw new UpdateException( "Can't initialize file manipulator", fileManipulatorException );
+ }
+
+ // copy configuration file into cache
+ String configurationFileCacheLocation = softwareCacheDir + "/config/" + configurationFile.getName();
+ LOGGER.debug( "Copying configuration file {} into cache", configurationFile.getName() );
+ try
+ {
+ fileManipulator.copy( configurationFileUri, configurationFileCacheLocation );
+ }
+ catch ( FileManipulatorException fileManipulatorException )
+ {
+ LOGGER.error( "Can't copy configuration file {} into cache", configurationFile.getName(),
+ fileManipulatorException );
+ throw new UpdateException( "Can't copy configuration file " + configurationFile.getName() + " into cache",
+ fileManipulatorException );
+ }
+
+ // change mappings into the configuration file cache
+ LOGGER.debug( "Replacing mappings key/value" );
+ for ( Iterator mappingIterator = configurationFile.getMappings().iterator(); mappingIterator.hasNext(); )
+ {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ FileManipulator.searchAndReplace( mapping.getKey(),
+ VariableUtils.replace( mapping.getValue(), environment.getVariables() ),
+ configurationFileCacheLocation );
+ }
+
+ // compare configuration file cache with target
+ LOGGER.debug( "Comparing the configuration file cache with the target location" );
+ String configurationFileDestinationPath =
+ VariableUtils.replace( configurationFile.getPath(), environment.getVariables() );
+ try
+ {
+ if ( !fileManipulator.contentEquals( configurationFileCacheLocation, configurationFileDestinationPath ) )
+ {
+ // the configuration file needs to be updated
+ LOGGER.debug( "Configuration file {} needs to be updated", configurationFile.getName() );
+ fileManipulator.copy( configurationFileCacheLocation, configurationFileDestinationPath );
+ updateLog.setStatus( "UPDATE PERFORMED" );
+ updateLog.setUpdated( true );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "Configuration file " + configurationFile.getName() + " updated" ) );
+ EventUtils.post( environment, "UPDATE",
+ "Configuration file " + configurationFile.getName() + " updated" );
+ LOGGER.info( "Configuration file {} updated", configurationFile.getName() );
+ }
+ }
+ catch ( FileManipulatorException fileManipulatorException )
+ {
+ LOGGER.error( "Configuration file {} update failed", configurationFile.getName(),
+ fileManipulatorException );
+ throw new UpdateException( "Configuration file " + configurationFile.getName() + " update failed: "
+ + fileManipulatorException.getMessage(), fileManipulatorException );
+ }
+ }
+
+ /**
+ * Wrapper method to update a software database (via WS).
+ *
+ * @param environmentName the target environment name.
+ * @param softwareName the target software name.
+ * @param databaseName the target database name.
+ * @param delegation true if the call is made by another agent (delegation), false if the call is made by a client.
+ * @throws KalumetException in case of update failure.
+ */
+ public static void updateDatabase( String environmentName, String softwareName, String databaseName,
+ boolean delegation )
+ throws KalumetException
+ {
+ LOGGER.info( "Software {} database {} update requested by WS", softwareName, databaseName );
+
+ // load configuration
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ Software software = environment.getSoftware( softwareName );
+ if ( software == null )
+ {
+ LOGGER.error( "Software {} is not found in environment {}", softwareName, environmentName );
+ throw new KalumetException(
+ "Software " + softwareName + " is not found in environment " + environmentName );
+ }
+ Database database = software.getDatabase( databaseName );
+ if ( database == null )
+ {
+ LOGGER.error( "Database {} is not found in software {}", databaseName, softwareName );
+ throw new KalumetException( "Database " + databaseName + " is not found in software " + softwareName );
+ }
+
+ // updating configuration cache
+ LOGGER.debug( "Updating configuration cache" );
+ Configuration.CONFIG_CACHE = kalumet;
+
+ // post journal event
+ EventUtils.post( environment, "UPDATE", "Software " + software.getName() + " database " + database.getName()
+ + " update requested by WS" );
+ // create update log
+ UpdateLog updateLog = new UpdateLog(
+ "Software " + software.getName() + " database " + database.getName() + " update in progress ...",
+ environment.getName(), environment );
+
+ if ( !delegation )
+ {
+ // the call is not a delegation from another agent, it's an atomic update
+ LOGGER.info( "Send a notification and waiting for the count down" );
+ EventUtils.post( environment, "UPDATE", "Send a notification and waiting for the count down" );
+ NotifierUtils.waitAndNotify( environment );
+ }
+
+ try
+ {
+ // call software updater
+ LOGGER.debug( "Call software updater" );
+ SoftwareUpdater.updateDatabase( environment, software, database, updateLog );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Database {} update failed", database.getName(), e );
+ EventUtils.post( environment, "ERROR",
+ "Database " + database.getName() + " update failed: " + e.getMessage() );
+ if ( !delegation )
+ {
+ updateLog.setStatus( "Database " + database.getName() + " update failed" );
+ updateLog.addUpdateMessage( new UpdateMessage( "error",
+ "Database " + database.getName() + " update failed: "
+ + e.getMessage() ) );
+ PublisherUtils.publish( environment );
+ }
+ throw new UpdateException( "Database " + database.getName() + " update failed", e );
+ }
+
+ // database updated
+ LOGGER.info( "Database {} updated", database.getName() );
+ EventUtils.post( environment, "UPDATE", "Database " + database.getName() + " updated" );
+ if ( !delegation )
+ {
+ updateLog.setStatus( "Database " + database.getName() + " updated" );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Database " + database.getName() + " updated" ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
+ }
+ }
+
+ /**
+ * Update a software database.
+ *
+ * @param environment the target <code>Environment</code>.
+ * @param software the target <code>Software</code>.
+ * @param database the target <code>Database</code>.
+ * @param updateLog the update logger to use.
+ */
+ public static void updateDatabase( Environment environment, Software software, Database database,
+ UpdateLog updateLog )
+ throws UpdateException
+ {
+ LOGGER.info( "Update software {} database {}", software.getName(), database.getName() );
+
+ if ( !database.isActive() )
+ {
+ LOGGER.info( "Software {} database {} (environment {}) is inactive, so not updated",
+ new Object[]{ software.getName(), database.getName(), environment.getName() } );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Software " + software.getName() + " database "
+ + database.getName() + " is inactive, so not updated" ) );
+ EventUtils.post( environment, "UPDATE", "Software " + software.getName() + " database " + database.getName()
+ + " is inactive, so not updated" );
+ return;
+ }
+
+ if ( database.getAgent() != null && database.getAgent().trim().length() > 0 && !database.getAgent().equals(
+ Configuration.AGENT_ID ) )
+ {
+ // the database update is delegated to another agent
+ LOGGER.info( "Delegating software {} database {} update to agent {}",
+ new Object[]{ software.getName(), database.getName(), database.getAgent() } );
+ Agent delegationAgent = Configuration.CONFIG_CACHE.getAgent( database.getAgent() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Delegating database " + database.getName()
+ + " update to agent " + database.getAgent() ) );
+ EventUtils.post( environment, "UPDATE",
+ "Delegating database " + database.getName() + " update to agent " + database.getAgent() );
+ if ( delegationAgent == null )
+ {
+ // the database agent is not found in the configuration
+ LOGGER.error( "Agent {} is not found in the configuration", database.getAgent() );
+ throw new UpdateException( "Agent " + database.getAgent() + " is not found in the configuration" );
+ }
+ try
+ {
+ // call the WebService
+ LOGGER.debug( "Call software WS" );
+ SoftwareClient client = new SoftwareClient( delegationAgent.getHostname(), delegationAgent.getPort() );
+ client.updateDatabase( environment.getName(), software.getName(), database.getName(), true );
+ }
+ catch ( ClientException clientException )
+ {
+ LOGGER.error( "Database {} update failed", database.getName(), clientException );
+ throw new UpdateException( "Database " + database.getName() + " update failed", clientException );
+ }
+ return;
+ }
+
+ // launch SQL scripts of the database
+ LOGGER.debug( "Executing SQL scripts" );
+ for ( Iterator sqlScriptIterator = database.getSqlScripts().iterator(); sqlScriptIterator.hasNext(); )
+ {
+ SqlScript sqlScript = (SqlScript) sqlScriptIterator.next();
+ try
+ {
+ SoftwareUpdater.executeSqlScript( environment, software, database, sqlScript, updateLog );
+ }
+ catch ( UpdateException updateException )
+ {
+ // SQL script execution has failed
+ if ( sqlScript.isBlocker() )
+ {
+ // the SQL script is update blocker
+ LOGGER.error( "SQL script {} execution failed", updateException );
+ throw new UpdateException( "SQL script " + sqlScript.getName() + " execution failed",
+ updateException );
+ }
+ else
+ {
+ // the SQL script is not update blocker
+ LOGGER.warn( "SQL script {} execution failed", updateException );
+ updateLog.addUpdateMessage( new UpdateMessage( "warn", "SQL script " + sqlScript.getName()
+ + " execution failed: " + updateException.getMessage() ) );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "SQL script " + sqlScript.getName()
+ + " is not update blocker, update continues" ) );
+ EventUtils.post( environment, "WARN", "SQL script " + sqlScript.getName() + " execution failed: "
+ + updateException.getMessage() );
+ EventUtils.post( environment, "UPDATE",
+ "SQL script " + sqlScript.getName() + " is not update blocker, update continues" );
+ }
+ }
+ }
+ }
+
+ /**
+ * Executes SQL script.
+ *
+ * @param environment the target <code>Environment</code>.
+ * @param software the target <code>Software</code>.
+ * @param database the target <code>Database</code>.
+ * @param sqlScript the target <code>SqlScript</code>.
+ * @param updateLog the update log to use.
+ * @throws UpdateException in case of error during the SQL script execution.
+ */
+ public static void executeSqlScript( Environment environment, Software software, Database database,
+ SqlScript sqlScript, UpdateLog updateLog )
+ throws UpdateException
+ {
+ LOGGER.info( "Executing SQL script {}", sqlScript.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Executing SQL script " + sqlScript.getName() ) );
+ EventUtils.post( environment, "UPDATE", "Executing SQL script " + sqlScript.getName() );
+
+ if ( !sqlScript.isActive() )
+ {
+ // the SQL script is not active
+ LOGGER.info( "SQL script {} is inactive, so not executed", sqlScript.getName() );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "SQL script " + sqlScript.getName() + " is inactive, so not executed" ) );
+ EventUtils.post( environment, "UPDATE",
+ "SQL script " + sqlScript.getName() + " is inactive, so not executed" );
+ return;
+ }
+
+ // construct the SQL script URI
+ String sqlScriptUri = VariableUtils.replace( sqlScript.getUri(), environment.getVariables() );
+ if ( !FileManipulator.protocolExists( sqlScriptUri ) )
+ {
+ // the SQL script URI is relative, constructs using the software URI
+ LOGGER.debug( "The SQL script URI is relative to the software URI" );
+ sqlScriptUri =
+ FileManipulator.format( VariableUtils.replace( software.getUri(), environment.getVariables() ) ) + "!/"
+ + sqlScriptUri;
+ }
+
+ // get the cache directory
+ LOGGER.debug( "Getting software cache directory" );
+ String softwareCacheDir = null;
+ try
+ {
+ softwareCacheDir = FileManipulator.createSoftwareCacheDir( environment, software );
+ }
+ catch ( FileManipulatorException fileManipulatorException )
+ {
+ LOGGER.error( "Can't initialize software cache directory", fileManipulatorException );
+ throw new UpdateException( "Can't initialize software cache directory", fileManipulatorException );
+ }
+
+ // get file manipulator instance
+ LOGGER.debug( "Initializing file manipulator" );
+ FileManipulator fileManipulator = null;
+ try
+ {
+ fileManipulator = new FileManipulator();
+ }
+ catch ( FileManipulatorException fileManipulatorException )
+ {
+ LOGGER.error( "Can't initialize file manipulator", fileManipulatorException );
+ throw new UpdateException( "Can't initialize file manipulator", fileManipulatorException );
+ }
+
+ // copy the SQL script into the software cache directory
+ LOGGER.debug( "Copying the SQL script into the software cache directory" );
+ String sqlScriptCache = softwareCacheDir + "/sql/" + sqlScript.getName() + ".cache";
+ String sqlScriptRuntime = softwareCacheDir + "/sql/" + sqlScript.getName();
+ try
+ {
+ fileManipulator.copy( sqlScriptUri, sqlScriptCache );
+ }
+ catch ( FileManipulatorException fileManipulatorException )
+ {
+ LOGGER.error( "Can't copy SQL script from {} to {}", new Object[]{ sqlScriptUri, sqlScriptCache },
+ fileManipulatorException );
+ throw new UpdateException( "Can't copy SQL script " + sqlScriptUri + " to " + sqlScriptCache,
+ fileManipulatorException );
+ }
+
+ if ( fileManipulator.isFolder( sqlScriptCache ) )
+ {
+ // TODO add a generic method to reuse in the case of directory
+
+ // the user provided a directory
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", sqlScript.getName() + "is a folder, iterate in the SQL scripts" ) );
+ EventUtils.post( environment, "UPDATE", sqlScript.getName() + " is a folder, iterate in the SQL scripts" );
+ LOGGER.info( "{} is a folder, iterate in the SQL scripts", sqlScript.getName() );
+ FileObject[] children = fileManipulator.browse( sqlScriptCache );
+ for ( int i = 0; i < children.length; i++ )
+ {
+ FileObject current = children[i];
+ String name = current.getName().getBaseName();
+ String singleSqlScriptCache = sqlScriptCache + "/" + name;
+ String singleSqlScriptRuntime = sqlScriptRuntime + "/" + name;
+ // change mappings in the current SQL script
+ for ( Iterator mappingIterator = sqlScript.getMappings().iterator(); mappingIterator.hasNext(); )
+ {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ FileManipulator.searchAndReplace( mapping.getKey(), VariableUtils.replace( mapping.getValue(),
+ environment.getVariables() ),
+ singleSqlScriptCache );
+ }
+ try
+ {
+ if ( sqlScript.isForce() || ( !fileManipulator.contentEquals( singleSqlScriptCache,
+ singleSqlScriptRuntime ) ) )
+ {
+ fileManipulator.copy( singleSqlScriptCache, singleSqlScriptRuntime );
+
+ if ( database.getSqlCommand() != null && database.getSqlCommand().trim().length() > 0 )
+ {
+ // execute SQL script using system command
+ String command =
+ VariableUtils.replace( database.getSqlCommand(), environment.getVariables() );
+ String output = SqlScriptUtils.executeUsingCommand( singleSqlScriptRuntime, command );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "SQL script " + name + " executed: " + output ) );
+ EventUtils.post( environment, "UPDATE", "SQL script " + name + " executed: " + output );
+ LOGGER.info( "SQL script {} executed succesfully", name );
+ }
+ else
+ {
+ // execute SQL script using JDBC
+ String user = null;
+ String password = null;
+ String driver = null;
+ String url = null;
+ if ( database.getConnectionPool() != null
+ && database.getConnectionPool().trim().length() > 0 )
+ {
+ // the database is linked to a connection pool
+ // looking for the connection pool (from the cache)
+ LOGGER.debug( "Database has a reference to a connection pool" );
+ // looking for the connection pool definition
+ String connectionPoolName =
+ VariableUtils.replace( database.getConnectionPool(), environment.getVariables() );
+ JDBCConnectionPool connectionPool = null;
+ for ( Iterator applicationServerIterator =
+ environment.getJEEApplicationServers().getJEEApplicationServers().iterator();
+ applicationServerIterator.hasNext(); )
+ {
+ JEEApplicationServer applicationServer =
+ (JEEApplicationServer) applicationServerIterator.next();
+ connectionPool = applicationServer.getJDBCConnectionPool( connectionPoolName );
+ if ( connectionPool != null )
+ {
+ break;
+ }
+ }
+ if ( connectionPool == null )
+ {
+ LOGGER.error( "JDBC connection pool {} is not found in any JEE application servers",
+ connectionPoolName );
+ throw new UpdateException( "JDBC connection pool " + connectionPoolName
+ + " is not found in any JEE application servers" );
+ }
+ user = VariableUtils.replace( connectionPool.getUser(), environment.getVariables() );
+ password =
+ VariableUtils.replace( connectionPool.getPassword(), environment.getVariables() );
+ driver =
+ VariableUtils.replace( connectionPool.getDriver(), environment.getVariables() );
+ url = VariableUtils.replace( connectionPool.getUrl(), environment.getVariables() );
+ }
+ else
+ {
+ // use the database connection data
+ user = VariableUtils.replace( database.getUser(), environment.getVariables() );
+ password = VariableUtils.replace( database.getPassword(), environment.getVariables() );
+ driver = VariableUtils.replace( database.getDriver(), environment.getVariables() );
+ url = VariableUtils.replace( database.getJdbcurl(), environment.getVariables() );
+ }
+ // execute SQL script using JDBC
+ SqlScriptUtils.executeUsingJdbc( singleSqlScriptRuntime, driver, user, password, url );
+ }
+ // add message
+ updateLog.setStatus( "Update performed" );
+ updateLog.setUpdated( true );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "SQL script " + sqlScript.getName() + " executed" ) );
+ EventUtils.post( environment, "UPDATE", "SQL script " + sqlScript.getName() + " executed" );
+ LOGGER.info( "SQL script " + sqlScript.getName() + " executed" );
+ }
+ }
+ catch ( Exception e )
+ {
+ // SQL script execution failed, delete the SQL script from the cache
+ try
+ {
+ fileManipulator.delete( sqlScriptRuntime );
+ }
+ catch ( FileManipulatorException fileManipulatorException )
+ {
+ LOGGER.warn( "Can't delete SQL script cache", fileManipulatorException );
+ }
+ LOGGER.error( "SQL script {} execution failed", sqlScript.getName(), e );
+ throw new UpdateException( "SQL script " + sqlScript.getName() + " execution failed", e );
+ }
+ }
+ }
+ else
+ {
+ // the user provided a single SQL script
+
+ // change mappings into the SQL script
+ LOGGER.debug( "Replacing mappings into the SQL script {}", sqlScript.getName() );
+ for ( Iterator mappingIterator = sqlScript.getMappings().iterator(); mappingIterator.hasNext(); )
+ {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ FileManipulator.searchAndReplace( mapping.getKey(), mapping.getValue(), sqlScriptCache );
+ }
+
+ // compare the SQL script origin with the runtime one
+ try
+ {
+ if ( !fileManipulator.contentEquals( sqlScriptCache, sqlScriptRuntime ) )
+ {
+ // the SQL script needs to be executed
+ LOGGER.debug( "The SQL script {} needs to be executed", sqlScript.getName() );
+ // copy the SQL script cache to the runtime
+ LOGGER.debug( "Copy the SQL script cache to the runtime" );
+ fileManipulator.copy( sqlScriptCache, sqlScriptRuntime );
+ if ( database.getSqlCommand() != null && database.getSqlCommand().trim().length() > 0 )
+ {
+ // execute the SQL script using a command
+ LOGGER.info( "Executing the SQL script using a system command" );
+ String command = VariableUtils.replace( database.getSqlCommand(), environment.getVariables() );
+ String output = SqlScriptUtils.executeUsingCommand( sqlScriptRuntime, command );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "SQL script " + sqlScript.getName() + " executed: " + output ) );
+ EventUtils.post( environment, "UPDATE",
+ "SQL script " + sqlScript.getName() + " executed: " + output );
+ LOGGER.info( "SQL script {} executed successfully", sqlScript.getName() );
+ }
+ else
+ {
+ // execute SQL script using JDBC
+ LOGGER.info( "Executing SQL script using JDBC" );
+ String user = null;
+ String password = null;
+ String driver = null;
+ String url = null;
+ if ( database.getConnectionPool() != null && database.getConnectionPool().trim().length() > 0 )
+ {
+ // the database has a reference to an existing connection pool
+ LOGGER.debug( "Database has a reference to a connection pool" );
+ // looking for the connection pool definition
+ String connectionPoolName =
+ VariableUtils.replace( database.getConnectionPool(), environment.getVariables() );
+ JDBCConnectionPool connectionPool = null;
+ for ( Iterator applicationServerIterator =
+ environment.getJEEApplicationServers().getJEEApplicationServers().iterator();
+ applicationServerIterator.hasNext(); )
+ {
+ JEEApplicationServer applicationServer =
+ (JEEApplicationServer) applicationServerIterator.next();
+ connectionPool = applicationServer.getJDBCConnectionPool( connectionPoolName );
+ if ( connectionPool != null )
+ {
+ break;
+ }
+ }
+ if ( connectionPool == null )
+ {
+ LOGGER.error( "JDBC connection pool {} is not found in any JEE application servers",
+ connectionPoolName );
+ throw new UpdateException( "JDBC connection pool " + connectionPoolName
+ + " is not found in any JEE application servers" );
+ }
+ user = VariableUtils.replace( connectionPool.getUser(), environment.getVariables() );
+ password =
+ VariableUtils.replace( connectionPool.getPassword(), environment.getVariables() );
+ driver = VariableUtils.replace( connectionPool.getDriver(), environment.getVariables() );
+ url = VariableUtils.replace( connectionPool.getUrl(), environment.getVariables() );
+ }
+ else
+ {
+ // use the database data
+ LOGGER.debug( "Use database data definition" );
+ user = VariableUtils.replace( database.getUser(), environment.getVariables() );
+ password = VariableUtils.replace( database.getPassword(), environment.getVariables() );
+ driver = VariableUtils.replace( database.getDriver(), environment.getVariables() );
+ url = VariableUtils.replace( database.getJdbcurl(), environment.getVariables() );
+ }
+ // execute SQL script
+ SqlScriptUtils.executeUsingJdbc( sqlScriptRuntime, driver, user, password, url );
+ }
+ // add log messages
+ updateLog.setStatus( "Update performed" );
+ updateLog.setUpdated( true );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "SQL script " + sqlScript.getName() + " executed" ) );
+ EventUtils.post( environment, "UPDATE", "SQL script " + sqlScript.getName() + " executed" );
+ LOGGER.info( "SQL script {} executed sucessfully", sqlScript.getName() );
+ }
+ }
+ catch ( Exception e )
+ {
+ // SQL script execution failed, delete SQL script from the cache
+ try
+ {
+ fileManipulator.delete( sqlScriptRuntime );
+ }
+ catch ( FileManipulatorException fileManipulatorException )
+ {
+ LOGGER.warn( "Can't delete SQL script cache", fileManipulatorException );
+ }
+ LOGGER.error( "SQL script {} execution failed", sqlScript.getName(), e );
+ throw new UpdateException( "SQL script " + sqlScript.getName() + " execution failed", e );
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/SqlScriptUpdater.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/SqlScriptUpdater.java
index 060d3f5..b41830c 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/SqlScriptUpdater.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/SqlScriptUpdater.java
@@ -24,8 +24,14 @@
import org.apache.kalumet.KalumetException;
import org.apache.kalumet.agent.Configuration;
import org.apache.kalumet.agent.utils.EventUtils;
-import org.apache.kalumet.model.*;
+import org.apache.kalumet.model.Database;
+import org.apache.kalumet.model.Environment;
+import org.apache.kalumet.model.JDBCConnectionPool;
import org.apache.kalumet.model.JEEApplication;
+import org.apache.kalumet.model.JEEApplicationServer;
+import org.apache.kalumet.model.Kalumet;
+import org.apache.kalumet.model.Mapping;
+import org.apache.kalumet.model.SqlScript;
import org.apache.kalumet.model.update.UpdateLog;
import org.apache.kalumet.model.update.UpdateMessage;
import org.apache.kalumet.utils.NotifierUtils;
@@ -43,387 +49,400 @@
public class SqlScriptUpdater
{
- private static final transient Logger LOGGER = LoggerFactory.getLogger( SqlScriptUpdater.class );
+ private static final transient Logger LOGGER = LoggerFactory.getLogger( SqlScriptUpdater.class );
- /**
- * Executes SQL script.
- *
- * @param environment the target <code>Environment</code>.
- * @param server the target <code>JEEApplicationServer</code>.
- * @param application the target <code>JEEApplication</code>.
- * @param database the target <code>Database</code>.
- * @param sqlScript the target <code>SqlScript</code>.
- * @param updateLog the <code>UpdateLog</code> to use.
- * @throws UpdateException in case of update failure.
- */
- public static void execute( Environment environment, JEEApplicationServer server, JEEApplication application,
- Database database, SqlScript sqlScript, UpdateLog updateLog )
- throws UpdateException
- {
- LOGGER.info( "Executing SQL script {}", sqlScript.getName() );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "Executing SQL script " + sqlScript.getName() ) );
- EventUtils.post( environment, "UPDATE", "Executing SQL script " + sqlScript.getName() );
+ /**
+ * Executes SQL script.
+ *
+ * @param environment the target <code>Environment</code>.
+ * @param server the target <code>JEEApplicationServer</code>.
+ * @param application the target <code>JEEApplication</code>.
+ * @param database the target <code>Database</code>.
+ * @param sqlScript the target <code>SqlScript</code>.
+ * @param updateLog the <code>UpdateLog</code> to use.
+ * @throws UpdateException in case of update failure.
+ */
+ public static void execute( Environment environment, JEEApplicationServer server, JEEApplication application,
+ Database database, SqlScript sqlScript, UpdateLog updateLog )
+ throws UpdateException
+ {
+ LOGGER.info( "Executing SQL script {}", sqlScript.getName() );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "Executing SQL script " + sqlScript.getName() ) );
+ EventUtils.post( environment, "UPDATE", "Executing SQL script " + sqlScript.getName() );
- if ( !sqlScript.isActive() )
- {
- // SQL script is not active
- LOGGER.info( "SQL Script {} is inactive, so not executed", sqlScript.getName() );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "SQL Script " + sqlScript.getName() + " is inactive, so not executed" ) );
- EventUtils.post( environment, "UPDATE", "SQL Script " + sqlScript.getName() + " is inactive, so not executed" );
- return;
- }
-
- // construct the SQL script URI
- String sqlScriptUri = VariableUtils.replace( sqlScript.getUri(), environment.getVariables() );
- if ( !FileManipulator.protocolExists( sqlScriptUri ) )
- {
- // the SQL script URI is relative , construct the SQL Script URI using
- // the JEE Application URI
- LOGGER.debug( "SQL Script URI is relative to JEE application URI" );
- sqlScriptUri =
- FileManipulator.format( VariableUtils.replace( application.getUri(), environment.getVariables() ) ) + "!/"
- + sqlScriptUri;
- }
- // get the application cache directory
- String applicationCacheDir = null;
- try
- {
- applicationCacheDir = FileManipulator.createJEEApplicationCacheDir( environment, application );
- }
- catch ( FileManipulatorException fileManipulatorException )
- {
- LOGGER.error( "Can't initialize JEE application cache directory", fileManipulatorException );
- throw new UpdateException( "Can't initialize JEE application cache directory", fileManipulatorException );
- }
-
- // get file manipulator instance
- FileManipulator fileManipulator = null;
- try
- {
- fileManipulator = new FileManipulator();
- }
- catch ( FileManipulatorException fileManipulatorException )
- {
- LOGGER.error( "Can't initialize the file manipulator", fileManipulatorException );
- throw new UpdateException( "Can't initialize the file manipulator", fileManipulatorException );
- }
-
- // copy the SQL script in the application working directory
- String sqlScriptCache = applicationCacheDir + "/sql/" + sqlScript.getName() + ".cache";
- String sqlScriptRuntime = applicationCacheDir + "/sql/" + sqlScript.getName();
- try
- {
- fileManipulator.copy( sqlScriptUri, sqlScriptCache );
- }
- catch ( FileManipulatorException fileManipulatorException )
- {
- LOGGER.error( "Can't copy the SQL script from {} to {}", new Object[]{ sqlScriptUri, sqlScriptCache },
- fileManipulatorException );
- throw new UpdateException( "Can't copy the SQL script from " + sqlScriptUri + " to " + sqlScriptCache,
- fileManipulatorException );
- }
-
- if ( fileManipulator.isFolder( sqlScriptCache ) )
- {
- // TODO add a generic method to reuse in the case of directory
-
- // the user provided a directory
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", sqlScript.getName() + " is a folder, iterate in the SQL scripts" ) );
- EventUtils.post( environment, "UPDATE", sqlScript.getName() + " is a folder, iterate in the SQL scripts" );
- LOGGER.info( sqlScript.getName() + " is a folder, iterate in the SQL scripts" );
- FileObject[] children = fileManipulator.browse( sqlScriptCache );
- for ( int i = 0; i < children.length; i++ )
- {
- FileObject current = children[i];
- String name = current.getName().getBaseName();
- String singleSqlScriptCache = sqlScriptCache + "/" + name;
- String singleSqlScriptRuntime = sqlScriptRuntime + "/" + name;
- // change mappings in the current SQL script
- for ( Iterator mappingIterator = sqlScript.getMappings().iterator(); mappingIterator.hasNext(); )
+ if ( !sqlScript.isActive() )
{
- Mapping mapping = (Mapping) mappingIterator.next();
- FileManipulator.searchAndReplace( mapping.getKey(),
- VariableUtils.replace( mapping.getValue(), environment.getVariables() ),
- singleSqlScriptCache );
+ // SQL script is not active
+ LOGGER.info( "SQL Script {} is inactive, so not executed", sqlScript.getName() );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "SQL Script " + sqlScript.getName() + " is inactive, so not executed" ) );
+ EventUtils.post( environment, "UPDATE",
+ "SQL Script " + sqlScript.getName() + " is inactive, so not executed" );
+ return;
}
+
+ // construct the SQL script URI
+ String sqlScriptUri = VariableUtils.replace( sqlScript.getUri(), environment.getVariables() );
+ if ( !FileManipulator.protocolExists( sqlScriptUri ) )
+ {
+ // the SQL script URI is relative , construct the SQL Script URI using
+ // the JEE Application URI
+ LOGGER.debug( "SQL Script URI is relative to JEE application URI" );
+ sqlScriptUri =
+ FileManipulator.format( VariableUtils.replace( application.getUri(), environment.getVariables() ) )
+ + "!/" + sqlScriptUri;
+ }
+ // get the application cache directory
+ String applicationCacheDir = null;
try
{
- if ( sqlScript.isForce() || ( !fileManipulator.contentEquals( singleSqlScriptCache,
- singleSqlScriptRuntime ) ) )
- {
- fileManipulator.copy( singleSqlScriptCache, singleSqlScriptRuntime );
- if ( database.getSqlCommand() != null && database.getSqlCommand().trim().length() > 0 )
- {
- // execute SQL script using system command
- String command = VariableUtils.replace( database.getSqlCommand(), environment.getVariables() );
- String output = SqlScriptUtils.executeUsingCommand( singleSqlScriptRuntime, command );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "SQL script " + name + " executed: " + output ) );
- EventUtils.post( environment, "UPDATE", "SQL script " + name + " executed:" + output );
- LOGGER.info( "SQL script " + name + " executed successfully" );
- }
- else
- {
- // execute SQL script using JDBC
- String user = null;
- String password = null;
- String driver = null;
- String url = null;
- if ( database.getConnectionPool() != null && database.getConnectionPool().trim().length() > 0 )
- {
- // the database is linked to a connection pool
- // looking for the connection pool (from the cache)
- String connectionPoolName =
- VariableUtils.replace( database.getConnectionPool(), environment.getVariables() );
- JDBCConnectionPool connectionPool = server.getJDBCConnectionPool( connectionPoolName );
- if ( connectionPool == null )
- {
- LOGGER.error( "JDBC connection pool {} is not found in JEE application server {}",
- database.getConnectionPool(), server.getName() );
- throw new UpdateException(
- "JDBC connection pool " + database.getConnectionPool() + " is not found in JEE application server "
- + server.getName() );
- }
- user = VariableUtils.replace( connectionPool.getUser(), environment.getVariables() );
- password = VariableUtils.replace( connectionPool.getPassword(), environment.getVariables() );
- driver = VariableUtils.replace( connectionPool.getDriver(), environment.getVariables() );
- url = VariableUtils.replace( connectionPool.getUrl(), environment.getVariables() );
- }
- else
- {
- // use the database connection data
- user = VariableUtils.replace( database.getUser(), environment.getVariables() );
- password = VariableUtils.replace( database.getPassword(), environment.getVariables() );
- driver = VariableUtils.replace( database.getDriver(), environment.getVariables() );
- url = VariableUtils.replace( database.getJdbcurl(), environment.getVariables() );
- }
- // execute SQL script using JDBC
- SqlScriptUtils.executeUsingJdbc( singleSqlScriptRuntime, driver, user, password, url );
- }
- // add message
- updateLog.setStatus( "Update performed" );
- updateLog.setUpdated( true );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "SQL script " + sqlScript.getName() + " executed" ) );
- EventUtils.post( environment, "UPDATE", "SQL script " + sqlScript.getName() + " executed" );
- LOGGER.info( "SQL script {} executed", sqlScript.getName() );
- }
- }
- catch ( Exception e )
- {
- // SQL script execution failed, delete the SQL script from the cache
- try
- {
- fileManipulator.delete( sqlScriptRuntime );
- }
- catch ( FileManipulatorException fileManipulatorException )
- {
- LOGGER.warn( "Can't delete {}/sql/{}", new Object[]{ applicationCacheDir, sqlScript.getName() },
- fileManipulatorException );
- }
- LOGGER.error( "SQL script {} execution failed", sqlScript.getName(), e );
- throw new UpdateException( "SQL script " + sqlScript.getName() + " execution failed", e );
- }
- }
- }
- else
- {
- // the user provided a single SQL script
-
- // change mappings in the SQL script
- for ( Iterator mappingIterator = sqlScript.getMappings().iterator(); mappingIterator.hasNext(); )
- {
- Mapping mapping = (Mapping) mappingIterator.next();
- FileManipulator.searchAndReplace( mapping.getKey(),
- VariableUtils.replace( mapping.getValue(), environment.getVariables() ),
- sqlScriptCache );
- }
-
- // compare the SQL script with the target one
- try
- {
- if ( sqlScript.isForce() || ( !fileManipulator.contentEquals( sqlScriptCache, sqlScriptRuntime ) ) )
- {
- // the SQL script needs to be updated and executed
- // copy the SQL script to the target
- fileManipulator.copy( sqlScriptCache, sqlScriptRuntime );
- if ( database.getSqlCommand() != null && database.getSqlCommand().trim().length() > 0 )
- {
- // execute SQL script using system command
- String command = VariableUtils.replace( database.getSqlCommand(), environment.getVariables() );
- String output = SqlScriptUtils.executeUsingCommand( sqlScriptRuntime, command );
- updateLog.addUpdateMessage(
- new UpdateMessage( "info", "SQL script " + sqlScript.getName() + " executed: " + output ) );
- EventUtils.post( environment, "UPDATE", "SQL script " + sqlScript.getName() + " executed: " + output );
- LOGGER.info( "SQL script " + sqlScript.getName() + " executed: " + output );
- }
- else
- {
- // execute SQL script using JDBC
- String user = null;
- String password = null;
- String driver = null;
- String url = null;
- if ( database.getConnectionPool() != null && database.getConnectionPool().trim().length() > 0 )
- {
- // the database is linked to a connection pool
- // looking for the connection pool (from the cache)
- String connectionPoolName =
- VariableUtils.replace( database.getConnectionPool(), environment.getVariables() );
- JDBCConnectionPool connectionPool = server.getJDBCConnectionPool( connectionPoolName );
- if ( connectionPool == null )
- {
- LOGGER.error( "JDBC connection pool {} is not found in JEE application server {}",
- database.getConnectionPool(), server.getName() );
- throw new UpdateException(
- "JDBC connection pool " + database.getConnectionPool() + " is not found in JEE application server "
- + server.getName() );
- }
- user = VariableUtils.replace( connectionPool.getUser(), environment.getVariables() );
- password = VariableUtils.replace( connectionPool.getPassword(), environment.getVariables() );
- driver = VariableUtils.replace( connectionPool.getDriver(), environment.getVariables() );
- url = VariableUtils.replace( connectionPool.getUrl(), environment.getVariables() );
- }
- else
- {
- // use the database connection data
- user = VariableUtils.replace( database.getUser(), environment.getVariables() );
- password = VariableUtils.replace( database.getPassword(), environment.getVariables() );
- driver = VariableUtils.replace( database.getDriver(), environment.getVariables() );
- url = VariableUtils.replace( database.getJdbcurl(), environment.getVariables() );
- }
- // execute SQL script using JDBC
- SqlScriptUtils.executeUsingJdbc( sqlScriptRuntime, driver, user, password, url );
- }
- // add message
- updateLog.setStatus( "Update performed" );
- updateLog.setUpdated( true );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "SQL script " + sqlScript.getName() + " executed" ) );
- EventUtils.post( environment, "UPDATE", "SQL script " + sqlScript.getName() + " executed" );
- LOGGER.info( "SQL script " + sqlScript.getName() + " executed" );
- }
- }
- catch ( Exception e )
- {
- // SQL script execution failed, delete the SQL script from the cache
- try
- {
- fileManipulator.delete( sqlScriptRuntime );
+ applicationCacheDir = FileManipulator.createJEEApplicationCacheDir( environment, application );
}
catch ( FileManipulatorException fileManipulatorException )
{
- LOGGER.warn( "Can't delete {}/sql/{}", new Object[]{ applicationCacheDir, sqlScript.getName() },
- fileManipulatorException );
+ LOGGER.error( "Can't initialize JEE application cache directory", fileManipulatorException );
+ throw new UpdateException( "Can't initialize JEE application cache directory", fileManipulatorException );
}
- LOGGER.error( "SQL script {} execution failed", sqlScript.getName(), e );
- throw new UpdateException( "SQL script " + sqlScript.getName() + " execution failed", e );
- }
+
+ // get file manipulator instance
+ FileManipulator fileManipulator = null;
+ try
+ {
+ fileManipulator = new FileManipulator();
+ }
+ catch ( FileManipulatorException fileManipulatorException )
+ {
+ LOGGER.error( "Can't initialize the file manipulator", fileManipulatorException );
+ throw new UpdateException( "Can't initialize the file manipulator", fileManipulatorException );
+ }
+
+ // copy the SQL script in the application working directory
+ String sqlScriptCache = applicationCacheDir + "/sql/" + sqlScript.getName() + ".cache";
+ String sqlScriptRuntime = applicationCacheDir + "/sql/" + sqlScript.getName();
+ try
+ {
+ fileManipulator.copy( sqlScriptUri, sqlScriptCache );
+ }
+ catch ( FileManipulatorException fileManipulatorException )
+ {
+ LOGGER.error( "Can't copy the SQL script from {} to {}", new Object[]{ sqlScriptUri, sqlScriptCache },
+ fileManipulatorException );
+ throw new UpdateException( "Can't copy the SQL script from " + sqlScriptUri + " to " + sqlScriptCache,
+ fileManipulatorException );
+ }
+
+ if ( fileManipulator.isFolder( sqlScriptCache ) )
+ {
+ // TODO add a generic method to reuse in the case of directory
+
+ // the user provided a directory
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", sqlScript.getName() + " is a folder, iterate in the SQL scripts" ) );
+ EventUtils.post( environment, "UPDATE", sqlScript.getName() + " is a folder, iterate in the SQL scripts" );
+ LOGGER.info( sqlScript.getName() + " is a folder, iterate in the SQL scripts" );
+ FileObject[] children = fileManipulator.browse( sqlScriptCache );
+ for ( int i = 0; i < children.length; i++ )
+ {
+ FileObject current = children[i];
+ String name = current.getName().getBaseName();
+ String singleSqlScriptCache = sqlScriptCache + "/" + name;
+ String singleSqlScriptRuntime = sqlScriptRuntime + "/" + name;
+ // change mappings in the current SQL script
+ for ( Iterator mappingIterator = sqlScript.getMappings().iterator(); mappingIterator.hasNext(); )
+ {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ FileManipulator.searchAndReplace( mapping.getKey(), VariableUtils.replace( mapping.getValue(),
+ environment.getVariables() ),
+ singleSqlScriptCache );
+ }
+ try
+ {
+ if ( sqlScript.isForce() || ( !fileManipulator.contentEquals( singleSqlScriptCache,
+ singleSqlScriptRuntime ) ) )
+ {
+ fileManipulator.copy( singleSqlScriptCache, singleSqlScriptRuntime );
+ if ( database.getSqlCommand() != null && database.getSqlCommand().trim().length() > 0 )
+ {
+ // execute SQL script using system command
+ String command =
+ VariableUtils.replace( database.getSqlCommand(), environment.getVariables() );
+ String output = SqlScriptUtils.executeUsingCommand( singleSqlScriptRuntime, command );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "SQL script " + name + " executed: " + output ) );
+ EventUtils.post( environment, "UPDATE", "SQL script " + name + " executed:" + output );
+ LOGGER.info( "SQL script " + name + " executed successfully" );
+ }
+ else
+ {
+ // execute SQL script using JDBC
+ String user = null;
+ String password = null;
+ String driver = null;
+ String url = null;
+ if ( database.getConnectionPool() != null
+ && database.getConnectionPool().trim().length() > 0 )
+ {
+ // the database is linked to a connection pool
+ // looking for the connection pool (from the cache)
+ String connectionPoolName =
+ VariableUtils.replace( database.getConnectionPool(), environment.getVariables() );
+ JDBCConnectionPool connectionPool = server.getJDBCConnectionPool( connectionPoolName );
+ if ( connectionPool == null )
+ {
+ LOGGER.error( "JDBC connection pool {} is not found in JEE application server {}",
+ database.getConnectionPool(), server.getName() );
+ throw new UpdateException( "JDBC connection pool " + database.getConnectionPool()
+ + " is not found in JEE application server "
+ + server.getName() );
+ }
+ user = VariableUtils.replace( connectionPool.getUser(), environment.getVariables() );
+ password =
+ VariableUtils.replace( connectionPool.getPassword(), environment.getVariables() );
+ driver =
+ VariableUtils.replace( connectionPool.getDriver(), environment.getVariables() );
+ url = VariableUtils.replace( connectionPool.getUrl(), environment.getVariables() );
+ }
+ else
+ {
+ // use the database connection data
+ user = VariableUtils.replace( database.getUser(), environment.getVariables() );
+ password = VariableUtils.replace( database.getPassword(), environment.getVariables() );
+ driver = VariableUtils.replace( database.getDriver(), environment.getVariables() );
+ url = VariableUtils.replace( database.getJdbcurl(), environment.getVariables() );
+ }
+ // execute SQL script using JDBC
+ SqlScriptUtils.executeUsingJdbc( singleSqlScriptRuntime, driver, user, password, url );
+ }
+ // add message
+ updateLog.setStatus( "Update performed" );
+ updateLog.setUpdated( true );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "SQL script " + sqlScript.getName() + " executed" ) );
+ EventUtils.post( environment, "UPDATE", "SQL script " + sqlScript.getName() + " executed" );
+ LOGGER.info( "SQL script {} executed", sqlScript.getName() );
+ }
+ }
+ catch ( Exception e )
+ {
+ // SQL script execution failed, delete the SQL script from the cache
+ try
+ {
+ fileManipulator.delete( sqlScriptRuntime );
+ }
+ catch ( FileManipulatorException fileManipulatorException )
+ {
+ LOGGER.warn( "Can't delete {}/sql/{}", new Object[]{ applicationCacheDir, sqlScript.getName() },
+ fileManipulatorException );
+ }
+ LOGGER.error( "SQL script {} execution failed", sqlScript.getName(), e );
+ throw new UpdateException( "SQL script " + sqlScript.getName() + " execution failed", e );
+ }
+ }
+ }
+ else
+ {
+ // the user provided a single SQL script
+
+ // change mappings in the SQL script
+ for ( Iterator mappingIterator = sqlScript.getMappings().iterator(); mappingIterator.hasNext(); )
+ {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ FileManipulator.searchAndReplace( mapping.getKey(), VariableUtils.replace( mapping.getValue(),
+ environment.getVariables() ),
+ sqlScriptCache );
+ }
+
+ // compare the SQL script with the target one
+ try
+ {
+ if ( sqlScript.isForce() || ( !fileManipulator.contentEquals( sqlScriptCache, sqlScriptRuntime ) ) )
+ {
+ // the SQL script needs to be updated and executed
+ // copy the SQL script to the target
+ fileManipulator.copy( sqlScriptCache, sqlScriptRuntime );
+ if ( database.getSqlCommand() != null && database.getSqlCommand().trim().length() > 0 )
+ {
+ // execute SQL script using system command
+ String command = VariableUtils.replace( database.getSqlCommand(), environment.getVariables() );
+ String output = SqlScriptUtils.executeUsingCommand( sqlScriptRuntime, command );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "SQL script " + sqlScript.getName() + " executed: " + output ) );
+ EventUtils.post( environment, "UPDATE",
+ "SQL script " + sqlScript.getName() + " executed: " + output );
+ LOGGER.info( "SQL script " + sqlScript.getName() + " executed: " + output );
+ }
+ else
+ {
+ // execute SQL script using JDBC
+ String user = null;
+ String password = null;
+ String driver = null;
+ String url = null;
+ if ( database.getConnectionPool() != null && database.getConnectionPool().trim().length() > 0 )
+ {
+ // the database is linked to a connection pool
+ // looking for the connection pool (from the cache)
+ String connectionPoolName =
+ VariableUtils.replace( database.getConnectionPool(), environment.getVariables() );
+ JDBCConnectionPool connectionPool = server.getJDBCConnectionPool( connectionPoolName );
+ if ( connectionPool == null )
+ {
+ LOGGER.error( "JDBC connection pool {} is not found in JEE application server {}",
+ database.getConnectionPool(), server.getName() );
+ throw new UpdateException( "JDBC connection pool " + database.getConnectionPool()
+ + " is not found in JEE application server "
+ + server.getName() );
+ }
+ user = VariableUtils.replace( connectionPool.getUser(), environment.getVariables() );
+ password =
+ VariableUtils.replace( connectionPool.getPassword(), environment.getVariables() );
+ driver = VariableUtils.replace( connectionPool.getDriver(), environment.getVariables() );
+ url = VariableUtils.replace( connectionPool.getUrl(), environment.getVariables() );
+ }
+ else
+ {
+ // use the database connection data
+ user = VariableUtils.replace( database.getUser(), environment.getVariables() );
+ password = VariableUtils.replace( database.getPassword(), environment.getVariables() );
+ driver = VariableUtils.replace( database.getDriver(), environment.getVariables() );
+ url = VariableUtils.replace( database.getJdbcurl(), environment.getVariables() );
+ }
+ // execute SQL script using JDBC
+ SqlScriptUtils.executeUsingJdbc( sqlScriptRuntime, driver, user, password, url );
+ }
+ // add message
+ updateLog.setStatus( "Update performed" );
+ updateLog.setUpdated( true );
+ updateLog.addUpdateMessage(
+ new UpdateMessage( "info", "SQL script " + sqlScript.getName() + " executed" ) );
+ EventUtils.post( environment, "UPDATE", "SQL script " + sqlScript.getName() + " executed" );
+ LOGGER.info( "SQL script " + sqlScript.getName() + " executed" );
+ }
+ }
+ catch ( Exception e )
+ {
+ // SQL script execution failed, delete the SQL script from the cache
+ try
+ {
+ fileManipulator.delete( sqlScriptRuntime );
+ }
+ catch ( FileManipulatorException fileManipulatorException )
+ {
+ LOGGER.warn( "Can't delete {}/sql/{}", new Object[]{ applicationCacheDir, sqlScript.getName() },
+ fileManipulatorException );
+ }
+ LOGGER.error( "SQL script {} execution failed", sqlScript.getName(), e );
+ throw new UpdateException( "SQL script " + sqlScript.getName() + " execution failed", e );
+ }
+ }
+
+ // change mappings in the SQL scripts
+ for ( Iterator mappingIterator = sqlScript.getMappings().iterator(); mappingIterator.hasNext(); )
+ {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ FileManipulator.searchAndReplace( mapping.getKey(),
+ VariableUtils.replace( mapping.getValue(), environment.getVariables() ),
+ sqlScriptCache );
+ }
}
- // change mappings in the SQL scripts
- for ( Iterator mappingIterator = sqlScript.getMappings().iterator(); mappingIterator.hasNext(); )
+ /**
+ * Wrapper method to execute a SQL script via WS.
+ *
+ * @param environmentName the target environment name.
+ * @param serverName the target JEE application server name.
+ * @param applicationName the target JEE application name.
+ * @param databaseName the target database name.
+ * @param sqlScriptName the target SQL script name.
+ * @throws KalumetException in case of execution failure.
+ */
+ public static void execute( String environmentName, String serverName, String applicationName, String databaseName,
+ String sqlScriptName )
+ throws KalumetException
{
- Mapping mapping = (Mapping) mappingIterator.next();
- FileManipulator.searchAndReplace( mapping.getKey(),
- VariableUtils.replace( mapping.getValue(), environment.getVariables() ),
- sqlScriptCache );
- }
- }
+ LOGGER.info( "SQL script {} execution requested by WS", sqlScriptName );
- /**
- * Wrapper method to execute a SQL script via WS.
- *
- * @param environmentName the target environment name.
- * @param serverName the target JEE application server name.
- * @param applicationName the target JEE application name.
- * @param databaseName the target database name.
- * @param sqlScriptName the target SQL script name.
- * @throws KalumetException in case of execution failure.
- */
- public static void execute( String environmentName, String serverName, String applicationName, String databaseName,
- String sqlScriptName )
- throws KalumetException
- {
- LOGGER.info( "SQL script {} execution requested by WS", sqlScriptName );
+ // load configuration
+ LOGGER.debug( "Loading configuration" );
+ Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- // load configuration
- LOGGER.debug( "Loading configuration" );
- Kalumet kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ // looking for component objects
+ LOGGER.debug( "Looking for component objects" );
+ Environment environment = kalumet.getEnvironment( environmentName );
+ if ( environment == null )
+ {
+ LOGGER.error( "Environment {} is not found in the configuration", environmentName );
+ throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
+ }
+ JEEApplicationServer applicationServer =
+ environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
+ if ( applicationServer == null )
+ {
+ LOGGER.error( "JEE application server {} is not found in environment {}", serverName,
+ environment.getName() );
+ throw new KalumetException(
+ "JEE application server " + serverName + " is not found in environment " + environment.getName() );
+ }
+ JEEApplication application = applicationServer.getJEEApplication( applicationName );
+ if ( application == null )
+ {
+ LOGGER.error( "JEE application {} is not found in JEE application server {}", applicationName,
+ applicationServer.getName() );
+ throw new KalumetException(
+ "JEE application " + applicationName + " is not found in JEE application server "
+ + applicationServer.getName() );
+ }
+ Database database = application.getDatabase( databaseName );
+ if ( database == null )
+ {
+ LOGGER.error( "Database {} is not found in JEE application {}", databaseName, application.getName() );
+ throw new KalumetException(
+ "Database " + databaseName + " is not found in JEE application " + application.getName() );
+ }
+ SqlScript sqlScript = database.getSqlScript( sqlScriptName );
+ if ( sqlScript == null )
+ {
+ LOGGER.error( "SQL script {} is not found in database {}", sqlScriptName, database.getName() );
+ throw new KalumetException(
+ "SQL script " + sqlScriptName + " is not found in database " + database.getName() );
+ }
- // looking for component objects
- LOGGER.debug( "Looking for component objects" );
- Environment environment = kalumet.getEnvironment( environmentName );
- if ( environment == null )
- {
- LOGGER.error( "Environment {} is not found in the configuration", environmentName );
- throw new KalumetException( "Environment " + environmentName + " is not found in the configuration" );
- }
- JEEApplicationServer applicationServer =
- environment.getJEEApplicationServers().getJEEApplicationServer( serverName );
- if ( applicationServer == null )
- {
- LOGGER.error( "JEE application server {} is not found in environment {}", serverName, environment.getName() );
- throw new KalumetException(
- "JEE application server " + serverName + " is not found in environment " + environment.getName() );
- }
- JEEApplication application = applicationServer.getJEEApplication( applicationName );
- if ( application == null )
- {
- LOGGER.error( "JEE application {} is not found in JEE application server {}", applicationName,
- applicationServer.getName() );
- throw new KalumetException( "JEE application " + applicationName + " is not found in JEE application server "
- + applicationServer.getName() );
- }
- Database database = application.getDatabase( databaseName );
- if ( database == null )
- {
- LOGGER.error( "Database {} is not found in JEE application {}", databaseName, application.getName() );
- throw new KalumetException(
- "Database " + databaseName + " is not found in JEE application " + application.getName() );
- }
- SqlScript sqlScript = database.getSqlScript( sqlScriptName );
- if ( sqlScript == null )
- {
- LOGGER.error( "SQL script {} is not found in database {}", sqlScriptName, database.getName() );
- throw new KalumetException( "SQL script " + sqlScriptName + " is not found in database " + database.getName() );
- }
+ // post an event and create the update log.
+ LOGGER.debug( "Post an event and create the update log" );
+ EventUtils.post( environment, "UPDATE", "SQL script " + sqlScript.getName() + " execution request by WS" );
+ UpdateLog updateLog =
+ new UpdateLog( "SQL script " + sqlScript.getName() + " execution in progress ...", sqlScript.getName(),
+ environment );
- // post an event and create the update log.
- LOGGER.debug( "Post an event and create the update log" );
- EventUtils.post( environment, "UPDATE", "SQL script " + sqlScript.getName() + " execution request by WS" );
- UpdateLog updateLog =
- new UpdateLog( "SQL script " + sqlScript.getName() + " execution in progress ...", sqlScript.getName(),
- environment );
+ // send a notification and waiting for the count down.
+ LOGGER.info( "Send a notification and waiting for the count down" );
+ NotifierUtils.waitAndNotify( environment );
- // send a notification and waiting for the count down.
- LOGGER.info( "Send a notification and waiting for the count down" );
- NotifierUtils.waitAndNotify( environment );
+ try
+ {
+ // call execution
+ LOGGER.debug( "Call SQL script updater" );
+ SqlScriptUpdater.execute( environment, applicationServer, application, database, sqlScript, updateLog );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "SQL script {} execution failed", sqlScript.getName(), e );
+ EventUtils.post( environment, "ERROR",
+ "SQL script " + sqlScript.getName() + " execution failed: " + e.getMessage() );
+ updateLog.setStatus( "SQL script " + sqlScript.getName() + " execution error" );
+ updateLog.addUpdateMessage( new UpdateMessage( "error",
+ "SQL script " + sqlScript.getName() + " execution failed: "
+ + e.getMessage() ) );
+ PublisherUtils.publish( environment );
+ throw new UpdateException( "SQL script " + sqlScript.getName() + " execution failed", e );
+ }
- try
- {
- // call execution
- LOGGER.debug( "Call SQL script updater" );
- SqlScriptUpdater.execute( environment, applicationServer, application, database, sqlScript, updateLog );
+ // execution completed.
+ LOGGER.info( "SQL script {} executed", sqlScript.getName() );
+ updateLog.setStatus( "SQL script " + sqlScript.getName() + " executed" );
+ updateLog.addUpdateMessage( new UpdateMessage( "info", "SQL script " + sqlScript.getName() + " executed" ) );
+ LOGGER.info( "Publishing update report" );
+ PublisherUtils.publish( environment );
}
- catch ( Exception e )
- {
- LOGGER.error( "SQL script {} execution failed", sqlScript.getName(), e );
- EventUtils.post( environment, "ERROR",
- "SQL script " + sqlScript.getName() + " execution failed: " + e.getMessage() );
- updateLog.setStatus( "SQL script " + sqlScript.getName() + " execution error" );
- updateLog.addUpdateMessage(
- new UpdateMessage( "error", "SQL script " + sqlScript.getName() + " execution failed: " + e.getMessage() ) );
- PublisherUtils.publish( environment );
- throw new UpdateException( "SQL script " + sqlScript.getName() + " execution failed", e );
- }
-
- // execution completed.
- LOGGER.info( "SQL script {} executed", sqlScript.getName() );
- updateLog.setStatus( "SQL script " + sqlScript.getName() + " executed" );
- updateLog.addUpdateMessage( new UpdateMessage( "info", "SQL script " + sqlScript.getName() + " executed" ) );
- LOGGER.info( "Publishing update report" );
- PublisherUtils.publish( environment );
- }
}
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/UpdateException.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/UpdateException.java
index e9d3b17..b1c3a78 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/UpdateException.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/updater/UpdateException.java
@@ -24,38 +24,38 @@
* Exception wrapper for updaters.
*/
public class UpdateException
- extends KalumetException
+ extends KalumetException
{
- /**
- * Update exception with the explanation message.
- *
- * @param message the explanation message.
- */
- public UpdateException( String message )
- {
- super( message );
- }
+ /**
+ * Update exception with the explanation message.
+ *
+ * @param message the explanation message.
+ */
+ public UpdateException( String message )
+ {
+ super( message );
+ }
- /**
- * Update exception with the cause.
- *
- * @param cause the cause.
- */
- public UpdateException( Throwable cause )
- {
- super( cause );
- }
+ /**
+ * Update exception with the cause.
+ *
+ * @param cause the cause.
+ */
+ public UpdateException( Throwable cause )
+ {
+ super( cause );
+ }
- /**
- * Update exception with the explanation message and cause.
- *
- * @param message the explanation message.
- * @param cause the cause.
- */
- public UpdateException( String message, Throwable cause )
- {
- super( message, cause );
- }
+ /**
+ * Update exception with the explanation message and cause.
+ *
+ * @param message the explanation message.
+ * @param cause the cause.
+ */
+ public UpdateException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
}
diff --git a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/utils/EventUtils.java b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/utils/EventUtils.java
index 29a9cd2..fea4782 100644
--- a/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/utils/EventUtils.java
+++ b/kalumet-modules/agent/src/main/java/org/apache/kalumet/agent/utils/EventUtils.java
@@ -31,47 +31,47 @@
public class EventUtils
{
- private final static transient Logger LOGGER = LoggerFactory.getLogger( EventUtils.class );
+ private final static transient Logger LOGGER = LoggerFactory.getLogger( EventUtils.class );
- /**
- * Wrapper method to post an event.
- *
- * @param environment the target environment.
- * @param author the event author.
- * @param severity the event severity.
- * @param event the event message.
- */
- public static void post( Environment environment, String author, String severity, String event )
- {
- LOGGER.debug( "Loading configuration from the cache" );
- Kalumet kalumet = Configuration.CONFIG_CACHE;
- if ( kalumet == null )
+ /**
+ * Wrapper method to post an event.
+ *
+ * @param environment the target environment.
+ * @param author the event author.
+ * @param severity the event severity.
+ * @param event the event message.
+ */
+ public static void post( Environment environment, String author, String severity, String event )
{
- LOGGER.debug( "No configuration in cache, updating it" );
- try
- {
- kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
- }
- catch ( KalumetException kalumetException )
- {
- LOGGER.warn( "Can't post journal event", kalumetException );
- return;
- }
- Configuration.CONFIG_CACHE = kalumet;
+ LOGGER.debug( "Loading configuration from the cache" );
+ Kalumet kalumet = Configuration.CONFIG_CACHE;
+ if ( kalumet == null )
+ {
+ LOGGER.debug( "No configuration in cache, updating it" );
+ try
+ {
+ kalumet = Kalumet.digeste( Configuration.CONFIG_LOCATION );
+ }
+ catch ( KalumetException kalumetException )
+ {
+ LOGGER.warn( "Can't post journal event", kalumetException );
+ return;
+ }
+ Configuration.CONFIG_CACHE = kalumet;
+ }
+ org.apache.kalumet.utils.EventUtils.post( environment, author, severity, event, kalumet );
}
- org.apache.kalumet.utils.EventUtils.post( environment, author, severity, event, kalumet );
- }
- /**
- * Wrapper method to post an event.
- *
- * @param environment the target environment.
- * @param severity the event severity.
- * @param event the event message.
- */
- public static void post( Environment environment, String severity, String event )
- {
- EventUtils.post( environment, Configuration.AGENT_ID, severity, event );
- }
+ /**
+ * Wrapper method to post an event.
+ *
+ * @param environment the target environment.
+ * @param severity the event severity.
+ * @param event the event message.
+ */
+ public static void post( Environment environment, String severity, String event )
+ {
+ EventUtils.post( environment, Configuration.AGENT_ID, severity, event );
+ }
}
diff --git a/kalumet-modules/common/pom.xml b/kalumet-modules/common/pom.xml
index 54c194e..5f69f7a 100644
--- a/kalumet-modules/common/pom.xml
+++ b/kalumet-modules/common/pom.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/FileManipulator.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/FileManipulator.java
index 104cc10..6f91b9f 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/FileManipulator.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/FileManipulator.java
@@ -55,743 +55,746 @@
public class FileManipulator
{
- private final static transient Logger LOGGER = LoggerFactory.getLogger( FileManipulator.class );
+ private final static transient Logger LOGGER = LoggerFactory.getLogger( FileManipulator.class );
- private static final String BASE_DIR = SystemUtils.USER_DIR;
+ private static final String BASE_DIR = SystemUtils.USER_DIR;
- private static final String WORKING_DIR = "work";
+ private static final String WORKING_DIR = "work";
- private static final String PROTOCOL_REGEX = "(.+):(.+)";
+ private static final String PROTOCOL_REGEX = "(.+):(.+)";
- private static final String JAR_EXTENSION = ".jar";
+ private static final String JAR_EXTENSION = ".jar";
- private static final String ZIP_EXTENSION = ".zip";
+ private static final String ZIP_EXTENSION = ".zip";
- private static final String TGZ_EXTENSION = ".tgz";
+ private static final String TGZ_EXTENSION = ".tgz";
- private static final String TARGZ_EXTENSION = ".tar.gz";
+ private static final String TARGZ_EXTENSION = ".tar.gz";
- private static final String TBZ2_EXTENSION = ".tbz2";
+ private static final String TBZ2_EXTENSION = ".tbz2";
- private static final String JAR_PROTOCOL = "jar:";
+ private static final String JAR_PROTOCOL = "jar:";
- private static final String ZIP_PROTOCOL = "zip:";
+ private static final String ZIP_PROTOCOL = "zip:";
- private static final String TGZ_PROTOCOL = "tgz:";
+ private static final String TGZ_PROTOCOL = "tgz:";
- private static final String TARGZ_PROTOCOL = "tgz:";
+ private static final String TARGZ_PROTOCOL = "tgz:";
- private static final String TBZ2_PROTOCOL = "tbz2:";
+ private static final String TBZ2_PROTOCOL = "tbz2:";
- private static FileManipulator _singleton = null;
+ private static FileManipulator _singleton = null;
- private FileSystemManager fileSystemManager;
+ private FileSystemManager fileSystemManager;
- /**
- * Private constructor to init the singleton.
- *
- * @throws FileManipulatorException in <code>FileManipulator</code> init failed.
- */
- public FileManipulator()
- throws FileManipulatorException
- {
- try
+ /**
+ * Private constructor to init the singleton.
+ *
+ * @throws FileManipulatorException in <code>FileManipulator</code> init failed.
+ */
+ public FileManipulator()
+ throws FileManipulatorException
{
- LOGGER.debug( "Creating VFS file system manager ..." );
- this.fileSystemManager = VFS.getManager();
- // this.fileSystemManager = new StandardFileSystemManager();
- // fileSystemManager.setCacheStrategy(CacheStrategy.ON_CALL);
- ( (StandardFileSystemManager) this.fileSystemManager ).setReplicator( new KalumetFileReplicator() );
- // fileSystemManager.init();
- }
- catch ( Exception e )
- {
- throw new FileManipulatorException( e );
- }
- }
-
- /**
- * Cleanly close the file manipulator.
- */
- public void close()
- {
- // nothing to do
- // just a hook in case of custom VFS filesystem implementation
- }
-
- /**
- * Get the current basedir path.
- *
- * @return the path of the local basedir directory.
- * @throws FileManipulatorException
- */
- public static String getBaseDir()
- throws FileManipulatorException
- {
- try
- {
- File baseDir = new File( FileManipulator.BASE_DIR );
- return baseDir.getPath();
- }
- catch ( Exception e )
- {
- LOGGER.error( "Can't get basedir", e );
- throw new FileManipulatorException( "Can't get basedir", e );
- }
- }
-
- /**
- * Resolve VFS path to add filename regex selector.
- *
- * @param vfsPath the file to resolve (can look like /tmp/folder/file*).
- * @return the resolved file object.
- * @throws FileSystemException if the VFS file object can't be resolved.
- * @throws FileManipulatorException if the regex is not valid (regex is allowed only on files, not directories).
- */
- public FileObject resolveFile( String vfsPath )
- throws FileSystemException, FileManipulatorException
- {
- LOGGER.debug( "Resolve VFS path {}", vfsPath );
- LOGGER.debug( "Check if the file name regex selector is required" );
- if ( ( vfsPath.indexOf( "/" ) == -1 ) || ( vfsPath.indexOf( "*" ) == -1 ) )
- {
- LOGGER.debug( "Regex select is not required for {}", vfsPath );
- return fileSystemManager.resolveFile( vfsPath );
- }
- LOGGER.debug( "Isolating the path end" );
- LOGGER.debug( "Finding the last index of / separator" );
- int separatorIndex = vfsPath.lastIndexOf( '/' );
- int tokenIndex = vfsPath.lastIndexOf( '*' );
- if ( tokenIndex < separatorIndex )
- {
- LOGGER.error( "Wildcard * is only supported on the file name, not on directories" );
- throw new FileManipulatorException( "Wildcard * is only supported on the file name, not on directories" );
- }
- String pattern = vfsPath.substring( separatorIndex + 1 );
- LOGGER.debug( "{} pattern found", pattern );
- String baseName = vfsPath.substring( 0, separatorIndex + 1 );
- LOGGER.debug( "Getting the base name {}", baseName );
- LOGGER.debug( "Looking for the file (first found is returned)" );
- FileObject baseUrl = fileSystemManager.resolveFile( baseName );
- FileObject[] fileObjects = baseUrl.findFiles( new FileNameRegexSelector( pattern ) );
- if ( fileObjects.length < 1 )
- {
- LOGGER.error( "No file matching {} found on {}", pattern, baseName );
- throw new FileManipulatorException( "No file matching " + pattern + " found on " + baseName );
- }
- baseUrl.close();
- return fileObjects[0];
- }
-
- /**
- * Check if the given VFS path is available (exists).
- *
- * @param vfsPath the VFS path
- * @return true if the VFS path exists, false else
- */
- public boolean exists( String vfsPath )
- {
- FileObject fileObject = null;
- try
- {
- fileObject = this.resolveFile( vfsPath );
- return fileObject.exists();
- }
- catch ( Exception e )
- {
- LOGGER.warn( "Can't check if the VFS path {} exists", vfsPath, e );
- return false;
- }
- finally
- {
- if ( fileObject != null )
- {
try
{
- fileObject.close();
+ LOGGER.debug( "Creating VFS file system manager ..." );
+ this.fileSystemManager = VFS.getManager();
+ // this.fileSystemManager = new StandardFileSystemManager();
+ // fileSystemManager.setCacheStrategy(CacheStrategy.ON_CALL);
+ ( (StandardFileSystemManager) this.fileSystemManager ).setReplicator( new KalumetFileReplicator() );
+ // fileSystemManager.init();
}
catch ( Exception e )
{
- // ignore
+ throw new FileManipulatorException( e );
}
- }
}
- }
- /**
- * Compare the content of two files.
- *
- * @param src the source file to compare.
- * @param dest the destination file to compare with.
- * @return true if the two files have exactly the same content, false else.
- * @throws FileManipulatorException if the compare failed.
- */
- public boolean contentEquals( String src, String dest )
- throws FileManipulatorException
- {
- FileObject srcFile = null;
- FileObject destFile = null;
- try
+ /**
+ * Cleanly close the file manipulator.
+ */
+ public void close()
{
- LOGGER.debug( "Comparing the content of {} and {}", src, dest );
- srcFile = this.resolveFile( src );
- destFile = this.resolveFile( dest );
- if ( !srcFile.exists() || !destFile.exists() )
- {
- LOGGER.debug( "{} or {} don't exist", src, dest );
+ // nothing to do
+ // just a hook in case of custom VFS filesystem implementation
+ }
+
+ /**
+ * Get the current basedir path.
+ *
+ * @return the path of the local basedir directory.
+ * @throws FileManipulatorException
+ */
+ public static String getBaseDir()
+ throws FileManipulatorException
+ {
+ try
+ {
+ File baseDir = new File( FileManipulator.BASE_DIR );
+ return baseDir.getPath();
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Can't get basedir", e );
+ throw new FileManipulatorException( "Can't get basedir", e );
+ }
+ }
+
+ /**
+ * Resolve VFS path to add filename regex selector.
+ *
+ * @param vfsPath the file to resolve (can look like /tmp/folder/file*).
+ * @return the resolved file object.
+ * @throws FileSystemException if the VFS file object can't be resolved.
+ * @throws FileManipulatorException if the regex is not valid (regex is allowed only on files, not directories).
+ */
+ public FileObject resolveFile( String vfsPath )
+ throws FileSystemException, FileManipulatorException
+ {
+ LOGGER.debug( "Resolve VFS path {}", vfsPath );
+ LOGGER.debug( "Check if the file name regex selector is required" );
+ if ( ( vfsPath.indexOf( "/" ) == -1 ) || ( vfsPath.indexOf( "*" ) == -1 ) )
+ {
+ LOGGER.debug( "Regex select is not required for {}", vfsPath );
+ return fileSystemManager.resolveFile( vfsPath );
+ }
+ LOGGER.debug( "Isolating the path end" );
+ LOGGER.debug( "Finding the last index of / separator" );
+ int separatorIndex = vfsPath.lastIndexOf( '/' );
+ int tokenIndex = vfsPath.lastIndexOf( '*' );
+ if ( tokenIndex < separatorIndex )
+ {
+ LOGGER.error( "Wildcard * is only supported on the file name, not on directories" );
+ throw new FileManipulatorException( "Wildcard * is only supported on the file name, not on directories" );
+ }
+ String pattern = vfsPath.substring( separatorIndex + 1 );
+ LOGGER.debug( "{} pattern found", pattern );
+ String baseName = vfsPath.substring( 0, separatorIndex + 1 );
+ LOGGER.debug( "Getting the base name {}", baseName );
+ LOGGER.debug( "Looking for the file (first found is returned)" );
+ FileObject baseUrl = fileSystemManager.resolveFile( baseName );
+ FileObject[] fileObjects = baseUrl.findFiles( new FileNameRegexSelector( pattern ) );
+ if ( fileObjects.length < 1 )
+ {
+ LOGGER.error( "No file matching {} found on {}", pattern, baseName );
+ throw new FileManipulatorException( "No file matching " + pattern + " found on " + baseName );
+ }
+ baseUrl.close();
+ return fileObjects[0];
+ }
+
+ /**
+ * Check if the given VFS path is available (exists).
+ *
+ * @param vfsPath the VFS path
+ * @return true if the VFS path exists, false else
+ */
+ public boolean exists( String vfsPath )
+ {
+ FileObject fileObject = null;
+ try
+ {
+ fileObject = this.resolveFile( vfsPath );
+ return fileObject.exists();
+ }
+ catch ( Exception e )
+ {
+ LOGGER.warn( "Can't check if the VFS path {} exists", vfsPath, e );
+ return false;
+ }
+ finally
+ {
+ if ( fileObject != null )
+ {
+ try
+ {
+ fileObject.close();
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+ }
+ }
+
+ /**
+ * Compare the content of two files.
+ *
+ * @param src the source file to compare.
+ * @param dest the destination file to compare with.
+ * @return true if the two files have exactly the same content, false else.
+ * @throws FileManipulatorException if the compare failed.
+ */
+ public boolean contentEquals( String src, String dest )
+ throws FileManipulatorException
+ {
+ FileObject srcFile = null;
+ FileObject destFile = null;
+ try
+ {
+ LOGGER.debug( "Comparing the content of {} and {}", src, dest );
+ srcFile = this.resolveFile( src );
+ destFile = this.resolveFile( dest );
+ if ( !srcFile.exists() || !destFile.exists() )
+ {
+ LOGGER.debug( "{} or {} don't exist", src, dest );
+ return false;
+ }
+ if ( !srcFile.getType().equals( FileType.FILE ) )
+ {
+ LOGGER.error( "The source {} is not a file", src );
+ throw new IllegalArgumentException( "The source URI " + src + " is not a file" );
+ }
+ if ( !destFile.getType().equals( FileType.FILE ) )
+ {
+ LOGGER.error( "The destination {} is not a file", dest );
+ throw new IllegalArgumentException( "The destination URI " + dest + " is not a file" );
+ }
+ return IOUtils.contentEquals( srcFile.getContent().getInputStream(),
+ destFile.getContent().getInputStream() );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Can't compare content of {} and {}", new Object[]{ src, dest }, e );
+ throw new FileManipulatorException( "Can't compare content of " + src + " and " + dest, e );
+ }
+ finally
+ {
+ if ( srcFile != null )
+ {
+ try
+ {
+ srcFile.close();
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+ if ( destFile != null )
+ {
+ try
+ {
+ destFile.close();
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+ }
+ }
+
+ /**
+ * Compare checksum of two files.
+ *
+ * @param src the source file.
+ * @param dest the destination file.
+ * @return true if the two files are the same (same signature), false else.
+ * @throws FileManipulatorException
+ */
+ public boolean checksumEquals( String src, String dest )
+ throws FileManipulatorException
+ {
+ FileObject srcFile = null;
+ FileObject destFile = null;
+ try
+ {
+ if ( !srcFile.exists() )
+ {
+ LOGGER.error( "Source {} doesn't exist", src );
+ throw new FileManipulatorException( "Source " + src + " doesn't exist" );
+ }
+ if ( destFile.exists() && destFile.getType().equals( FileType.FOLDER ) )
+ {
+ destFile = this.resolveFile( dest + "/" + srcFile.getName().getBaseName() );
+ }
+ if ( !destFile.exists() )
+ {
+ return false;
+ }
+ if ( !srcFile.getType().equals( FileType.FILE ) )
+ {
+ LOGGER.error( "Source {} is not a file", src );
+ throw new FileManipulatorException( "Source " + src + " is not a file" );
+ }
+ if ( !destFile.getType().equals( FileType.FILE ) )
+ {
+ LOGGER.error( "Destination {} is not a file", dest );
+ throw new FileManipulatorException( "Destination " + dest + " is not a file" );
+ }
+ LOGGER.debug( "Create the message digest" );
+ MessageDigest messageDigest = MessageDigest.getInstance( "MD5" );
+ LOGGER.debug( "Generate the checksum for the source" );
+ DigestInputStream srcStream = new DigestInputStream( srcFile.getContent().getInputStream(), messageDigest );
+ byte[] srcBuffer = new byte[8192];
+ while ( srcStream.read( srcBuffer ) != -1 )
+ {
+ ;
+ }
+ byte[] srcMd5 = messageDigest.digest();
+ // reset the message digest
+ messageDigest.reset();
+ LOGGER.debug( "Generate the checksum for the destination" );
+ DigestInputStream destStream =
+ new DigestInputStream( destFile.getContent().getInputStream(), messageDigest );
+ byte[] destBuffer = new byte[8192];
+ while ( destStream.read( destBuffer ) != -1 )
+ {
+ ;
+ }
+ byte[] destMd5 = messageDigest.digest();
+ LOGGER.debug( "Compare the checksum" );
+ return MessageDigest.isEqual( srcMd5, destMd5 );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Can't compare checksum of {} and {}", new Object[]{ src, dest }, e );
+ throw new FileManipulatorException( "Can't compare checksum of " + src + " and " + dest, e );
+ }
+ finally
+ {
+ if ( srcFile != null )
+ {
+ try
+ {
+ srcFile.close();
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+ if ( destFile != null )
+ {
+ try
+ {
+ destFile.close();
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+ }
+ }
+
+ /**
+ * Copy files.
+ *
+ * @param src the source VFS path.
+ * @param dest the destination VFS path.
+ * @throws FileManipulatorException in case of copy failure.
+ */
+ public void copy( String src, String dest )
+ throws FileManipulatorException
+ {
+ FileObject srcFile = null;
+ FileObject destFile = null;
+ try
+ {
+ srcFile = this.resolveFile( src );
+ destFile = this.resolveFile( dest );
+ if ( srcFile.getType().equals( FileType.FOLDER ) )
+ {
+ LOGGER.debug( "Source {} is a folder", src );
+ if ( !destFile.exists() )
+ {
+ LOGGER.debug( "Destination folder {} doesn't exist, create it", dest );
+ destFile.createFolder();
+ }
+ if ( !destFile.getType().equals( FileType.FOLDER ) )
+ {
+ LOGGER.error( "Destination {} must be a folder", dest );
+ throw new IllegalArgumentException( "Destination " + dest + " must be a folder" );
+ }
+ LOGGER.debug( "Copy source folder {} to {} using SELECT_ALL selector", src, dest );
+ destFile.copyFrom( srcFile, Selectors.SELECT_ALL );
+ }
+ else
+ {
+ LOGGER.debug( "Source {} is a file", src );
+ if ( destFile.exists() && destFile.getType().equals( FileType.FOLDER ) )
+ {
+ destFile = this.resolveFile( dest + "/" + srcFile.getName().getBaseName() );
+ }
+ destFile.copyFrom( srcFile, Selectors.SELECT_SELF );
+ }
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Can't copy from {} to {}", new Object[]{ src, dest }, e );
+ throw new FileManipulatorException( "Can't copy from " + src + " to " + dest, e );
+ }
+ finally
+ {
+ if ( srcFile != null )
+ {
+ try
+ {
+ srcFile.close();
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+ if ( destFile != null )
+ {
+ try
+ {
+ destFile.close();
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+ }
+ }
+
+ /**
+ * Check if a given path is a directory.
+ *
+ * @param vfsPath the VFS path to check.
+ * @return true if the path is a folder, false else.
+ */
+ public boolean isFolder( String vfsPath )
+ {
+ FileObject file = null;
+ try
+ {
+ file = this.resolveFile( vfsPath );
+ return ( file.getType().equals( FileType.FOLDER ) );
+ }
+ catch ( Exception e )
+ {
+ LOGGER.warn( "Can't check if {} is a folder", vfsPath, e );
+ }
+ finally
+ {
+ if ( file != null )
+ {
+ try
+ {
+ file.close();
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+ }
return false;
- }
- if ( !srcFile.getType().equals( FileType.FILE ) )
- {
- LOGGER.error( "The source {} is not a file", src );
- throw new IllegalArgumentException( "The source URI " + src + " is not a file" );
- }
- if ( !destFile.getType().equals( FileType.FILE ) )
- {
- LOGGER.error( "The destination {} is not a file", dest );
- throw new IllegalArgumentException( "The destination URI " + dest + " is not a file" );
- }
- return IOUtils.contentEquals( srcFile.getContent().getInputStream(), destFile.getContent().getInputStream() );
}
- catch ( Exception e )
- {
- LOGGER.error( "Can't compare content of {} and {}", new Object[]{ src, dest }, e );
- throw new FileManipulatorException( "Can't compare content of " + src + " and " + dest, e );
- }
- finally
- {
- if ( srcFile != null )
- {
- try
- {
- srcFile.close();
- }
- catch ( Exception e )
- {
- // ignore
- }
- }
- if ( destFile != null )
- {
- try
- {
- destFile.close();
- }
- catch ( Exception e )
- {
- // ignore
- }
- }
- }
- }
- /**
- * Compare checksum of two files.
- *
- * @param src the source file.
- * @param dest the destination file.
- * @return true if the two files are the same (same signature), false else.
- * @throws FileManipulatorException
- */
- public boolean checksumEquals( String src, String dest )
- throws FileManipulatorException
- {
- FileObject srcFile = null;
- FileObject destFile = null;
- try
+ /**
+ * Browse (Return the children) of a give VFS path
+ *
+ * @param vfsPath the VFS path.
+ * @return the children array.
+ */
+ public FileObject[] browse( String vfsPath )
{
- if ( !srcFile.exists() )
- {
- LOGGER.error( "Source {} doesn't exist", src );
- throw new FileManipulatorException( "Source " + src + " doesn't exist" );
- }
- if ( destFile.exists() && destFile.getType().equals( FileType.FOLDER ) )
- {
- destFile = this.resolveFile( dest + "/" + srcFile.getName().getBaseName() );
- }
- if ( !destFile.exists() )
- {
+ FileObject file = null;
+ try
+ {
+ file = this.resolveFile( vfsPath );
+ if ( !file.getType().equals( FileType.FOLDER ) )
+ {
+ throw new IllegalArgumentException( "{} is not a directory" );
+ }
+ return file.getChildren();
+ }
+ catch ( Exception e )
+ {
+ LOGGER.warn( "Can't get {} children", vfsPath, e );
+ }
+ finally
+ {
+ if ( file != null )
+ {
+ try
+ {
+ file.close();
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Read a VFS path and return the input stream content.
+ *
+ * @param vfsPath the VFS path.
+ * @return the input stream content.
+ * @throws FileManipulatorException in case of read failure.
+ */
+ public InputStream read( String vfsPath )
+ throws FileManipulatorException
+ {
+ FileObject file = null;
+ try
+ {
+ file = this.resolveFile( vfsPath );
+ if ( !file.exists() || !file.getType().equals( FileType.FILE ) )
+ {
+ LOGGER.error( "{} doesn't exist or is not a file" );
+ throw new IllegalArgumentException( vfsPath + " doesn't exist or is not a file" );
+ }
+ return file.getContent().getInputStream();
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Can't read {}", vfsPath, e );
+ throw new FileManipulatorException( "Can't read " + vfsPath, e );
+ }
+ }
+
+ /**
+ * Get the VFS path output stream to write into.
+ *
+ * @param vfsPath the VFS path.
+ * @return the output stream.
+ * @throws FileManipulatorException in case of writing failure.
+ */
+ public OutputStream write( String vfsPath )
+ throws FileManipulatorException
+ {
+ FileObject file = null;
+ try
+ {
+ file = this.resolveFile( vfsPath );
+ if ( file.exists() && !file.getType().equals( FileType.FILE ) )
+ {
+ LOGGER.error( "{} is not a file", vfsPath );
+ throw new IllegalArgumentException( vfsPath + " is not a file" );
+ }
+ return file.getContent().getOutputStream();
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Can't write {}", vfsPath, e );
+ throw new FileManipulatorException( "Can't write " + vfsPath, e );
+ }
+ }
+
+ /**
+ * Creates the environment cache directory.
+ *
+ * @param environment the <code>Environment</code>.
+ * @return the environment cache directory path.
+ * @throws FileManipulatorException in case of creation failure.
+ */
+ public static String createEnvironmentCacheDir( Environment environment )
+ throws FileManipulatorException
+ {
+ String directory =
+ FileManipulator.getBaseDir() + "/" + FileManipulator.WORKING_DIR + "/" + environment.getName();
+ FileManipulator fileManipulator = new FileManipulator();
+ fileManipulator.createDirectory( directory );
+ fileManipulator.close();
+ return directory;
+ }
+
+ /**
+ * Creates an environment jeeApplication cache directory.
+ *
+ * @param environment the <code>Environment</code>.
+ * @param jeeApplication the <code>JEEApplication</code>.
+ * @return the environment jeeApplication cache directory path.
+ * @throws FileManipulatorException in case of creation failure.
+ */
+ public static String createJEEApplicationCacheDir( Environment environment, JEEApplication jeeApplication )
+ throws FileManipulatorException
+ {
+ String directory = FileManipulator.createEnvironmentCacheDir( environment );
+ directory = directory + "/applications/" + jeeApplication.getName();
+ FileManipulator fileManipulator = new FileManipulator();
+ fileManipulator.createDirectory( directory );
+ fileManipulator.close();
+ return directory;
+ }
+
+ /**
+ * Creates an environment software cache directory.
+ *
+ * @param environment the <code>Environment</code>.
+ * @param software the <code>Software</code>.
+ * @return the environment software cache directory path.
+ * @throws FileManipulatorException in case of creation failure.
+ */
+ public static String createSoftwareCacheDir( Environment environment, Software software )
+ throws FileManipulatorException
+ {
+ String directory = FileManipulator.createEnvironmentCacheDir( environment );
+ directory = directory + "/softwares/" + software.getName();
+ FileManipulator fileManipulator = new FileManipulator();
+ fileManipulator.createDirectory( directory );
+ fileManipulator.close();
+ return directory;
+ }
+
+ /**
+ * Creates a directory.
+ *
+ * @param path the directory path to create.
+ * @throws FileManipulatorException in case of creation failure.
+ */
+ public void createDirectory( String path )
+ throws FileManipulatorException
+ {
+ FileObject directory = null;
+ try
+ {
+ directory = this.resolveFile( path );
+ directory.createFolder();
+ }
+ catch ( Exception e )
+ {
+ LOGGER.error( "Can't create directory {}", path, e );
+ throw new FileManipulatorException( "Can't create directory " + path, e );
+ }
+ finally
+ {
+ if ( directory != null )
+ {
+ try
+ {
+ directory.close();
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+ }
+ }
+
+ /**
+ * Check if the given VFS path begins with a protocol (file:, http:, ...).
+ *
+ * @param path the VFS path to check.
+ * @return true
+ */
+ public static boolean protocolExists( String path )
+ {
+ // make a regex on the path
+ LOGGER.debug( "Looking for protocol in {}", path );
+ PatternMatcher matcher = new Perl5Matcher();
+ PatternCompiler compiler = new Perl5Compiler();
+ Pattern pattern = null;
+ try
+ {
+ pattern = compiler.compile( FileManipulator.PROTOCOL_REGEX );
+ }
+ catch ( MalformedPatternException malformedPatternException )
+ {
+ LOGGER.warn( "URL protocol check failed", malformedPatternException );
+ return false;
+ }
+ PatternMatcherInput input = new PatternMatcherInput( path );
+ if ( matcher.contains( input, pattern ) )
+ {
+ LOGGER.debug( "{} matches the protocol regex" );
+ return true;
+ }
+ LOGGER.debug( "{} doesn't match the protocol regex" );
return false;
- }
- if ( !srcFile.getType().equals( FileType.FILE ) )
- {
- LOGGER.error( "Source {} is not a file", src );
- throw new FileManipulatorException( "Source " + src + " is not a file" );
- }
- if ( !destFile.getType().equals( FileType.FILE ) )
- {
- LOGGER.error( "Destination {} is not a file", dest );
- throw new FileManipulatorException( "Destination " + dest + " is not a file" );
- }
- LOGGER.debug( "Create the message digest" );
- MessageDigest messageDigest = MessageDigest.getInstance( "MD5" );
- LOGGER.debug( "Generate the checksum for the source" );
- DigestInputStream srcStream = new DigestInputStream( srcFile.getContent().getInputStream(), messageDigest );
- byte[] srcBuffer = new byte[8192];
- while ( srcStream.read( srcBuffer ) != -1 )
- {
- ;
- }
- byte[] srcMd5 = messageDigest.digest();
- // reset the message digest
- messageDigest.reset();
- LOGGER.debug( "Generate the checksum for the destination" );
- DigestInputStream destStream = new DigestInputStream( destFile.getContent().getInputStream(), messageDigest );
- byte[] destBuffer = new byte[8192];
- while ( destStream.read( destBuffer ) != -1 )
- {
- ;
- }
- byte[] destMd5 = messageDigest.digest();
- LOGGER.debug( "Compare the checksum" );
- return MessageDigest.isEqual( srcMd5, destMd5 );
}
- catch ( Exception e )
+
+ /**
+ * Format an URL to a VFS compliant URL (finding the protocol corresponding to the extension).
+ *
+ * @param url source URL
+ * @return the VFS formatted URL.
+ */
+ public static String format( String url )
{
- LOGGER.error( "Can't compare checksum of {} and {}", new Object[]{ src, dest }, e );
- throw new FileManipulatorException( "Can't compare checksum of " + src + " and " + dest, e );
+ String formattedUrl = url.trim();
+ if ( formattedUrl.endsWith( JAR_EXTENSION ) && !formattedUrl.startsWith( JAR_PROTOCOL ) )
+ {
+ return JAR_PROTOCOL + formattedUrl;
+ }
+ if ( formattedUrl.endsWith( ZIP_EXTENSION ) && !formattedUrl.startsWith( ZIP_PROTOCOL ) )
+ {
+ return ZIP_PROTOCOL + formattedUrl;
+ }
+ if ( formattedUrl.endsWith( TGZ_EXTENSION ) && !formattedUrl.startsWith( TGZ_PROTOCOL ) )
+ {
+ return TGZ_PROTOCOL + formattedUrl;
+ }
+ if ( formattedUrl.endsWith( TARGZ_EXTENSION ) && !formattedUrl.startsWith( TARGZ_PROTOCOL ) )
+ {
+ return TARGZ_PROTOCOL + formattedUrl;
+ }
+ if ( formattedUrl.endsWith( TBZ2_EXTENSION ) && !formattedUrl.startsWith( TBZ2_PROTOCOL ) )
+ {
+ return TBZ2_PROTOCOL + formattedUrl;
+ }
+ return formattedUrl;
}
- finally
+
+ /**
+ * Delete a VFS path.
+ *
+ * @param path the VFS path.
+ * @throws FileManipulatorException in case of deletion failure.
+ */
+ public void delete( String path )
+ throws FileManipulatorException
{
- if ( srcFile != null )
- {
+ FileObject file = null;
try
{
- srcFile.close();
+ file = this.resolveFile( path );
+ file.delete( Selectors.SELECT_ALL );
}
catch ( Exception e )
{
- // ignore
+ LOGGER.error( "Can't delete {}", path, e );
+ throw new FileManipulatorException( "Can't delete " + path, e );
}
- }
- if ( destFile != null )
- {
+ finally
+ {
+ if ( file != null )
+ {
+ try
+ {
+ file.close();
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+ }
+ }
+
+ /**
+ * Search and replace a regex in a given VFS path.
+ *
+ * @param regex the regexp to search.
+ * @param substitute the replacement string.
+ * @param path the VFS path where to search and replace.
+ */
+ public static void searchAndReplace( String path, String regex, String substitute )
+ {
try
{
- destFile.close();
+ String content = FileUtils.readFileToString( new File( path ), null );
+ content = StringUtils.replace( content, regex, substitute );
+ FileUtils.writeStringToFile( new File( path ), content, null );
}
- catch ( Exception e )
+ catch ( IOException ioException )
{
- // ignore
+ LOGGER.warn( "Can't replace {} with {} in {}", new Object[]{ regex, substitute, path }, ioException );
}
- }
}
- }
-
- /**
- * Copy files.
- *
- * @param src the source VFS path.
- * @param dest the destination VFS path.
- * @throws FileManipulatorException in case of copy failure.
- */
- public void copy( String src, String dest )
- throws FileManipulatorException
- {
- FileObject srcFile = null;
- FileObject destFile = null;
- try
- {
- srcFile = this.resolveFile( src );
- destFile = this.resolveFile( dest );
- if ( srcFile.getType().equals( FileType.FOLDER ) )
- {
- LOGGER.debug( "Source {} is a folder", src );
- if ( !destFile.exists() )
- {
- LOGGER.debug( "Destination folder {} doesn't exist, create it", dest );
- destFile.createFolder();
- }
- if ( !destFile.getType().equals( FileType.FOLDER ) )
- {
- LOGGER.error( "Destination {} must be a folder", dest );
- throw new IllegalArgumentException( "Destination " + dest + " must be a folder" );
- }
- LOGGER.debug( "Copy source folder {} to {} using SELECT_ALL selector", src, dest );
- destFile.copyFrom( srcFile, Selectors.SELECT_ALL );
- }
- else
- {
- LOGGER.debug( "Source {} is a file", src );
- if ( destFile.exists() && destFile.getType().equals( FileType.FOLDER ) )
- {
- destFile = this.resolveFile( dest + "/" + srcFile.getName().getBaseName() );
- }
- destFile.copyFrom( srcFile, Selectors.SELECT_SELF );
- }
- }
- catch ( Exception e )
- {
- LOGGER.error( "Can't copy from {} to {}", new Object[]{ src, dest }, e );
- throw new FileManipulatorException( "Can't copy from " + src + " to " + dest, e );
- }
- finally
- {
- if ( srcFile != null )
- {
- try
- {
- srcFile.close();
- }
- catch ( Exception e )
- {
- // ignore
- }
- }
- if ( destFile != null )
- {
- try
- {
- destFile.close();
- }
- catch ( Exception e )
- {
- // ignore
- }
- }
- }
- }
-
- /**
- * Check if a given path is a directory.
- *
- * @param vfsPath the VFS path to check.
- * @return true if the path is a folder, false else.
- */
- public boolean isFolder( String vfsPath )
- {
- FileObject file = null;
- try
- {
- file = this.resolveFile( vfsPath );
- return ( file.getType().equals( FileType.FOLDER ) );
- }
- catch ( Exception e )
- {
- LOGGER.warn( "Can't check if {} is a folder", vfsPath, e );
- }
- finally
- {
- if ( file != null )
- {
- try
- {
- file.close();
- }
- catch ( Exception e )
- {
- // ignore
- }
- }
- }
- return false;
- }
-
- /**
- * Browse (Return the children) of a give VFS path
- *
- * @param vfsPath the VFS path.
- * @return the children array.
- */
- public FileObject[] browse( String vfsPath )
- {
- FileObject file = null;
- try
- {
- file = this.resolveFile( vfsPath );
- if ( !file.getType().equals( FileType.FOLDER ) )
- {
- throw new IllegalArgumentException( "{} is not a directory" );
- }
- return file.getChildren();
- }
- catch ( Exception e )
- {
- LOGGER.warn( "Can't get {} children", vfsPath, e );
- }
- finally
- {
- if ( file != null )
- {
- try
- {
- file.close();
- }
- catch ( Exception e )
- {
- // ignore
- }
- }
- }
- return null;
- }
-
- /**
- * Read a VFS path and return the input stream content.
- *
- * @param vfsPath the VFS path.
- * @return the input stream content.
- * @throws FileManipulatorException in case of read failure.
- */
- public InputStream read( String vfsPath )
- throws FileManipulatorException
- {
- FileObject file = null;
- try
- {
- file = this.resolveFile( vfsPath );
- if ( !file.exists() || !file.getType().equals( FileType.FILE ) )
- {
- LOGGER.error( "{} doesn't exist or is not a file" );
- throw new IllegalArgumentException( vfsPath + " doesn't exist or is not a file" );
- }
- return file.getContent().getInputStream();
- }
- catch ( Exception e )
- {
- LOGGER.error( "Can't read {}", vfsPath, e );
- throw new FileManipulatorException( "Can't read " + vfsPath, e );
- }
- }
-
- /**
- * Get the VFS path output stream to write into.
- *
- * @param vfsPath the VFS path.
- * @return the output stream.
- * @throws FileManipulatorException in case of writing failure.
- */
- public OutputStream write( String vfsPath )
- throws FileManipulatorException
- {
- FileObject file = null;
- try
- {
- file = this.resolveFile( vfsPath );
- if ( file.exists() && !file.getType().equals( FileType.FILE ) )
- {
- LOGGER.error( "{} is not a file", vfsPath );
- throw new IllegalArgumentException( vfsPath + " is not a file" );
- }
- return file.getContent().getOutputStream();
- }
- catch ( Exception e )
- {
- LOGGER.error( "Can't write {}", vfsPath, e );
- throw new FileManipulatorException( "Can't write " + vfsPath, e );
- }
- }
-
- /**
- * Creates the environment cache directory.
- *
- * @param environment the <code>Environment</code>.
- * @return the environment cache directory path.
- * @throws FileManipulatorException in case of creation failure.
- */
- public static String createEnvironmentCacheDir( Environment environment )
- throws FileManipulatorException
- {
- String directory = FileManipulator.getBaseDir() + "/" + FileManipulator.WORKING_DIR + "/" + environment.getName();
- FileManipulator fileManipulator = new FileManipulator();
- fileManipulator.createDirectory( directory );
- fileManipulator.close();
- return directory;
- }
-
- /**
- * Creates an environment jeeApplication cache directory.
- *
- * @param environment the <code>Environment</code>.
- * @param jeeApplication the <code>JEEApplication</code>.
- * @return the environment jeeApplication cache directory path.
- * @throws FileManipulatorException in case of creation failure.
- */
- public static String createJEEApplicationCacheDir( Environment environment, JEEApplication jeeApplication )
- throws FileManipulatorException
- {
- String directory = FileManipulator.createEnvironmentCacheDir( environment );
- directory = directory + "/applications/" + jeeApplication.getName();
- FileManipulator fileManipulator = new FileManipulator();
- fileManipulator.createDirectory( directory );
- fileManipulator.close();
- return directory;
- }
-
- /**
- * Creates an environment software cache directory.
- *
- * @param environment the <code>Environment</code>.
- * @param software the <code>Software</code>.
- * @return the environment software cache directory path.
- * @throws FileManipulatorException in case of creation failure.
- */
- public static String createSoftwareCacheDir( Environment environment, Software software )
- throws FileManipulatorException
- {
- String directory = FileManipulator.createEnvironmentCacheDir( environment );
- directory = directory + "/softwares/" + software.getName();
- FileManipulator fileManipulator = new FileManipulator();
- fileManipulator.createDirectory( directory );
- fileManipulator.close();
- return directory;
- }
-
- /**
- * Creates a directory.
- *
- * @param path the directory path to create.
- * @throws FileManipulatorException in case of creation failure.
- */
- public void createDirectory( String path )
- throws FileManipulatorException
- {
- FileObject directory = null;
- try
- {
- directory = this.resolveFile( path );
- directory.createFolder();
- }
- catch ( Exception e )
- {
- LOGGER.error( "Can't create directory {}", path, e );
- throw new FileManipulatorException( "Can't create directory " + path, e );
- }
- finally
- {
- if ( directory != null )
- {
- try
- {
- directory.close();
- }
- catch ( Exception e )
- {
- // ignore
- }
- }
- }
- }
-
- /**
- * Check if the given VFS path begins with a protocol (file:, http:, ...).
- *
- * @param path the VFS path to check.
- * @return true
- */
- public static boolean protocolExists( String path )
- {
- // make a regex on the path
- LOGGER.debug( "Looking for protocol in {}", path );
- PatternMatcher matcher = new Perl5Matcher();
- PatternCompiler compiler = new Perl5Compiler();
- Pattern pattern = null;
- try
- {
- pattern = compiler.compile( FileManipulator.PROTOCOL_REGEX );
- }
- catch ( MalformedPatternException malformedPatternException )
- {
- LOGGER.warn( "URL protocol check failed", malformedPatternException );
- return false;
- }
- PatternMatcherInput input = new PatternMatcherInput( path );
- if ( matcher.contains( input, pattern ) )
- {
- LOGGER.debug( "{} matches the protocol regex" );
- return true;
- }
- LOGGER.debug( "{} doesn't match the protocol regex" );
- return false;
- }
-
- /**
- * Format an URL to a VFS compliant URL (finding the protocol corresponding to the extension).
- *
- * @param url source URL
- * @return the VFS formatted URL.
- */
- public static String format( String url )
- {
- String formattedUrl = url.trim();
- if ( formattedUrl.endsWith( JAR_EXTENSION ) && !formattedUrl.startsWith( JAR_PROTOCOL ) )
- {
- return JAR_PROTOCOL + formattedUrl;
- }
- if ( formattedUrl.endsWith( ZIP_EXTENSION ) && !formattedUrl.startsWith( ZIP_PROTOCOL ) )
- {
- return ZIP_PROTOCOL + formattedUrl;
- }
- if ( formattedUrl.endsWith( TGZ_EXTENSION ) && !formattedUrl.startsWith( TGZ_PROTOCOL ) )
- {
- return TGZ_PROTOCOL + formattedUrl;
- }
- if ( formattedUrl.endsWith( TARGZ_EXTENSION ) && !formattedUrl.startsWith( TARGZ_PROTOCOL ) )
- {
- return TARGZ_PROTOCOL + formattedUrl;
- }
- if ( formattedUrl.endsWith( TBZ2_EXTENSION ) && !formattedUrl.startsWith( TBZ2_PROTOCOL ) )
- {
- return TBZ2_PROTOCOL + formattedUrl;
- }
- return formattedUrl;
- }
-
- /**
- * Delete a VFS path.
- *
- * @param path the VFS path.
- * @throws FileManipulatorException in case of deletion failure.
- */
- public void delete( String path )
- throws FileManipulatorException
- {
- FileObject file = null;
- try
- {
- file = this.resolveFile( path );
- file.delete( Selectors.SELECT_ALL );
- }
- catch ( Exception e )
- {
- LOGGER.error( "Can't delete {}", path, e );
- throw new FileManipulatorException( "Can't delete " + path, e );
- }
- finally
- {
- if ( file != null )
- {
- try
- {
- file.close();
- }
- catch ( Exception e )
- {
- // ignore
- }
- }
- }
- }
-
- /**
- * Search and replace a regex in a given VFS path.
- *
- * @param regex the regexp to search.
- * @param substitute the replacement string.
- * @param path the VFS path where to search and replace.
- */
- public static void searchAndReplace( String path, String regex, String substitute )
- {
- try
- {
- String content = FileUtils.readFileToString( new File( path ), null );
- content = StringUtils.replace( content, regex, substitute );
- FileUtils.writeStringToFile( new File( path ), content, null );
- }
- catch ( IOException ioException )
- {
- LOGGER.warn( "Can't replace {} with {} in {}", new Object[]{ regex, substitute, path }, ioException );
- }
- }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/FileManipulatorException.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/FileManipulatorException.java
index 899cc6e..0e1d288 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/FileManipulatorException.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/FileManipulatorException.java
@@ -22,22 +22,22 @@
* Exception wrapper for all file manipulation failures.
*/
public class FileManipulatorException
- extends KalumetException
+ extends KalumetException
{
- public FileManipulatorException( String message )
- {
- super( message );
- }
+ public FileManipulatorException( String message )
+ {
+ super( message );
+ }
- public FileManipulatorException( Throwable cause )
- {
- super( cause );
- }
+ public FileManipulatorException( Throwable cause )
+ {
+ super( cause );
+ }
- public FileManipulatorException( String message, Throwable cause )
- {
- super( message, cause );
- }
+ public FileManipulatorException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/FileNameRegexSelector.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/FileNameRegexSelector.java
index d603539..1d1f7e0 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/FileNameRegexSelector.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/FileNameRegexSelector.java
@@ -33,53 +33,53 @@
* VFS file selector based on name regex.
*/
public class FileNameRegexSelector
- implements FileSelector
+ implements FileSelector
{
- private static final transient Logger LOGGER = LoggerFactory.getLogger( FileNameRegexSelector.class );
+ private static final transient Logger LOGGER = LoggerFactory.getLogger( FileNameRegexSelector.class );
- private Pattern pattern;
+ private Pattern pattern;
- private PatternMatcher matcher;
+ private PatternMatcher matcher;
- /**
- * Default constructor with the matcher pattern.
- *
- * @param pattern the file name regex pattern to use.
- * @throws FileManipulatorException if the regex pattern is malformed.
- */
- public FileNameRegexSelector( String pattern )
- throws FileManipulatorException
- {
- LOGGER.debug( "Creating the glob regex" );
- PatternCompiler compiler = new GlobCompiler();
- try
+ /**
+ * Default constructor with the matcher pattern.
+ *
+ * @param pattern the file name regex pattern to use.
+ * @throws FileManipulatorException if the regex pattern is malformed.
+ */
+ public FileNameRegexSelector( String pattern )
+ throws FileManipulatorException
{
- this.pattern = compiler.compile( pattern );
- this.matcher = new Perl5Matcher();
+ LOGGER.debug( "Creating the glob regex" );
+ PatternCompiler compiler = new GlobCompiler();
+ try
+ {
+ this.pattern = compiler.compile( pattern );
+ this.matcher = new Perl5Matcher();
+ }
+ catch ( MalformedPatternException malformedPatternException )
+ {
+ LOGGER.error( "Invalid regex pattern " + pattern, malformedPatternException );
+ throw new FileManipulatorException( "Invalid regex pattern " + pattern, malformedPatternException );
+ }
}
- catch ( MalformedPatternException malformedPatternException )
+
+ /**
+ * @see org.apache.commons.vfs.FileSelector#includeFile(org.apache.commons.vfs.FileSelectInfo)
+ */
+ public boolean includeFile( FileSelectInfo fileInfo )
{
- LOGGER.error( "Invalid regex pattern " + pattern, malformedPatternException );
- throw new FileManipulatorException( "Invalid regex pattern " + pattern, malformedPatternException );
+ String fileName = fileInfo.getFile().getName().getBaseName();
+ return matcher.matches( fileName, pattern );
}
- }
- /**
- * @see org.apache.commons.vfs.FileSelector#includeFile(org.apache.commons.vfs.FileSelectInfo)
- */
- public boolean includeFile( FileSelectInfo fileInfo )
- {
- String fileName = fileInfo.getFile().getName().getBaseName();
- return matcher.matches( fileName, pattern );
- }
-
- /**
- * @see org.apache.commons.vfs.FileSelector#traverseDescendents(org.apache.commons.vfs.FileSelectInfo)
- */
- public boolean traverseDescendents( FileSelectInfo fileInfo )
- {
- return true;
- }
+ /**
+ * @see org.apache.commons.vfs.FileSelector#traverseDescendents(org.apache.commons.vfs.FileSelectInfo)
+ */
+ public boolean traverseDescendents( FileSelectInfo fileInfo )
+ {
+ return true;
+ }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/KalumetException.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/KalumetException.java
index d7e7f5c..17c302a 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/KalumetException.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/KalumetException.java
@@ -22,38 +22,38 @@
* Generic Kalumet exception wrapper.
*/
public class KalumetException
- extends Exception
+ extends Exception
{
- /**
- * Create exception with the explanation message.
- *
- * @param message the explanation message.
- */
- public KalumetException( String message )
- {
- super( message );
- }
+ /**
+ * Create exception with the explanation message.
+ *
+ * @param message the explanation message.
+ */
+ public KalumetException( String message )
+ {
+ super( message );
+ }
- /**
- * Create exception with the cause.
- *
- * @param cause the cause.
- */
- public KalumetException( Throwable cause )
- {
- super( cause );
- }
+ /**
+ * Create exception with the cause.
+ *
+ * @param cause the cause.
+ */
+ public KalumetException( Throwable cause )
+ {
+ super( cause );
+ }
- /**
- * Create exception with the explanation message and the cause.
- *
- * @param message the explanation message.
- * @param cause the cause.
- */
- public KalumetException( String message, Throwable cause )
- {
- super( message, cause );
- }
+ /**
+ * Create exception with the explanation message and the cause.
+ *
+ * @param message the explanation message.
+ * @param cause the cause.
+ */
+ public KalumetException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/KalumetFileReplicator.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/KalumetFileReplicator.java
index 8d55e11..ac3ba12 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/KalumetFileReplicator.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/KalumetFileReplicator.java
@@ -38,153 +38,153 @@
* VFS file replicator to avoid huge space usage in the VFS cache.
*/
public class KalumetFileReplicator
- extends AbstractVfsComponent
- implements FileReplicator, TemporaryFileStore
+ extends AbstractVfsComponent
+ implements FileReplicator, TemporaryFileStore
{
- private final static transient Logger LOGGER = LoggerFactory.getLogger( KalumetFileReplicator.class );
+ private final static transient Logger LOGGER = LoggerFactory.getLogger( KalumetFileReplicator.class );
- private final List<WeakFileReference> copies = new ArrayList<WeakFileReference>();
+ private final List<WeakFileReference> copies = new ArrayList<WeakFileReference>();
- private File tmpDir;
+ private File tmpDir;
- private ReferenceQueue<WeakFileReference> queue = new ReferenceQueue<WeakFileReference>();
+ private ReferenceQueue<WeakFileReference> queue = new ReferenceQueue<WeakFileReference>();
- private char[] TMP_RESERVED_CHARS =
- new char[]{ '?', '/', '\\', ' ', '&', '"', '\'', '*', '#', ';', ':', '<', '>', '|' };
+ private char[] TMP_RESERVED_CHARS =
+ new char[]{ '?', '/', '\\', ' ', '&', '"', '\'', '*', '#', ';', ':', '<', '>', '|' };
- /**
- * Constructor to set the location of the temporary directory.
- *
- * @param tmpDir the temporary cache directory.
- */
- public KalumetFileReplicator( final File tmpDir )
- {
- this.tmpDir = tmpDir;
- }
-
- /**
- * Default constructor.
- */
- public KalumetFileReplicator()
- {
-
- }
-
- /**
- * Initialize the VFS component.
- *
- * @throws FileSystemException in case of init failure.
- */
- public void init()
- throws FileSystemException
- {
- if ( tmpDir == null )
+ /**
+ * Constructor to set the location of the temporary directory.
+ *
+ * @param tmpDir the temporary cache directory.
+ */
+ public KalumetFileReplicator( final File tmpDir )
{
- tmpDir = new File( "kalumet_cache" ).getAbsoluteFile();
+ this.tmpDir = tmpDir;
}
- }
- /**
- * Close the replication class, deleting all temporary files.
- */
- public void close()
- {
- // delete the temporary files
- while ( copies.size() > 0 )
+ /**
+ * Default constructor.
+ */
+ public KalumetFileReplicator()
{
- WeakFileReference fileReference = copies.remove( 0 );
- try
- {
- File file = new File( fileReference.getPath() );
- FileObject fileObject = getContext().toFileObject( file );
- fileObject.delete( Selectors.SELECT_ALL );
- }
- catch ( FileSystemException fileSystemException )
- {
- LOGGER.error( "Can't delete temporary files", fileSystemException );
- }
+
}
- // clean the tmp directory, if it's empty
- if ( tmpDir != null && tmpDir.exists() && tmpDir.list().length == 0 )
+
+ /**
+ * Initialize the VFS component.
+ *
+ * @throws FileSystemException in case of init failure.
+ */
+ public void init()
+ throws FileSystemException
{
- tmpDir.delete();
- tmpDir = null;
+ if ( tmpDir == null )
+ {
+ tmpDir = new File( "kalumet_cache" ).getAbsoluteFile();
+ }
}
- }
- /**
- * Allocates a new temporary file.
- *
- * @param baseName the file base name.
- * @return the temporary file.
- * @throws FileSystemException if the allocation failed.
- */
- public File allocateFile( final String baseName )
- throws FileSystemException
- {
- WeakFileReference fileReference = queue.poll().get();
- while ( fileReference != null )
+ /**
+ * Close the replication class, deleting all temporary files.
+ */
+ public void close()
{
- File toDelete = new File( fileReference.getPath() );
- if ( toDelete.exists() )
- {
- toDelete.delete();
- }
- copies.remove( fileReference );
- fileReference = queue.poll().get();
+ // delete the temporary files
+ while ( copies.size() > 0 )
+ {
+ WeakFileReference fileReference = copies.remove( 0 );
+ try
+ {
+ File file = new File( fileReference.getPath() );
+ FileObject fileObject = getContext().toFileObject( file );
+ fileObject.delete( Selectors.SELECT_ALL );
+ }
+ catch ( FileSystemException fileSystemException )
+ {
+ LOGGER.error( "Can't delete temporary files", fileSystemException );
+ }
+ }
+ // clean the tmp directory, if it's empty
+ if ( tmpDir != null && tmpDir.exists() && tmpDir.list().length == 0 )
+ {
+ tmpDir.delete();
+ tmpDir = null;
+ }
}
- // create the filename
- final String baseNamePath = createFileName( baseName );
- final File file = createFile( tmpDir, baseNamePath );
- // keep track to delete later
- copies.add( new WeakFileReference( file, queue ) );
- return file;
- }
- /**
- * Create the temporary file name.
- *
- * @param baseName the temporary file base name.
- * @return the temporary file name.
- */
- protected String createFileName( final String baseName )
- {
- String safeBaseName = UriParser.encode( baseName, TMP_RESERVED_CHARS ).replace( '%', '_' );
- return "tmp_" + safeBaseName;
- }
+ /**
+ * Allocates a new temporary file.
+ *
+ * @param baseName the file base name.
+ * @return the temporary file.
+ * @throws FileSystemException if the allocation failed.
+ */
+ public File allocateFile( final String baseName )
+ throws FileSystemException
+ {
+ WeakFileReference fileReference = queue.poll().get();
+ while ( fileReference != null )
+ {
+ File toDelete = new File( fileReference.getPath() );
+ if ( toDelete.exists() )
+ {
+ toDelete.delete();
+ }
+ copies.remove( fileReference );
+ fileReference = queue.poll().get();
+ }
+ // create the filename
+ final String baseNamePath = createFileName( baseName );
+ final File file = createFile( tmpDir, baseNamePath );
+ // keep track to delete later
+ copies.add( new WeakFileReference( file, queue ) );
+ return file;
+ }
- /**
- * Create a temporary file.
- *
- * @param parent the parent file.
- * @param name the file name.
- * @return the file.
- * @throws FileSystemException in case of creation failure.
- */
- protected File createFile( final File parent, final String name )
- throws FileSystemException
- {
- return new File( parent, UriParser.decode( name ) );
- }
+ /**
+ * Create the temporary file name.
+ *
+ * @param baseName the temporary file base name.
+ * @return the temporary file name.
+ */
+ protected String createFileName( final String baseName )
+ {
+ String safeBaseName = UriParser.encode( baseName, TMP_RESERVED_CHARS ).replace( '%', '_' );
+ return "tmp_" + safeBaseName;
+ }
- /**
- * Create a local (in cache) copy of the file, and all its descendants.
- *
- * @param src the source file.
- * @param selector the file selector.
- * @return the replicate file.
- * @throws FileSystemException in case of replication failure.
- */
- public File replicateFile( final FileObject src, final FileSelector selector )
- throws FileSystemException
- {
- final String baseName = src.getName().getBaseName();
- final File file = allocateFile( baseName );
- // copy from the source file
- final FileObject dest = getContext().toFileObject( file );
- dest.copyFrom( src, selector );
- return file;
- }
+ /**
+ * Create a temporary file.
+ *
+ * @param parent the parent file.
+ * @param name the file name.
+ * @return the file.
+ * @throws FileSystemException in case of creation failure.
+ */
+ protected File createFile( final File parent, final String name )
+ throws FileSystemException
+ {
+ return new File( parent, UriParser.decode( name ) );
+ }
+
+ /**
+ * Create a local (in cache) copy of the file, and all its descendants.
+ *
+ * @param src the source file.
+ * @param selector the file selector.
+ * @return the replicate file.
+ * @throws FileSystemException in case of replication failure.
+ */
+ public File replicateFile( final FileObject src, final FileSelector selector )
+ throws FileSystemException
+ {
+ final String baseName = src.getName().getBaseName();
+ final File file = allocateFile( baseName );
+ // copy from the source file
+ final FileObject dest = getContext().toFileObject( file );
+ dest.copyFrom( src, selector );
+ return file;
+ }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/WeakFileReference.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/WeakFileReference.java
index 28e4703..a451016 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/WeakFileReference.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/WeakFileReference.java
@@ -26,30 +26,30 @@
* Managed files by reference.
*/
public class WeakFileReference
- extends WeakReference
+ extends WeakReference
{
- private String absolutePath;
+ private String absolutePath;
- /**
- * Default constructor.
- *
- * @param file the file to manage reference.
- * @param queue the references queue.
- */
- public WeakFileReference( File file, ReferenceQueue queue )
- {
- super( file, queue );
- this.absolutePath = file.getAbsolutePath();
- }
+ /**
+ * Default constructor.
+ *
+ * @param file the file to manage reference.
+ * @param queue the references queue.
+ */
+ public WeakFileReference( File file, ReferenceQueue queue )
+ {
+ super( file, queue );
+ this.absolutePath = file.getAbsolutePath();
+ }
- /**
- * Gets the absolute path of the file.
- *
- * @return the absolute path of the file.
- */
- public String getPath()
- {
- return this.absolutePath;
- }
+ /**
+ * Gets the absolute path of the file.
+ *
+ * @return the absolute path of the file.
+ */
+ public String getPath()
+ {
+ return this.absolutePath;
+ }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Access.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Access.java
index 6bb20ba..74f526b 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Access.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Access.java
@@ -31,109 +31,109 @@
* Represents the <code>access</code> tag in the Kalumet XML DOM.
*/
public class Access
- implements Serializable, Cloneable
+ implements Serializable, Cloneable
{
- private static final long serialVersionUID = -3233389055334111823L;
+ private static final long serialVersionUID = -3233389055334111823L;
- private String group;
+ private String group;
- private List properties;
+ private List properties;
- public Access()
- {
- properties = new LinkedList();
- }
-
- public String getGroup()
- {
- return this.group;
- }
-
- public void setGroup( String group )
- {
- this.group = group;
- }
-
- public List getProperties()
- {
- return properties;
- }
-
- public void setProperties( List properties )
- {
- this.properties = properties;
- }
-
- /**
- * Add a new <code>Property</code> in the <code>Access</code>.
- *
- * @param property the <code>Property</code> to add.
- */
- public void addProperty( Property property )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getProperty( property.getName() ) != null )
+ public Access()
{
- throw new ModelObjectAlreadyExistsException( "Property name already exists in access." );
+ properties = new LinkedList();
}
- this.properties.add( property );
- }
- /**
- * Get the <code>Property</code> identified by a given name in the <code>Access</code>.
- *
- * @param name the <code>Property</code> name.
- * @return the <code>Property</code> found or null if no <code>Property</code> found.
- */
- public Property getProperty( String name )
- {
- for ( Iterator propertyIterator = this.properties.iterator(); propertyIterator.hasNext(); )
+ public String getGroup()
{
- Property property = (Property) propertyIterator.next();
- if ( property.getName().equals( name ) )
- {
- return property;
- }
+ return this.group;
}
- return null;
- }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- Access clone = new Access();
- clone.setGroup( this.getGroup() );
- for ( Iterator propertyIterator = this.getProperties().iterator(); propertyIterator.hasNext(); )
+ public void setGroup( String group )
{
- Property property = (Property) propertyIterator.next();
- clone.properties.add( (Property) property.clone() );
+ this.group = group;
}
- return clone;
- }
- /**
- * Transforms the <code>Access</code> POJO into a DOM element.
- *
- * @param document the core DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "access" );
- element.setAttribute( "group", this.getGroup() );
- // properties
- ElementImpl properties = new ElementImpl( document, "properties" );
- for ( Iterator propertyIterator = this.getProperties().iterator(); propertyIterator.hasNext(); )
+ public List getProperties()
{
- Property property = (Property) propertyIterator.next();
- properties.appendChild( property.toDOMElement( document ) );
+ return properties;
}
- element.appendChild( properties );
- return element;
- }
+
+ public void setProperties( List properties )
+ {
+ this.properties = properties;
+ }
+
+ /**
+ * Add a new <code>Property</code> in the <code>Access</code>.
+ *
+ * @param property the <code>Property</code> to add.
+ */
+ public void addProperty( Property property )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getProperty( property.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "Property name already exists in access." );
+ }
+ this.properties.add( property );
+ }
+
+ /**
+ * Get the <code>Property</code> identified by a given name in the <code>Access</code>.
+ *
+ * @param name the <code>Property</code> name.
+ * @return the <code>Property</code> found or null if no <code>Property</code> found.
+ */
+ public Property getProperty( String name )
+ {
+ for ( Iterator propertyIterator = this.properties.iterator(); propertyIterator.hasNext(); )
+ {
+ Property property = (Property) propertyIterator.next();
+ if ( property.getName().equals( name ) )
+ {
+ return property;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ Access clone = new Access();
+ clone.setGroup( this.getGroup() );
+ for ( Iterator propertyIterator = this.getProperties().iterator(); propertyIterator.hasNext(); )
+ {
+ Property property = (Property) propertyIterator.next();
+ clone.properties.add( (Property) property.clone() );
+ }
+ return clone;
+ }
+
+ /**
+ * Transforms the <code>Access</code> POJO into a DOM element.
+ *
+ * @param document the core DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "access" );
+ element.setAttribute( "group", this.getGroup() );
+ // properties
+ ElementImpl properties = new ElementImpl( document, "properties" );
+ for ( Iterator propertyIterator = this.getProperties().iterator(); propertyIterator.hasNext(); )
+ {
+ Property property = (Property) propertyIterator.next();
+ properties.appendChild( property.toDOMElement( document ) );
+ }
+ element.appendChild( properties );
+ return element;
+ }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Agent.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Agent.java
index c170ce5..d10f2d3 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Agent.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Agent.java
@@ -28,128 +28,128 @@
* Represents the <code>agent</code> tag in the Kalumet DOM.
*/
public class Agent
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = -2827134650188545192L;
+ private static final long serialVersionUID = -2827134650188545192L;
- private String id;
+ private String id;
- private String hostname;
+ private String hostname;
- private int port;
+ private int port;
- private String cron;
+ private String cron;
- private int maxmanagedenvironments;
+ private int maxmanagedenvironments;
- private int maxjeeapplicationserversstarted;
+ private int maxjeeapplicationserversstarted;
- public Agent()
- {
- }
+ public Agent()
+ {
+ }
- public String getId()
- {
- return this.id;
- }
+ public String getId()
+ {
+ return this.id;
+ }
- public void setId( String id )
- {
- this.id = id;
- }
+ public void setId( String id )
+ {
+ this.id = id;
+ }
- public String getHostname()
- {
- return this.hostname;
- }
+ public String getHostname()
+ {
+ return this.hostname;
+ }
- public void setHostname( String hostname )
- {
- this.hostname = hostname;
- }
+ public void setHostname( String hostname )
+ {
+ this.hostname = hostname;
+ }
- public int getPort()
- {
- return this.port;
- }
+ public int getPort()
+ {
+ return this.port;
+ }
- public void setPort( int port )
- {
- this.port = port;
- }
+ public void setPort( int port )
+ {
+ this.port = port;
+ }
- public String getCron()
- {
- return cron;
- }
+ public String getCron()
+ {
+ return cron;
+ }
- public void setCron( String cron )
- {
- this.cron = cron;
- }
+ public void setCron( String cron )
+ {
+ this.cron = cron;
+ }
- public int getMaxmanagedenvironments()
- {
- return this.maxmanagedenvironments;
- }
+ public int getMaxmanagedenvironments()
+ {
+ return this.maxmanagedenvironments;
+ }
- public void setMaxmanagedenvironments( int maxmanagedenvironments )
- {
- this.maxmanagedenvironments = maxmanagedenvironments;
- }
+ public void setMaxmanagedenvironments( int maxmanagedenvironments )
+ {
+ this.maxmanagedenvironments = maxmanagedenvironments;
+ }
- public int getMaxjeeapplicationserversstarted()
- {
- return this.maxjeeapplicationserversstarted;
- }
+ public int getMaxjeeapplicationserversstarted()
+ {
+ return this.maxjeeapplicationserversstarted;
+ }
- public void setMaxjeeapplicationserversstarted(int maxenvironmentsactive)
- {
- this.maxjeeapplicationserversstarted = maxenvironmentsactive;
- }
+ public void setMaxjeeapplicationserversstarted( int maxenvironmentsactive )
+ {
+ this.maxjeeapplicationserversstarted = maxenvironmentsactive;
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- Agent clone = new Agent();
- clone.setId( this.getId() );
- clone.setHostname( this.getHostname() );
- clone.setPort( this.getPort() );
- clone.setCron( this.getCron() );
- clone.setMaxmanagedenvironments( this.getMaxmanagedenvironments() );
- clone.setMaxjeeapplicationserversstarted(this.getMaxjeeapplicationserversstarted());
- return clone;
- }
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ Agent clone = new Agent();
+ clone.setId( this.getId() );
+ clone.setHostname( this.getHostname() );
+ clone.setPort( this.getPort() );
+ clone.setCron( this.getCron() );
+ clone.setMaxmanagedenvironments( this.getMaxmanagedenvironments() );
+ clone.setMaxjeeapplicationserversstarted( this.getMaxjeeapplicationserversstarted() );
+ return clone;
+ }
- /**
- * Transforms the <code>Agent</code> POJO into a DOM element.
- *
- * @param document the DOM core document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "agent" );
- element.setAttribute( "id", this.getId() );
- element.setAttribute( "hostname", this.getHostname() );
- element.setAttribute( "port", new Integer( this.getPort() ).toString() );
- element.setAttribute( "cron", this.getCron() );
- element.setAttribute( "maxmanagedenvironments", new Integer( this.getMaxmanagedenvironments() ).toString() );
- element.setAttribute( "maxjeeapplicationserversstarted",
- new Integer( this.getMaxjeeapplicationserversstarted() ).toString() );
- return element;
- }
+ /**
+ * Transforms the <code>Agent</code> POJO into a DOM element.
+ *
+ * @param document the DOM core document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "agent" );
+ element.setAttribute( "id", this.getId() );
+ element.setAttribute( "hostname", this.getHostname() );
+ element.setAttribute( "port", new Integer( this.getPort() ).toString() );
+ element.setAttribute( "cron", this.getCron() );
+ element.setAttribute( "maxmanagedenvironments", new Integer( this.getMaxmanagedenvironments() ).toString() );
+ element.setAttribute( "maxjeeapplicationserversstarted",
+ new Integer( this.getMaxjeeapplicationserversstarted() ).toString() );
+ return element;
+ }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherAgent )
- {
- return this.getId().compareTo( ( (Agent) anotherAgent ).getId() );
- }
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherAgent )
+ {
+ return this.getId().compareTo( ( (Agent) anotherAgent ).getId() );
+ }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Archive.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Archive.java
index 9646fb3..11fe338 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Archive.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Archive.java
@@ -28,183 +28,183 @@
* Represents the <code>archive</code> tag in the Kalumet DOM.
*/
public class Archive
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = 7125281479795326133L;
+ private static final long serialVersionUID = 7125281479795326133L;
- private String name;
+ private String name;
- private String uri;
+ private String uri;
- private String classloaderorder;
+ private String classloaderorder;
- private String classloaderpolicy;
+ private String classloaderpolicy;
- private String vhost;
+ private String vhost;
- private String path;
+ private String path;
- private String context;
+ private String context;
- private boolean active;
+ private boolean active;
- private boolean blocker;
+ private boolean blocker;
- private String agent;
+ private String agent;
- public Archive()
- {
- }
+ public Archive()
+ {
+ }
- public String getName()
- {
- return this.name;
- }
+ public String getName()
+ {
+ return this.name;
+ }
- public void setName( String name )
- {
- this.name = name;
- }
+ public void setName( String name )
+ {
+ this.name = name;
+ }
- public String getUri()
- {
- return this.uri;
- }
+ public String getUri()
+ {
+ return this.uri;
+ }
- public void setUri( String uri )
- {
- this.uri = uri;
- }
+ public void setUri( String uri )
+ {
+ this.uri = uri;
+ }
- public String getClassloaderorder()
- {
- return classloaderorder;
- }
+ public String getClassloaderorder()
+ {
+ return classloaderorder;
+ }
- public void setClassloaderorder( String classloaderorder )
- {
- this.classloaderorder = classloaderorder;
- }
+ public void setClassloaderorder( String classloaderorder )
+ {
+ this.classloaderorder = classloaderorder;
+ }
- public String getClassloaderpolicy()
- {
- return classloaderpolicy;
- }
+ public String getClassloaderpolicy()
+ {
+ return classloaderpolicy;
+ }
- public void setClassloaderpolicy( String classloaderpolicy )
- {
- this.classloaderpolicy = classloaderpolicy;
- }
+ public void setClassloaderpolicy( String classloaderpolicy )
+ {
+ this.classloaderpolicy = classloaderpolicy;
+ }
- public String getVhost()
- {
- return this.vhost;
- }
+ public String getVhost()
+ {
+ return this.vhost;
+ }
- public void setVhost( String vhost )
- {
- this.vhost = vhost;
- }
+ public void setVhost( String vhost )
+ {
+ this.vhost = vhost;
+ }
- public String getPath()
- {
- return this.path;
- }
+ public String getPath()
+ {
+ return this.path;
+ }
- public void setPath( String path )
- {
- this.path = path;
- }
+ public void setPath( String path )
+ {
+ this.path = path;
+ }
- public String getContext()
- {
- return this.context;
- }
+ public String getContext()
+ {
+ return this.context;
+ }
- public void setContext( String context )
- {
- this.context = context;
- }
+ public void setContext( String context )
+ {
+ this.context = context;
+ }
- public boolean isActive()
- {
- return this.active;
- }
+ public boolean isActive()
+ {
+ return this.active;
+ }
- public void setActive( boolean active )
- {
- this.active = active;
- }
+ public void setActive( boolean active )
+ {
+ this.active = active;
+ }
- public boolean isBlocker()
- {
- return this.blocker;
- }
+ public boolean isBlocker()
+ {
+ return this.blocker;
+ }
- public void setBlocker( boolean blocker )
- {
- this.blocker = blocker;
- }
+ public void setBlocker( boolean blocker )
+ {
+ this.blocker = blocker;
+ }
- public String getAgent()
- {
- return agent;
- }
+ public String getAgent()
+ {
+ return agent;
+ }
- public void setAgent( String agent )
- {
- this.agent = agent;
- }
+ public void setAgent( String agent )
+ {
+ this.agent = agent;
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- Archive clone = new Archive();
- clone.setName( this.getName() );
- clone.setUri( this.getUri() );
- clone.setClassloaderorder( this.getClassloaderorder() );
- clone.setClassloaderpolicy( this.getClassloaderpolicy() );
- clone.setVhost( this.getVhost() );
- clone.setPath( this.getPath() );
- clone.setContext( this.getContext() );
- clone.setActive( this.isActive() );
- clone.setBlocker( this.isBlocker() );
- clone.setAgent( this.getAgent() );
- return clone;
- }
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ Archive clone = new Archive();
+ clone.setName( this.getName() );
+ clone.setUri( this.getUri() );
+ clone.setClassloaderorder( this.getClassloaderorder() );
+ clone.setClassloaderpolicy( this.getClassloaderpolicy() );
+ clone.setVhost( this.getVhost() );
+ clone.setPath( this.getPath() );
+ clone.setContext( this.getContext() );
+ clone.setActive( this.isActive() );
+ clone.setBlocker( this.isBlocker() );
+ clone.setAgent( this.getAgent() );
+ return clone;
+ }
- /**
- * Transforms the <code>Archive</code> specific POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "archive" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "uri", this.getUri() );
- element.setAttribute( "classloaderorder", this.getClassloaderorder() );
- element.setAttribute( "classloaderpolicy", this.getClassloaderpolicy() );
- element.setAttribute( "vhost", this.getVhost() );
- element.setAttribute( "path", this.getPath() );
- element.setAttribute( "context", this.getContext() );
- element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
- element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
- element.setAttribute( "agent", this.getAgent() );
- return element;
- }
+ /**
+ * Transforms the <code>Archive</code> specific POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "archive" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "uri", this.getUri() );
+ element.setAttribute( "classloaderorder", this.getClassloaderorder() );
+ element.setAttribute( "classloaderpolicy", this.getClassloaderpolicy() );
+ element.setAttribute( "vhost", this.getVhost() );
+ element.setAttribute( "path", this.getPath() );
+ element.setAttribute( "context", this.getContext() );
+ element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
+ element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
+ element.setAttribute( "agent", this.getAgent() );
+ return element;
+ }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherArchive )
- {
- return this.getName().compareTo( ( (Archive) anotherArchive ).getName() );
- }
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherArchive )
+ {
+ return this.getName().compareTo( ( (Archive) anotherArchive ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Cache.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Cache.java
index 2aec347..fadddea 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Cache.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Cache.java
@@ -29,57 +29,57 @@
* file.
*/
public class Cache
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = 1931779797709903317L;
+ private static final long serialVersionUID = 1931779797709903317L;
- private String path;
+ private String path;
- public Cache()
- {
- }
+ public Cache()
+ {
+ }
- public String getPath()
- {
- return this.path;
- }
+ public String getPath()
+ {
+ return this.path;
+ }
- public void setPath( String path )
- {
- this.path = path;
- }
+ public void setPath( String path )
+ {
+ this.path = path;
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- Cache clone = new Cache();
- clone.setPath( this.getPath() );
- return clone;
- }
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ Cache clone = new Cache();
+ clone.setPath( this.getPath() );
+ return clone;
+ }
- /**
- * Transforms the <code>Cache</code> POJO to a DOM element.
- *
- * @param document the core XML document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "cache" );
- element.setAttribute( "path", this.getPath() );
- return element;
- }
+ /**
+ * Transforms the <code>Cache</code> POJO to a DOM element.
+ *
+ * @param document the core XML document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "cache" );
+ element.setAttribute( "path", this.getPath() );
+ return element;
+ }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherCache )
- {
- return this.getPath().compareTo( ( (Cache) anotherCache ).getPath() );
- }
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherCache )
+ {
+ return this.getPath().compareTo( ( (Cache) anotherCache ).getPath() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Command.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Command.java
index 907d224..32695e9 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Command.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Command.java
@@ -29,114 +29,114 @@
* Represent a <code>command</code> tag, mainly inside <code>software</code>.
*/
public class Command
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = -3671135569540426579L;
+ private static final long serialVersionUID = -3671135569540426579L;
- private String name;
+ private String name;
- private boolean active;
+ private boolean active;
- private boolean blocker;
+ private boolean blocker;
- private String agent;
+ private String agent;
- private String command;
+ private String command;
- public Command()
- {
- }
+ public Command()
+ {
+ }
- public String getName()
- {
- return name;
- }
+ public String getName()
+ {
+ return name;
+ }
- public void setName( String name )
- {
- this.name = name;
- }
+ public void setName( String name )
+ {
+ this.name = name;
+ }
- public boolean isActive()
- {
- return active;
- }
+ public boolean isActive()
+ {
+ return active;
+ }
- public boolean isBlocker()
- {
- return blocker;
- }
+ public boolean isBlocker()
+ {
+ return blocker;
+ }
- public void setBlocker( boolean blocker )
- {
- this.blocker = blocker;
- }
+ public void setBlocker( boolean blocker )
+ {
+ this.blocker = blocker;
+ }
- public void setActive( boolean active )
- {
- this.active = active;
- }
+ public void setActive( boolean active )
+ {
+ this.active = active;
+ }
- public String getAgent()
- {
- return agent;
- }
+ public String getAgent()
+ {
+ return agent;
+ }
- public void setAgent( String agent )
- {
- this.agent = agent;
- }
+ public void setAgent( String agent )
+ {
+ this.agent = agent;
+ }
- public String getCommand()
- {
- return command;
- }
+ public String getCommand()
+ {
+ return command;
+ }
- public void setCommand( String command )
- {
- this.command = command;
- }
+ public void setCommand( String command )
+ {
+ this.command = command;
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- Command clone = new Command();
- clone.setName( this.getName() );
- clone.setActive( this.isActive() );
- clone.setBlocker( this.isBlocker() );
- clone.setAgent( this.getAgent() );
- clone.setCommand( this.getCommand() );
- return clone;
- }
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ Command clone = new Command();
+ clone.setName( this.getName() );
+ clone.setActive( this.isActive() );
+ clone.setBlocker( this.isBlocker() );
+ clone.setAgent( this.getAgent() );
+ clone.setCommand( this.getCommand() );
+ return clone;
+ }
- /**
- * Transforms a <code>command</code> into a XML DOM element.
- *
- * @param document the DOM document.
- * @return the <code>command</code> DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "command" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
- element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
- element.setAttribute( "agent", this.getAgent() );
- CDATASectionImpl content = new CDATASectionImpl( document, this.getCommand() );
- element.appendChild( content );
- return element;
- }
+ /**
+ * Transforms a <code>command</code> into a XML DOM element.
+ *
+ * @param document the DOM document.
+ * @return the <code>command</code> DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "command" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
+ element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
+ element.setAttribute( "agent", this.getAgent() );
+ CDATASectionImpl content = new CDATASectionImpl( document, this.getCommand() );
+ element.appendChild( content );
+ return element;
+ }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherCommand )
- {
- return this.getName().compareTo( ( (Command) anotherCommand ).getName() );
- }
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherCommand )
+ {
+ return this.getName().compareTo( ( (Command) anotherCommand ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/ConfigurationFile.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/ConfigurationFile.java
index 2c3ac46..cf2b635 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/ConfigurationFile.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/ConfigurationFile.java
@@ -31,201 +31,201 @@
* Represents the <code>configurationfile</code> tag in the Kalumet DOM.
*/
public class ConfigurationFile
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = -1898011382653346087L;
+ private static final long serialVersionUID = -1898011382653346087L;
- private String name;
+ private String name;
- private String uri;
+ private String uri;
- private String path;
+ private String path;
- private boolean active;
+ private boolean active;
- private boolean blocker;
+ private boolean blocker;
- private String agent;
+ private String agent;
- private LinkedList mappings;
+ private LinkedList mappings;
- public ConfigurationFile()
- {
- this.mappings = new LinkedList();
- }
-
- public String getName()
- {
- return this.name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public String getUri()
- {
- return this.uri;
- }
-
- public void setUri( String uri )
- {
- this.uri = uri;
- }
-
- public String getPath()
- {
- return this.path;
- }
-
- public void setPath( String path )
- {
- this.path = path;
- }
-
- public boolean isActive()
- {
- return this.active;
- }
-
- public void setActive( boolean active )
- {
- this.active = active;
- }
-
- public boolean isBlocker()
- {
- return this.blocker;
- }
-
- public void setBlocker( boolean blocker )
- {
- this.blocker = blocker;
- }
-
- public String getAgent()
- {
- return agent;
- }
-
- public void setAgent( String agent )
- {
- this.agent = agent;
- }
-
- /**
- * Add a new <code>Mapping</code> in the <code>ConfigurationFile</code>
- * mappings container.
- *
- * @param mapping the <code>Mapping</code> to add.
- */
- public void addMapping( Mapping mapping )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getMapping( mapping.getKey() ) != null )
+ public ConfigurationFile()
{
- throw new ModelObjectAlreadyExistsException( "Mapping key already exists in the configuration file." );
+ this.mappings = new LinkedList();
}
- this.mappings.add( mapping );
- }
- /**
- * Get the <code>Mapping</code> list in the <code>ConfigurationFile</code>
- * mappings container.
- *
- * @return the <code>Mapping</code> list.
- */
- public List getMappings()
- {
- return this.mappings;
- }
-
- /**
- * Set the <code>Mapping</code> list in the
- * <code>ConfigurationFile</code> mappings container.
- *
- * @param mappings the new <code>Mapping</code> list.
- */
- public void setMappings( LinkedList mappings )
- {
- this.mappings = mappings;
- }
-
- /**
- * Get the <code>Mapping</code> identified by a given key in the
- * <code>ConfigurationFile</code> mappings container.
- *
- * @param key the <code>Mapping</code> key.
- * @return the <code>Mapping</code> found or null if no <code>Mapping</code> found.
- */
- public Mapping getMapping( String key )
- {
- for ( Iterator mappingIterator = this.getMappings().iterator(); mappingIterator.hasNext(); )
+ public String getName()
{
- Mapping mapping = (Mapping) mappingIterator.next();
- if ( mapping.getKey().equals( key ) )
- {
- return mapping;
- }
+ return this.name;
}
- return null;
- }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- ConfigurationFile clone = new ConfigurationFile();
- clone.setName( this.getName() );
- clone.setUri( this.getUri() );
- clone.setPath( this.getPath() );
- clone.setActive( this.isActive() );
- clone.setBlocker( this.isBlocker() );
- clone.setAgent( this.getAgent() );
- for ( Iterator mappingIterator = this.mappings.iterator(); mappingIterator.hasNext(); )
+ public void setName( String name )
{
- Mapping mapping = (Mapping) mappingIterator.next();
- clone.mappings.add( (Mapping) mapping.clone() );
+ this.name = name;
}
- return clone;
- }
- /**
- * Transform the <code>ConfigurationFile</code> POJO to a DOM element.
- *
- * @param document the core XML document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "configurationfile" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "uri", this.getUri() );
- element.setAttribute( "path", this.getPath() );
- element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
- element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
- element.setAttribute( "agent", this.getAgent() );
- // mappings
- ElementImpl mappings = new ElementImpl( document, "mappings" );
- for ( Iterator mappingIterator = this.getMappings().iterator(); mappingIterator.hasNext(); )
+ public String getUri()
{
- Mapping mapping = (Mapping) mappingIterator.next();
- mappings.appendChild( mapping.toDOMElement( document ) );
+ return this.uri;
}
- element.appendChild( mappings );
- return element;
- }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherConfigurationFile )
- {
- return this.getName().compareTo( ( (ConfigurationFile) anotherConfigurationFile ).getName() );
- }
+ public void setUri( String uri )
+ {
+ this.uri = uri;
+ }
+
+ public String getPath()
+ {
+ return this.path;
+ }
+
+ public void setPath( String path )
+ {
+ this.path = path;
+ }
+
+ public boolean isActive()
+ {
+ return this.active;
+ }
+
+ public void setActive( boolean active )
+ {
+ this.active = active;
+ }
+
+ public boolean isBlocker()
+ {
+ return this.blocker;
+ }
+
+ public void setBlocker( boolean blocker )
+ {
+ this.blocker = blocker;
+ }
+
+ public String getAgent()
+ {
+ return agent;
+ }
+
+ public void setAgent( String agent )
+ {
+ this.agent = agent;
+ }
+
+ /**
+ * Add a new <code>Mapping</code> in the <code>ConfigurationFile</code>
+ * mappings container.
+ *
+ * @param mapping the <code>Mapping</code> to add.
+ */
+ public void addMapping( Mapping mapping )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getMapping( mapping.getKey() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "Mapping key already exists in the configuration file." );
+ }
+ this.mappings.add( mapping );
+ }
+
+ /**
+ * Get the <code>Mapping</code> list in the <code>ConfigurationFile</code>
+ * mappings container.
+ *
+ * @return the <code>Mapping</code> list.
+ */
+ public List getMappings()
+ {
+ return this.mappings;
+ }
+
+ /**
+ * Set the <code>Mapping</code> list in the
+ * <code>ConfigurationFile</code> mappings container.
+ *
+ * @param mappings the new <code>Mapping</code> list.
+ */
+ public void setMappings( LinkedList mappings )
+ {
+ this.mappings = mappings;
+ }
+
+ /**
+ * Get the <code>Mapping</code> identified by a given key in the
+ * <code>ConfigurationFile</code> mappings container.
+ *
+ * @param key the <code>Mapping</code> key.
+ * @return the <code>Mapping</code> found or null if no <code>Mapping</code> found.
+ */
+ public Mapping getMapping( String key )
+ {
+ for ( Iterator mappingIterator = this.getMappings().iterator(); mappingIterator.hasNext(); )
+ {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ if ( mapping.getKey().equals( key ) )
+ {
+ return mapping;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ ConfigurationFile clone = new ConfigurationFile();
+ clone.setName( this.getName() );
+ clone.setUri( this.getUri() );
+ clone.setPath( this.getPath() );
+ clone.setActive( this.isActive() );
+ clone.setBlocker( this.isBlocker() );
+ clone.setAgent( this.getAgent() );
+ for ( Iterator mappingIterator = this.mappings.iterator(); mappingIterator.hasNext(); )
+ {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ clone.mappings.add( (Mapping) mapping.clone() );
+ }
+ return clone;
+ }
+
+ /**
+ * Transform the <code>ConfigurationFile</code> POJO to a DOM element.
+ *
+ * @param document the core XML document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "configurationfile" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "uri", this.getUri() );
+ element.setAttribute( "path", this.getPath() );
+ element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
+ element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
+ element.setAttribute( "agent", this.getAgent() );
+ // mappings
+ ElementImpl mappings = new ElementImpl( document, "mappings" );
+ for ( Iterator mappingIterator = this.getMappings().iterator(); mappingIterator.hasNext(); )
+ {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ mappings.appendChild( mapping.toDOMElement( document ) );
+ }
+ element.appendChild( mappings );
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherConfigurationFile )
+ {
+ return this.getName().compareTo( ( (ConfigurationFile) anotherConfigurationFile ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/ContentManager.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/ContentManager.java
index ec2e645..c7a5c80 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/ContentManager.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/ContentManager.java
@@ -31,187 +31,187 @@
* Represent the <code>contentmanager</code> tag in the Kalumet DOM.
*/
public class ContentManager
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = -6772514401403559365L;
+ private static final long serialVersionUID = -6772514401403559365L;
- private String name;
+ private String name;
- private String classname;
+ private String classname;
- private boolean active;
+ private boolean active;
- private boolean blocker;
+ private boolean blocker;
- private String agent;
+ private String agent;
- private LinkedList properties;
+ private LinkedList properties;
- public ContentManager()
- {
- this.properties = new LinkedList();
- }
-
- public String getName()
- {
- return this.name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public String getClassname()
- {
- return this.classname;
- }
-
- public void setClassname( String classname )
- {
- this.classname = classname;
- }
-
- public boolean isActive()
- {
- return this.active;
- }
-
- public void setActive( boolean active )
- {
- this.active = active;
- }
-
- public boolean isBlocker()
- {
- return this.blocker;
- }
-
- public String getAgent()
- {
- return agent;
- }
-
- public void setAgent( String agent )
- {
- this.agent = agent;
- }
-
- public void setBlocker( boolean blocker )
- {
- this.blocker = blocker;
- }
-
- /**
- * Add a new <code>Property</code> in the <code>ContentManager</code>
- * properties container.
- *
- * @param property the <code>Property</code> to add.
- */
- public void addProperty( Property property )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getProperty( property.getName() ) != null )
+ public ContentManager()
{
- throw new ModelObjectAlreadyExistsException( "Property name already exists in content manager." );
+ this.properties = new LinkedList();
}
- this.properties.add( property );
- }
- /**
- * Get the <code>Property</code> list in the <code>ContentManager</code>
- * properties container.
- *
- * @return the <code>Property</code> list.
- */
- public List getProperties()
- {
- return this.properties;
- }
-
- /**
- * Set the <code>Property</code> list in the
- * <code>ContentManager</code> properties container.
- *
- * @param properties the new <code>Property</code> list.
- */
- public void setProperties( LinkedList properties )
- {
- this.properties = properties;
- }
-
- /**
- * Get the <code>Property</code> identified by a given name in the
- * <code>ContentManager</code> properties container.
- *
- * @param name the <code>Property</code> name.
- * @return the <code>Property</code> found or null if no <code>Property</code> found.
- */
- public Property getProperty( String name )
- {
- for ( Iterator propertyIterator = this.getProperties().iterator(); propertyIterator.hasNext(); )
+ public String getName()
{
- Property property = (Property) propertyIterator.next();
- if ( property.getName().equals( name ) )
- {
- return property;
- }
+ return this.name;
}
- return null;
- }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- ContentManager clone = new ContentManager();
- clone.setName( this.getName() );
- clone.setClassname( this.getClassname() );
- clone.setActive( this.isActive() );
- clone.setBlocker( this.isBlocker() );
- clone.setAgent( this.getAgent() );
- for ( Iterator propertyIterator = this.properties.iterator(); propertyIterator.hasNext(); )
+ public void setName( String name )
{
- Property property = (Property) propertyIterator.next();
- clone.properties.add( (Property) property.clone() );
+ this.name = name;
}
- return clone;
- }
- /**
- * Transform the <code>ContentManager</code> POJO to a DOM element.
- *
- * @param document the core XML document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "contentmanager" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "classname", this.getClassname() );
- element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
- element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
- element.setAttribute( "agent", this.getAgent() );
- // properties
- ElementImpl properties = new ElementImpl( document, "properties" );
- for ( Iterator propertyIterator = this.getProperties().iterator(); propertyIterator.hasNext(); )
+ public String getClassname()
{
- Property property = (Property) propertyIterator.next();
- properties.appendChild( property.toDOMElement( document ) );
+ return this.classname;
}
- element.appendChild( properties );
- return element;
- }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherContentManager )
- {
- return this.getName().compareTo( ( (ContentManager) anotherContentManager ).getName() );
- }
+ public void setClassname( String classname )
+ {
+ this.classname = classname;
+ }
+
+ public boolean isActive()
+ {
+ return this.active;
+ }
+
+ public void setActive( boolean active )
+ {
+ this.active = active;
+ }
+
+ public boolean isBlocker()
+ {
+ return this.blocker;
+ }
+
+ public String getAgent()
+ {
+ return agent;
+ }
+
+ public void setAgent( String agent )
+ {
+ this.agent = agent;
+ }
+
+ public void setBlocker( boolean blocker )
+ {
+ this.blocker = blocker;
+ }
+
+ /**
+ * Add a new <code>Property</code> in the <code>ContentManager</code>
+ * properties container.
+ *
+ * @param property the <code>Property</code> to add.
+ */
+ public void addProperty( Property property )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getProperty( property.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "Property name already exists in content manager." );
+ }
+ this.properties.add( property );
+ }
+
+ /**
+ * Get the <code>Property</code> list in the <code>ContentManager</code>
+ * properties container.
+ *
+ * @return the <code>Property</code> list.
+ */
+ public List getProperties()
+ {
+ return this.properties;
+ }
+
+ /**
+ * Set the <code>Property</code> list in the
+ * <code>ContentManager</code> properties container.
+ *
+ * @param properties the new <code>Property</code> list.
+ */
+ public void setProperties( LinkedList properties )
+ {
+ this.properties = properties;
+ }
+
+ /**
+ * Get the <code>Property</code> identified by a given name in the
+ * <code>ContentManager</code> properties container.
+ *
+ * @param name the <code>Property</code> name.
+ * @return the <code>Property</code> found or null if no <code>Property</code> found.
+ */
+ public Property getProperty( String name )
+ {
+ for ( Iterator propertyIterator = this.getProperties().iterator(); propertyIterator.hasNext(); )
+ {
+ Property property = (Property) propertyIterator.next();
+ if ( property.getName().equals( name ) )
+ {
+ return property;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ ContentManager clone = new ContentManager();
+ clone.setName( this.getName() );
+ clone.setClassname( this.getClassname() );
+ clone.setActive( this.isActive() );
+ clone.setBlocker( this.isBlocker() );
+ clone.setAgent( this.getAgent() );
+ for ( Iterator propertyIterator = this.properties.iterator(); propertyIterator.hasNext(); )
+ {
+ Property property = (Property) propertyIterator.next();
+ clone.properties.add( (Property) property.clone() );
+ }
+ return clone;
+ }
+
+ /**
+ * Transform the <code>ContentManager</code> POJO to a DOM element.
+ *
+ * @param document the core XML document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "contentmanager" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "classname", this.getClassname() );
+ element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
+ element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
+ element.setAttribute( "agent", this.getAgent() );
+ // properties
+ ElementImpl properties = new ElementImpl( document, "properties" );
+ for ( Iterator propertyIterator = this.getProperties().iterator(); propertyIterator.hasNext(); )
+ {
+ Property property = (Property) propertyIterator.next();
+ properties.appendChild( property.toDOMElement( document ) );
+ }
+ element.appendChild( properties );
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherContentManager )
+ {
+ return this.getName().compareTo( ( (ContentManager) anotherContentManager ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Database.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Database.java
index 8efa40e..ffb65fa 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Database.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Database.java
@@ -31,257 +31,257 @@
* Represent the <code>database</code> tag in the Kalumet configuration DOM.
*/
public class Database
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = 119112072290707974L;
+ private static final long serialVersionUID = 119112072290707974L;
- private String name;
+ private String name;
- private String driver;
+ private String driver;
- private String user;
+ private String user;
- private String password;
+ private String password;
- private String jdbcurl;
+ private String jdbcurl;
- private String connectionPool;
+ private String connectionPool;
- private String sqlCommand;
+ private String sqlCommand;
- private String agent;
+ private String agent;
- private boolean active;
+ private boolean active;
- private boolean blocker;
+ private boolean blocker;
- private LinkedList sqlScripts;
+ private LinkedList sqlScripts;
- public Database()
- {
- this.sqlScripts = new LinkedList();
- }
-
- public String getName()
- {
- return this.name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public String getDriver()
- {
- return this.driver;
- }
-
- public void setDriver( String driver )
- {
- this.driver = driver;
- }
-
- public String getUser()
- {
- return this.user;
- }
-
- public void setUser( String user )
- {
- this.user = user;
- }
-
- public String getPassword()
- {
- return this.password;
- }
-
- public void setPassword( String password )
- {
- this.password = password;
- }
-
- public String getJdbcurl()
- {
- return this.jdbcurl;
- }
-
- public void setJdbcurl( String jdbcurl )
- {
- this.jdbcurl = jdbcurl;
- }
-
- public String getConnectionPool()
- {
- return connectionPool;
- }
-
- public void setConnectionPool( String connectionPool )
- {
- this.connectionPool = connectionPool;
- }
-
- public String getSqlCommand()
- {
- return sqlCommand;
- }
-
- public void setSqlCommand( String sqlCommand )
- {
- this.sqlCommand = sqlCommand;
- }
-
- public String getAgent()
- {
- return agent;
- }
-
- public void setAgent( String agent )
- {
- this.agent = agent;
- }
-
- public boolean isActive()
- {
- return this.active;
- }
-
- public void setActive( boolean active )
- {
- this.active = active;
- }
-
- public boolean isBlocker()
- {
- return this.blocker;
- }
-
- public void setBlocker( boolean blocker )
- {
- this.blocker = blocker;
- }
-
- /**
- * Add a new <code>SqlScript</code> in the <code>Database</code> sqlscripts
- * container.
- *
- * @param sqlScript the <code>SqlScript</code> to add.
- */
- public void addSqlScript( SqlScript sqlScript )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getSqlScript( sqlScript.getName() ) != null )
+ public Database()
{
- throw new ModelObjectAlreadyExistsException( "SQL script name already exists in database." );
+ this.sqlScripts = new LinkedList();
}
- this.sqlScripts.add( sqlScript );
- }
- /**
- * Get the <code>SqlScript</code> list in the <code>Database</code>
- * sqlscripts container.
- *
- * @return the <code>SqlScript</code> list.
- */
- public List getSqlScripts()
- {
- return this.sqlScripts;
- }
-
- /**
- * Set the <code>SqlScript</code> list in the <code>Database</code>
- * sqlscripts container.
- *
- * @param sqlScripts the new <code>SqlScript</code> list.
- */
- public void setSqlScripts( LinkedList sqlScripts )
- {
- this.sqlScripts = sqlScripts;
- }
-
- /**
- * Get the <code>SqlScript</code> identified by a given name in the
- * <code>Database</code> sqlscripts container.
- *
- * @param name the <code>SqlScript</code> name.
- * @return the <code>SqlScript</code> found or null if no <code>SqlScript</code> found.
- */
- public SqlScript getSqlScript( String name )
- {
- for ( Iterator sqlScriptIterator = this.getSqlScripts().iterator(); sqlScriptIterator.hasNext(); )
+ public String getName()
{
- SqlScript sqlScript = (SqlScript) sqlScriptIterator.next();
- if ( sqlScript.getName().equals( name ) )
- {
- return sqlScript;
- }
+ return this.name;
}
- return null;
- }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- Database clone = new Database();
- clone.setName( this.getName() );
- clone.setDriver( this.getDriver() );
- clone.setUser( this.getUser() );
- clone.setPassword( this.getPassword() );
- clone.setJdbcurl( this.getJdbcurl() );
- clone.setConnectionPool( this.getConnectionPool() );
- clone.setSqlCommand( this.getSqlCommand() );
- clone.setAgent( this.getAgent() );
- clone.setActive( this.isActive() );
- clone.setBlocker( this.isBlocker() );
- for ( Iterator sqlScriptIterator = this.sqlScripts.iterator(); sqlScriptIterator.hasNext(); )
+ public void setName( String name )
{
- SqlScript sqlScript = (SqlScript) sqlScriptIterator.next();
- clone.sqlScripts.add( (SqlScript) sqlScript.clone() );
+ this.name = name;
}
- return clone;
- }
- /**
- * Transform the <code>Database</code> POJO to a DOM element.
- *
- * @param document the core XML document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "database" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "driver", this.getDriver() );
- element.setAttribute( "user", this.getUser() );
- element.setAttribute( "password", this.getPassword() );
- element.setAttribute( "jdbcurl", this.getJdbcurl() );
- element.setAttribute( "connectionPool", this.getConnectionPool() );
- element.setAttribute( "sqlCommand", this.getSqlCommand() );
- element.setAttribute( "agent", this.getAgent() );
- element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
- element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
- // sqlscripts
- ElementImpl sqlscripts = new ElementImpl( document, "sqlscripts" );
- for ( Iterator sqlScriptIterator = this.getSqlScripts().iterator(); sqlScriptIterator.hasNext(); )
+ public String getDriver()
{
- SqlScript sqlScript = (SqlScript) sqlScriptIterator.next();
- sqlscripts.appendChild( sqlScript.toDOMElement( document ) );
+ return this.driver;
}
- element.appendChild( sqlscripts );
- return element;
- }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherDatabase )
- {
- return this.getName().compareTo( ( (Database) anotherDatabase ).getName() );
- }
+ public void setDriver( String driver )
+ {
+ this.driver = driver;
+ }
+
+ public String getUser()
+ {
+ return this.user;
+ }
+
+ public void setUser( String user )
+ {
+ this.user = user;
+ }
+
+ public String getPassword()
+ {
+ return this.password;
+ }
+
+ public void setPassword( String password )
+ {
+ this.password = password;
+ }
+
+ public String getJdbcurl()
+ {
+ return this.jdbcurl;
+ }
+
+ public void setJdbcurl( String jdbcurl )
+ {
+ this.jdbcurl = jdbcurl;
+ }
+
+ public String getConnectionPool()
+ {
+ return connectionPool;
+ }
+
+ public void setConnectionPool( String connectionPool )
+ {
+ this.connectionPool = connectionPool;
+ }
+
+ public String getSqlCommand()
+ {
+ return sqlCommand;
+ }
+
+ public void setSqlCommand( String sqlCommand )
+ {
+ this.sqlCommand = sqlCommand;
+ }
+
+ public String getAgent()
+ {
+ return agent;
+ }
+
+ public void setAgent( String agent )
+ {
+ this.agent = agent;
+ }
+
+ public boolean isActive()
+ {
+ return this.active;
+ }
+
+ public void setActive( boolean active )
+ {
+ this.active = active;
+ }
+
+ public boolean isBlocker()
+ {
+ return this.blocker;
+ }
+
+ public void setBlocker( boolean blocker )
+ {
+ this.blocker = blocker;
+ }
+
+ /**
+ * Add a new <code>SqlScript</code> in the <code>Database</code> sqlscripts
+ * container.
+ *
+ * @param sqlScript the <code>SqlScript</code> to add.
+ */
+ public void addSqlScript( SqlScript sqlScript )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getSqlScript( sqlScript.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "SQL script name already exists in database." );
+ }
+ this.sqlScripts.add( sqlScript );
+ }
+
+ /**
+ * Get the <code>SqlScript</code> list in the <code>Database</code>
+ * sqlscripts container.
+ *
+ * @return the <code>SqlScript</code> list.
+ */
+ public List getSqlScripts()
+ {
+ return this.sqlScripts;
+ }
+
+ /**
+ * Set the <code>SqlScript</code> list in the <code>Database</code>
+ * sqlscripts container.
+ *
+ * @param sqlScripts the new <code>SqlScript</code> list.
+ */
+ public void setSqlScripts( LinkedList sqlScripts )
+ {
+ this.sqlScripts = sqlScripts;
+ }
+
+ /**
+ * Get the <code>SqlScript</code> identified by a given name in the
+ * <code>Database</code> sqlscripts container.
+ *
+ * @param name the <code>SqlScript</code> name.
+ * @return the <code>SqlScript</code> found or null if no <code>SqlScript</code> found.
+ */
+ public SqlScript getSqlScript( String name )
+ {
+ for ( Iterator sqlScriptIterator = this.getSqlScripts().iterator(); sqlScriptIterator.hasNext(); )
+ {
+ SqlScript sqlScript = (SqlScript) sqlScriptIterator.next();
+ if ( sqlScript.getName().equals( name ) )
+ {
+ return sqlScript;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ Database clone = new Database();
+ clone.setName( this.getName() );
+ clone.setDriver( this.getDriver() );
+ clone.setUser( this.getUser() );
+ clone.setPassword( this.getPassword() );
+ clone.setJdbcurl( this.getJdbcurl() );
+ clone.setConnectionPool( this.getConnectionPool() );
+ clone.setSqlCommand( this.getSqlCommand() );
+ clone.setAgent( this.getAgent() );
+ clone.setActive( this.isActive() );
+ clone.setBlocker( this.isBlocker() );
+ for ( Iterator sqlScriptIterator = this.sqlScripts.iterator(); sqlScriptIterator.hasNext(); )
+ {
+ SqlScript sqlScript = (SqlScript) sqlScriptIterator.next();
+ clone.sqlScripts.add( (SqlScript) sqlScript.clone() );
+ }
+ return clone;
+ }
+
+ /**
+ * Transform the <code>Database</code> POJO to a DOM element.
+ *
+ * @param document the core XML document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "database" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "driver", this.getDriver() );
+ element.setAttribute( "user", this.getUser() );
+ element.setAttribute( "password", this.getPassword() );
+ element.setAttribute( "jdbcurl", this.getJdbcurl() );
+ element.setAttribute( "connectionPool", this.getConnectionPool() );
+ element.setAttribute( "sqlCommand", this.getSqlCommand() );
+ element.setAttribute( "agent", this.getAgent() );
+ element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
+ element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
+ // sqlscripts
+ ElementImpl sqlscripts = new ElementImpl( document, "sqlscripts" );
+ for ( Iterator sqlScriptIterator = this.getSqlScripts().iterator(); sqlScriptIterator.hasNext(); )
+ {
+ SqlScript sqlScript = (SqlScript) sqlScriptIterator.next();
+ sqlscripts.appendChild( sqlScript.toDOMElement( document ) );
+ }
+ element.appendChild( sqlscripts );
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherDatabase )
+ {
+ return this.getName().compareTo( ( (Database) anotherDatabase ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Destination.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Destination.java
index 38c9e7a..f26c69d 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Destination.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Destination.java
@@ -28,57 +28,57 @@
* Represent the <code>destination</code> tag in the Kalumet configuration DOM.
*/
public class Destination
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = 1088692045286398988L;
+ private static final long serialVersionUID = 1088692045286398988L;
- private String address;
+ private String address;
- public Destination()
- {
- }
+ public Destination()
+ {
+ }
- public String getAddress()
- {
- return this.address;
- }
+ public String getAddress()
+ {
+ return this.address;
+ }
- public void setAddress( String address )
- {
- this.address = address;
- }
+ public void setAddress( String address )
+ {
+ this.address = address;
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- Destination clone = new Destination();
- clone.setAddress( this.getAddress() );
- return clone;
- }
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ Destination clone = new Destination();
+ clone.setAddress( this.getAddress() );
+ return clone;
+ }
- /**
- * Transform the <code>Destination</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "destination" );
- element.setAttribute( "address", this.getAddress() );
- return element;
- }
+ /**
+ * Transform the <code>Destination</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "destination" );
+ element.setAttribute( "address", this.getAddress() );
+ return element;
+ }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherDestination )
- {
- return this.getAddress().compareTo( ( (Destination) anotherDestination ).getAddress() );
- }
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherDestination )
+ {
+ return this.getAddress().compareTo( ( (Destination) anotherDestination ).getAddress() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Email.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Email.java
index 8444c5a..7726feb 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Email.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Email.java
@@ -31,145 +31,146 @@
* Represent the <code>Email</code> tag in the Kalumet configuration DOM.
*/
public class Email
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = -88087573038809801L;
+ private static final long serialVersionUID = -88087573038809801L;
- private String mailhost;
+ private String mailhost;
- private String from;
+ private String from;
- private LinkedList destinations;
+ private LinkedList destinations;
- public Email()
- {
- this.destinations = new LinkedList();
- }
-
- public String getMailhost()
- {
- return this.mailhost;
- }
-
- public void setMailhost( String mailhost )
- {
- this.mailhost = mailhost;
- }
-
- public String getFrom()
- {
- return this.from;
- }
-
- public void setFrom( String from )
- {
- this.from = from;
- }
-
- /**
- * Add a new <code>Destination</code> in the <code>Email</code>
- * destinations container.
- *
- * @param destination the <code>Destination</code> to add.
- */
- public void addDestination( Destination destination )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getDestination( destination.getAddress() ) != null )
+ public Email()
{
- throw new ModelObjectAlreadyExistsException( "Destination address already exists in the email destinations." );
+ this.destinations = new LinkedList();
}
- this.destinations.add( destination );
- }
- /**
- * Get the <code>Destination</code> list in the <code>Email</code>
- * destinations container.
- *
- * @return the <code>Destination</code> list.
- */
- public List getDestinations()
- {
- return this.destinations;
- }
-
- /**
- * Set the <code>Destination</code> list in the <code>Email</code>
- * destinations container.
- *
- * @param destinations the new <code>Destination</code> list.
- */
- public void setDestinations( LinkedList destinations )
- {
- this.destinations = destinations;
- }
-
- /**
- * Get the <code>Destination</code> identified by a given address in the
- * <code>Email</code> destinations container.
- *
- * @param address the <code>Destination</code> address.
- * @return the <code>Destination</code> found or null if not found.
- */
- public Destination getDestination( String address )
- {
- for ( Iterator destinationIterator = this.getDestinations().iterator(); destinationIterator.hasNext(); )
+ public String getMailhost()
{
- Destination destination = (Destination) destinationIterator.next();
- if ( destination.getAddress().equals( address ) )
- {
- return destination;
- }
+ return this.mailhost;
}
- return null;
- }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- Email clone = new Email();
- clone.setMailhost( this.getMailhost() );
- clone.setFrom( this.getFrom() );
- for ( Iterator destinationIterator = this.destinations.iterator(); destinationIterator.hasNext(); )
+ public void setMailhost( String mailhost )
{
- Destination destination = (Destination) destinationIterator.next();
- clone.destinations.add( (Destination) destination.clone() );
+ this.mailhost = mailhost;
}
- return clone;
- }
- /**
- * Transform the <code>Email</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "email" );
- element.setAttribute( "mailhost", this.getMailhost() );
- element.setAttribute( "from", this.getFrom() );
- // destinations
- ElementImpl destinations = new ElementImpl( document, "destinations" );
- for ( Iterator destinationIterator = this.getDestinations().iterator(); destinationIterator.hasNext(); )
+ public String getFrom()
{
- Destination destination = (Destination) destinationIterator.next();
- destinations.appendChild( destination.toDOMElement( document ) );
+ return this.from;
}
- element.appendChild( destinations );
- return element;
- }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherEmail )
- {
- return this.getMailhost().compareTo( ( (Email) anotherEmail ).getMailhost() );
- }
+ public void setFrom( String from )
+ {
+ this.from = from;
+ }
+
+ /**
+ * Add a new <code>Destination</code> in the <code>Email</code>
+ * destinations container.
+ *
+ * @param destination the <code>Destination</code> to add.
+ */
+ public void addDestination( Destination destination )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getDestination( destination.getAddress() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException(
+ "Destination address already exists in the email destinations." );
+ }
+ this.destinations.add( destination );
+ }
+
+ /**
+ * Get the <code>Destination</code> list in the <code>Email</code>
+ * destinations container.
+ *
+ * @return the <code>Destination</code> list.
+ */
+ public List getDestinations()
+ {
+ return this.destinations;
+ }
+
+ /**
+ * Set the <code>Destination</code> list in the <code>Email</code>
+ * destinations container.
+ *
+ * @param destinations the new <code>Destination</code> list.
+ */
+ public void setDestinations( LinkedList destinations )
+ {
+ this.destinations = destinations;
+ }
+
+ /**
+ * Get the <code>Destination</code> identified by a given address in the
+ * <code>Email</code> destinations container.
+ *
+ * @param address the <code>Destination</code> address.
+ * @return the <code>Destination</code> found or null if not found.
+ */
+ public Destination getDestination( String address )
+ {
+ for ( Iterator destinationIterator = this.getDestinations().iterator(); destinationIterator.hasNext(); )
+ {
+ Destination destination = (Destination) destinationIterator.next();
+ if ( destination.getAddress().equals( address ) )
+ {
+ return destination;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ Email clone = new Email();
+ clone.setMailhost( this.getMailhost() );
+ clone.setFrom( this.getFrom() );
+ for ( Iterator destinationIterator = this.destinations.iterator(); destinationIterator.hasNext(); )
+ {
+ Destination destination = (Destination) destinationIterator.next();
+ clone.destinations.add( (Destination) destination.clone() );
+ }
+ return clone;
+ }
+
+ /**
+ * Transform the <code>Email</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "email" );
+ element.setAttribute( "mailhost", this.getMailhost() );
+ element.setAttribute( "from", this.getFrom() );
+ // destinations
+ ElementImpl destinations = new ElementImpl( document, "destinations" );
+ for ( Iterator destinationIterator = this.getDestinations().iterator(); destinationIterator.hasNext(); )
+ {
+ Destination destination = (Destination) destinationIterator.next();
+ destinations.appendChild( destination.toDOMElement( document ) );
+ }
+ element.appendChild( destinations );
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherEmail )
+ {
+ return this.getMailhost().compareTo( ( (Email) anotherEmail ).getMailhost() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Environment.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Environment.java
index 0fcd2c0..7dbdb01 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Environment.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Environment.java
@@ -32,711 +32,712 @@
* Represent the <code>environment</code> tag in the Kalumet configuration DOM.
*/
public class Environment
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = -5131247974934459040L;
+ private static final long serialVersionUID = -5131247974934459040L;
- private String name;
+ private String name;
- private String group;
+ private String group;
- private String tag;
+ private String tag;
- private boolean autoupdate;
+ private boolean autoupdate;
- private String agent;
+ private String agent;
- private String lock;
+ private String lock;
- private String releaseLocation;
+ private String releaseLocation;
- private String notes;
+ private String notes;
- private String weblinks;
+ private String weblinks;
- private LinkedList variables;
+ private LinkedList variables;
- private LinkedList freeFields;
+ private LinkedList freeFields;
- private LinkedList accesses;
+ private LinkedList accesses;
- private JEEApplicationServers jeeApplicationServers;
+ private JEEApplicationServers jeeApplicationServers;
- private LinkedList softwares;
+ private LinkedList softwares;
- private LinkedList logFiles;
+ private LinkedList logFiles;
- private Notifiers notifiers;
+ private Notifiers notifiers;
- private LinkedList publishers;
+ private LinkedList publishers;
- private Statistics statistics;
+ private Statistics statistics;
- public Environment()
- {
- this.variables = new LinkedList();
- this.freeFields = new LinkedList();
- this.accesses = new LinkedList();
- this.jeeApplicationServers = new JEEApplicationServers();
- this.softwares = new LinkedList();
- this.logFiles = new LinkedList();
- this.notifiers = new Notifiers();
- this.publishers = new LinkedList();
- this.statistics = new Statistics();
- }
-
- public String getName()
- {
- return this.name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public String getGroup()
- {
- return this.group;
- }
-
- public void setGroup( String group )
- {
- this.group = group;
- }
-
- public String getTag()
- {
- return this.tag;
- }
-
- public void setTag( String flag )
- {
- this.tag = flag;
- }
-
- public boolean isAutoupdate()
- {
- return this.autoupdate;
- }
-
- public void setAutoupdate( boolean autoupdate )
- {
- this.autoupdate = autoupdate;
- }
-
- public String getAgent()
- {
- return this.agent;
- }
-
- public void setAgent( String agent )
- {
- this.agent = agent;
- }
-
- public String getLock()
- {
- return this.lock;
- }
-
- public void setLock( String lock )
- {
- this.lock = lock;
- }
-
- public String getReleaseLocation()
- {
- return this.releaseLocation;
- }
-
- public void setReleaseLocation( String releaseLocation )
- {
- this.releaseLocation = releaseLocation;
- }
-
- public String getNotes()
- {
- return this.notes;
- }
-
- public void setNotes( String notes )
- {
- this.notes = notes;
- }
-
- public String getWeblinks()
- {
- return this.weblinks;
- }
-
- public void setWeblinks( String weblinks )
- {
- this.weblinks = weblinks;
- }
-
- /**
- * Add a new <code>Variable</code> in the <code>Environment</code>
- * variables container.
- *
- * @param variable the <code>Variable</code> to add.
- */
- public void addVariable( Variable variable )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getVariable( variable.getName() ) != null )
+ public Environment()
{
- throw new ModelObjectAlreadyExistsException( "Variable name already exists in the environment variables." );
+ this.variables = new LinkedList();
+ this.freeFields = new LinkedList();
+ this.accesses = new LinkedList();
+ this.jeeApplicationServers = new JEEApplicationServers();
+ this.softwares = new LinkedList();
+ this.logFiles = new LinkedList();
+ this.notifiers = new Notifiers();
+ this.publishers = new LinkedList();
+ this.statistics = new Statistics();
}
- this.variables.add( variable );
- }
- /**
- * Get the <code>Variable</code> list in the <code>Environment</code>
- * variables container.
- *
- * @return the <code>Variable</code> list.
- */
- public List getVariables()
- {
- return this.variables;
- }
-
- /**
- * Set the <code>Variable</code> list in the <code>Environment</code>
- * variables container.
- *
- * @param variables the new <code>Variable</code> list.
- */
- public void setVariables( LinkedList variables )
- {
- this.variables = variables;
- }
-
- /**
- * Get the <code>Variable</code> identified by a given name in the
- * <code>Environment</code> variables container.
- *
- * @param name the <code>Variable</code> name.
- * @return the <code>Variable</code> found or null if not found.
- */
- public Variable getVariable( String name )
- {
- for ( Iterator variableIterator = this.getVariables().iterator(); variableIterator.hasNext(); )
+ public String getName()
{
- Variable variable = (Variable) variableIterator.next();
- if ( variable.getName().equals( name ) )
- {
- return variable;
- }
+ return this.name;
}
- return null;
- }
- /**
- * Add a new <code>FreeField</code> in the <code>Environment</code>
- * free fields container.
- *
- * @param freeField the <code>FreeField</code> to add.
- */
- public void addFreeField( FreeField freeField )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getFreeField( freeField.getName() ) != null )
+ public void setName( String name )
{
- throw new ModelObjectAlreadyExistsException( "Freefield name already exists in the environment freefields." );
+ this.name = name;
}
- this.freeFields.add( freeField );
- }
- /**
- * Get the <code>FreeField</code> list in the <code>Environment</code>
- * free fields container.
- *
- * @return the <code>FreeField</code> list.
- */
- public List getFreeFields()
- {
- return this.freeFields;
- }
-
- /**
- * Set the <code>FreeField<code> list in the <code>Environment</code>
- * free fields container.
- *
- * @param freeFields the new <code>FreeField</code> list.
- */
- public void setFreeFields( LinkedList freeFields )
- {
- this.freeFields = freeFields;
- }
-
- /**
- * Get the <code>FreeField</code> identified by a given name in the
- * <code>Environment</code> free fields container.
- *
- * @param name the <code>FreeField</code> name.
- * @return the <code>FreeField</code> found or null if not found.
- */
- public FreeField getFreeField( String name )
- {
- for ( Iterator freeFieldIterator = this.getFreeFields().iterator(); freeFieldIterator.hasNext(); )
+ public String getGroup()
{
- FreeField freeField = (FreeField) freeFieldIterator.next();
- if ( freeField.getName().equals( name ) )
- {
- return freeField;
- }
+ return this.group;
}
- return null;
- }
- /**
- * Add a new <code>Access</code> in the <code>Environment</code> accesses
- * container.
- *
- * @param access the <code>Access</code> to add.
- */
- public void addAccess( Access access )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getAccess( access.getGroup() ) != null )
+ public void setGroup( String group )
{
- throw new ModelObjectAlreadyExistsException( "Access group id already exists in the environnement accesses." );
+ this.group = group;
}
- this.accesses.add( access );
- }
- /**
- * Get the <code>Access</code> list in the <code>Environment</code>
- * accesses container.
- *
- * @return the <code>Access</code> list.
- */
- public List getAccesses()
- {
- return this.accesses;
- }
-
- /**
- * Set the <code>Access</code> list in the <code>Environment</code>
- * accesses container.
- *
- * @param accesses the new <code>Access</code> list.
- */
- public void setAccesses( LinkedList accesses )
- {
- this.accesses = accesses;
- }
-
- /**
- * Get the <code>Access</code> identified by a given group id in the
- * <code>Environment</code> accesses container.
- *
- * @param group the group id.
- * @return the <code>Access</code> found or null if not found.
- */
- public Access getAccess( String group )
- {
- for ( Iterator accessIterator = this.getAccesses().iterator(); accessIterator.hasNext(); )
+ public String getTag()
{
- Access access = (Access) accessIterator.next();
- if ( access.getGroup().equals( group ) )
- {
- return access;
- }
+ return this.tag;
}
- return null;
- }
- /**
- * Set the <code>JEEApplicationServers</code> container in the
- * <code>Environment</code>.
- *
- * @param jeeApplicationServers the <code>JEEApplicationServers</code> to set.
- */
- public void setJEEApplicationServers(JEEApplicationServers jeeApplicationServers)
- {
- this.jeeApplicationServers = jeeApplicationServers;
- }
-
- /**
- * Get the <code>JEEApplicationServers</code> container in the
- * <code>Environment</code>.
- *
- * @return the <code>JEEApplicationServers</code> container.
- */
- public JEEApplicationServers getJEEApplicationServers()
- {
- return this.jeeApplicationServers;
- }
-
- /**
- * Add a new <code>Software</code> in the <code>Environment</code>
- * softwares container.
- *
- * @param software the <code>Software</code> to add.
- */
- public void addSoftware( Software software )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getSoftware( software.getName() ) != null )
+ public void setTag( String flag )
{
- throw new ModelObjectAlreadyExistsException( "Software name already exists in the environment." );
+ this.tag = flag;
}
- this.softwares.add( software );
- }
- /**
- * Get the <code>Software</code> list in the <code>Environment</code>
- * softwares container.
- *
- * @return the <code>Software</code> list.
- */
- public List getSoftwares()
- {
- return this.softwares;
- }
-
- /**
- * Set the <code>Software</code> list in the <code>Environment</code>
- * softwares container.
- *
- * @param softwares the new <code>Software</code> list.
- */
- public void setSoftwares( LinkedList softwares )
- {
- this.softwares = softwares;
- }
-
- /**
- * Get the <code>Software</code> identified by a given name in the
- * <code>Environment</code> softwares container.
- *
- * @param name the <code>Software</code> name.
- * @return the <code>Software</code> found or null if not found.
- */
- public Software getSoftware( String name )
- {
- for ( Iterator softwareIterator = this.getSoftwares().iterator(); softwareIterator.hasNext(); )
+ public boolean isAutoupdate()
{
- Software software = (Software) softwareIterator.next();
- if ( software.getName().equals( name ) )
- {
- return software;
- }
+ return this.autoupdate;
}
- return null;
- }
- /**
- * Get the environment log files list.
- *
- * @return the log files list.
- */
- public List getLogFiles()
- {
- return this.logFiles;
- }
+ public void setAutoupdate( boolean autoupdate )
+ {
+ this.autoupdate = autoupdate;
+ }
- /**
- * Set the environment log files list.
- *
- * @param logFiles the log files list.
- */
- public void setLogFiles( LinkedList logFiles )
- {
- this.logFiles = logFiles;
- }
+ public String getAgent()
+ {
+ return this.agent;
+ }
- /**
- * Get a log file identified by a name.
- *
- * @param name the log file name.
- * @return the log file or null if not found.
- */
- public LogFile getLogFile( String name )
- {
- for ( Iterator logFileIterator = this.getLogFiles().iterator(); logFileIterator.hasNext(); )
+ public void setAgent( String agent )
{
- LogFile logFile = (LogFile) logFileIterator.next();
- if ( logFile.getName().equals( name ) )
- {
- return logFile;
- }
+ this.agent = agent;
}
- return null;
- }
- /**
- * Add a new log file in the environment.
- *
- * @param logFile the log file to add.
- * @throws ModelObjectAlreadyExistsException
- * if the log file name already exists.
- */
- public void addLogFile( LogFile logFile )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getLogFile( logFile.getName() ) != null )
+ public String getLock()
{
- throw new ModelObjectAlreadyExistsException( "Log file name already exists in environment." );
+ return this.lock;
}
- this.logFiles.add( logFile );
- }
- /**
- * Set the <code>Notifiers</code> in the <code>Environment</code>.
- *
- * @param notifiers the <code>Notifiers</code> to set.
- */
- public void setNotifiers( Notifiers notifiers )
- {
- this.notifiers = notifiers;
- }
+ public void setLock( String lock )
+ {
+ this.lock = lock;
+ }
- /**
- * Get the <code>Notifiers</code> in the <code>Environment</code>.
- *
- * @return the <code>Notifiers</code> in the <code>Environment</code>.
- */
- public Notifiers getNotifiers()
- {
- return this.notifiers;
- }
+ public String getReleaseLocation()
+ {
+ return this.releaseLocation;
+ }
- /**
- * Add a new <code>Email</code> publisher in the <code>Environment</code>
- * publishers container.
- *
- * @param email the <code>Email</code> to add.
- */
- public void addPublisher( Email email )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getPublisher( email.getMailhost() ) != null )
+ public void setReleaseLocation( String releaseLocation )
{
- throw new ModelObjectAlreadyExistsException( "Email publisher mailhost already exists in environment." );
+ this.releaseLocation = releaseLocation;
}
- this.publishers.add( email );
- }
- /**
- * Get the <code>Email</code> publisher list in the
- * <code>Environment</code> publishers container.
- *
- * @return the <code>Email</code> publisher list.
- */
- public List getPublishers()
- {
- return this.publishers;
- }
+ public String getNotes()
+ {
+ return this.notes;
+ }
- /**
- * Set the <code>Email</code> publisher list in the
- * <code>Environment</code> publishers container.
- *
- * @param publishers the new <code>Email</code> publisher list.
- */
- public void setPublishers( LinkedList publishers )
- {
- this.publishers = publishers;
- }
+ public void setNotes( String notes )
+ {
+ this.notes = notes;
+ }
- /**
- * Get the <code>Email</code> publisher identified by a given mail host
- * in the <code>Environment</code> publishers container.
- *
- * @param mailhost the <code>Email</code> mail host.
- * @return the <code>Email</code> found or null if not found.
- */
- public Email getPublisher( String mailhost )
- {
- for ( Iterator publisherIterator = this.getPublishers().iterator(); publisherIterator.hasNext(); )
+ public String getWeblinks()
{
- Email email = (Email) publisherIterator.next();
- if ( email.getMailhost().equals( mailhost ) )
- {
- return email;
- }
+ return this.weblinks;
}
- return null;
- }
- /**
- * Set the <code>Statistics</code> container.
- *
- * @return statistics the new <code>Statistics</code> container.
- */
- public Statistics getStatistics()
- {
- return statistics;
- }
+ public void setWeblinks( String weblinks )
+ {
+ this.weblinks = weblinks;
+ }
- /**
- * Get the <code>Statistics</code> container.
- *
- * @param statistics the current <code>Statistics</code> container.
- */
- public void setStatistics( Statistics statistics )
- {
- this.statistics = statistics;
- }
+ /**
+ * Add a new <code>Variable</code> in the <code>Environment</code>
+ * variables container.
+ *
+ * @param variable the <code>Variable</code> to add.
+ */
+ public void addVariable( Variable variable )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getVariable( variable.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "Variable name already exists in the environment variables." );
+ }
+ this.variables.add( variable );
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- Environment clone = new Environment();
- clone.setName( this.getName() );
- clone.setGroup( this.getGroup() );
- clone.setTag( this.getTag() );
- clone.setAutoupdate( this.isAutoupdate() );
- clone.setAgent( this.getAgent() );
- clone.setLock( this.getLock() );
- clone.setReleaseLocation( this.getReleaseLocation() );
- clone.setNotes( this.getNotes() );
- clone.setWeblinks( this.getWeblinks() );
- for ( Iterator variableIterator = this.variables.iterator(); variableIterator.hasNext(); )
+ /**
+ * Get the <code>Variable</code> list in the <code>Environment</code>
+ * variables container.
+ *
+ * @return the <code>Variable</code> list.
+ */
+ public List getVariables()
{
- Variable variable = (Variable) variableIterator.next();
- clone.variables.add( (Variable) variable.clone() );
+ return this.variables;
}
- for ( Iterator freeFieldIterator = this.freeFields.iterator(); freeFieldIterator.hasNext(); )
- {
- FreeField freeField = (FreeField) freeFieldIterator.next();
- clone.freeFields.add( (FreeField) freeField.clone() );
- }
- for ( Iterator accessIterator = this.accesses.iterator(); accessIterator.hasNext(); )
- {
- Access access = (Access) accessIterator.next();
- clone.accesses.add( (Access) access.clone() );
- }
- clone.setJEEApplicationServers((JEEApplicationServers) this.getJEEApplicationServers().clone());
- for ( Iterator softwareIterator = this.softwares.iterator(); softwareIterator.hasNext(); )
- {
- Software software = (Software) softwareIterator.next();
- clone.softwares.add( (Software) software.clone() );
- }
- for ( Iterator logFilesIterator = this.logFiles.iterator(); logFilesIterator.hasNext(); )
- {
- LogFile logFile = (LogFile) logFilesIterator.next();
- clone.softwares.add( (LogFile) logFile.clone() );
- }
- clone.setNotifiers( (Notifiers) this.getNotifiers().clone() );
- for ( Iterator publisherIterator = this.publishers.iterator(); publisherIterator.hasNext(); )
- {
- Email publisher = (Email) publisherIterator.next();
- clone.publishers.add( (Email) publisher.clone() );
- }
- clone.setStatistics( (Statistics) this.getStatistics().clone() );
- return clone;
- }
- /**
- * Transform the <code>Environment</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "environment" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "group", this.getGroup() );
- element.setAttribute( "tag", this.getTag() );
- element.setAttribute( "autoupdate", new Boolean( this.isAutoupdate() ).toString() );
- element.setAttribute( "agent", this.getAgent() );
- element.setAttribute( "lock", this.getLock() );
- element.setAttribute( "releaseLocation", this.getReleaseLocation() );
- // variables element
- ElementImpl variables = new ElementImpl( document, "variables" );
- // add variable to variables
- for ( Iterator variableIterator = this.getVariables().iterator(); variableIterator.hasNext(); )
+ /**
+ * Set the <code>Variable</code> list in the <code>Environment</code>
+ * variables container.
+ *
+ * @param variables the new <code>Variable</code> list.
+ */
+ public void setVariables( LinkedList variables )
{
- Variable variable = (Variable) variableIterator.next();
- variables.appendChild( variable.toDOMElement( document ) );
+ this.variables = variables;
}
- // add variables to environment
- element.appendChild( variables );
- // freefields element
- ElementImpl freefields = new ElementImpl( document, "freefields" );
- // add freefield to freefields
- for ( Iterator freeFieldIterator = this.getFreeFields().iterator(); freeFieldIterator.hasNext(); )
- {
- FreeField freefield = (FreeField) freeFieldIterator.next();
- freefields.appendChild( freefield.toDOMElement( document ) );
- }
- // add freefields to environment
- element.appendChild( freefields );
- // accesses element
- ElementImpl accesses = new ElementImpl( document, "accesses" );
- // add access to accesses
- for ( Iterator accessIterator = this.getAccesses().iterator(); accessIterator.hasNext(); )
- {
- Access access = (Access) accessIterator.next();
- accesses.appendChild( access.toDOMElement( document ) );
- }
- // add accesses to environment
- element.appendChild( accesses );
- // add notes
- ElementImpl notes = new ElementImpl( document, "notes" );
- CDATASectionImpl notesContent = new CDATASectionImpl( document, this.getNotes() );
- notes.appendChild( notesContent );
- element.appendChild( notes );
- // add weblinks
- ElementImpl weblinks = new ElementImpl( document, "weblinks" );
- CDATASectionImpl weblinksContent = new CDATASectionImpl( document, this.getWeblinks() );
- weblinks.appendChild( weblinksContent );
- element.appendChild( weblinks );
- // add JEE servers
- element.appendChild( this.getJEEApplicationServers().toDOMElement( document ) );
- // softwares element
- ElementImpl softwares = new ElementImpl( document, "softwares" );
- // add software to softwares
- for ( Iterator softwareIterator = this.getSoftwares().iterator(); softwareIterator.hasNext(); )
- {
- Software software = (Software) softwareIterator.next();
- softwares.appendChild( software.toDOMElement( document ) );
- }
- // add softwares to environment
- element.appendChild( softwares );
- // logfiles element
- ElementImpl logfiles = new ElementImpl( document, "logfiles" );
- // add logfile to logfiles
- for ( Iterator logFileIterator = this.getLogFiles().iterator(); logFileIterator.hasNext(); )
- {
- LogFile logFile = (LogFile) logFileIterator.next();
- logfiles.appendChild( logFile.toDOMElement( document ) );
- }
- // add logfiles to environment
- element.appendChild( logfiles );
- // add notifiers to environments
- element.appendChild( this.getNotifiers().toDOMElement( document ) );
- // publishers element
- ElementImpl publishers = new ElementImpl( document, "publishers" );
- // add email publisher to publishers
- for ( Iterator publisherIterator = this.getPublishers().iterator(); publisherIterator.hasNext(); )
- {
- Email email = (Email) publisherIterator.next();
- publishers.appendChild( email.toDOMElement( document ) );
- }
- // add publishers to environment
- element.appendChild( publishers );
- // add statistics
- element.appendChild( this.getStatistics().toDOMElement( document ) );
- return element;
- }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherEnvironment )
- {
- return this.getName().compareTo( ( (Environment) anotherEnvironment ).getName() );
- }
+ /**
+ * Get the <code>Variable</code> identified by a given name in the
+ * <code>Environment</code> variables container.
+ *
+ * @param name the <code>Variable</code> name.
+ * @return the <code>Variable</code> found or null if not found.
+ */
+ public Variable getVariable( String name )
+ {
+ for ( Iterator variableIterator = this.getVariables().iterator(); variableIterator.hasNext(); )
+ {
+ Variable variable = (Variable) variableIterator.next();
+ if ( variable.getName().equals( name ) )
+ {
+ return variable;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add a new <code>FreeField</code> in the <code>Environment</code>
+ * free fields container.
+ *
+ * @param freeField the <code>FreeField</code> to add.
+ */
+ public void addFreeField( FreeField freeField )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getFreeField( freeField.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException(
+ "Freefield name already exists in the environment freefields." );
+ }
+ this.freeFields.add( freeField );
+ }
+
+ /**
+ * Get the <code>FreeField</code> list in the <code>Environment</code>
+ * free fields container.
+ *
+ * @return the <code>FreeField</code> list.
+ */
+ public List getFreeFields()
+ {
+ return this.freeFields;
+ }
+
+ /**
+ * Set the <code>FreeField<code> list in the <code>Environment</code>
+ * free fields container.
+ *
+ * @param freeFields the new <code>FreeField</code> list.
+ */
+ public void setFreeFields( LinkedList freeFields )
+ {
+ this.freeFields = freeFields;
+ }
+
+ /**
+ * Get the <code>FreeField</code> identified by a given name in the
+ * <code>Environment</code> free fields container.
+ *
+ * @param name the <code>FreeField</code> name.
+ * @return the <code>FreeField</code> found or null if not found.
+ */
+ public FreeField getFreeField( String name )
+ {
+ for ( Iterator freeFieldIterator = this.getFreeFields().iterator(); freeFieldIterator.hasNext(); )
+ {
+ FreeField freeField = (FreeField) freeFieldIterator.next();
+ if ( freeField.getName().equals( name ) )
+ {
+ return freeField;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add a new <code>Access</code> in the <code>Environment</code> accesses
+ * container.
+ *
+ * @param access the <code>Access</code> to add.
+ */
+ public void addAccess( Access access )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getAccess( access.getGroup() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException(
+ "Access group id already exists in the environnement accesses." );
+ }
+ this.accesses.add( access );
+ }
+
+ /**
+ * Get the <code>Access</code> list in the <code>Environment</code>
+ * accesses container.
+ *
+ * @return the <code>Access</code> list.
+ */
+ public List getAccesses()
+ {
+ return this.accesses;
+ }
+
+ /**
+ * Set the <code>Access</code> list in the <code>Environment</code>
+ * accesses container.
+ *
+ * @param accesses the new <code>Access</code> list.
+ */
+ public void setAccesses( LinkedList accesses )
+ {
+ this.accesses = accesses;
+ }
+
+ /**
+ * Get the <code>Access</code> identified by a given group id in the
+ * <code>Environment</code> accesses container.
+ *
+ * @param group the group id.
+ * @return the <code>Access</code> found or null if not found.
+ */
+ public Access getAccess( String group )
+ {
+ for ( Iterator accessIterator = this.getAccesses().iterator(); accessIterator.hasNext(); )
+ {
+ Access access = (Access) accessIterator.next();
+ if ( access.getGroup().equals( group ) )
+ {
+ return access;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Set the <code>JEEApplicationServers</code> container in the
+ * <code>Environment</code>.
+ *
+ * @param jeeApplicationServers the <code>JEEApplicationServers</code> to set.
+ */
+ public void setJEEApplicationServers( JEEApplicationServers jeeApplicationServers )
+ {
+ this.jeeApplicationServers = jeeApplicationServers;
+ }
+
+ /**
+ * Get the <code>JEEApplicationServers</code> container in the
+ * <code>Environment</code>.
+ *
+ * @return the <code>JEEApplicationServers</code> container.
+ */
+ public JEEApplicationServers getJEEApplicationServers()
+ {
+ return this.jeeApplicationServers;
+ }
+
+ /**
+ * Add a new <code>Software</code> in the <code>Environment</code>
+ * softwares container.
+ *
+ * @param software the <code>Software</code> to add.
+ */
+ public void addSoftware( Software software )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getSoftware( software.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "Software name already exists in the environment." );
+ }
+ this.softwares.add( software );
+ }
+
+ /**
+ * Get the <code>Software</code> list in the <code>Environment</code>
+ * softwares container.
+ *
+ * @return the <code>Software</code> list.
+ */
+ public List getSoftwares()
+ {
+ return this.softwares;
+ }
+
+ /**
+ * Set the <code>Software</code> list in the <code>Environment</code>
+ * softwares container.
+ *
+ * @param softwares the new <code>Software</code> list.
+ */
+ public void setSoftwares( LinkedList softwares )
+ {
+ this.softwares = softwares;
+ }
+
+ /**
+ * Get the <code>Software</code> identified by a given name in the
+ * <code>Environment</code> softwares container.
+ *
+ * @param name the <code>Software</code> name.
+ * @return the <code>Software</code> found or null if not found.
+ */
+ public Software getSoftware( String name )
+ {
+ for ( Iterator softwareIterator = this.getSoftwares().iterator(); softwareIterator.hasNext(); )
+ {
+ Software software = (Software) softwareIterator.next();
+ if ( software.getName().equals( name ) )
+ {
+ return software;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get the environment log files list.
+ *
+ * @return the log files list.
+ */
+ public List getLogFiles()
+ {
+ return this.logFiles;
+ }
+
+ /**
+ * Set the environment log files list.
+ *
+ * @param logFiles the log files list.
+ */
+ public void setLogFiles( LinkedList logFiles )
+ {
+ this.logFiles = logFiles;
+ }
+
+ /**
+ * Get a log file identified by a name.
+ *
+ * @param name the log file name.
+ * @return the log file or null if not found.
+ */
+ public LogFile getLogFile( String name )
+ {
+ for ( Iterator logFileIterator = this.getLogFiles().iterator(); logFileIterator.hasNext(); )
+ {
+ LogFile logFile = (LogFile) logFileIterator.next();
+ if ( logFile.getName().equals( name ) )
+ {
+ return logFile;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add a new log file in the environment.
+ *
+ * @param logFile the log file to add.
+ * @throws ModelObjectAlreadyExistsException if the log file name already exists.
+ */
+ public void addLogFile( LogFile logFile )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getLogFile( logFile.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "Log file name already exists in environment." );
+ }
+ this.logFiles.add( logFile );
+ }
+
+ /**
+ * Set the <code>Notifiers</code> in the <code>Environment</code>.
+ *
+ * @param notifiers the <code>Notifiers</code> to set.
+ */
+ public void setNotifiers( Notifiers notifiers )
+ {
+ this.notifiers = notifiers;
+ }
+
+ /**
+ * Get the <code>Notifiers</code> in the <code>Environment</code>.
+ *
+ * @return the <code>Notifiers</code> in the <code>Environment</code>.
+ */
+ public Notifiers getNotifiers()
+ {
+ return this.notifiers;
+ }
+
+ /**
+ * Add a new <code>Email</code> publisher in the <code>Environment</code>
+ * publishers container.
+ *
+ * @param email the <code>Email</code> to add.
+ */
+ public void addPublisher( Email email )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getPublisher( email.getMailhost() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "Email publisher mailhost already exists in environment." );
+ }
+ this.publishers.add( email );
+ }
+
+ /**
+ * Get the <code>Email</code> publisher list in the
+ * <code>Environment</code> publishers container.
+ *
+ * @return the <code>Email</code> publisher list.
+ */
+ public List getPublishers()
+ {
+ return this.publishers;
+ }
+
+ /**
+ * Set the <code>Email</code> publisher list in the
+ * <code>Environment</code> publishers container.
+ *
+ * @param publishers the new <code>Email</code> publisher list.
+ */
+ public void setPublishers( LinkedList publishers )
+ {
+ this.publishers = publishers;
+ }
+
+ /**
+ * Get the <code>Email</code> publisher identified by a given mail host
+ * in the <code>Environment</code> publishers container.
+ *
+ * @param mailhost the <code>Email</code> mail host.
+ * @return the <code>Email</code> found or null if not found.
+ */
+ public Email getPublisher( String mailhost )
+ {
+ for ( Iterator publisherIterator = this.getPublishers().iterator(); publisherIterator.hasNext(); )
+ {
+ Email email = (Email) publisherIterator.next();
+ if ( email.getMailhost().equals( mailhost ) )
+ {
+ return email;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Set the <code>Statistics</code> container.
+ *
+ * @return statistics the new <code>Statistics</code> container.
+ */
+ public Statistics getStatistics()
+ {
+ return statistics;
+ }
+
+ /**
+ * Get the <code>Statistics</code> container.
+ *
+ * @param statistics the current <code>Statistics</code> container.
+ */
+ public void setStatistics( Statistics statistics )
+ {
+ this.statistics = statistics;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ Environment clone = new Environment();
+ clone.setName( this.getName() );
+ clone.setGroup( this.getGroup() );
+ clone.setTag( this.getTag() );
+ clone.setAutoupdate( this.isAutoupdate() );
+ clone.setAgent( this.getAgent() );
+ clone.setLock( this.getLock() );
+ clone.setReleaseLocation( this.getReleaseLocation() );
+ clone.setNotes( this.getNotes() );
+ clone.setWeblinks( this.getWeblinks() );
+ for ( Iterator variableIterator = this.variables.iterator(); variableIterator.hasNext(); )
+ {
+ Variable variable = (Variable) variableIterator.next();
+ clone.variables.add( (Variable) variable.clone() );
+ }
+ for ( Iterator freeFieldIterator = this.freeFields.iterator(); freeFieldIterator.hasNext(); )
+ {
+ FreeField freeField = (FreeField) freeFieldIterator.next();
+ clone.freeFields.add( (FreeField) freeField.clone() );
+ }
+ for ( Iterator accessIterator = this.accesses.iterator(); accessIterator.hasNext(); )
+ {
+ Access access = (Access) accessIterator.next();
+ clone.accesses.add( (Access) access.clone() );
+ }
+ clone.setJEEApplicationServers( (JEEApplicationServers) this.getJEEApplicationServers().clone() );
+ for ( Iterator softwareIterator = this.softwares.iterator(); softwareIterator.hasNext(); )
+ {
+ Software software = (Software) softwareIterator.next();
+ clone.softwares.add( (Software) software.clone() );
+ }
+ for ( Iterator logFilesIterator = this.logFiles.iterator(); logFilesIterator.hasNext(); )
+ {
+ LogFile logFile = (LogFile) logFilesIterator.next();
+ clone.softwares.add( (LogFile) logFile.clone() );
+ }
+ clone.setNotifiers( (Notifiers) this.getNotifiers().clone() );
+ for ( Iterator publisherIterator = this.publishers.iterator(); publisherIterator.hasNext(); )
+ {
+ Email publisher = (Email) publisherIterator.next();
+ clone.publishers.add( (Email) publisher.clone() );
+ }
+ clone.setStatistics( (Statistics) this.getStatistics().clone() );
+ return clone;
+ }
+
+ /**
+ * Transform the <code>Environment</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "environment" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "group", this.getGroup() );
+ element.setAttribute( "tag", this.getTag() );
+ element.setAttribute( "autoupdate", new Boolean( this.isAutoupdate() ).toString() );
+ element.setAttribute( "agent", this.getAgent() );
+ element.setAttribute( "lock", this.getLock() );
+ element.setAttribute( "releaseLocation", this.getReleaseLocation() );
+ // variables element
+ ElementImpl variables = new ElementImpl( document, "variables" );
+ // add variable to variables
+ for ( Iterator variableIterator = this.getVariables().iterator(); variableIterator.hasNext(); )
+ {
+ Variable variable = (Variable) variableIterator.next();
+ variables.appendChild( variable.toDOMElement( document ) );
+ }
+ // add variables to environment
+ element.appendChild( variables );
+ // freefields element
+ ElementImpl freefields = new ElementImpl( document, "freefields" );
+ // add freefield to freefields
+ for ( Iterator freeFieldIterator = this.getFreeFields().iterator(); freeFieldIterator.hasNext(); )
+ {
+ FreeField freefield = (FreeField) freeFieldIterator.next();
+ freefields.appendChild( freefield.toDOMElement( document ) );
+ }
+ // add freefields to environment
+ element.appendChild( freefields );
+ // accesses element
+ ElementImpl accesses = new ElementImpl( document, "accesses" );
+ // add access to accesses
+ for ( Iterator accessIterator = this.getAccesses().iterator(); accessIterator.hasNext(); )
+ {
+ Access access = (Access) accessIterator.next();
+ accesses.appendChild( access.toDOMElement( document ) );
+ }
+ // add accesses to environment
+ element.appendChild( accesses );
+ // add notes
+ ElementImpl notes = new ElementImpl( document, "notes" );
+ CDATASectionImpl notesContent = new CDATASectionImpl( document, this.getNotes() );
+ notes.appendChild( notesContent );
+ element.appendChild( notes );
+ // add weblinks
+ ElementImpl weblinks = new ElementImpl( document, "weblinks" );
+ CDATASectionImpl weblinksContent = new CDATASectionImpl( document, this.getWeblinks() );
+ weblinks.appendChild( weblinksContent );
+ element.appendChild( weblinks );
+ // add JEE servers
+ element.appendChild( this.getJEEApplicationServers().toDOMElement( document ) );
+ // softwares element
+ ElementImpl softwares = new ElementImpl( document, "softwares" );
+ // add software to softwares
+ for ( Iterator softwareIterator = this.getSoftwares().iterator(); softwareIterator.hasNext(); )
+ {
+ Software software = (Software) softwareIterator.next();
+ softwares.appendChild( software.toDOMElement( document ) );
+ }
+ // add softwares to environment
+ element.appendChild( softwares );
+ // logfiles element
+ ElementImpl logfiles = new ElementImpl( document, "logfiles" );
+ // add logfile to logfiles
+ for ( Iterator logFileIterator = this.getLogFiles().iterator(); logFileIterator.hasNext(); )
+ {
+ LogFile logFile = (LogFile) logFileIterator.next();
+ logfiles.appendChild( logFile.toDOMElement( document ) );
+ }
+ // add logfiles to environment
+ element.appendChild( logfiles );
+ // add notifiers to environments
+ element.appendChild( this.getNotifiers().toDOMElement( document ) );
+ // publishers element
+ ElementImpl publishers = new ElementImpl( document, "publishers" );
+ // add email publisher to publishers
+ for ( Iterator publisherIterator = this.getPublishers().iterator(); publisherIterator.hasNext(); )
+ {
+ Email email = (Email) publisherIterator.next();
+ publishers.appendChild( email.toDOMElement( document ) );
+ }
+ // add publishers to environment
+ element.appendChild( publishers );
+ // add statistics
+ element.appendChild( this.getStatistics().toDOMElement( document ) );
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherEnvironment )
+ {
+ return this.getName().compareTo( ( (Environment) anotherEnvironment ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/FreeField.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/FreeField.java
index 506d6e2..5c8f760 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/FreeField.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/FreeField.java
@@ -29,72 +29,72 @@
* Represent the <code>freefield</code> tag in the Kalumet configuration DOM.
*/
public class FreeField
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = -39120916167747289L;
+ private static final long serialVersionUID = -39120916167747289L;
- private String name;
+ private String name;
- private String content;
+ private String content;
- public FreeField()
- {
- }
+ public FreeField()
+ {
+ }
- public String getName()
- {
- return this.name;
- }
+ public String getName()
+ {
+ return this.name;
+ }
- public void setName( String name )
- {
- this.name = name;
- }
+ public void setName( String name )
+ {
+ this.name = name;
+ }
- public String getContent()
- {
- return this.content;
- }
+ public String getContent()
+ {
+ return this.content;
+ }
- public void setContent( String content )
- {
- this.content = content;
- }
+ public void setContent( String content )
+ {
+ this.content = content;
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- FreeField clone = new FreeField();
- clone.setName( this.getName() );
- clone.setContent( this.getContent() );
- return clone;
- }
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ FreeField clone = new FreeField();
+ clone.setName( this.getName() );
+ clone.setContent( this.getContent() );
+ return clone;
+ }
- /**
- * Transform the <code>FreeField</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "freefield" );
- element.setAttribute( "name", this.getName() );
- CDATASectionImpl content = new CDATASectionImpl( document, this.getContent() );
- element.appendChild( content );
- return element;
- }
+ /**
+ * Transform the <code>FreeField</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "freefield" );
+ element.setAttribute( "name", this.getName() );
+ CDATASectionImpl content = new CDATASectionImpl( document, this.getContent() );
+ element.appendChild( content );
+ return element;
+ }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherFreeField )
- {
- return this.getName().compareTo( ( (FreeField) anotherFreeField ).getName() );
- }
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherFreeField )
+ {
+ return this.getName().compareTo( ( (FreeField) anotherFreeField ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Group.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Group.java
index 021a466..1eed278 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Group.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Group.java
@@ -31,145 +31,145 @@
* Represent the <code>group</code> tag in the Kalumet configuration DOM.
*/
public class Group
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = 5188524193501221530L;
+ private static final long serialVersionUID = 5188524193501221530L;
- private String id;
+ private String id;
- private String name;
+ private String name;
- private LinkedList users;
+ private LinkedList users;
- public Group()
- {
- this.users = new LinkedList();
- }
-
- public String getId()
- {
- return this.id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- public String getName()
- {
- return this.name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- /**
- * Add a new <code>User</code> in the <code>Group</code> container.
- *
- * @param user the <code>User</code> to add.
- */
- public void addUser( User user )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getUser( user.getId() ) != null )
+ public Group()
{
- throw new ModelObjectAlreadyExistsException( "User id already exists in group." );
+ this.users = new LinkedList();
}
- this.users.add( user );
- }
- /**
- * Get the <code>User</code> list in the <code>Group</code> container.
- *
- * @return the <code>User</code> list.
- */
- public List getUsers()
- {
- return this.users;
- }
-
- /**
- * Set the <code>User</code> list in the <code>Group</code>
- * container.
- *
- * @param users the new <code>User</code> list.
- */
- public void setUsers( LinkedList users )
- {
- this.users = users;
- }
-
- /**
- * Get a <code>User</code> identified by a given id in the
- * <code>Group</code> container;
- *
- * @param id the <code>User</code> id.
- * @return the found <code>User</code> or null if not found.
- */
- public User getUser( String id )
- {
- for ( Iterator userIterator = this.getUsers().iterator(); userIterator.hasNext(); )
+ public String getId()
{
- User user = (User) userIterator.next();
- if ( user.getId().equals( id ) )
- {
- return user;
- }
+ return this.id;
}
- return null;
- }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- Group clone = new Group();
- clone.setId( this.getId() );
- clone.setName( this.getName() );
- for ( Iterator userIterator = this.users.iterator(); userIterator.hasNext(); )
+ public void setId( String id )
{
- User user = (User) userIterator.next();
- clone.users.add( (User) user.clone() );
+ this.id = id;
}
- return clone;
- }
- /**
- * Transform the <code>Group</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "group" );
- element.setAttribute( "id", this.getId() );
- element.setAttribute( "name", this.getName() );
- // users element
- ElementImpl users = new ElementImpl( document, "users" );
- // add user in the users element
- for ( Iterator userIterator = this.getUsers().iterator(); userIterator.hasNext(); )
+ public String getName()
{
- User user = (User) userIterator.next();
- users.appendChild( user.toDOMElement( document ) );
+ return this.name;
}
- // add users to group element
- element.appendChild( users );
- return element;
- }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherGroup )
- {
- return this.getId().compareTo( ( (Group) anotherGroup ).getId() );
- }
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ /**
+ * Add a new <code>User</code> in the <code>Group</code> container.
+ *
+ * @param user the <code>User</code> to add.
+ */
+ public void addUser( User user )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getUser( user.getId() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "User id already exists in group." );
+ }
+ this.users.add( user );
+ }
+
+ /**
+ * Get the <code>User</code> list in the <code>Group</code> container.
+ *
+ * @return the <code>User</code> list.
+ */
+ public List getUsers()
+ {
+ return this.users;
+ }
+
+ /**
+ * Set the <code>User</code> list in the <code>Group</code>
+ * container.
+ *
+ * @param users the new <code>User</code> list.
+ */
+ public void setUsers( LinkedList users )
+ {
+ this.users = users;
+ }
+
+ /**
+ * Get a <code>User</code> identified by a given id in the
+ * <code>Group</code> container;
+ *
+ * @param id the <code>User</code> id.
+ * @return the found <code>User</code> or null if not found.
+ */
+ public User getUser( String id )
+ {
+ for ( Iterator userIterator = this.getUsers().iterator(); userIterator.hasNext(); )
+ {
+ User user = (User) userIterator.next();
+ if ( user.getId().equals( id ) )
+ {
+ return user;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ Group clone = new Group();
+ clone.setId( this.getId() );
+ clone.setName( this.getName() );
+ for ( Iterator userIterator = this.users.iterator(); userIterator.hasNext(); )
+ {
+ User user = (User) userIterator.next();
+ clone.users.add( (User) user.clone() );
+ }
+ return clone;
+ }
+
+ /**
+ * Transform the <code>Group</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "group" );
+ element.setAttribute( "id", this.getId() );
+ element.setAttribute( "name", this.getName() );
+ // users element
+ ElementImpl users = new ElementImpl( document, "users" );
+ // add user in the users element
+ for ( Iterator userIterator = this.getUsers().iterator(); userIterator.hasNext(); )
+ {
+ User user = (User) userIterator.next();
+ users.appendChild( user.toDOMElement( document ) );
+ }
+ // add users to group element
+ element.appendChild( users );
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherGroup )
+ {
+ return this.getId().compareTo( ( (Group) anotherGroup ).getId() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JDBCConnectionPool.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JDBCConnectionPool.java
index 66e9819..24d68d1 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JDBCConnectionPool.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JDBCConnectionPool.java
@@ -29,211 +29,211 @@
* configuration file.
*/
public class JDBCConnectionPool
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = 8052573645587249685L;
+ private static final long serialVersionUID = 8052573645587249685L;
- private String name;
+ private String name;
- private String driver;
+ private String driver;
- private String helperclass;
+ private String helperclass;
- private int increment;
+ private int increment;
- private int initial;
+ private int initial;
- private int maximal;
+ private int maximal;
- private String user;
+ private String user;
- private String password;
+ private String password;
- private String url;
+ private String url;
- private String classpath;
+ private String classpath;
- private boolean active;
+ private boolean active;
- private boolean blocker;
+ private boolean blocker;
- public JDBCConnectionPool()
- {
- }
+ public JDBCConnectionPool()
+ {
+ }
- public String getName()
- {
- return this.name;
- }
+ public String getName()
+ {
+ return this.name;
+ }
- public void setName( String name )
- {
- this.name = name;
- }
+ public void setName( String name )
+ {
+ this.name = name;
+ }
- public String getDriver()
- {
- return this.driver;
- }
+ public String getDriver()
+ {
+ return this.driver;
+ }
- public void setDriver( String driver )
- {
- this.driver = driver;
- }
+ public void setDriver( String driver )
+ {
+ this.driver = driver;
+ }
- public String getHelperclass()
- {
- return this.helperclass;
- }
+ public String getHelperclass()
+ {
+ return this.helperclass;
+ }
- public void setHelperclass( String helperclass )
- {
- this.helperclass = helperclass;
- }
+ public void setHelperclass( String helperclass )
+ {
+ this.helperclass = helperclass;
+ }
- public int getIncrement()
- {
- return this.increment;
- }
+ public int getIncrement()
+ {
+ return this.increment;
+ }
- public void setIncrement( int increment )
- {
- this.increment = increment;
- }
+ public void setIncrement( int increment )
+ {
+ this.increment = increment;
+ }
- public int getInitial()
- {
- return this.initial;
- }
+ public int getInitial()
+ {
+ return this.initial;
+ }
- public void setInitial( int initial )
- {
- this.initial = initial;
- }
+ public void setInitial( int initial )
+ {
+ this.initial = initial;
+ }
- public int getMaximal()
- {
- return this.maximal;
- }
+ public int getMaximal()
+ {
+ return this.maximal;
+ }
- public void setMaximal( int maximal )
- {
- this.maximal = maximal;
- }
+ public void setMaximal( int maximal )
+ {
+ this.maximal = maximal;
+ }
- public String getUser()
- {
- return this.user;
- }
+ public String getUser()
+ {
+ return this.user;
+ }
- public void setUser( String user )
- {
- this.user = user;
- }
+ public void setUser( String user )
+ {
+ this.user = user;
+ }
- public String getPassword()
- {
- return this.password;
- }
+ public String getPassword()
+ {
+ return this.password;
+ }
- public void setPassword( String password )
- {
- this.password = password;
- }
+ public void setPassword( String password )
+ {
+ this.password = password;
+ }
- public String getUrl()
- {
- return this.url;
- }
+ public String getUrl()
+ {
+ return this.url;
+ }
- public void setUrl( String url )
- {
- this.url = url;
- }
+ public void setUrl( String url )
+ {
+ this.url = url;
+ }
- public String getClasspath()
- {
- return this.classpath;
- }
+ public String getClasspath()
+ {
+ return this.classpath;
+ }
- public void setClasspath( String classpath )
- {
- this.classpath = classpath;
- }
+ public void setClasspath( String classpath )
+ {
+ this.classpath = classpath;
+ }
- public boolean isActive()
- {
- return this.active;
- }
+ public boolean isActive()
+ {
+ return this.active;
+ }
- public void setActive( boolean active )
- {
- this.active = active;
- }
+ public void setActive( boolean active )
+ {
+ this.active = active;
+ }
- public boolean isBlocker()
- {
- return this.blocker;
- }
+ public boolean isBlocker()
+ {
+ return this.blocker;
+ }
- public void setBlocker( boolean blocker )
- {
- this.blocker = blocker;
- }
+ public void setBlocker( boolean blocker )
+ {
+ this.blocker = blocker;
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- JDBCConnectionPool clone = new JDBCConnectionPool();
- clone.setName( this.getName() );
- clone.setDriver( this.getDriver() );
- clone.setHelperclass( this.getHelperclass() );
- clone.setIncrement( this.getIncrement() );
- clone.setInitial( this.getInitial() );
- clone.setMaximal( this.getMaximal() );
- clone.setUser( this.getUser() );
- clone.setPassword( this.getPassword() );
- clone.setUrl( this.getUrl() );
- clone.setClasspath( this.getClasspath() );
- clone.setActive( this.isActive() );
- clone.setBlocker( this.isBlocker() );
- return clone;
- }
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ JDBCConnectionPool clone = new JDBCConnectionPool();
+ clone.setName( this.getName() );
+ clone.setDriver( this.getDriver() );
+ clone.setHelperclass( this.getHelperclass() );
+ clone.setIncrement( this.getIncrement() );
+ clone.setInitial( this.getInitial() );
+ clone.setMaximal( this.getMaximal() );
+ clone.setUser( this.getUser() );
+ clone.setPassword( this.getPassword() );
+ clone.setUrl( this.getUrl() );
+ clone.setClasspath( this.getClasspath() );
+ clone.setActive( this.isActive() );
+ clone.setBlocker( this.isBlocker() );
+ return clone;
+ }
- /**
- * Transform the <code>JDBCConnectionPool</code> POJO to a DOM element.
- *
- * @param document the core XML document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "jdbcconnectionpool" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "driver", this.getDriver() );
- element.setAttribute( "helperclass", this.getHelperclass() );
- element.setAttribute( "increment", new Integer( this.getIncrement() ).toString() );
- element.setAttribute( "initial", new Integer( this.getInitial() ).toString() );
- element.setAttribute( "maximal", new Integer( this.getMaximal() ).toString() );
- element.setAttribute( "user", this.getUser() );
- element.setAttribute( "password", this.getPassword() );
- element.setAttribute( "url", this.getUrl() );
- element.setAttribute( "classpath", this.getClasspath() );
- element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
- element.setAttribute( "blocker", new Boolean( this.isActive() ).toString() );
- return element;
- }
+ /**
+ * Transform the <code>JDBCConnectionPool</code> POJO to a DOM element.
+ *
+ * @param document the core XML document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "jdbcconnectionpool" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "driver", this.getDriver() );
+ element.setAttribute( "helperclass", this.getHelperclass() );
+ element.setAttribute( "increment", new Integer( this.getIncrement() ).toString() );
+ element.setAttribute( "initial", new Integer( this.getInitial() ).toString() );
+ element.setAttribute( "maximal", new Integer( this.getMaximal() ).toString() );
+ element.setAttribute( "user", this.getUser() );
+ element.setAttribute( "password", this.getPassword() );
+ element.setAttribute( "url", this.getUrl() );
+ element.setAttribute( "classpath", this.getClasspath() );
+ element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
+ element.setAttribute( "blocker", new Boolean( this.isActive() ).toString() );
+ return element;
+ }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherConnectionPool )
- {
- return this.getName().compareTo( ( (JDBCConnectionPool) anotherConnectionPool ).getName() );
- }
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherConnectionPool )
+ {
+ return this.getName().compareTo( ( (JDBCConnectionPool) anotherConnectionPool ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JDBCDataSource.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JDBCDataSource.java
index 6958806..08aa6eb 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JDBCDataSource.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JDBCDataSource.java
@@ -28,99 +28,99 @@
* Represent the <code>jdbcdatasource</code> tag in the Kalumet configuration DOM.
*/
public class JDBCDataSource
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = -6850328756411047364L;
+ private static final long serialVersionUID = -6850328756411047364L;
- private String name;
+ private String name;
- private String pool;
+ private String pool;
- private boolean active;
+ private boolean active;
- private boolean blocker;
+ private boolean blocker;
- public JDBCDataSource()
- {
- }
+ public JDBCDataSource()
+ {
+ }
- public String getName()
- {
- return this.name;
- }
+ public String getName()
+ {
+ return this.name;
+ }
- public void setName( String name )
- {
- this.name = name;
- }
+ public void setName( String name )
+ {
+ this.name = name;
+ }
- public String getPool()
- {
- return this.pool;
- }
+ public String getPool()
+ {
+ return this.pool;
+ }
- public void setPool( String pool )
- {
- this.pool = pool;
- }
+ public void setPool( String pool )
+ {
+ this.pool = pool;
+ }
- public boolean isActive()
- {
- return this.active;
- }
+ public boolean isActive()
+ {
+ return this.active;
+ }
- public void setActive( boolean active )
- {
- this.active = active;
- }
+ public void setActive( boolean active )
+ {
+ this.active = active;
+ }
- public boolean isBlocker()
- {
- return this.blocker;
- }
+ public boolean isBlocker()
+ {
+ return this.blocker;
+ }
- public void setBlocker( boolean blocker )
- {
- this.blocker = blocker;
- }
+ public void setBlocker( boolean blocker )
+ {
+ this.blocker = blocker;
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- JDBCDataSource clone = new JDBCDataSource();
- clone.setName( this.getName() );
- clone.setPool( this.getPool() );
- clone.setActive( this.isActive() );
- clone.setBlocker( this.isBlocker() );
- return clone;
- }
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ JDBCDataSource clone = new JDBCDataSource();
+ clone.setName( this.getName() );
+ clone.setPool( this.getPool() );
+ clone.setActive( this.isActive() );
+ clone.setBlocker( this.isBlocker() );
+ return clone;
+ }
- /**
- * Transforms the <code>JDBCDataSource</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "jdbcdatasource" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "pool", this.getPool() );
- element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
- element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
- return element;
- }
+ /**
+ * Transforms the <code>JDBCDataSource</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "jdbcdatasource" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "pool", this.getPool() );
+ element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
+ element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
+ return element;
+ }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherDataSource )
- {
- return this.getName().compareTo( ( (JDBCDataSource) anotherDataSource ).getName() );
- }
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherDataSource )
+ {
+ return this.getName().compareTo( ( (JDBCDataSource) anotherDataSource ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JEEApplication.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JEEApplication.java
index 6024154..c220fbf 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JEEApplication.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JEEApplication.java
@@ -31,414 +31,414 @@
* Represents the <code>jeeapplication</code> tag in the Kalumet DOM.
*/
public class JEEApplication
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = -1198170476993837094L;
+ private static final long serialVersionUID = -1198170476993837094L;
- private String name;
+ private String name;
- private String uri;
+ private String uri;
- private boolean active;
+ private boolean active;
- private boolean blocker;
+ private boolean blocker;
- private String agent;
+ private String agent;
- private LinkedList archives;
+ private LinkedList archives;
- private LinkedList contentManagers;
+ private LinkedList contentManagers;
- private LinkedList configurationFiles;
+ private LinkedList configurationFiles;
- private LinkedList databases;
+ private LinkedList databases;
- /**
- * Default constructor to create a <code>JEEApplication</code>
- */
- public JEEApplication()
- {
- this.archives = new LinkedList();
- this.contentManagers = new LinkedList();
- this.configurationFiles = new LinkedList();
- this.databases = new LinkedList();
- }
-
- public String getName()
- {
- return this.name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public String getUri()
- {
- return this.uri;
- }
-
- public void setUri( String uri )
- {
- this.uri = uri;
- }
-
- public boolean isActive()
- {
- return this.active;
- }
-
- public void setActive( boolean active )
- {
- this.active = active;
- }
-
- public boolean isBlocker()
- {
- return this.blocker;
- }
-
- public void setBlocker( boolean blocker )
- {
- this.blocker = blocker;
- }
-
- public String getAgent()
- {
- return agent;
- }
-
- public void setAgent( String agent )
- {
- this.agent = agent;
- }
-
- /**
- * Add a new <code>Archive</code> in the <code>JEEApplication</code> archives container.
- *
- * @param archive the <code>Archive</code> to add.
- * @throws ModelObjectAlreadyExistsException
- * if the archive name already exists in the application.
- */
- public void addArchive( Archive archive )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getArchive( archive.getName() ) != null )
+ /**
+ * Default constructor to create a <code>JEEApplication</code>
+ */
+ public JEEApplication()
{
- throw new ModelObjectAlreadyExistsException( "Archive name already exists in the JEE application." );
+ this.archives = new LinkedList();
+ this.contentManagers = new LinkedList();
+ this.configurationFiles = new LinkedList();
+ this.databases = new LinkedList();
}
- this.archives.add( archive );
- }
- /**
- * Get the <code>Archive</code> list in the <code>JEEApplication</code> archives container.
- *
- * @return the <code>Archive</code> list
- */
- public List getArchives()
- {
- return this.archives;
- }
-
- /**
- * Overwrite the <code>Archive</code> list in the <code>JEEApplication</code> archives container.
- *
- * @param archives the new <code>Archive</code> list.
- */
- public void setArchives( LinkedList archives )
- {
- this.archives = archives;
- }
-
- /**
- * Get the <code>Archive</code> identified by a given name in the <code>JEEApplication</code> archives container.
- *
- * @param name the <code>Archive</code> name.
- * @return the <code>Archive</code> found or null if not found.
- */
- public Archive getArchive( String name )
- {
- for ( Iterator archiveIterator = this.getArchives().iterator(); archiveIterator.hasNext(); )
+ public String getName()
{
- Archive archive = (Archive) archiveIterator.next();
- if ( archive.getName().equals( name ) )
- {
- return archive;
- }
+ return this.name;
}
- return null;
- }
- /**
- * Add a new <code>ContentManager</code> in the <code>JEEApplication</code> content managers container.
- *
- * @param contentManager the <code>ContentManager</code> to add.
- * @throws ModelObjectAlreadyExistsException
- * if the <code>ContentManager</code> already exists in the application.
- */
- public void addContentManager( ContentManager contentManager )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getContentManager( contentManager.getName() ) != null )
+ public void setName( String name )
{
- throw new ModelObjectAlreadyExistsException( "Content manager name already exists in the JEE application." );
+ this.name = name;
}
- this.contentManagers.add( contentManager );
- }
- /**
- * Get the <code>ContentManager</code> list in the <code>JEEApplication</code> content managers container.
- *
- * @return the <code>ContentManager</code> list.
- */
- public List getContentManagers()
- {
- return this.contentManagers;
- }
-
- /**
- * Overwrite the <code>ContentManager</code> list in the <code>JEEApplication</code> content managers container.
- *
- * @param contentManagers the new <code>ContentManagers</code> list.
- */
- public void setContentManagers( LinkedList contentManagers )
- {
- this.contentManagers = contentManagers;
- }
-
- /**
- * Return the <code>ContentManager</code> identified by a given name in the <code>JEEApplication</code> content managers container.
- *
- * @return the <code>ContentManager</code> found or null if not found.
- */
- public ContentManager getContentManager( String name )
- {
- for ( Iterator contentManagerIterator = this.getContentManagers().iterator(); contentManagerIterator.hasNext(); )
+ public String getUri()
{
- ContentManager contentManager = (ContentManager) contentManagerIterator.next();
- if ( contentManager.getName().equals( name ) )
- {
- return contentManager;
- }
+ return this.uri;
}
- return null;
- }
- /**
- * Add a new <code>ConfigurationFile</code> in the <code>JEEApplication</code>
- * configuration files container.
- *
- * @param configurationFile the <code>ConfigurationFile</code> to add.
- * @throws ModelObjectAlreadyExistsException
- * if the <code>ConfigurationFile</code> name already exists in the application.
- */
- public void addConfigurationFile( ConfigurationFile configurationFile )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getConfigurationFile( configurationFile.getName() ) != null )
+ public void setUri( String uri )
{
- throw new ModelObjectAlreadyExistsException( "Configuration file name already exists in the JEE application." );
+ this.uri = uri;
}
- this.configurationFiles.add( configurationFile );
- }
- /**
- * Get the <code>ConfigurationFile</code> list in the
- * <code>JEEApplication</code> configuration files container.
- *
- * @return the <code>ConfigurationFile</code> list.
- */
- public List getConfigurationFiles()
- {
- return this.configurationFiles;
- }
+ public boolean isActive()
+ {
+ return this.active;
+ }
- /**
- * Overwrite the <code>ConfigurationFile</code> list in the
- * <code>JEEApplication</code> configuration files container.
- *
- * @param configurationFiles the new <code>ConfigurationFile</code> list.
- */
- public void setConfigurationFiles( LinkedList configurationFiles )
- {
- this.configurationFiles = configurationFiles;
- }
+ public void setActive( boolean active )
+ {
+ this.active = active;
+ }
- /**
- * Get the <code>ConfigurationFile</code> identified by a given name in the
- * <code>JEEApplication</code> configuration files container.
- *
- * @param name the <code>ConfigurationFile</code> name.
- * @return the <code>ConfigurationFile</code> found or null if not found.
- */
- public ConfigurationFile getConfigurationFile( String name )
- {
- for ( Iterator configurationFileIterator = this.getConfigurationFiles().iterator();
- configurationFileIterator.hasNext(); )
+ public boolean isBlocker()
{
- ConfigurationFile configurationFile = (ConfigurationFile) configurationFileIterator.next();
- if ( configurationFile.getName().equals( name ) )
- {
- return configurationFile;
- }
+ return this.blocker;
}
- return null;
- }
- /**
- * Add a new <code>Database</code> in the <code>JEEApplication</code>
- * databases container.
- *
- * @param database the <code>Database</code> to add.
- * @throws ModelObjectAlreadyExistsException
- * if the <code>Database</code> name already exists in the application.
- */
- public void addDatabase( Database database )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getDatabase( database.getName() ) != null )
+ public void setBlocker( boolean blocker )
{
- throw new ModelObjectAlreadyExistsException( "Database name already exists in the JEE application." );
+ this.blocker = blocker;
}
- this.databases.add( database );
- }
- /**
- * Get the <code>Database</code> list in the <code>JEEApplication</code>
- * databases container.
- *
- * @return the <code>Database</code> list.
- */
- public List getDatabases()
- {
- return this.databases;
- }
+ public String getAgent()
+ {
+ return agent;
+ }
- /**
- * Overwrite the <code>Database</code> list in the <code>JEEApplication</code>
- * databases container.
- *
- * @param databases the new <code>Database</code> list.
- */
- public void setDatabases( LinkedList databases )
- {
- this.databases = databases;
- }
+ public void setAgent( String agent )
+ {
+ this.agent = agent;
+ }
- /**
- * Get the <code>Database</code> identified by a given name in the
- * <code>JEEApplication</code> databases container.
- *
- * @param name the <code>Database</code> name.
- * @return the <code>Database</code> found or null if not found.
- */
- public Database getDatabase( String name )
- {
- for ( Iterator databaseIterator = this.getDatabases().iterator(); databaseIterator.hasNext(); )
+ /**
+ * Add a new <code>Archive</code> in the <code>JEEApplication</code> archives container.
+ *
+ * @param archive the <code>Archive</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the archive name already exists in the application.
+ */
+ public void addArchive( Archive archive )
+ throws ModelObjectAlreadyExistsException
{
- Database database = (Database) databaseIterator.next();
- if ( database.getName().equals( name ) )
- {
- return database;
- }
+ if ( this.getArchive( archive.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "Archive name already exists in the JEE application." );
+ }
+ this.archives.add( archive );
}
- return null;
- }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- JEEApplication clone = new JEEApplication();
- clone.setName( this.getName() );
- clone.setUri( this.getUri() );
- clone.setActive( this.isActive() );
- clone.setBlocker( this.isBlocker() );
- clone.setAgent( this.getAgent() );
- for ( Iterator archiveIterator = this.archives.iterator(); archiveIterator.hasNext(); )
+ /**
+ * Get the <code>Archive</code> list in the <code>JEEApplication</code> archives container.
+ *
+ * @return the <code>Archive</code> list
+ */
+ public List getArchives()
{
- Archive archive = (Archive) archiveIterator.next();
- clone.archives.add( (Archive) archive.clone() );
+ return this.archives;
}
- for ( Iterator contentManagerIterator = this.contentManagers.iterator(); contentManagerIterator.hasNext(); )
- {
- ContentManager contentManager = (ContentManager) contentManagerIterator.next();
- clone.contentManagers.add( (ContentManager) contentManager.clone() );
- }
- for ( Iterator configurationFileIterator = this.configurationFiles.iterator();
- configurationFileIterator.hasNext(); )
- {
- ConfigurationFile configurationFile = (ConfigurationFile) configurationFileIterator.next();
- clone.configurationFiles.add( (ConfigurationFile) configurationFile.clone() );
- }
- for ( Iterator databaseIterator = this.databases.iterator(); databaseIterator.hasNext(); )
- {
- Database database = (Database) databaseIterator.next();
- clone.databases.add( (Database) database.clone() );
- }
- return clone;
- }
- /**
- * Transforms the <code>JEEApplication</code> POJO to a DOM element.
- *
- * @param document the core DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "jeeapplication" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "uri", this.getUri() );
- element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
- element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
- element.setAttribute( "agent", this.getAgent() );
- // archives
- ElementImpl archives = new ElementImpl( document, "archives" );
- for ( Iterator archiveIterator = this.getArchives().iterator(); archiveIterator.hasNext(); )
+ /**
+ * Overwrite the <code>Archive</code> list in the <code>JEEApplication</code> archives container.
+ *
+ * @param archives the new <code>Archive</code> list.
+ */
+ public void setArchives( LinkedList archives )
{
- Archive archive = (Archive) archiveIterator.next();
- archives.appendChild( archive.toDOMElement( document ) );
+ this.archives = archives;
}
- element.appendChild( archives );
- // contentmanagers
- ElementImpl contentmanagers = new ElementImpl( document, "contentmanagers" );
- for ( Iterator contentManagerIterator = this.getContentManagers().iterator(); contentManagerIterator.hasNext(); )
- {
- ContentManager contentManager = (ContentManager) contentManagerIterator.next();
- contentmanagers.appendChild( contentManager.toDOMElement( document ) );
- }
- element.appendChild( contentmanagers );
- // configurationfiles
- ElementImpl configurationfiles = new ElementImpl( document, "configurationfiles" );
- for ( Iterator configurationFileIterator = this.getConfigurationFiles().iterator();
- configurationFileIterator.hasNext(); )
- {
- ConfigurationFile configurationFile = (ConfigurationFile) configurationFileIterator.next();
- configurationfiles.appendChild( configurationFile.toDOMElement( document ) );
- }
- element.appendChild( configurationfiles );
- // databases
- ElementImpl databases = new ElementImpl( document, "databases" );
- for ( Iterator databaseIterator = this.getDatabases().iterator(); databaseIterator.hasNext(); )
- {
- Database database = (Database) databaseIterator.next();
- databases.appendChild( database.toDOMElement( document ) );
- }
- element.appendChild( databases );
- return element;
- }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherApplication )
- {
- return this.getName().compareTo( ( (JEEApplication) anotherApplication ).getName() );
- }
+ /**
+ * Get the <code>Archive</code> identified by a given name in the <code>JEEApplication</code> archives container.
+ *
+ * @param name the <code>Archive</code> name.
+ * @return the <code>Archive</code> found or null if not found.
+ */
+ public Archive getArchive( String name )
+ {
+ for ( Iterator archiveIterator = this.getArchives().iterator(); archiveIterator.hasNext(); )
+ {
+ Archive archive = (Archive) archiveIterator.next();
+ if ( archive.getName().equals( name ) )
+ {
+ return archive;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add a new <code>ContentManager</code> in the <code>JEEApplication</code> content managers container.
+ *
+ * @param contentManager the <code>ContentManager</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>ContentManager</code> already exists in the application.
+ */
+ public void addContentManager( ContentManager contentManager )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getContentManager( contentManager.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException(
+ "Content manager name already exists in the JEE application." );
+ }
+ this.contentManagers.add( contentManager );
+ }
+
+ /**
+ * Get the <code>ContentManager</code> list in the <code>JEEApplication</code> content managers container.
+ *
+ * @return the <code>ContentManager</code> list.
+ */
+ public List getContentManagers()
+ {
+ return this.contentManagers;
+ }
+
+ /**
+ * Overwrite the <code>ContentManager</code> list in the <code>JEEApplication</code> content managers container.
+ *
+ * @param contentManagers the new <code>ContentManagers</code> list.
+ */
+ public void setContentManagers( LinkedList contentManagers )
+ {
+ this.contentManagers = contentManagers;
+ }
+
+ /**
+ * Return the <code>ContentManager</code> identified by a given name in the <code>JEEApplication</code> content managers container.
+ *
+ * @return the <code>ContentManager</code> found or null if not found.
+ */
+ public ContentManager getContentManager( String name )
+ {
+ for ( Iterator contentManagerIterator = this.getContentManagers().iterator();
+ contentManagerIterator.hasNext(); )
+ {
+ ContentManager contentManager = (ContentManager) contentManagerIterator.next();
+ if ( contentManager.getName().equals( name ) )
+ {
+ return contentManager;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add a new <code>ConfigurationFile</code> in the <code>JEEApplication</code>
+ * configuration files container.
+ *
+ * @param configurationFile the <code>ConfigurationFile</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>ConfigurationFile</code> name already exists in the application.
+ */
+ public void addConfigurationFile( ConfigurationFile configurationFile )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getConfigurationFile( configurationFile.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException(
+ "Configuration file name already exists in the JEE application." );
+ }
+ this.configurationFiles.add( configurationFile );
+ }
+
+ /**
+ * Get the <code>ConfigurationFile</code> list in the
+ * <code>JEEApplication</code> configuration files container.
+ *
+ * @return the <code>ConfigurationFile</code> list.
+ */
+ public List getConfigurationFiles()
+ {
+ return this.configurationFiles;
+ }
+
+ /**
+ * Overwrite the <code>ConfigurationFile</code> list in the
+ * <code>JEEApplication</code> configuration files container.
+ *
+ * @param configurationFiles the new <code>ConfigurationFile</code> list.
+ */
+ public void setConfigurationFiles( LinkedList configurationFiles )
+ {
+ this.configurationFiles = configurationFiles;
+ }
+
+ /**
+ * Get the <code>ConfigurationFile</code> identified by a given name in the
+ * <code>JEEApplication</code> configuration files container.
+ *
+ * @param name the <code>ConfigurationFile</code> name.
+ * @return the <code>ConfigurationFile</code> found or null if not found.
+ */
+ public ConfigurationFile getConfigurationFile( String name )
+ {
+ for ( Iterator configurationFileIterator = this.getConfigurationFiles().iterator();
+ configurationFileIterator.hasNext(); )
+ {
+ ConfigurationFile configurationFile = (ConfigurationFile) configurationFileIterator.next();
+ if ( configurationFile.getName().equals( name ) )
+ {
+ return configurationFile;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add a new <code>Database</code> in the <code>JEEApplication</code>
+ * databases container.
+ *
+ * @param database the <code>Database</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>Database</code> name already exists in the application.
+ */
+ public void addDatabase( Database database )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getDatabase( database.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "Database name already exists in the JEE application." );
+ }
+ this.databases.add( database );
+ }
+
+ /**
+ * Get the <code>Database</code> list in the <code>JEEApplication</code>
+ * databases container.
+ *
+ * @return the <code>Database</code> list.
+ */
+ public List getDatabases()
+ {
+ return this.databases;
+ }
+
+ /**
+ * Overwrite the <code>Database</code> list in the <code>JEEApplication</code>
+ * databases container.
+ *
+ * @param databases the new <code>Database</code> list.
+ */
+ public void setDatabases( LinkedList databases )
+ {
+ this.databases = databases;
+ }
+
+ /**
+ * Get the <code>Database</code> identified by a given name in the
+ * <code>JEEApplication</code> databases container.
+ *
+ * @param name the <code>Database</code> name.
+ * @return the <code>Database</code> found or null if not found.
+ */
+ public Database getDatabase( String name )
+ {
+ for ( Iterator databaseIterator = this.getDatabases().iterator(); databaseIterator.hasNext(); )
+ {
+ Database database = (Database) databaseIterator.next();
+ if ( database.getName().equals( name ) )
+ {
+ return database;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ JEEApplication clone = new JEEApplication();
+ clone.setName( this.getName() );
+ clone.setUri( this.getUri() );
+ clone.setActive( this.isActive() );
+ clone.setBlocker( this.isBlocker() );
+ clone.setAgent( this.getAgent() );
+ for ( Iterator archiveIterator = this.archives.iterator(); archiveIterator.hasNext(); )
+ {
+ Archive archive = (Archive) archiveIterator.next();
+ clone.archives.add( (Archive) archive.clone() );
+ }
+ for ( Iterator contentManagerIterator = this.contentManagers.iterator(); contentManagerIterator.hasNext(); )
+ {
+ ContentManager contentManager = (ContentManager) contentManagerIterator.next();
+ clone.contentManagers.add( (ContentManager) contentManager.clone() );
+ }
+ for ( Iterator configurationFileIterator = this.configurationFiles.iterator();
+ configurationFileIterator.hasNext(); )
+ {
+ ConfigurationFile configurationFile = (ConfigurationFile) configurationFileIterator.next();
+ clone.configurationFiles.add( (ConfigurationFile) configurationFile.clone() );
+ }
+ for ( Iterator databaseIterator = this.databases.iterator(); databaseIterator.hasNext(); )
+ {
+ Database database = (Database) databaseIterator.next();
+ clone.databases.add( (Database) database.clone() );
+ }
+ return clone;
+ }
+
+ /**
+ * Transforms the <code>JEEApplication</code> POJO to a DOM element.
+ *
+ * @param document the core DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "jeeapplication" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "uri", this.getUri() );
+ element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
+ element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
+ element.setAttribute( "agent", this.getAgent() );
+ // archives
+ ElementImpl archives = new ElementImpl( document, "archives" );
+ for ( Iterator archiveIterator = this.getArchives().iterator(); archiveIterator.hasNext(); )
+ {
+ Archive archive = (Archive) archiveIterator.next();
+ archives.appendChild( archive.toDOMElement( document ) );
+ }
+ element.appendChild( archives );
+ // contentmanagers
+ ElementImpl contentmanagers = new ElementImpl( document, "contentmanagers" );
+ for ( Iterator contentManagerIterator = this.getContentManagers().iterator();
+ contentManagerIterator.hasNext(); )
+ {
+ ContentManager contentManager = (ContentManager) contentManagerIterator.next();
+ contentmanagers.appendChild( contentManager.toDOMElement( document ) );
+ }
+ element.appendChild( contentmanagers );
+ // configurationfiles
+ ElementImpl configurationfiles = new ElementImpl( document, "configurationfiles" );
+ for ( Iterator configurationFileIterator = this.getConfigurationFiles().iterator();
+ configurationFileIterator.hasNext(); )
+ {
+ ConfigurationFile configurationFile = (ConfigurationFile) configurationFileIterator.next();
+ configurationfiles.appendChild( configurationFile.toDOMElement( document ) );
+ }
+ element.appendChild( configurationfiles );
+ // databases
+ ElementImpl databases = new ElementImpl( document, "databases" );
+ for ( Iterator databaseIterator = this.getDatabases().iterator(); databaseIterator.hasNext(); )
+ {
+ Database database = (Database) databaseIterator.next();
+ databases.appendChild( database.toDOMElement( document ) );
+ }
+ element.appendChild( databases );
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherApplication )
+ {
+ return this.getName().compareTo( ( (JEEApplication) anotherApplication ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JEEApplicationServer.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JEEApplicationServer.java
index 9b40edc..76c344b 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JEEApplicationServer.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JEEApplicationServer.java
@@ -32,868 +32,864 @@
* Represents the <code>jeeapplicationserver</code> tag in the Kalumet DOM.
*/
public class JEEApplicationServer
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = 2272703476099937797L;
+ private static final long serialVersionUID = 2272703476099937797L;
- private String name;
+ private String name;
- private boolean active;
+ private boolean active;
- private boolean blocker;
+ private boolean blocker;
- private String classname;
+ private String classname;
- private String jmxurl;
+ private String jmxurl;
- private String adminuser;
+ private String adminuser;
- private String adminpassword;
+ private String adminpassword;
- private boolean updateRequireRestart;
+ private boolean updateRequireRestart;
- private boolean updateRequireCacheCleaning;
+ private boolean updateRequireCacheCleaning;
- private boolean usejmxstop;
+ private boolean usejmxstop;
- private boolean deletecomponents;
+ private boolean deletecomponents;
- private String startupcommand;
+ private String startupcommand;
- private String shutdowncommand;
+ private String shutdowncommand;
- private String agent;
+ private String agent;
- private LinkedList jdbcConnectionPools;
+ private LinkedList jdbcConnectionPools;
- private LinkedList jdbcDataSources;
+ private LinkedList jdbcDataSources;
- private LinkedList jmsConnectionFactories;
+ private LinkedList jmsConnectionFactories;
- private LinkedList jmsServers;
+ private LinkedList jmsServers;
- private LinkedList jndiBindings;
+ private LinkedList jndiBindings;
- private LinkedList sharedLibraries;
+ private LinkedList sharedLibraries;
- private LinkedList jeeApplications;
+ private LinkedList jeeApplications;
- private LinkedList caches;
+ private LinkedList caches;
- private LinkedList logAccesses;
+ private LinkedList logAccesses;
- /**
- * Default constructor to create a new <code>JEEApplicationServer</code>.
- */
- public JEEApplicationServer()
- {
- this.jdbcConnectionPools = new LinkedList();
- this.jdbcDataSources = new LinkedList();
- this.jmsConnectionFactories = new LinkedList();
- this.jmsServers = new LinkedList();
- this.jndiBindings = new LinkedList();
- this.sharedLibraries = new LinkedList();
- this.jeeApplications = new LinkedList();
- this.caches = new LinkedList();
- this.logAccesses = new LinkedList();
- }
-
- public String getName()
- {
- return this.name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public boolean isActive()
- {
- return active;
- }
-
- public void setActive( boolean active )
- {
- this.active = active;
- }
-
- public boolean isBlocker()
- {
- return blocker;
- }
-
- public void setBlocker( boolean blocker )
- {
- this.blocker = blocker;
- }
-
- public String getClassname()
- {
- return this.classname;
- }
-
- public void setClassname( String classname )
- {
- this.classname = classname;
- }
-
- public String getJmxurl()
- {
- return this.jmxurl;
- }
-
- public void setJmxurl( String jmxurl )
- {
- this.jmxurl = jmxurl;
- }
-
- public String getAdminuser()
- {
- return this.adminuser;
- }
-
- public void setAdminuser( String adminuser )
- {
- this.adminuser = adminuser;
- }
-
- public String getAdminpassword()
- {
- return this.adminpassword;
- }
-
- public void setAdminpassword( String adminpassword )
- {
- this.adminpassword = adminpassword;
- }
-
- public boolean isUpdateRequireRestart()
- {
- return this.updateRequireRestart;
- }
-
- public void setUpdateRequireRestart( boolean updateRequireRestart )
- {
- this.updateRequireRestart = updateRequireRestart;
- }
-
- public boolean isUpdateRequireCacheCleaning()
- {
- return this.updateRequireCacheCleaning;
- }
-
- public void setUpdateRequireCacheCleaning( boolean updateRequireCacheCleaning )
- {
- this.updateRequireCacheCleaning = updateRequireCacheCleaning;
- }
-
- public boolean isUsejmxstop()
- {
- return this.usejmxstop;
- }
-
- public void setUsejmxstop( boolean usejmxstop )
- {
- this.usejmxstop = usejmxstop;
- }
-
- public boolean isDeletecomponents()
- {
- return this.deletecomponents;
- }
-
- public void setDeletecomponents( boolean deletecomponents )
- {
- this.deletecomponents = deletecomponents;
- }
-
- public String getStartupcommand()
- {
- return this.startupcommand;
- }
-
- public void setStartupcommand( String startupcommand )
- {
- this.startupcommand = startupcommand;
- }
-
- public String getShutdowncommand()
- {
- return this.shutdowncommand;
- }
-
- public void setShutdowncommand( String shutdowncommand )
- {
- this.shutdowncommand = shutdowncommand;
- }
-
- public String getAgent()
- {
- return agent;
- }
-
- public void setAgent( String agent )
- {
- this.agent = agent;
- }
-
- /**
- * Add a new <code>JDBCConnectionPool</code> in the
- * <code>JEEApplicationServer</code> connection pools container.
- *
- * @param JDBCConnectionPool the <code>JDBCConnectionPool</code> to add.
- * @throws ModelObjectAlreadyExistsException
- * if the <code>JDBCConnectionPool</code> name already exists in the application server.
- */
- public void addJDBCConnectionPool( JDBCConnectionPool JDBCConnectionPool )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getJDBCConnectionPool( JDBCConnectionPool.getName() ) != null )
+ /**
+ * Default constructor to create a new <code>JEEApplicationServer</code>.
+ */
+ public JEEApplicationServer()
{
- throw new ModelObjectAlreadyExistsException( "JDBC connection pool name already exists in the JEE server." );
+ this.jdbcConnectionPools = new LinkedList();
+ this.jdbcDataSources = new LinkedList();
+ this.jmsConnectionFactories = new LinkedList();
+ this.jmsServers = new LinkedList();
+ this.jndiBindings = new LinkedList();
+ this.sharedLibraries = new LinkedList();
+ this.jeeApplications = new LinkedList();
+ this.caches = new LinkedList();
+ this.logAccesses = new LinkedList();
}
- this.jdbcConnectionPools.add( JDBCConnectionPool );
- }
- /**
- * Get the <code>JDBCConnectionPool</code> list in the
- * <code>JEEApplicationServer</code> connection pools container.
- *
- * @return the <code>JDBCConnectionPool</code> list.
- */
- public List getJDBCConnectionPools()
- {
- return this.jdbcConnectionPools;
- }
-
- /**
- * Overwrite the <code>JDBCConnectionPool</code> list in the
- * <code>JEEApplicationServer</code> connection pools container.
- *
- * @param jdbcConnectionPools the new <code>JDBCConnectionPool</code> list.
- */
- public void setJDBCConnectionPools( LinkedList jdbcConnectionPools )
- {
- this.jdbcConnectionPools = jdbcConnectionPools;
- }
-
- /**
- * Get the <code>JDBCConnectionPool</code> identified by a given name in the
- * <code>JEEApplicationServer</code> connection pools container.
- *
- * @param name the <code>JDBCConnectionPool</code> name.
- * @return the <code>JDBCConnectionPool</code> found or null if not found.
- */
- public JDBCConnectionPool getJDBCConnectionPool( String name )
- {
- for ( Iterator connectionPoolIterator = this.getJDBCConnectionPools().iterator();
- connectionPoolIterator.hasNext(); )
+ public String getName()
{
- JDBCConnectionPool JDBCConnectionPool = (JDBCConnectionPool) connectionPoolIterator.next();
- if ( JDBCConnectionPool.getName().equals( name ) )
- {
- return JDBCConnectionPool;
- }
+ return this.name;
}
- return null;
- }
- /**
- * Add a new <code>JDBCDataSource</code> in the <code>JEEApplicationServer</code>
- * data sources container.
- *
- * @param JDBCDataSource the <code>JDBCDataSource</code> to add.
- * @throws ModelObjectAlreadyExistsException
- * if the <code>JDBCDataSource</code> name already exists in the application server.
- */
- public void addJDBCDataSource( JDBCDataSource JDBCDataSource )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getJDBCDataSource( JDBCDataSource.getName() ) != null )
+ public void setName( String name )
{
- throw new ModelObjectAlreadyExistsException( "JDBC data source name already exists in the JEE server." );
+ this.name = name;
}
- this.jdbcDataSources.add( JDBCDataSource );
- }
- /**
- * Get the <code>JDBCDataSource</code> list in the
- * <code>JEEApplicationServer</code> data sources container.
- *
- * @return the <code>JDBCDataSource</code> list.
- */
- public List getJDBCDataSources()
- {
- return this.jdbcDataSources;
- }
-
- /**
- * Overwrite the <code>JDBCDataSource</code> list in the
- * <code>JEEApplicationServer</code> data sources container.
- *
- * @param dataSources the new <code>JDBCDataSource</code> list.
- */
- public void setJDBCDataSources( LinkedList dataSources )
- {
- this.jdbcDataSources = dataSources;
- }
-
- /**
- * Get the <code>JDBCDataSource</code> identified by a given name in the
- * <code>JEEApplicationServer</code> data sources container.
- *
- * @param name the <code>JDBCDataSource</code> name.
- * @return the <code>JDBCDataSource</code> found or null if not found.
- */
- public JDBCDataSource getJDBCDataSource( String name )
- {
- for ( Iterator dataSourceIterator = this.getJDBCDataSources().iterator(); dataSourceIterator.hasNext(); )
+ public boolean isActive()
{
- JDBCDataSource JDBCDataSource = (JDBCDataSource) dataSourceIterator.next();
- if ( JDBCDataSource.getName().equals( name ) )
- {
- return JDBCDataSource;
- }
+ return active;
}
- return null;
- }
- /**
- * Add a new <code>JMSConnectionFactory</code> in the
- * <code>JEEApplicationServer</code> JMS connection factories container.
- *
- * @param jmsConnectionFactory the <code>JMSConnectionFactory</code> to add.
- * @throws ModelObjectAlreadyExistsException
- *
- */
- public void addJMSConnectionFactory( JMSConnectionFactory jmsConnectionFactory )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getJMSConnectionFactory( jmsConnectionFactory.getName() ) != null )
+ public void setActive( boolean active )
{
- throw new ModelObjectAlreadyExistsException( "JMS connection factory name already exists in the JEE server." );
+ this.active = active;
}
- this.jmsConnectionFactories.add( jmsConnectionFactory );
- }
- /**
- * Get the <code>JMSConnectionFactory</code> list in the
- * <code>JEEApplicationServer</code> JMS connection factories container.
- *
- * @return the <code>JMSConnectionFactory</code> list.
- */
- public List getJMSConnectionFactories()
- {
- return this.jmsConnectionFactories;
- }
+ public boolean isBlocker()
+ {
+ return blocker;
+ }
- /**
- * Overwrites the <code>JMSConnectionFactory</code> list in the
- * <code>JEEApplicationServer</code> JMS connection factories container.
- *
- * @param jmsConnectionFactories the new <code>JMSConnectionFactory</code> list.
- */
- public void setJMSConnectionFactories( LinkedList jmsConnectionFactories )
- {
- this.jmsConnectionFactories = jmsConnectionFactories;
- }
+ public void setBlocker( boolean blocker )
+ {
+ this.blocker = blocker;
+ }
- /**
- * Gets the <code>JMSConnectionFactory</code> identified by a given name in
- * the <code>JEEApplicationServer</code> JMS connection factories container.
- *
- * @param name the <code>JMSConnectionFactory</code> name.
- * @return the <code>JMSConnectionFactory</code> found or null if not found.
- */
- public JMSConnectionFactory getJMSConnectionFactory( String name )
- {
- for ( Iterator jmsConnectionFactoryIterator = this.getJMSConnectionFactories().iterator();
- jmsConnectionFactoryIterator.hasNext(); )
+ public String getClassname()
{
- JMSConnectionFactory jmsConnectionFactory = (JMSConnectionFactory) jmsConnectionFactoryIterator.next();
- if ( jmsConnectionFactory.getName().equals( name ) )
- {
- return jmsConnectionFactory;
- }
+ return this.classname;
}
- return null;
- }
- /**
- * Adds a new <code>JMSServer</code> in the <code>JEEApplicationServer</code>
- * JMS servers container.
- *
- * @param jmsServer the <code>JMSServer</code> to add.
- * @throws ModelObjectAlreadyExistsException
- * if the <code>JMSServer</code> name already exists in the application server.
- */
- public void addJMSServer( JMSServer jmsServer )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getJMSServer( jmsServer.getName() ) != null )
+ public void setClassname( String classname )
{
- throw new ModelObjectAlreadyExistsException( "JMS server name already exists in the JEE application server." );
+ this.classname = classname;
}
- this.jmsServers.add( jmsServer );
- }
- /**
- * Gets the <code>JMSServer</code> list in the <code>JEEApplicationServer</code>
- * JMS servers container.
- *
- * @return the <code>JMSServer</code> list.
- */
- public List getJMSServers()
- {
- return this.jmsServers;
- }
+ public String getJmxurl()
+ {
+ return this.jmxurl;
+ }
- /**
- * Overwrites the <code>JMSServer</code> list in the
- * <code>JEEApplicationServer</code> JMS servers container.
- *
- * @param jmsServers the new <code>JMSServer</code> list.
- */
- public void setJMSServers( LinkedList jmsServers )
- {
- this.jmsServers = jmsServers;
- }
+ public void setJmxurl( String jmxurl )
+ {
+ this.jmxurl = jmxurl;
+ }
- /**
- * Gets the <code>JMSServer</code> identified by a given name in the
- * <code>JEEApplicationServer</code> JMS servers container.
- *
- * @param name the <code>JMSServer</code> name.
- * @return the <code>JMSServer</code> found or null if not found.
- */
- public JMSServer getJMSServer( String name )
- {
- for ( Iterator jmsServerIterator = this.getJMSServers().iterator(); jmsServerIterator.hasNext(); )
+ public String getAdminuser()
{
- JMSServer jmsServer = (JMSServer) jmsServerIterator.next();
- if ( jmsServer.getName().equals( name ) )
- {
- return jmsServer;
- }
+ return this.adminuser;
}
- return null;
- }
- /**
- * Adds a new <code>JNDIBinding</code> in the
- * <code>JEEApplicationServer</code> name space bindings container.
- *
- * @param JNDIBinding the <code>JNDIBinding</code> to add.
- * @throws ModelObjectAlreadyExistsException
- * if the <code>JNDIBinding</code> name already exists in the application server.
- */
- public void addJNDIBinding( JNDIBinding JNDIBinding )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getJNDIBinding( JNDIBinding.getName() ) != null )
+ public void setAdminuser( String adminuser )
{
- throw new ModelObjectAlreadyExistsException( "Name space binding name already exists in the JEE server." );
+ this.adminuser = adminuser;
}
- this.jndiBindings.add( JNDIBinding );
- }
- /**
- * Gets the <code>JNDIBinding</code> list in the
- * <code>JEEApplicationServer</code> name space bindings container.
- *
- * @return the <code>JNDIBinding</code> list.
- */
- public List getJNDIBindings()
- {
- return this.jndiBindings;
- }
+ public String getAdminpassword()
+ {
+ return this.adminpassword;
+ }
- /**
- * Overwrites the <code>JNDIBinding</code> list in the
- * <code>JEEApplicationServer</code> name space bindings container.
- *
- * @param jndiBindings the new <code>JNDIBinding</code> list.
- */
- public void setJNDIBindings( LinkedList jndiBindings )
- {
- this.jndiBindings = jndiBindings;
- }
+ public void setAdminpassword( String adminpassword )
+ {
+ this.adminpassword = adminpassword;
+ }
- /**
- * Gets the <code>JNDIBinding</code> identified by a given name in the
- * <code>JEEApplicationServer</code> name space bindings container.
- *
- * @param name the <code>JNDIBinding</code> name.
- * @return the <code>JNDIBinding</code> found or null if not found.
- */
- public JNDIBinding getJNDIBinding( String name )
- {
- for ( Iterator jndiBindingIterator = this.getJNDIBindings().iterator(); jndiBindingIterator.hasNext(); )
+ public boolean isUpdateRequireRestart()
{
- JNDIBinding JNDIBinding = (JNDIBinding) jndiBindingIterator.next();
- if ( JNDIBinding.getName().equals( name ) )
- {
- return JNDIBinding;
- }
+ return this.updateRequireRestart;
}
- return null;
- }
- /**
- * Adds a new <code>SharedLibrary</code> in the
- * <code>JEEApplicationServer</code> shared libraries container.
- *
- * @param sharedLibrary the <code>SharedLibrary</code> to add.
- * @throws ModelObjectAlreadyExistsException
- * if the <code>SharedLibrary</code> name already exists in the application server.
- */
- public void addSharedLibrary( SharedLibrary sharedLibrary )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getSharedLibrary( sharedLibrary.getName() ) != null )
+ public void setUpdateRequireRestart( boolean updateRequireRestart )
{
- throw new ModelObjectAlreadyExistsException( "Shared library name already exists in the JEE server." );
+ this.updateRequireRestart = updateRequireRestart;
}
- this.sharedLibraries.add( sharedLibrary );
- }
- /**
- * Gets the <code>SharedLibrary</code> list in the
- * <code>JEEApplicationServer</code> shared libraries container.
- *
- * @return the <code>SharedLibrary</code> list.
- */
- public List getSharedLibraries()
- {
- return this.sharedLibraries;
- }
+ public boolean isUpdateRequireCacheCleaning()
+ {
+ return this.updateRequireCacheCleaning;
+ }
- /**
- * Overwrites the <code>SharedLibrary</code> list in the
- * <code>JEEApplicationServer</code> shared libraries container.
- *
- * @param sharedLibraries the new <code>SharedLibrary</code> list.
- */
- public void setSharedLibraries( LinkedList sharedLibraries )
- {
- this.sharedLibraries = sharedLibraries;
- }
+ public void setUpdateRequireCacheCleaning( boolean updateRequireCacheCleaning )
+ {
+ this.updateRequireCacheCleaning = updateRequireCacheCleaning;
+ }
- /**
- * Gets the <code>SharedLibrary</code> identified by a given name in the
- * <code>JEEApplicationServer</code> shared libraries container.
- *
- * @param name the <code>SharedLibrary</code> name.
- * @return the <code>SharedLibrary</code> found or null if not found.
- */
- public SharedLibrary getSharedLibrary( String name )
- {
- for ( Iterator sharedLibraryIterator = this.getSharedLibraries().iterator(); sharedLibraryIterator.hasNext(); )
+ public boolean isUsejmxstop()
{
- SharedLibrary sharedLibrary = (SharedLibrary) sharedLibraryIterator.next();
- if ( sharedLibrary.getName().equals( name ) )
- {
- return sharedLibrary;
- }
+ return this.usejmxstop;
}
- return null;
- }
- /**
- * Adds a new <code>JEEApplication</code> in the <code>JEEApplicationServer</code>
- * jeeApplications container.
- *
- * @param jeeApplication the <code>JEEApplication</code> to add.
- * @throws ModelObjectAlreadyExistsException
- * if the <code>JEEApplication</code> name already exists in the jeeApplication server.
- */
- public void addJEEApplication( JEEApplication jeeApplication )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getJEEApplication(jeeApplication.getName()) != null )
+ public void setUsejmxstop( boolean usejmxstop )
{
- throw new ModelObjectAlreadyExistsException(
- "JEE application name already exists in the JEE application server." );
+ this.usejmxstop = usejmxstop;
}
- this.jeeApplications.add(jeeApplication);
- }
- /**
- * Gets the <code>JEEApplication</code> list in the
- * <code>JEEApplicationServer</code> jeeApplications container.
- *
- * @return the <code>JEEApplication</code> list.
- */
- public List getJEEApplications()
- {
- return this.jeeApplications;
- }
+ public boolean isDeletecomponents()
+ {
+ return this.deletecomponents;
+ }
- /**
- * Overwrites the <code>JEEApplication</code> list in the
- * <code>JEEApplicationServer</code> jeeApplications container.
- *
- * @param jeeApplications the new <code>JEEApplication</code> list.
- */
- public void setJEEApplications( LinkedList jeeApplications )
- {
- this.jeeApplications = jeeApplications;
- }
+ public void setDeletecomponents( boolean deletecomponents )
+ {
+ this.deletecomponents = deletecomponents;
+ }
- /**
- * Gets the <code>JEEApplication</code> identified by a given name in the
- * <code>JEEApplicationServer</code> jeeApplications container.
- *
- * @param name the <code>JEEApplication</code> name.
- * @return the <code>JEEApplication</code> found or null if not found.
- */
- public JEEApplication getJEEApplication( String name )
- {
- for ( Iterator applicationIterator = this.getJEEApplications().iterator(); applicationIterator.hasNext(); )
+ public String getStartupcommand()
{
- JEEApplication jeeApplication = (JEEApplication) applicationIterator.next();
- if ( jeeApplication.getName().equals( name ) )
- {
- return jeeApplication;
- }
+ return this.startupcommand;
}
- return null;
- }
- /**
- * Adds a new <code>Cache</code> in the <code>JEEApplicationServer</code> caches
- * container.
- *
- * @param cache the <code>Cache</code> to add.
- * @throws ModelObjectAlreadyExistsException
- * if the <code>Cache</code> path already exists in the application server.
- */
- public void addCache( Cache cache )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getCache( cache.getPath() ) != null )
+ public void setStartupcommand( String startupcommand )
{
- throw new ModelObjectAlreadyExistsException( "Cache path already exists in the JEE application server." );
+ this.startupcommand = startupcommand;
}
- this.caches.add( cache );
- }
- /**
- * Gets the <code>Cache</code> list in the <code>JEEApplicationServer</code>
- * caches container.
- *
- * @return the <code>Cache</code> list.
- */
- public List getCaches()
- {
- return this.caches;
- }
+ public String getShutdowncommand()
+ {
+ return this.shutdowncommand;
+ }
- /**
- * Overwrites the <code>Cache</code> list in the
- * <code>JEEApplicationServer</code> caches container.
- *
- * @param caches the new <code>Cache</code> list.
- */
- public void setCaches( LinkedList caches )
- {
- this.caches = caches;
- }
+ public void setShutdowncommand( String shutdowncommand )
+ {
+ this.shutdowncommand = shutdowncommand;
+ }
- /**
- * Gets the <code>Cache</code> identified by a given path in the
- * <code>JEEApplicationServer</code> caches container.
- *
- * @param path the <code>Cache</code> path.
- * @return the <code>Cache</code> found or null if not found.
- */
- public Cache getCache( String path )
- {
- for ( Iterator cacheIterator = this.getCaches().iterator(); cacheIterator.hasNext(); )
+ public String getAgent()
{
- Cache cache = (Cache) cacheIterator.next();
- if ( cache.getPath().equals( path ) )
- {
- return cache;
- }
+ return agent;
}
- return null;
- }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- JEEApplicationServer clone = new JEEApplicationServer();
- clone.setName( this.getName() );
- clone.setActive( this.isActive() );
- clone.setBlocker( this.isBlocker() );
- clone.setClassname( this.getClassname() );
- clone.setJmxurl( this.getJmxurl() );
- clone.setAdminuser( this.getAdminuser() );
- clone.setAdminpassword( this.getAdminpassword() );
- clone.setUpdateRequireRestart( this.isUpdateRequireRestart() );
- clone.setUpdateRequireCacheCleaning( this.isUpdateRequireCacheCleaning() );
- clone.setUsejmxstop( this.isUsejmxstop() );
- clone.setDeletecomponents( this.isDeletecomponents() );
- clone.setStartupcommand( this.getStartupcommand() );
- clone.setShutdowncommand( this.getShutdowncommand() );
- clone.setAgent( this.getAgent() );
- for ( Iterator jdbcConnectionPoolIterator = this.jdbcConnectionPools.iterator();
- jdbcConnectionPoolIterator.hasNext(); )
+ public void setAgent( String agent )
{
- JDBCConnectionPool JDBCConnectionPool = (JDBCConnectionPool) jdbcConnectionPoolIterator.next();
- clone.jdbcConnectionPools.add( (JDBCConnectionPool) JDBCConnectionPool.clone() );
+ this.agent = agent;
}
- for ( Iterator jdbcDataSourceIterator = this.jdbcDataSources.iterator(); jdbcDataSourceIterator.hasNext(); )
- {
- JDBCDataSource JDBCDataSource = (JDBCDataSource) jdbcDataSourceIterator.next();
- clone.jdbcDataSources.add( (JDBCDataSource) JDBCDataSource.clone() );
- }
- for ( Iterator jmsConnectionFactoryIterator = this.jmsConnectionFactories.iterator();
- jmsConnectionFactoryIterator.hasNext(); )
- {
- JMSConnectionFactory jmsConnectionFactory = (JMSConnectionFactory) jmsConnectionFactoryIterator.next();
- clone.jmsConnectionFactories.add( (JMSConnectionFactory) jmsConnectionFactory.clone() );
- }
- for ( Iterator jmsServerIterator = this.jmsServers.iterator(); jmsServerIterator.hasNext(); )
- {
- JMSServer jmsServer = (JMSServer) jmsServerIterator.next();
- clone.jmsServers.add( (JMSServer) jmsServer.clone() );
- }
- for ( Iterator jndiBindingIterator = this.jndiBindings.iterator(); jndiBindingIterator.hasNext(); )
- {
- JNDIBinding JNDIBinding = (JNDIBinding) jndiBindingIterator.next();
- clone.jndiBindings.add( (JNDIBinding) JNDIBinding.clone() );
- }
- for ( Iterator sharedLibraryIterator = this.sharedLibraries.iterator(); sharedLibraryIterator.hasNext(); )
- {
- SharedLibrary sharedLibrary = (SharedLibrary) sharedLibraryIterator.next();
- clone.sharedLibraries.add( (SharedLibrary) sharedLibrary.clone() );
- }
- for ( Iterator applicationIterator = this.jeeApplications.iterator(); applicationIterator.hasNext(); )
- {
- JEEApplication jeeApplication = (JEEApplication) applicationIterator.next();
- clone.jeeApplications.add( (JEEApplication) jeeApplication.clone() );
- }
- for ( Iterator cacheIterator = this.caches.iterator(); cacheIterator.hasNext(); )
- {
- Cache cache = (Cache) cacheIterator.next();
- clone.caches.add( (Cache) cache.clone() );
- }
- return clone;
- }
- /**
- * Transforms the <code>JEEApplicationServer</code> POJO to a DOM element.
- *
- * @param document the core XML document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "jeeapplicationserver" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
- element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
- element.setAttribute( "classname", this.getClassname() );
- element.setAttribute( "jmxurl", this.getJmxurl() );
- element.setAttribute( "adminuser", this.getAdminuser() );
- element.setAttribute( "adminpassword", this.getAdminpassword() );
- element.setAttribute( "updateRequireRestart", new Boolean( this.isUpdateRequireRestart() ).toString() );
- element.setAttribute( "updateRequireCacheCleaning", new Boolean( this.isUpdateRequireCacheCleaning() ).toString() );
- element.setAttribute( "usejmxstop", new Boolean( this.isUsejmxstop() ).toString() );
- element.setAttribute( "deletecomponents", new Boolean( this.isDeletecomponents() ).toString() );
- element.setAttribute( "agent", this.getAgent() );
- // add startup command
- ElementImpl startupcommand = new ElementImpl( document, "startupcommand" );
- CDATASectionImpl startupcommandContent = new CDATASectionImpl( document, this.getStartupcommand() );
- startupcommand.appendChild( startupcommandContent );
- element.appendChild( startupcommand );
- // add shutdown command
- ElementImpl shutdowncommand = new ElementImpl( document, "shutdowncommand" );
- CDATASectionImpl shutdowncommandContent = new CDATASectionImpl( document, this.getShutdowncommand() );
- shutdowncommand.appendChild( shutdowncommandContent );
- element.appendChild( shutdowncommand );
- // connectionpools
- ElementImpl jdbcconnectionpools = new ElementImpl( document, "jdbcconnectionpools" );
- for ( Iterator jdbcConnectionPoolIterator = this.getJDBCConnectionPools().iterator();
- jdbcConnectionPoolIterator.hasNext(); )
+ /**
+ * Add a new <code>JDBCConnectionPool</code> in the
+ * <code>JEEApplicationServer</code> connection pools container.
+ *
+ * @param JDBCConnectionPool the <code>JDBCConnectionPool</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>JDBCConnectionPool</code> name already exists in the application server.
+ */
+ public void addJDBCConnectionPool( JDBCConnectionPool JDBCConnectionPool )
+ throws ModelObjectAlreadyExistsException
{
- JDBCConnectionPool JDBCConnectionPool = (JDBCConnectionPool) jdbcConnectionPoolIterator.next();
- jdbcconnectionpools.appendChild( JDBCConnectionPool.toDOMElement( document ) );
+ if ( this.getJDBCConnectionPool( JDBCConnectionPool.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException(
+ "JDBC connection pool name already exists in the JEE server." );
+ }
+ this.jdbcConnectionPools.add( JDBCConnectionPool );
}
- element.appendChild( jdbcconnectionpools );
- // jdbcdatasources
- ElementImpl jdbcdatasources = new ElementImpl( document, "jdbcdatasources" );
- for ( Iterator dataSourceIterator = this.getJDBCDataSources().iterator(); dataSourceIterator.hasNext(); )
- {
- JDBCDataSource JDBCDataSource = (JDBCDataSource) dataSourceIterator.next();
- jdbcdatasources.appendChild( JDBCDataSource.toDOMElement( document ) );
- }
- element.appendChild( jdbcdatasources );
- // jmsconnectionfactories
- ElementImpl jmsconnectionfactories = new ElementImpl( document, "jmsconnectionfactories" );
- for ( Iterator jmsConnectionFactoryIterator = this.getJMSConnectionFactories().iterator();
- jmsConnectionFactoryIterator.hasNext(); )
- {
- JMSConnectionFactory jmsConnectionFactory = (JMSConnectionFactory) jmsConnectionFactoryIterator.next();
- jmsconnectionfactories.appendChild( jmsConnectionFactory.toDOMElement( document ) );
- }
- element.appendChild( jmsconnectionfactories );
- // jmsservers
- ElementImpl jmsservers = new ElementImpl( document, "jmsservers" );
- for ( Iterator jmsServerIterator = this.getJMSServers().iterator(); jmsServerIterator.hasNext(); )
- {
- JMSServer jmsServer = (JMSServer) jmsServerIterator.next();
- jmsservers.appendChild( jmsServer.toDOMElement( document ) );
- }
- element.appendChild( jmsservers );
- // jndibindings
- ElementImpl jndiBindings = new ElementImpl( document, "jndibindings" );
- for ( Iterator jndiBindingIterator = this.getJNDIBindings().iterator(); jndiBindingIterator.hasNext(); )
- {
- JNDIBinding JNDIBinding = (JNDIBinding) jndiBindingIterator.next();
- jndiBindings.appendChild( JNDIBinding.toDOMElement( document ) );
- }
- element.appendChild( jndiBindings );
- // sharedlibraries
- ElementImpl sharedlibraries = new ElementImpl( document, "sharedlibrairies" );
- for ( Iterator sharedLibraryIterator = this.getSharedLibraries().iterator(); sharedLibraryIterator.hasNext(); )
- {
- SharedLibrary sharedLibrary = (SharedLibrary) sharedLibraryIterator.next();
- sharedlibraries.appendChild( sharedLibrary.toDOMElement( document ) );
- }
- element.appendChild( sharedlibraries );
- // jeeapplications
- ElementImpl applications = new ElementImpl( document, "jeeapplications" );
- for ( Iterator applicationIterator = this.getJEEApplications().iterator(); applicationIterator.hasNext(); )
- {
- JEEApplication jeeApplication = (JEEApplication) applicationIterator.next();
- applications.appendChild(jeeApplication.toDOMElement(document));
- }
- element.appendChild( applications );
- // caches
- ElementImpl caches = new ElementImpl( document, "caches" );
- for ( Iterator cacheIterator = this.getCaches().iterator(); cacheIterator.hasNext(); )
- {
- Cache cache = (Cache) cacheIterator.next();
- caches.appendChild( cache.toDOMElement( document ) );
- }
- element.appendChild( caches );
- return element;
- }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherApplicationServer )
- {
- return this.getName().compareTo( ( (JEEApplicationServer) anotherApplicationServer ).getName() );
- }
+ /**
+ * Get the <code>JDBCConnectionPool</code> list in the
+ * <code>JEEApplicationServer</code> connection pools container.
+ *
+ * @return the <code>JDBCConnectionPool</code> list.
+ */
+ public List getJDBCConnectionPools()
+ {
+ return this.jdbcConnectionPools;
+ }
+
+ /**
+ * Overwrite the <code>JDBCConnectionPool</code> list in the
+ * <code>JEEApplicationServer</code> connection pools container.
+ *
+ * @param jdbcConnectionPools the new <code>JDBCConnectionPool</code> list.
+ */
+ public void setJDBCConnectionPools( LinkedList jdbcConnectionPools )
+ {
+ this.jdbcConnectionPools = jdbcConnectionPools;
+ }
+
+ /**
+ * Get the <code>JDBCConnectionPool</code> identified by a given name in the
+ * <code>JEEApplicationServer</code> connection pools container.
+ *
+ * @param name the <code>JDBCConnectionPool</code> name.
+ * @return the <code>JDBCConnectionPool</code> found or null if not found.
+ */
+ public JDBCConnectionPool getJDBCConnectionPool( String name )
+ {
+ for ( Iterator connectionPoolIterator = this.getJDBCConnectionPools().iterator();
+ connectionPoolIterator.hasNext(); )
+ {
+ JDBCConnectionPool JDBCConnectionPool = (JDBCConnectionPool) connectionPoolIterator.next();
+ if ( JDBCConnectionPool.getName().equals( name ) )
+ {
+ return JDBCConnectionPool;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add a new <code>JDBCDataSource</code> in the <code>JEEApplicationServer</code>
+ * data sources container.
+ *
+ * @param JDBCDataSource the <code>JDBCDataSource</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>JDBCDataSource</code> name already exists in the application server.
+ */
+ public void addJDBCDataSource( JDBCDataSource JDBCDataSource )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getJDBCDataSource( JDBCDataSource.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "JDBC data source name already exists in the JEE server." );
+ }
+ this.jdbcDataSources.add( JDBCDataSource );
+ }
+
+ /**
+ * Get the <code>JDBCDataSource</code> list in the
+ * <code>JEEApplicationServer</code> data sources container.
+ *
+ * @return the <code>JDBCDataSource</code> list.
+ */
+ public List getJDBCDataSources()
+ {
+ return this.jdbcDataSources;
+ }
+
+ /**
+ * Overwrite the <code>JDBCDataSource</code> list in the
+ * <code>JEEApplicationServer</code> data sources container.
+ *
+ * @param dataSources the new <code>JDBCDataSource</code> list.
+ */
+ public void setJDBCDataSources( LinkedList dataSources )
+ {
+ this.jdbcDataSources = dataSources;
+ }
+
+ /**
+ * Get the <code>JDBCDataSource</code> identified by a given name in the
+ * <code>JEEApplicationServer</code> data sources container.
+ *
+ * @param name the <code>JDBCDataSource</code> name.
+ * @return the <code>JDBCDataSource</code> found or null if not found.
+ */
+ public JDBCDataSource getJDBCDataSource( String name )
+ {
+ for ( Iterator dataSourceIterator = this.getJDBCDataSources().iterator(); dataSourceIterator.hasNext(); )
+ {
+ JDBCDataSource JDBCDataSource = (JDBCDataSource) dataSourceIterator.next();
+ if ( JDBCDataSource.getName().equals( name ) )
+ {
+ return JDBCDataSource;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add a new <code>JMSConnectionFactory</code> in the
+ * <code>JEEApplicationServer</code> JMS connection factories container.
+ *
+ * @param jmsConnectionFactory the <code>JMSConnectionFactory</code> to add.
+ * @throws ModelObjectAlreadyExistsException
+ */
+ public void addJMSConnectionFactory( JMSConnectionFactory jmsConnectionFactory )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getJMSConnectionFactory( jmsConnectionFactory.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException(
+ "JMS connection factory name already exists in the JEE server." );
+ }
+ this.jmsConnectionFactories.add( jmsConnectionFactory );
+ }
+
+ /**
+ * Get the <code>JMSConnectionFactory</code> list in the
+ * <code>JEEApplicationServer</code> JMS connection factories container.
+ *
+ * @return the <code>JMSConnectionFactory</code> list.
+ */
+ public List getJMSConnectionFactories()
+ {
+ return this.jmsConnectionFactories;
+ }
+
+ /**
+ * Overwrites the <code>JMSConnectionFactory</code> list in the
+ * <code>JEEApplicationServer</code> JMS connection factories container.
+ *
+ * @param jmsConnectionFactories the new <code>JMSConnectionFactory</code> list.
+ */
+ public void setJMSConnectionFactories( LinkedList jmsConnectionFactories )
+ {
+ this.jmsConnectionFactories = jmsConnectionFactories;
+ }
+
+ /**
+ * Gets the <code>JMSConnectionFactory</code> identified by a given name in
+ * the <code>JEEApplicationServer</code> JMS connection factories container.
+ *
+ * @param name the <code>JMSConnectionFactory</code> name.
+ * @return the <code>JMSConnectionFactory</code> found or null if not found.
+ */
+ public JMSConnectionFactory getJMSConnectionFactory( String name )
+ {
+ for ( Iterator jmsConnectionFactoryIterator = this.getJMSConnectionFactories().iterator();
+ jmsConnectionFactoryIterator.hasNext(); )
+ {
+ JMSConnectionFactory jmsConnectionFactory = (JMSConnectionFactory) jmsConnectionFactoryIterator.next();
+ if ( jmsConnectionFactory.getName().equals( name ) )
+ {
+ return jmsConnectionFactory;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Adds a new <code>JMSServer</code> in the <code>JEEApplicationServer</code>
+ * JMS servers container.
+ *
+ * @param jmsServer the <code>JMSServer</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>JMSServer</code> name already exists in the application server.
+ */
+ public void addJMSServer( JMSServer jmsServer )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getJMSServer( jmsServer.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException(
+ "JMS server name already exists in the JEE application server." );
+ }
+ this.jmsServers.add( jmsServer );
+ }
+
+ /**
+ * Gets the <code>JMSServer</code> list in the <code>JEEApplicationServer</code>
+ * JMS servers container.
+ *
+ * @return the <code>JMSServer</code> list.
+ */
+ public List getJMSServers()
+ {
+ return this.jmsServers;
+ }
+
+ /**
+ * Overwrites the <code>JMSServer</code> list in the
+ * <code>JEEApplicationServer</code> JMS servers container.
+ *
+ * @param jmsServers the new <code>JMSServer</code> list.
+ */
+ public void setJMSServers( LinkedList jmsServers )
+ {
+ this.jmsServers = jmsServers;
+ }
+
+ /**
+ * Gets the <code>JMSServer</code> identified by a given name in the
+ * <code>JEEApplicationServer</code> JMS servers container.
+ *
+ * @param name the <code>JMSServer</code> name.
+ * @return the <code>JMSServer</code> found or null if not found.
+ */
+ public JMSServer getJMSServer( String name )
+ {
+ for ( Iterator jmsServerIterator = this.getJMSServers().iterator(); jmsServerIterator.hasNext(); )
+ {
+ JMSServer jmsServer = (JMSServer) jmsServerIterator.next();
+ if ( jmsServer.getName().equals( name ) )
+ {
+ return jmsServer;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Adds a new <code>JNDIBinding</code> in the
+ * <code>JEEApplicationServer</code> name space bindings container.
+ *
+ * @param JNDIBinding the <code>JNDIBinding</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>JNDIBinding</code> name already exists in the application server.
+ */
+ public void addJNDIBinding( JNDIBinding JNDIBinding )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getJNDIBinding( JNDIBinding.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "Name space binding name already exists in the JEE server." );
+ }
+ this.jndiBindings.add( JNDIBinding );
+ }
+
+ /**
+ * Gets the <code>JNDIBinding</code> list in the
+ * <code>JEEApplicationServer</code> name space bindings container.
+ *
+ * @return the <code>JNDIBinding</code> list.
+ */
+ public List getJNDIBindings()
+ {
+ return this.jndiBindings;
+ }
+
+ /**
+ * Overwrites the <code>JNDIBinding</code> list in the
+ * <code>JEEApplicationServer</code> name space bindings container.
+ *
+ * @param jndiBindings the new <code>JNDIBinding</code> list.
+ */
+ public void setJNDIBindings( LinkedList jndiBindings )
+ {
+ this.jndiBindings = jndiBindings;
+ }
+
+ /**
+ * Gets the <code>JNDIBinding</code> identified by a given name in the
+ * <code>JEEApplicationServer</code> name space bindings container.
+ *
+ * @param name the <code>JNDIBinding</code> name.
+ * @return the <code>JNDIBinding</code> found or null if not found.
+ */
+ public JNDIBinding getJNDIBinding( String name )
+ {
+ for ( Iterator jndiBindingIterator = this.getJNDIBindings().iterator(); jndiBindingIterator.hasNext(); )
+ {
+ JNDIBinding JNDIBinding = (JNDIBinding) jndiBindingIterator.next();
+ if ( JNDIBinding.getName().equals( name ) )
+ {
+ return JNDIBinding;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Adds a new <code>SharedLibrary</code> in the
+ * <code>JEEApplicationServer</code> shared libraries container.
+ *
+ * @param sharedLibrary the <code>SharedLibrary</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>SharedLibrary</code> name already exists in the application server.
+ */
+ public void addSharedLibrary( SharedLibrary sharedLibrary )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getSharedLibrary( sharedLibrary.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "Shared library name already exists in the JEE server." );
+ }
+ this.sharedLibraries.add( sharedLibrary );
+ }
+
+ /**
+ * Gets the <code>SharedLibrary</code> list in the
+ * <code>JEEApplicationServer</code> shared libraries container.
+ *
+ * @return the <code>SharedLibrary</code> list.
+ */
+ public List getSharedLibraries()
+ {
+ return this.sharedLibraries;
+ }
+
+ /**
+ * Overwrites the <code>SharedLibrary</code> list in the
+ * <code>JEEApplicationServer</code> shared libraries container.
+ *
+ * @param sharedLibraries the new <code>SharedLibrary</code> list.
+ */
+ public void setSharedLibraries( LinkedList sharedLibraries )
+ {
+ this.sharedLibraries = sharedLibraries;
+ }
+
+ /**
+ * Gets the <code>SharedLibrary</code> identified by a given name in the
+ * <code>JEEApplicationServer</code> shared libraries container.
+ *
+ * @param name the <code>SharedLibrary</code> name.
+ * @return the <code>SharedLibrary</code> found or null if not found.
+ */
+ public SharedLibrary getSharedLibrary( String name )
+ {
+ for ( Iterator sharedLibraryIterator = this.getSharedLibraries().iterator(); sharedLibraryIterator.hasNext(); )
+ {
+ SharedLibrary sharedLibrary = (SharedLibrary) sharedLibraryIterator.next();
+ if ( sharedLibrary.getName().equals( name ) )
+ {
+ return sharedLibrary;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Adds a new <code>JEEApplication</code> in the <code>JEEApplicationServer</code>
+ * jeeApplications container.
+ *
+ * @param jeeApplication the <code>JEEApplication</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>JEEApplication</code> name already exists in the jeeApplication server.
+ */
+ public void addJEEApplication( JEEApplication jeeApplication )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getJEEApplication( jeeApplication.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException(
+ "JEE application name already exists in the JEE application server." );
+ }
+ this.jeeApplications.add( jeeApplication );
+ }
+
+ /**
+ * Gets the <code>JEEApplication</code> list in the
+ * <code>JEEApplicationServer</code> jeeApplications container.
+ *
+ * @return the <code>JEEApplication</code> list.
+ */
+ public List getJEEApplications()
+ {
+ return this.jeeApplications;
+ }
+
+ /**
+ * Overwrites the <code>JEEApplication</code> list in the
+ * <code>JEEApplicationServer</code> jeeApplications container.
+ *
+ * @param jeeApplications the new <code>JEEApplication</code> list.
+ */
+ public void setJEEApplications( LinkedList jeeApplications )
+ {
+ this.jeeApplications = jeeApplications;
+ }
+
+ /**
+ * Gets the <code>JEEApplication</code> identified by a given name in the
+ * <code>JEEApplicationServer</code> jeeApplications container.
+ *
+ * @param name the <code>JEEApplication</code> name.
+ * @return the <code>JEEApplication</code> found or null if not found.
+ */
+ public JEEApplication getJEEApplication( String name )
+ {
+ for ( Iterator applicationIterator = this.getJEEApplications().iterator(); applicationIterator.hasNext(); )
+ {
+ JEEApplication jeeApplication = (JEEApplication) applicationIterator.next();
+ if ( jeeApplication.getName().equals( name ) )
+ {
+ return jeeApplication;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Adds a new <code>Cache</code> in the <code>JEEApplicationServer</code> caches
+ * container.
+ *
+ * @param cache the <code>Cache</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>Cache</code> path already exists in the application server.
+ */
+ public void addCache( Cache cache )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getCache( cache.getPath() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "Cache path already exists in the JEE application server." );
+ }
+ this.caches.add( cache );
+ }
+
+ /**
+ * Gets the <code>Cache</code> list in the <code>JEEApplicationServer</code>
+ * caches container.
+ *
+ * @return the <code>Cache</code> list.
+ */
+ public List getCaches()
+ {
+ return this.caches;
+ }
+
+ /**
+ * Overwrites the <code>Cache</code> list in the
+ * <code>JEEApplicationServer</code> caches container.
+ *
+ * @param caches the new <code>Cache</code> list.
+ */
+ public void setCaches( LinkedList caches )
+ {
+ this.caches = caches;
+ }
+
+ /**
+ * Gets the <code>Cache</code> identified by a given path in the
+ * <code>JEEApplicationServer</code> caches container.
+ *
+ * @param path the <code>Cache</code> path.
+ * @return the <code>Cache</code> found or null if not found.
+ */
+ public Cache getCache( String path )
+ {
+ for ( Iterator cacheIterator = this.getCaches().iterator(); cacheIterator.hasNext(); )
+ {
+ Cache cache = (Cache) cacheIterator.next();
+ if ( cache.getPath().equals( path ) )
+ {
+ return cache;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ JEEApplicationServer clone = new JEEApplicationServer();
+ clone.setName( this.getName() );
+ clone.setActive( this.isActive() );
+ clone.setBlocker( this.isBlocker() );
+ clone.setClassname( this.getClassname() );
+ clone.setJmxurl( this.getJmxurl() );
+ clone.setAdminuser( this.getAdminuser() );
+ clone.setAdminpassword( this.getAdminpassword() );
+ clone.setUpdateRequireRestart( this.isUpdateRequireRestart() );
+ clone.setUpdateRequireCacheCleaning( this.isUpdateRequireCacheCleaning() );
+ clone.setUsejmxstop( this.isUsejmxstop() );
+ clone.setDeletecomponents( this.isDeletecomponents() );
+ clone.setStartupcommand( this.getStartupcommand() );
+ clone.setShutdowncommand( this.getShutdowncommand() );
+ clone.setAgent( this.getAgent() );
+ for ( Iterator jdbcConnectionPoolIterator = this.jdbcConnectionPools.iterator();
+ jdbcConnectionPoolIterator.hasNext(); )
+ {
+ JDBCConnectionPool JDBCConnectionPool = (JDBCConnectionPool) jdbcConnectionPoolIterator.next();
+ clone.jdbcConnectionPools.add( (JDBCConnectionPool) JDBCConnectionPool.clone() );
+ }
+ for ( Iterator jdbcDataSourceIterator = this.jdbcDataSources.iterator(); jdbcDataSourceIterator.hasNext(); )
+ {
+ JDBCDataSource JDBCDataSource = (JDBCDataSource) jdbcDataSourceIterator.next();
+ clone.jdbcDataSources.add( (JDBCDataSource) JDBCDataSource.clone() );
+ }
+ for ( Iterator jmsConnectionFactoryIterator = this.jmsConnectionFactories.iterator();
+ jmsConnectionFactoryIterator.hasNext(); )
+ {
+ JMSConnectionFactory jmsConnectionFactory = (JMSConnectionFactory) jmsConnectionFactoryIterator.next();
+ clone.jmsConnectionFactories.add( (JMSConnectionFactory) jmsConnectionFactory.clone() );
+ }
+ for ( Iterator jmsServerIterator = this.jmsServers.iterator(); jmsServerIterator.hasNext(); )
+ {
+ JMSServer jmsServer = (JMSServer) jmsServerIterator.next();
+ clone.jmsServers.add( (JMSServer) jmsServer.clone() );
+ }
+ for ( Iterator jndiBindingIterator = this.jndiBindings.iterator(); jndiBindingIterator.hasNext(); )
+ {
+ JNDIBinding JNDIBinding = (JNDIBinding) jndiBindingIterator.next();
+ clone.jndiBindings.add( (JNDIBinding) JNDIBinding.clone() );
+ }
+ for ( Iterator sharedLibraryIterator = this.sharedLibraries.iterator(); sharedLibraryIterator.hasNext(); )
+ {
+ SharedLibrary sharedLibrary = (SharedLibrary) sharedLibraryIterator.next();
+ clone.sharedLibraries.add( (SharedLibrary) sharedLibrary.clone() );
+ }
+ for ( Iterator applicationIterator = this.jeeApplications.iterator(); applicationIterator.hasNext(); )
+ {
+ JEEApplication jeeApplication = (JEEApplication) applicationIterator.next();
+ clone.jeeApplications.add( (JEEApplication) jeeApplication.clone() );
+ }
+ for ( Iterator cacheIterator = this.caches.iterator(); cacheIterator.hasNext(); )
+ {
+ Cache cache = (Cache) cacheIterator.next();
+ clone.caches.add( (Cache) cache.clone() );
+ }
+ return clone;
+ }
+
+ /**
+ * Transforms the <code>JEEApplicationServer</code> POJO to a DOM element.
+ *
+ * @param document the core XML document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "jeeapplicationserver" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
+ element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
+ element.setAttribute( "classname", this.getClassname() );
+ element.setAttribute( "jmxurl", this.getJmxurl() );
+ element.setAttribute( "adminuser", this.getAdminuser() );
+ element.setAttribute( "adminpassword", this.getAdminpassword() );
+ element.setAttribute( "updateRequireRestart", new Boolean( this.isUpdateRequireRestart() ).toString() );
+ element.setAttribute( "updateRequireCacheCleaning",
+ new Boolean( this.isUpdateRequireCacheCleaning() ).toString() );
+ element.setAttribute( "usejmxstop", new Boolean( this.isUsejmxstop() ).toString() );
+ element.setAttribute( "deletecomponents", new Boolean( this.isDeletecomponents() ).toString() );
+ element.setAttribute( "agent", this.getAgent() );
+ // add startup command
+ ElementImpl startupcommand = new ElementImpl( document, "startupcommand" );
+ CDATASectionImpl startupcommandContent = new CDATASectionImpl( document, this.getStartupcommand() );
+ startupcommand.appendChild( startupcommandContent );
+ element.appendChild( startupcommand );
+ // add shutdown command
+ ElementImpl shutdowncommand = new ElementImpl( document, "shutdowncommand" );
+ CDATASectionImpl shutdowncommandContent = new CDATASectionImpl( document, this.getShutdowncommand() );
+ shutdowncommand.appendChild( shutdowncommandContent );
+ element.appendChild( shutdowncommand );
+ // connectionpools
+ ElementImpl jdbcconnectionpools = new ElementImpl( document, "jdbcconnectionpools" );
+ for ( Iterator jdbcConnectionPoolIterator = this.getJDBCConnectionPools().iterator();
+ jdbcConnectionPoolIterator.hasNext(); )
+ {
+ JDBCConnectionPool JDBCConnectionPool = (JDBCConnectionPool) jdbcConnectionPoolIterator.next();
+ jdbcconnectionpools.appendChild( JDBCConnectionPool.toDOMElement( document ) );
+ }
+ element.appendChild( jdbcconnectionpools );
+ // jdbcdatasources
+ ElementImpl jdbcdatasources = new ElementImpl( document, "jdbcdatasources" );
+ for ( Iterator dataSourceIterator = this.getJDBCDataSources().iterator(); dataSourceIterator.hasNext(); )
+ {
+ JDBCDataSource JDBCDataSource = (JDBCDataSource) dataSourceIterator.next();
+ jdbcdatasources.appendChild( JDBCDataSource.toDOMElement( document ) );
+ }
+ element.appendChild( jdbcdatasources );
+ // jmsconnectionfactories
+ ElementImpl jmsconnectionfactories = new ElementImpl( document, "jmsconnectionfactories" );
+ for ( Iterator jmsConnectionFactoryIterator = this.getJMSConnectionFactories().iterator();
+ jmsConnectionFactoryIterator.hasNext(); )
+ {
+ JMSConnectionFactory jmsConnectionFactory = (JMSConnectionFactory) jmsConnectionFactoryIterator.next();
+ jmsconnectionfactories.appendChild( jmsConnectionFactory.toDOMElement( document ) );
+ }
+ element.appendChild( jmsconnectionfactories );
+ // jmsservers
+ ElementImpl jmsservers = new ElementImpl( document, "jmsservers" );
+ for ( Iterator jmsServerIterator = this.getJMSServers().iterator(); jmsServerIterator.hasNext(); )
+ {
+ JMSServer jmsServer = (JMSServer) jmsServerIterator.next();
+ jmsservers.appendChild( jmsServer.toDOMElement( document ) );
+ }
+ element.appendChild( jmsservers );
+ // jndibindings
+ ElementImpl jndiBindings = new ElementImpl( document, "jndibindings" );
+ for ( Iterator jndiBindingIterator = this.getJNDIBindings().iterator(); jndiBindingIterator.hasNext(); )
+ {
+ JNDIBinding JNDIBinding = (JNDIBinding) jndiBindingIterator.next();
+ jndiBindings.appendChild( JNDIBinding.toDOMElement( document ) );
+ }
+ element.appendChild( jndiBindings );
+ // sharedlibraries
+ ElementImpl sharedlibraries = new ElementImpl( document, "sharedlibrairies" );
+ for ( Iterator sharedLibraryIterator = this.getSharedLibraries().iterator(); sharedLibraryIterator.hasNext(); )
+ {
+ SharedLibrary sharedLibrary = (SharedLibrary) sharedLibraryIterator.next();
+ sharedlibraries.appendChild( sharedLibrary.toDOMElement( document ) );
+ }
+ element.appendChild( sharedlibraries );
+ // jeeapplications
+ ElementImpl applications = new ElementImpl( document, "jeeapplications" );
+ for ( Iterator applicationIterator = this.getJEEApplications().iterator(); applicationIterator.hasNext(); )
+ {
+ JEEApplication jeeApplication = (JEEApplication) applicationIterator.next();
+ applications.appendChild( jeeApplication.toDOMElement( document ) );
+ }
+ element.appendChild( applications );
+ // caches
+ ElementImpl caches = new ElementImpl( document, "caches" );
+ for ( Iterator cacheIterator = this.getCaches().iterator(); cacheIterator.hasNext(); )
+ {
+ Cache cache = (Cache) cacheIterator.next();
+ caches.appendChild( cache.toDOMElement( document ) );
+ }
+ element.appendChild( caches );
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherApplicationServer )
+ {
+ return this.getName().compareTo( ( (JEEApplicationServer) anotherApplicationServer ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JEEApplicationServers.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JEEApplicationServers.java
index f23d021..86da0a4 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JEEApplicationServers.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JEEApplicationServers.java
@@ -31,124 +31,125 @@
* Represents the <code>jeeapplicationservers</code> tag in the Kalumet DOM.
*/
public class JEEApplicationServers
- implements Serializable, Cloneable
+ implements Serializable, Cloneable
{
- private static final long serialVersionUID = -4940898204749451109L;
+ private static final long serialVersionUID = -4940898204749451109L;
- private boolean cluster;
+ private boolean cluster;
- private LinkedList jeeApplicationServers;
+ private LinkedList jeeApplicationServers;
- public JEEApplicationServers()
- {
- this.jeeApplicationServers = new LinkedList();
- }
-
- public boolean isCluster()
- {
- return this.cluster;
- }
-
- public void setCluster( boolean cluster )
- {
- this.cluster = cluster;
- }
-
- /**
- * Adds a new <code>JEEApplicationServer</code> in the
- * <code>JEEApplicationServers</code> container.
- *
- * @param jeeApplicationServer the <code>JEEApplicationServer</code> to add.
- */
- public void addJEEApplicationServer( JEEApplicationServer jeeApplicationServer )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getJEEApplicationServer( jeeApplicationServer.getName() ) != null )
+ public JEEApplicationServers()
{
- throw new ModelObjectAlreadyExistsException( "JEE application server name already exists in the environment." );
+ this.jeeApplicationServers = new LinkedList();
}
- this.jeeApplicationServers.add(jeeApplicationServer);
- }
- /**
- * Gets the <code>JEEApplicationServer</code> list in the
- * <code>JEEApplicationServers</code> container.
- *
- * @return the <code>JEEApplicationServer</code> list.
- */
- public List getJEEApplicationServers()
- {
- return this.jeeApplicationServers;
- }
-
- /**
- * Overwrites the <code>JEEApplicationServer</code> list in the
- * <code>JEEApplicationServers</code> container.
- *
- * @param jeeApplicationServers the new <code>JEEApplicationServer</code> list.
- */
- public void setJEEApplicationServers( LinkedList jeeApplicationServers )
- {
- this.jeeApplicationServers = jeeApplicationServers;
- }
-
- /**
- * Gets the <code>JEEApplicationServer</code> identified by a given name in the
- * <code>JEEApplicationServers</code> container.
- *
- * @param name the <code>JEEApplicationServer</code> name.
- * @return the <code>JEEApplicationServer</code> found or null if no found.
- */
- public JEEApplicationServer getJEEApplicationServer( String name )
- {
- for ( Iterator applicationServerIterator = this.getJEEApplicationServers().iterator();
- applicationServerIterator.hasNext(); )
+ public boolean isCluster()
{
- JEEApplicationServer jeeApplicationServer = (JEEApplicationServer) applicationServerIterator.next();
- if ( jeeApplicationServer.getName().equals( name ) )
- {
- return jeeApplicationServer;
- }
+ return this.cluster;
}
- return null;
- }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- JEEApplicationServers clone = new JEEApplicationServers();
- clone.setCluster( this.isCluster() );
- for ( Iterator applicationServerIterator = this.jeeApplicationServers.iterator();
- applicationServerIterator.hasNext(); )
+ public void setCluster( boolean cluster )
{
- JEEApplicationServer jeeApplicationServer = (JEEApplicationServer) applicationServerIterator.next();
- clone.jeeApplicationServers.add( (JEEApplicationServer) jeeApplicationServer.clone() );
+ this.cluster = cluster;
}
- return clone;
- }
- /**
- * Transforms the <code>JEEApplicationServers</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "jeeapplicationservers" );
- element.setAttribute( "cluster", new Boolean( this.isCluster() ).toString() );
- // add JEE application server child nodes
- for ( Iterator applicationServerIterator = this.getJEEApplicationServers().iterator();
- applicationServerIterator.hasNext(); )
+ /**
+ * Adds a new <code>JEEApplicationServer</code> in the
+ * <code>JEEApplicationServers</code> container.
+ *
+ * @param jeeApplicationServer the <code>JEEApplicationServer</code> to add.
+ */
+ public void addJEEApplicationServer( JEEApplicationServer jeeApplicationServer )
+ throws ModelObjectAlreadyExistsException
{
- JEEApplicationServer jeeApplicationServer = (JEEApplicationServer) applicationServerIterator.next();
- element.appendChild(jeeApplicationServer.toDOMElement(document));
+ if ( this.getJEEApplicationServer( jeeApplicationServer.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException(
+ "JEE application server name already exists in the environment." );
+ }
+ this.jeeApplicationServers.add( jeeApplicationServer );
}
- return element;
- }
+
+ /**
+ * Gets the <code>JEEApplicationServer</code> list in the
+ * <code>JEEApplicationServers</code> container.
+ *
+ * @return the <code>JEEApplicationServer</code> list.
+ */
+ public List getJEEApplicationServers()
+ {
+ return this.jeeApplicationServers;
+ }
+
+ /**
+ * Overwrites the <code>JEEApplicationServer</code> list in the
+ * <code>JEEApplicationServers</code> container.
+ *
+ * @param jeeApplicationServers the new <code>JEEApplicationServer</code> list.
+ */
+ public void setJEEApplicationServers( LinkedList jeeApplicationServers )
+ {
+ this.jeeApplicationServers = jeeApplicationServers;
+ }
+
+ /**
+ * Gets the <code>JEEApplicationServer</code> identified by a given name in the
+ * <code>JEEApplicationServers</code> container.
+ *
+ * @param name the <code>JEEApplicationServer</code> name.
+ * @return the <code>JEEApplicationServer</code> found or null if no found.
+ */
+ public JEEApplicationServer getJEEApplicationServer( String name )
+ {
+ for ( Iterator applicationServerIterator = this.getJEEApplicationServers().iterator();
+ applicationServerIterator.hasNext(); )
+ {
+ JEEApplicationServer jeeApplicationServer = (JEEApplicationServer) applicationServerIterator.next();
+ if ( jeeApplicationServer.getName().equals( name ) )
+ {
+ return jeeApplicationServer;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ JEEApplicationServers clone = new JEEApplicationServers();
+ clone.setCluster( this.isCluster() );
+ for ( Iterator applicationServerIterator = this.jeeApplicationServers.iterator();
+ applicationServerIterator.hasNext(); )
+ {
+ JEEApplicationServer jeeApplicationServer = (JEEApplicationServer) applicationServerIterator.next();
+ clone.jeeApplicationServers.add( (JEEApplicationServer) jeeApplicationServer.clone() );
+ }
+ return clone;
+ }
+
+ /**
+ * Transforms the <code>JEEApplicationServers</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "jeeapplicationservers" );
+ element.setAttribute( "cluster", new Boolean( this.isCluster() ).toString() );
+ // add JEE application server child nodes
+ for ( Iterator applicationServerIterator = this.getJEEApplicationServers().iterator();
+ applicationServerIterator.hasNext(); )
+ {
+ JEEApplicationServer jeeApplicationServer = (JEEApplicationServer) applicationServerIterator.next();
+ element.appendChild( jeeApplicationServer.toDOMElement( document ) );
+ }
+ return element;
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JMSConnectionFactory.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JMSConnectionFactory.java
index 46a9e42..eaee95e 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JMSConnectionFactory.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JMSConnectionFactory.java
@@ -28,81 +28,81 @@
* Represent the <code>jmsconnectionfactory</code> tag in the Kalumet configuration DOM.
*/
public class JMSConnectionFactory
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = 4118489349470578800L;
+ private static final long serialVersionUID = 4118489349470578800L;
- private String name;
+ private String name;
- private boolean active;
+ private boolean active;
- private boolean blocker;
+ private boolean blocker;
- public String getName()
- {
- return this.name;
- }
+ public String getName()
+ {
+ return this.name;
+ }
- public void setName( String name )
- {
- this.name = name;
- }
+ public void setName( String name )
+ {
+ this.name = name;
+ }
- public boolean isActive()
- {
- return this.active;
- }
+ public boolean isActive()
+ {
+ return this.active;
+ }
- public void setActive( boolean active )
- {
- this.active = active;
- }
+ public void setActive( boolean active )
+ {
+ this.active = active;
+ }
- public boolean isBlocker()
- {
- return this.blocker;
- }
+ public boolean isBlocker()
+ {
+ return this.blocker;
+ }
- public void setBlocker( boolean blocker )
- {
- this.blocker = blocker;
- }
+ public void setBlocker( boolean blocker )
+ {
+ this.blocker = blocker;
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- JMSConnectionFactory clone = new JMSConnectionFactory();
- clone.setName( this.getName() );
- clone.setActive( this.isActive() );
- clone.setBlocker( this.isBlocker() );
- return clone;
- }
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ JMSConnectionFactory clone = new JMSConnectionFactory();
+ clone.setName( this.getName() );
+ clone.setActive( this.isActive() );
+ clone.setBlocker( this.isBlocker() );
+ return clone;
+ }
- /**
- * Transform the <code>JMSConnectionFactory</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "jmsconnectionfactory" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
- element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
- return element;
- }
+ /**
+ * Transform the <code>JMSConnectionFactory</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "jmsconnectionfactory" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
+ element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
+ return element;
+ }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherJMSConnectionFactory )
- {
- return this.getName().compareTo( ( (JMSConnectionFactory) anotherJMSConnectionFactory ).getName() );
- }
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherJMSConnectionFactory )
+ {
+ return this.getName().compareTo( ( (JMSConnectionFactory) anotherJMSConnectionFactory ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JMSQueue.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JMSQueue.java
index 848fb7f..819a970 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JMSQueue.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JMSQueue.java
@@ -28,57 +28,57 @@
* Represent the <code>jmsqueue</code> tag in the Kalumet configuration DOM.
*/
public class JMSQueue
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = -5239170363052872967L;
+ private static final long serialVersionUID = -5239170363052872967L;
- private String name;
+ private String name;
- public JMSQueue()
- {
- }
+ public JMSQueue()
+ {
+ }
- public String getName()
- {
- return this.name;
- }
+ public String getName()
+ {
+ return this.name;
+ }
- public void setName( String name )
- {
- this.name = name;
- }
+ public void setName( String name )
+ {
+ this.name = name;
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- JMSQueue clone = new JMSQueue();
- clone.setName( this.getName() );
- return clone;
- }
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ JMSQueue clone = new JMSQueue();
+ clone.setName( this.getName() );
+ return clone;
+ }
- /**
- * Transform the <code>JMSQueue</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "jmsqueue" );
- element.setAttribute( "name", this.getName() );
- return element;
- }
+ /**
+ * Transform the <code>JMSQueue</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "jmsqueue" );
+ element.setAttribute( "name", this.getName() );
+ return element;
+ }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherJMSQueue )
- {
- return this.getName().compareTo( ( (JMSQueue) anotherJMSQueue ).getName() );
- }
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherJMSQueue )
+ {
+ return this.getName().compareTo( ( (JMSQueue) anotherJMSQueue ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JMSServer.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JMSServer.java
index 67a7eac..e68d2db 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JMSServer.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JMSServer.java
@@ -31,233 +31,233 @@
* Represent the <code>jmsserver</code> tag in the Kalumet configuration DOM.
*/
public class JMSServer
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = -6330087943208308843L;
+ private static final long serialVersionUID = -6330087943208308843L;
- private String name;
+ private String name;
- private boolean active;
+ private boolean active;
- private boolean blocker;
+ private boolean blocker;
- private LinkedList jmsQueues;
+ private LinkedList jmsQueues;
- private LinkedList jmsTopics;
+ private LinkedList jmsTopics;
- public JMSServer()
- {
- this.jmsQueues = new LinkedList();
- this.jmsTopics = new LinkedList();
- }
-
- public String getName()
- {
- return this.name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public boolean isActive()
- {
- return this.active;
- }
-
- public void setActive( boolean active )
- {
- this.active = active;
- }
-
- public boolean isBlocker()
- {
- return this.blocker;
- }
-
- public void setBlocker( boolean blocker )
- {
- this.blocker = blocker;
- }
-
- /**
- * Add a new <code>JMSQueue</code> in the <code>JMSServer</code>
- * JMS queues container.
- *
- * @param jmsQueue the <code>JMSQueue</code> to add.
- */
- public void addJMSQueue( JMSQueue jmsQueue )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getJMSQueue( jmsQueue.getName() ) != null )
+ public JMSServer()
{
- throw new ModelObjectAlreadyExistsException( "JMS queue name already exists in JMS server." );
+ this.jmsQueues = new LinkedList();
+ this.jmsTopics = new LinkedList();
}
- this.jmsQueues.add( jmsQueue );
- }
- /**
- * Get the <code>JMSQueue</code> list in the <code>JMSServer</code>
- * JMS queues container.
- *
- * @return the <code>JMSQueue</code> list.
- */
- public List getJMSQueues()
- {
- return this.jmsQueues;
- }
-
- /**
- * Set the <code>JMSQueue</code> list in the <code>JMSServer</code>
- * JMS queues container.
- *
- * @param jmsQueues the new <code>JMSQueue</code> list.
- */
- public void setJMSQueues( LinkedList jmsQueues )
- {
- this.jmsQueues = jmsQueues;
- }
-
- /**
- * Get the <code>JMSQueue</code> identified by a given name in the
- * <code>JMSServer</code> JMS queues container.
- *
- * @param name the <code>JMSQueue</code> name.
- * @return the <code>JMSQueue</code> found or null if not found.
- */
- public JMSQueue getJMSQueue( String name )
- {
- for ( Iterator jmsQueueIterator = this.getJMSQueues().iterator(); jmsQueueIterator.hasNext(); )
+ public String getName()
{
- JMSQueue jmsQueue = (JMSQueue) jmsQueueIterator.next();
- if ( jmsQueue.getName().equals( name ) )
- {
- return jmsQueue;
- }
+ return this.name;
}
- return null;
- }
- /**
- * Add a new <code>JMSTopic</code> in the <code>JMSServer</code>
- * JMS topics container.
- *
- * @param jmsTopic the <code>JMSTopic</code> to add.
- */
- public void addJMSTopic( JMSTopic jmsTopic )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getJMSTopic( jmsTopic.getName() ) != null )
+ public void setName( String name )
{
- throw new ModelObjectAlreadyExistsException( "JMS topic name already exists in JMS server." );
+ this.name = name;
}
- this.jmsTopics.add( jmsTopic );
- }
- /**
- * Get the <code>JMSTopic</code> list in the <code>JMSServer</code>
- * JMS topics container.
- *
- * @return the <code>JMSTopic</code> list.
- */
- public List getJMSTopics()
- {
- return this.jmsTopics;
- }
-
- /**
- * Set the <code>JMSTopic</code> list in the <code>JMSServer</code>
- * JMS topics container.
- *
- * @param jmsTopics the new <code>JMSTopic</code> list.
- */
- public void setJMSTopics( LinkedList jmsTopics )
- {
- this.jmsTopics = jmsTopics;
- }
-
- /**
- * Get the <code>JMSTopic</code> identified by a given name in the
- * <code>JMSServer</code> JMS topics container.
- *
- * @param name the <code>JMSTopic</code> name.
- * @return the <code>JMSTopic</code> found or null if not found.
- */
- public JMSTopic getJMSTopic( String name )
- {
- for ( Iterator jmsTopicIterator = this.getJMSTopics().iterator(); jmsTopicIterator.hasNext(); )
+ public boolean isActive()
{
- JMSTopic jmsTopic = (JMSTopic) jmsTopicIterator.next();
- if ( jmsTopic.getName().equals( name ) )
- {
- return jmsTopic;
- }
+ return this.active;
}
- return null;
- }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- JMSServer clone = new JMSServer();
- clone.setName( this.getName() );
- clone.setActive( this.isActive() );
- clone.setBlocker( this.isBlocker() );
- for ( Iterator jmsQueueIterator = this.jmsQueues.iterator(); jmsQueueIterator.hasNext(); )
+ public void setActive( boolean active )
{
- JMSQueue jmsQueue = (JMSQueue) jmsQueueIterator.next();
- clone.jmsQueues.add( (JMSQueue) jmsQueue.clone() );
+ this.active = active;
}
- for ( Iterator jmsTopicIterator = this.jmsTopics.iterator(); jmsTopicIterator.hasNext(); )
- {
- JMSTopic jmsTopic = (JMSTopic) jmsTopicIterator.next();
- clone.jmsTopics.add( (JMSTopic) jmsTopic.clone() );
- }
- return clone;
- }
- /**
- * Transform the <code>JMSServer</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "jmsserver" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
- element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
- // jmsqueues
- ElementImpl jmsqueues = new ElementImpl( document, "jmsqueues" );
- for ( Iterator jmsQueueIterator = this.getJMSQueues().iterator(); jmsQueueIterator.hasNext(); )
+ public boolean isBlocker()
{
- JMSQueue jmsQueue = (JMSQueue) jmsQueueIterator.next();
- jmsqueues.appendChild( jmsQueue.toDOMElement( document ) );
+ return this.blocker;
}
- element.appendChild( jmsqueues );
- // jmstopics
- ElementImpl jmstopics = new ElementImpl( document, "jmstopics" );
- for ( Iterator jmsTopicIterator = this.getJMSTopics().iterator(); jmsTopicIterator.hasNext(); )
- {
- JMSTopic jmsTopic = (JMSTopic) jmsTopicIterator.next();
- jmstopics.appendChild( jmsTopic.toDOMElement( document ) );
- }
- element.appendChild( jmstopics );
- return element;
- }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherJMSServer )
- {
- return this.getName().compareTo( ( (JMSServer) anotherJMSServer ).getName() );
- }
+ public void setBlocker( boolean blocker )
+ {
+ this.blocker = blocker;
+ }
+
+ /**
+ * Add a new <code>JMSQueue</code> in the <code>JMSServer</code>
+ * JMS queues container.
+ *
+ * @param jmsQueue the <code>JMSQueue</code> to add.
+ */
+ public void addJMSQueue( JMSQueue jmsQueue )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getJMSQueue( jmsQueue.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "JMS queue name already exists in JMS server." );
+ }
+ this.jmsQueues.add( jmsQueue );
+ }
+
+ /**
+ * Get the <code>JMSQueue</code> list in the <code>JMSServer</code>
+ * JMS queues container.
+ *
+ * @return the <code>JMSQueue</code> list.
+ */
+ public List getJMSQueues()
+ {
+ return this.jmsQueues;
+ }
+
+ /**
+ * Set the <code>JMSQueue</code> list in the <code>JMSServer</code>
+ * JMS queues container.
+ *
+ * @param jmsQueues the new <code>JMSQueue</code> list.
+ */
+ public void setJMSQueues( LinkedList jmsQueues )
+ {
+ this.jmsQueues = jmsQueues;
+ }
+
+ /**
+ * Get the <code>JMSQueue</code> identified by a given name in the
+ * <code>JMSServer</code> JMS queues container.
+ *
+ * @param name the <code>JMSQueue</code> name.
+ * @return the <code>JMSQueue</code> found or null if not found.
+ */
+ public JMSQueue getJMSQueue( String name )
+ {
+ for ( Iterator jmsQueueIterator = this.getJMSQueues().iterator(); jmsQueueIterator.hasNext(); )
+ {
+ JMSQueue jmsQueue = (JMSQueue) jmsQueueIterator.next();
+ if ( jmsQueue.getName().equals( name ) )
+ {
+ return jmsQueue;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add a new <code>JMSTopic</code> in the <code>JMSServer</code>
+ * JMS topics container.
+ *
+ * @param jmsTopic the <code>JMSTopic</code> to add.
+ */
+ public void addJMSTopic( JMSTopic jmsTopic )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getJMSTopic( jmsTopic.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "JMS topic name already exists in JMS server." );
+ }
+ this.jmsTopics.add( jmsTopic );
+ }
+
+ /**
+ * Get the <code>JMSTopic</code> list in the <code>JMSServer</code>
+ * JMS topics container.
+ *
+ * @return the <code>JMSTopic</code> list.
+ */
+ public List getJMSTopics()
+ {
+ return this.jmsTopics;
+ }
+
+ /**
+ * Set the <code>JMSTopic</code> list in the <code>JMSServer</code>
+ * JMS topics container.
+ *
+ * @param jmsTopics the new <code>JMSTopic</code> list.
+ */
+ public void setJMSTopics( LinkedList jmsTopics )
+ {
+ this.jmsTopics = jmsTopics;
+ }
+
+ /**
+ * Get the <code>JMSTopic</code> identified by a given name in the
+ * <code>JMSServer</code> JMS topics container.
+ *
+ * @param name the <code>JMSTopic</code> name.
+ * @return the <code>JMSTopic</code> found or null if not found.
+ */
+ public JMSTopic getJMSTopic( String name )
+ {
+ for ( Iterator jmsTopicIterator = this.getJMSTopics().iterator(); jmsTopicIterator.hasNext(); )
+ {
+ JMSTopic jmsTopic = (JMSTopic) jmsTopicIterator.next();
+ if ( jmsTopic.getName().equals( name ) )
+ {
+ return jmsTopic;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ JMSServer clone = new JMSServer();
+ clone.setName( this.getName() );
+ clone.setActive( this.isActive() );
+ clone.setBlocker( this.isBlocker() );
+ for ( Iterator jmsQueueIterator = this.jmsQueues.iterator(); jmsQueueIterator.hasNext(); )
+ {
+ JMSQueue jmsQueue = (JMSQueue) jmsQueueIterator.next();
+ clone.jmsQueues.add( (JMSQueue) jmsQueue.clone() );
+ }
+ for ( Iterator jmsTopicIterator = this.jmsTopics.iterator(); jmsTopicIterator.hasNext(); )
+ {
+ JMSTopic jmsTopic = (JMSTopic) jmsTopicIterator.next();
+ clone.jmsTopics.add( (JMSTopic) jmsTopic.clone() );
+ }
+ return clone;
+ }
+
+ /**
+ * Transform the <code>JMSServer</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "jmsserver" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
+ element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
+ // jmsqueues
+ ElementImpl jmsqueues = new ElementImpl( document, "jmsqueues" );
+ for ( Iterator jmsQueueIterator = this.getJMSQueues().iterator(); jmsQueueIterator.hasNext(); )
+ {
+ JMSQueue jmsQueue = (JMSQueue) jmsQueueIterator.next();
+ jmsqueues.appendChild( jmsQueue.toDOMElement( document ) );
+ }
+ element.appendChild( jmsqueues );
+ // jmstopics
+ ElementImpl jmstopics = new ElementImpl( document, "jmstopics" );
+ for ( Iterator jmsTopicIterator = this.getJMSTopics().iterator(); jmsTopicIterator.hasNext(); )
+ {
+ JMSTopic jmsTopic = (JMSTopic) jmsTopicIterator.next();
+ jmstopics.appendChild( jmsTopic.toDOMElement( document ) );
+ }
+ element.appendChild( jmstopics );
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherJMSServer )
+ {
+ return this.getName().compareTo( ( (JMSServer) anotherJMSServer ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JMSTopic.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JMSTopic.java
index cf1ed71..7e05d14 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JMSTopic.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JMSTopic.java
@@ -28,57 +28,57 @@
* Represent the <code>jmstopic</code> tag in the Kalumet configuration DOM.
*/
public class JMSTopic
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = -1602613331569475624L;
+ private static final long serialVersionUID = -1602613331569475624L;
- private String name;
+ private String name;
- public JMSTopic()
- {
- }
+ public JMSTopic()
+ {
+ }
- public String getName()
- {
- return this.name;
- }
+ public String getName()
+ {
+ return this.name;
+ }
- public void setName( String name )
- {
- this.name = name;
- }
+ public void setName( String name )
+ {
+ this.name = name;
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- JMSTopic clone = new JMSTopic();
- clone.setName( this.getName() );
- return clone;
- }
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ JMSTopic clone = new JMSTopic();
+ clone.setName( this.getName() );
+ return clone;
+ }
- /**
- * Transform the <code>JMSTopic</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "jmstopic" );
- element.setAttribute( "name", this.getName() );
- return element;
- }
+ /**
+ * Transform the <code>JMSTopic</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "jmstopic" );
+ element.setAttribute( "name", this.getName() );
+ return element;
+ }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherJMSTopic )
- {
- return this.getName().compareTo( ( (JMSTopic) anotherJMSTopic ).getName() );
- }
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherJMSTopic )
+ {
+ return this.getName().compareTo( ( (JMSTopic) anotherJMSTopic ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JNDIBinding.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JNDIBinding.java
index 6c054a0..f705317 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JNDIBinding.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/JNDIBinding.java
@@ -28,127 +28,127 @@
* Represent the <code>jndibinding</code> tag in the Kalumet configuration DOM.
*/
public class JNDIBinding
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = -2336476111740231781L;
+ private static final long serialVersionUID = -2336476111740231781L;
- private String name;
+ private String name;
- private String jndiname;
+ private String jndiname;
- private String jndialias;
+ private String jndialias;
- private String providerurl;
+ private String providerurl;
- private boolean active;
+ private boolean active;
- private boolean blocker;
+ private boolean blocker;
- public JNDIBinding()
- {
- }
+ public JNDIBinding()
+ {
+ }
- public String getName()
- {
- return this.name;
- }
+ public String getName()
+ {
+ return this.name;
+ }
- public void setName( String name )
- {
- this.name = name;
- }
+ public void setName( String name )
+ {
+ this.name = name;
+ }
- public String getJndiname()
- {
- return this.jndiname;
- }
+ public String getJndiname()
+ {
+ return this.jndiname;
+ }
- public void setJndiname( String jndiname )
- {
- this.jndiname = jndiname;
- }
+ public void setJndiname( String jndiname )
+ {
+ this.jndiname = jndiname;
+ }
- public String getJndialias()
- {
- return this.jndialias;
- }
+ public String getJndialias()
+ {
+ return this.jndialias;
+ }
- public void setJndialias( String jndialias )
- {
- this.jndialias = jndialias;
- }
+ public void setJndialias( String jndialias )
+ {
+ this.jndialias = jndialias;
+ }
- public String getProviderurl()
- {
- return this.providerurl;
- }
+ public String getProviderurl()
+ {
+ return this.providerurl;
+ }
- public void setProviderurl( String providerurl )
- {
- this.providerurl = providerurl;
- }
+ public void setProviderurl( String providerurl )
+ {
+ this.providerurl = providerurl;
+ }
- public boolean isActive()
- {
- return this.active;
- }
+ public boolean isActive()
+ {
+ return this.active;
+ }
- public void setActive( boolean active )
- {
- this.active = active;
- }
+ public void setActive( boolean active )
+ {
+ this.active = active;
+ }
- public boolean isBlocker()
- {
- return this.blocker;
- }
+ public boolean isBlocker()
+ {
+ return this.blocker;
+ }
- public void setBlocker( boolean blocker )
- {
- this.blocker = blocker;
- }
+ public void setBlocker( boolean blocker )
+ {
+ this.blocker = blocker;
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- JNDIBinding clone = new JNDIBinding();
- clone.setName( this.getName() );
- clone.setJndiname( this.getJndiname() );
- clone.setJndialias( this.getJndialias() );
- clone.setProviderurl( this.getProviderurl() );
- clone.setActive( this.isActive() );
- clone.setBlocker( this.isBlocker() );
- return clone;
- }
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ JNDIBinding clone = new JNDIBinding();
+ clone.setName( this.getName() );
+ clone.setJndiname( this.getJndiname() );
+ clone.setJndialias( this.getJndialias() );
+ clone.setProviderurl( this.getProviderurl() );
+ clone.setActive( this.isActive() );
+ clone.setBlocker( this.isBlocker() );
+ return clone;
+ }
- /**
- * Transform the <code>JNDIBinding</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "jndibinding" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "jndiname", this.getJndiname() );
- element.setAttribute( "jndialias", this.getJndialias() );
- element.setAttribute( "providerurl", this.getProviderurl() );
- element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
- element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
- return element;
- }
+ /**
+ * Transform the <code>JNDIBinding</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "jndibinding" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "jndiname", this.getJndiname() );
+ element.setAttribute( "jndialias", this.getJndialias() );
+ element.setAttribute( "providerurl", this.getProviderurl() );
+ element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
+ element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
+ return element;
+ }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherNameSpaceBinding )
- {
- return this.getName().compareTo( ( (JNDIBinding) anotherNameSpaceBinding ).getName() );
- }
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherNameSpaceBinding )
+ {
+ return this.getName().compareTo( ( (JNDIBinding) anotherNameSpaceBinding ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Kalumet.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Kalumet.java
index a5b0636..18c1e9b 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Kalumet.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Kalumet.java
@@ -40,968 +40,977 @@
* Represents the <code>kalumet</code> root tag in the main Kalumet DOM.
*/
public class Kalumet
- implements Serializable, Cloneable
+ implements Serializable, Cloneable
{
- private static final long serialVersionUID = -3237352886418250595L;
+ private static final long serialVersionUID = -3237352886418250595L;
- private static ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+ private static ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- private LinkedList properties;
+ private LinkedList properties;
- private Security security;
+ private Security security;
- private LinkedList agents;
+ private LinkedList agents;
- private LinkedList environments;
+ private LinkedList environments;
- public Kalumet()
- {
- this.properties = new LinkedList();
- this.security = new Security();
- this.agents = new LinkedList();
- this.environments = new LinkedList();
- }
-
- /**
- * Adds a new <code>Property</code> in the <code>Kalumet</code>
- * container.
- *
- * @param property the <code>Property</code> to add.
- */
- public void addProperty( Property property )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getProperty( property.getName() ) != null )
+ public Kalumet()
{
- throw new ModelObjectAlreadyExistsException( "Property name already exists in Kalumet configuration." );
+ this.properties = new LinkedList();
+ this.security = new Security();
+ this.agents = new LinkedList();
+ this.environments = new LinkedList();
}
- this.properties.add( property );
- }
- /**
- * Gets the <code>Property</code> list in the <code>Kalumet</code>
- * container.
- *
- * @return the <code>Property</code> list.
- */
- public List getProperties()
- {
- return this.properties;
- }
-
- /**
- * Overwrites the <code>Property</code> list in the <code>Kalumet</code>
- * container.
- *
- * @param properties the new <code>Property</code> list.
- */
- public void setProperties( LinkedList properties )
- {
- this.properties = properties;
- }
-
- /**
- * Get the <code>Property</code> identified by a given name in the
- * <code>Kalumet</code> container.
- *
- * @param name the <code>Property</code> name.
- * @return the found <code>Property</code> or null if no <code>Property</code> found.
- */
- public Property getProperty( String name )
- {
- for ( Iterator propertyIterator = this.getProperties().iterator(); propertyIterator.hasNext(); )
+ /**
+ * Adds a new <code>Property</code> in the <code>Kalumet</code>
+ * container.
+ *
+ * @param property the <code>Property</code> to add.
+ */
+ public void addProperty( Property property )
+ throws ModelObjectAlreadyExistsException
{
- Property property = (Property) propertyIterator.next();
- if ( property.getName().equals( name ) )
- {
- return property;
- }
+ if ( this.getProperty( property.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "Property name already exists in Kalumet configuration." );
+ }
+ this.properties.add( property );
}
- return null;
- }
- /**
- * Set the <code>Security</code> definition of the <code>Kalumet</code>
- * container.
- *
- * @param security the <code>Security</code> definition.
- */
- public void setSecurity( Security security )
- {
- this.security = security;
- }
-
- /**
- * Get the <code>Security</code> definition of the <code>Kalumet</code>
- * container.
- *
- * @return the <code>Security</code> definition.
- */
- public Security getSecurity()
- {
- return this.security;
- }
-
- /**
- * Add a new <code>Agent</code> in the <code>Kalumet</code> container.
- *
- * @param agent the <code>Agent</code> to add.
- */
- public void addAgent( Agent agent )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getAgent( agent.getId() ) != null )
+ /**
+ * Gets the <code>Property</code> list in the <code>Kalumet</code>
+ * container.
+ *
+ * @return the <code>Property</code> list.
+ */
+ public List getProperties()
{
- throw new ModelObjectAlreadyExistsException( "Agent id already exists in Kalumet configuration." );
+ return this.properties;
}
- this.agents.add( agent );
- }
- /**
- * Overwrite the <code>Agent</code> list in the <code>Kalumet</code>
- * container with a new list.
- *
- * @param agents the new <code>Agent</code> list.
- */
- public void setAgents( LinkedList agents )
- {
- this.agents = agents;
- }
-
- /**
- * Return the <code>Agent</code> list in the <code>Kalumet</code>
- * container.
- *
- * @return the <code>Agent</code> list.
- */
- public List getAgents()
- {
- return this.agents;
- }
-
- /**
- * Get the <code>Agent</code> identified by a given id in the
- * <code>Kalumet</code> container.
- *
- * @param id the <code>Agent</code> id.
- * @return the found <code>Agent</code> or null if no <code>Agent</code> found.
- */
- public Agent getAgent( String id )
- {
- for ( Iterator agentIterator = this.getAgents().iterator(); agentIterator.hasNext(); )
+ /**
+ * Overwrites the <code>Property</code> list in the <code>Kalumet</code>
+ * container.
+ *
+ * @param properties the new <code>Property</code> list.
+ */
+ public void setProperties( LinkedList properties )
{
- Agent agent = (Agent) agentIterator.next();
- if ( agent.getId().equals( id ) )
- {
- return agent;
- }
+ this.properties = properties;
}
- return null;
- }
- /**
- * Add a new <code>Environment</code> to the <code>Kalumet</code>
- * container.
- *
- * @param environment the <code>Environment</code> to add.
- */
- public void addEnvironment( Environment environment )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getEnvironment( environment.getName() ) != null )
+ /**
+ * Get the <code>Property</code> identified by a given name in the
+ * <code>Kalumet</code> container.
+ *
+ * @param name the <code>Property</code> name.
+ * @return the found <code>Property</code> or null if no <code>Property</code> found.
+ */
+ public Property getProperty( String name )
{
- throw new ModelObjectAlreadyExistsException( "Environment name already exists in Kalumet configuration." );
+ for ( Iterator propertyIterator = this.getProperties().iterator(); propertyIterator.hasNext(); )
+ {
+ Property property = (Property) propertyIterator.next();
+ if ( property.getName().equals( name ) )
+ {
+ return property;
+ }
+ }
+ return null;
}
- this.environments.add( environment );
- }
- /**
- * Get the <code>Environment</code> list in the <code>Kalumet</code>
- * container.
- *
- * @return the <code>Environment</code> list.
- */
- public List getEnvironments()
- {
- return this.environments;
- }
-
- /**
- * Overwrite the <code>Environment</code> list in the
- * <code>Kalumet</code> container.
- *
- * @param environments the new <code>Environment</code> list.
- */
- public void setEnvironments( LinkedList environments )
- {
- this.environments = environments;
- }
-
- /**
- * Get the <code>Environment</code> identified by the given name in the
- * <code>Kalumet</code> container.
- *
- * @param name the <code>Environment</code> name.
- * @return the found <code>Environment</code> or null if no <code>Environment</code> found.
- */
- public Environment getEnvironment( String name )
- {
- for ( Iterator environmentIterator = this.getEnvironments().iterator(); environmentIterator.hasNext(); )
+ /**
+ * Set the <code>Security</code> definition of the <code>Kalumet</code>
+ * container.
+ *
+ * @param security the <code>Security</code> definition.
+ */
+ public void setSecurity( Security security )
{
- Environment environment = (Environment) environmentIterator.next();
- if ( environment.getName().equals( name ) )
- {
- return environment;
- }
+ this.security = security;
}
- return null;
- }
- /**
- * Get the <code>Environment</code> map order by group.
- *
- * @return the groups/environments map.
- */
- public Map getEnvironmentsByGroups()
- {
- HashMap map = new HashMap();
- for ( Iterator environmentIterator = environments.iterator(); environmentIterator.hasNext(); )
+ /**
+ * Get the <code>Security</code> definition of the <code>Kalumet</code>
+ * container.
+ *
+ * @return the <code>Security</code> definition.
+ */
+ public Security getSecurity()
{
- Environment current = (Environment) environmentIterator.next();
- if ( !map.containsKey( current.getGroup() ) )
- {
- map.put( current.getGroup(), new LinkedList() );
- }
- ( (List) map.get( current.getGroup() ) ).add( current );
+ return this.security;
}
- return map;
- }
- /**
- * Get the <code>Environment</code> list for a given <code>User</code> id.
- *
- * @param userid the <code>User</code> id.
- * @return the <code>Environment</code> list of the user.
- */
- public List getUserEnvironments( String userid )
- {
- LinkedList userEnvironments = new LinkedList();
- Security security = this.getSecurity();
- for ( Iterator environmentIterator = this.getEnvironments().iterator(); environmentIterator.hasNext(); )
+ /**
+ * Add a new <code>Agent</code> in the <code>Kalumet</code> container.
+ *
+ * @param agent the <code>Agent</code> to add.
+ */
+ public void addAgent( Agent agent )
+ throws ModelObjectAlreadyExistsException
{
- Environment environment = (Environment) environmentIterator.next();
- if ( security.checkEnvironmentUserAccess( environment, userid, null ) )
- {
- userEnvironments.add( environment );
- }
+ if ( this.getAgent( agent.getId() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "Agent id already exists in Kalumet configuration." );
+ }
+ this.agents.add( agent );
}
- return userEnvironments;
- }
- /**
- * Get the <code>Environment</code> user map order by group.
- *
- * @param userid the <code>User</code> id.
- * @return the groups/environments user map.
- */
- public Map getUserEnvironmentsByGroups( String userid )
- {
- HashMap map = new HashMap();
- for ( Iterator userEnvironmentIterator = this.getUserEnvironments( userid ).iterator();
- userEnvironmentIterator.hasNext(); )
+ /**
+ * Overwrite the <code>Agent</code> list in the <code>Kalumet</code>
+ * container with a new list.
+ *
+ * @param agents the new <code>Agent</code> list.
+ */
+ public void setAgents( LinkedList agents )
{
- Environment environment = (Environment) userEnvironmentIterator.next();
- if ( !map.containsKey( environment.getGroup() ) )
- {
- map.put( environment.getGroup(), new LinkedList() );
- }
- ( (List) map.get( environment.getGroup() ) ).add( environment );
+ this.agents = agents;
}
- return map;
- }
- /**
- * Get the <code>Environment</code> list for a given <code>Agent</code> id.
- *
- * @param id the <code>Agent</code> id.
- * @return the <code>Environment</code> list managed by the <code>Agent</code>.
- */
- public List getEnvironmentsByAgent( String id )
- {
- LinkedList list = new LinkedList();
- for ( Iterator environmentIterator = this.getEnvironments().iterator(); environmentIterator.hasNext(); )
+ /**
+ * Return the <code>Agent</code> list in the <code>Kalumet</code>
+ * container.
+ *
+ * @return the <code>Agent</code> list.
+ */
+ public List getAgents()
{
- Environment current = (Environment) environmentIterator.next();
- if ( current.getAgent().equals( id ) )
- {
- list.add( current );
- }
+ return this.agents;
}
- return list;
- }
- /**
- * Digeste a given XML file and return the main kalumet root tag.
- *
- * @param path the Kalumet XML file to parse.
- * @return the main <code>Kalumet</code> corresponding with the root tag.
- */
- public static Kalumet digeste( String path )
- throws KalumetException
- {
- if ( !path.startsWith( "http:" ) && !path.startsWith( "HTTP:" ) && !path.startsWith( "file:" ) && !path.startsWith(
- "FILE:" ) )
+ /**
+ * Get the <code>Agent</code> identified by a given id in the
+ * <code>Kalumet</code> container.
+ *
+ * @param id the <code>Agent</code> id.
+ * @return the found <code>Agent</code> or null if no <code>Agent</code> found.
+ */
+ public Agent getAgent( String id )
{
- path = "file:" + path;
+ for ( Iterator agentIterator = this.getAgents().iterator(); agentIterator.hasNext(); )
+ {
+ Agent agent = (Agent) agentIterator.next();
+ if ( agent.getId().equals( id ) )
+ {
+ return agent;
+ }
+ }
+ return null;
}
- Kalumet kalumet = null;
- try
+
+ /**
+ * Add a new <code>Environment</code> to the <code>Kalumet</code>
+ * container.
+ *
+ * @param environment the <code>Environment</code> to add.
+ */
+ public void addEnvironment( Environment environment )
+ throws ModelObjectAlreadyExistsException
{
- lock.readLock().lock();
-
- // init the digester with no validation on the XML file (no DTD)
- Digester digester = new Digester();
- digester.setValidating( false );
-
- // kalumet tag rules
- digester.addObjectCreate( "kalumet", "org.apache.kalumet.model.Kalumet" );
- digester.addSetProperties( "kalumet" );
-
- // properties/property tag rules
- digester.addObjectCreate( "kalumet/properties/property", "org.apache.kalumet.model.Property" );
- digester.addSetProperties( "kalumet/properties/property" );
-
- // add property in the kalumet tag rule
- digester.addSetNext( "kalumet/properties/property", "addProperty", "org.apache.kalumet.model.Property" );
-
- // security tag rules
- digester.addObjectCreate( "kalumet/security", "org.apache.kalumet.model.Security" );
- digester.addSetProperties( "kalumet/security" );
-
- // user tag rules
- digester.addObjectCreate( "kalumet/security/users/user", "org.apache.kalumet.model.User" );
- digester.addSetProperties( "kalumet/security/users/user" );
-
- // add user to security tag rule
- digester.addSetNext( "kalumet/security/users/user", "addUser", "org.apache.kalumet.model.User" );
-
- // group tag rules
- digester.addObjectCreate( "kalumet/security/groups/group", "org.apache.kalumet.model.Group" );
- digester.addSetProperties( "kalumet/security/groups/group" );
-
- // user group tag rules
- digester.addObjectCreate( "kalumet/security/groups/group/users/user", "org.apache.kalumet.model.User" );
- digester.addSetProperties( "kalumet/security/groups/group/users/user" );
-
- // add user in group tag rule
- digester.addSetNext( "kalumet/security/groups/group/users/user", "addUser", "org.apache.kalumet.model.User" );
-
- // add group to security tag rule
- digester.addSetNext( "kalumet/security/groups/group", "addGroup", "org.apache.kalumet.model.Group" );
-
- // add security to kalumet tag rule
- digester.addSetNext( "kalumet/security", "setSecurity", "org.apache.kalumet.model.Security" );
-
- // agent tag rules
- digester.addObjectCreate( "kalumet/agents/agent", "org.apache.kalumet.model.Agent" );
- digester.addSetProperties( "kalumet/agents/agent" );
-
- // add agent to kalumet tag rule
- digester.addSetNext( "kalumet/agents/agent", "addAgent", "org.apache.kalumet.model.Agent" );
-
- // environment tag rules
- digester.addObjectCreate( "kalumet/environments/environment", "org.apache.kalumet.model.Environment" );
- digester.addSetProperties( "kalumet/environments/environment" );
-
- // variables tag rules
- digester.addObjectCreate( "kalumet/environments/environment/variables/variable",
- "org.apache.kalumet.model.Variable" );
- digester.addSetProperties( "kalumet/environments/environment/variables/variable" );
-
- // add variable to environment tag rule
- digester.addSetNext( "kalumet/environments/environment/variables/variable", "addVariable",
- "org.apache.kalumet.model.Variable" );
-
- // freefield tag rules
- digester.addObjectCreate( "kalumet/environments/environment/freefields/freefield",
- "org.apache.kalumet.model.FreeField" );
- digester.addSetProperties( "kalumet/environments/environment/freefields/freefield" );
- // add freefield content
- digester.addCallMethod( "kalumet/environments/environment/freefields/freefield", "setContent", 0 );
-
- // add freefield to environment tag rule
- digester.addSetNext( "kalumet/environments/environment/freefields/freefield", "addFreeField",
- "org.apache.kalumet.model.FreeField" );
-
- // access tag rules
- digester.addObjectCreate( "kalumet/environments/environment/accesses/access", "org.apache.kalumet.model.Access" );
- digester.addSetProperties( "kalumet/environments/environment/accesses/access" );
-
- // access properties rules
- digester.addObjectCreate( "kalumet/environments/environment/accesses/access/properties/property",
- "org.apache.kalumet.model.Property" );
- digester.addSetProperties( "kalumet/environments/environment/accesses/access/properties/property" );
-
- // add property in access tag rule
- digester.addSetNext( "kalumet/environments/environment/accesses/access/properties/property", "addProperty",
- "org.apache.kalumet.model.Property" );
-
- // add access to environment tag rule
- digester.addSetNext( "kalumet/environments/environment/accesses/access", "addAccess",
- "org.apache.kalumet.model.Access" );
-
- // environment notes and weblinks tag rules
- digester.addCallMethod( "kalumet/environments/environment/notes", "setNotes", 0 );
- digester.addCallMethod( "kalumet/environments/environment/weblinks", "setWeblinks", 0 );
-
- // jeeapplicationservers tag rules
- digester.addObjectCreate( "kalumet/environments/environment/jeeapplicationservers",
- "org.apache.kalumet.model.JEEApplicationServers" );
- digester.addSetProperties( "kalumet/environments/environment/jeeapplicationservers" );
-
- // jeeapplicationserver tag rules
- digester.addObjectCreate( "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver",
- "org.apache.kalumet.model.JEEApplicationServer" );
- digester.addSetProperties( "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver" );
-
- // jeeapplicationserver startupcommand and shutdowncommand tag rules
- digester.addCallMethod(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/startupcommand",
- "setStartupcommand", 0 );
- digester.addCallMethod(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/shutdowncommand",
- "setShutdowncommand", 0 );
-
- // jdbcconnectionpool tag rules
- digester.addObjectCreate(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jdbcconnectionpools/jdbcconnectionpool",
- "org.apache.kalumet.model.JDBCConnectionPool" );
- digester.addSetProperties(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jdbcconnectionpools/jdbcconnectionpool" );
-
- // add jdbcconnectionpool to jeeapplicationserver
- digester.addSetNext(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jdbcconnectionpools/jdbcconnectionpool",
- "addJDBCConnectionPool", "org.apache.kalumet.model.JDBCConnectionPool" );
-
- // jdbcdatasource tag rules
- digester.addObjectCreate(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jdbcdatasources/jdbcdatasource",
- "org.apache.kalumet.model.JDBCDataSource" );
- digester.addSetProperties(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jdbcdatasources/jdbcdatasource" );
-
- // add jdbcdatasource to jeeapplicationserver
- digester.addSetNext(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jdbcdatasources/jdbcdatasource",
- "addJDBCDataSource", "org.apache.kalumet.model.JDBCDataSource" );
-
- // jmsconnectionfactory tag rules
- digester.addObjectCreate(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsconnectionfactories/jmsconnectionfactory",
- "org.apache.kalumet.model.JMSConnectionFactory" );
- digester.addSetProperties(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsconnectionfactories/jmsconnectionfactory" );
-
- // add jmsconnectionfactory to jeeapplicationserver
- digester.addSetNext(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsconnectionfactories/jmsconnectionfactory",
- "addJMSConnectionFactory", "org.apache.kalumet.model.JMSConnectionFactory" );
-
- // jmsserver tag rules
- digester.addObjectCreate(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsservers/jmsserver",
- "org.apache.kalumet.model.JMSServer" );
- digester.addSetProperties(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsservers/jmsserver" );
-
- // jmsqueue tag rules
- digester.addObjectCreate(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsservers/jmsserver/jmsqueues/jmsqueue",
- "org.apache.kalumet.model.JMSQueue" );
- digester.addSetProperties(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsservers/jmsserver/jmsqueues/jmsqueue" );
-
- // add jmsqueue to jmsserver
- digester.addSetNext(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsservers/jmsserver/jmsqueues/jmsqueue",
- "addJMSQueue", "org.apache.kalumet.model.JMSQueue" );
-
- // jmstopic tag rules
- digester.addObjectCreate(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsservers/jmsserver/jmstopics/jmstopic",
- "org.apache.kalumet.model.JMSTopic" );
- digester.addSetProperties(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsservers/jmsserver/jmstopics/jmstopic" );
-
- // add jmstopic to jmsserver
- digester.addSetNext(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsservers/jmsserver/jmstopics/jmstopic",
- "addJMSTopic", "org.apache.kalumet.model.JMSTopic" );
-
- // add jmsserver to jeeapplicationserver
- digester.addSetNext(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsservers/jmsserver",
- "addJMSServer", "org.apache.kalumet.model.JMSServer" );
-
- // jndibinding tag rules
- digester.addObjectCreate(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jndibindings/jndibinding",
- "org.apache.kalumet.model.JNDIBinding" );
- digester.addSetProperties(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jndibindings/jndibinding" );
-
- // add jndibinding to jeeapplicationserver
- digester.addSetNext(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jndibindings/jndibinding",
- "addJNDIBinding", "org.apache.kalumet.model.JNDIBinding" );
-
- // sharedlibrary tag rules
- digester.addObjectCreate(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/sharedlibrairies/sharedlibrary",
- "org.apache.kalumet.model.SharedLibrary" );
- digester.addSetProperties(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/sharedlibrairies/sharedlibrary" );
-
- // add sharedlibrary to jeeapplicationserver
- digester.addSetNext(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/sharedlibrairies/sharedlibrary",
- "addSharedLibrary", "org.apache.kalumet.model.SharedLibrary" );
-
- // application tag rules
- digester.addObjectCreate(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication",
- "org.apache.kalumet.model.JEEApplication" );
- digester.addSetProperties(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication" );
-
- // archive tag rules
- digester.addObjectCreate(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/archives/archive",
- "org.apache.kalumet.model.Archive" );
- digester.addSetProperties(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/archives/archive" );
-
- // add archive archive to application
- digester.addSetNext(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/archives/archive",
- "addArchive", "org.apache.kalumet.model.Archive" );
-
- // contentmanager tag rules
- digester.addObjectCreate(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/contentmanagers/contentmanager",
- "org.apache.kalumet.model.ContentManager" );
- digester.addSetProperties(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/contentmanagers/contentmanager" );
-
- // contentmanager property tag rules
- digester.addObjectCreate(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/contentmanagers/contentmanager/properties/property",
- "org.apache.kalumet.model.Property" );
- digester.addSetProperties(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/contentmanagers/contentmanager/properties/property" );
-
- // add property in contentmanager
- digester.addSetNext(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/contentmanagers/contentmanager/properties/property",
- "addProperty", "org.apache.kalumet.model.Property" );
-
- // add contentmanager to application
- digester.addSetNext(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/contentmanagers/contentmanager",
- "addContentManager", "org.apache.kalumet.model.ContentManager" );
-
- // configurationfile tag rules
- digester.addObjectCreate(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/configurationfiles/configurationfile",
- "org.apache.kalumet.model.ConfigurationFile" );
- digester.addSetProperties(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/configurationfiles/configurationfile" );
-
- // mapping tag rules
- digester.addObjectCreate(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/configurationfiles/configurationfile/mappings/mapping",
- "org.apache.kalumet.model.Mapping" );
- digester.addSetProperties(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/configurationfiles/configurationfile/mappings/mapping" );
-
- // add mapping to configurationfile
- digester.addSetNext(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/configurationfiles/configurationfile/mappings/mapping",
- "addMapping", "org.apache.kalumet.model.Mapping" );
-
- // add configurationfile to application
- digester.addSetNext(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/configurationfiles/configurationfile",
- "addConfigurationFile", "org.apache.kalumet.model.ConfigurationFile" );
-
- // database tag rules
- digester.addObjectCreate(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/databases/database",
- "org.apache.kalumet.model.Database" );
- digester.addSetProperties(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/databases/database" );
-
- // sqlscript tag rules
- digester.addObjectCreate(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/databases/database/sqlscripts/sqlscript",
- "org.apache.kalumet.model.SqlScript" );
- digester.addSetProperties(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/databases/database/sqlscripts/sqlscript" );
-
- // sqlscript mapping tag rules
- digester.addObjectCreate(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/databases/database/sqlscripts/sqlscript/mappings/mapping",
- "org.apache.kalumet.model.Mapping" );
- digester.addSetProperties(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/databases/database/sqlscripts/sqlscript/mappings/mapping" );
-
- // add mapping to sqlscript
- digester.addSetNext(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/databases/database/sqlscripts/sqlscript/mappings/mapping",
- "addMapping", "org.apache.kalumet.model.Mapping" );
-
- // add sqlscript to database
- digester.addSetNext(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/databases/database/sqlscripts/sqlscript",
- "addSqlScript", "org.apache.kalumet.model.SqlScript" );
-
- // add database to application
- digester.addSetNext(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/databases/database",
- "addDatabase", "org.apache.kalumet.model.Database" );
-
- // add application to applicationserver
- digester.addSetNext(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/application",
- "addApplication", "org.apache.kalumet.model.JEEApplication" );
-
- // cache tag rules
- digester.addObjectCreate(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/caches/cache",
- "org.apache.kalumet.model.Cache" );
- digester.addSetProperties(
- "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/caches/cache" );
-
- // add cache to applicationserver
- digester.addSetNext( "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/caches/cache",
- "addCache", "org.apache.kalumet.model.Cache" );
-
- // add applicationserver to applicationservers tag rule
- digester.addSetNext( "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver",
- "addJEEApplicationServer", "org.apache.kalumet.model.JEEApplicationServer" );
-
- // add applicationservers to environment tag rule
- digester.addSetNext( "kalumet/environments/environment/jeeapplicationservers", "setJEEApplicationServers",
- "org.apache.kalumet.model.JEEApplicationServers" );
-
- // logfile tag rules
- digester.addObjectCreate( "kalumet/environments/environment/logfiles/logfile",
- "org.apache.kalumet.model.LogFile" );
- digester.addSetProperties( "kalumet/environments/environment/logfiles/logfile" );
-
- // add logfile to environment tag rule
- digester.addSetNext( "kalumet/environments/environment/logfiles/logfile", "addLogFile",
- "org.apache.kalumet.model.LogFile" );
-
- // software tag rules
- digester.addObjectCreate( "kalumet/environments/environment/softwares/software",
- "org.apache.kalumet.model.Software" );
- digester.addSetProperties( "kalumet/environments/environment/softwares/software" );
-
- // software update plan command item
- digester.addObjectCreate( "kalumet/environments/environment/softwares/software/updateplan/command",
- "org.apache.kalumet.model.Command" );
- digester.addSetProperties( "kalumet/environments/environment/softwares/software/updateplan/command" );
- digester.addCallMethod( "kalumet/environments/environment/softwares/software/updateplan/command", "setCommand",
- 0 );
- digester.addSetNext( "kalumet/environments/environment/softwares/software/updateplan/command", "addCommand",
- "org.apache.kalumet.model.Command" );
-
- // software update plan location item
- digester.addObjectCreate( "kalumet/environments/environment/softwares/software/updateplan/location",
- "org.apache.kalumet.model.Location" );
- digester.addSetProperties( "kalumet/environments/environment/softwares/software/updateplan/location" );
- digester.addSetNext( "kalumet/environments/environment/softwares/software/updateplan/location", "addLocation",
- "org.apache.kalumet.model.Location" );
-
- // software update plan configuration file item
- digester.addObjectCreate( "kalumet/environments/environment/softwares/software/updateplan/configurationfile",
- "org.apache.kalumet.model.ConfigurationFile" );
- digester.addSetProperties( "kalumet/environments/environment/softwares/software/updateplan/configurationfile" );
- digester.addObjectCreate(
- "kalumet/environments/environment/softwares/software/updateplan/configurationfile/mappings/mapping",
- "org.apache.kalumet.model.Mapping" );
- digester.addSetProperties(
- "kalumet/environments/environment/softwares/software/updateplan/configurationfile/mappings/mapping" );
- digester.addSetNext(
- "kalumet/environments/environment/softwares/software/updateplan/configurationfile/mappings/mapping",
- "addMapping", "org.apache.kalumet.model.Mapping" );
- digester.addSetNext( "kalumet/environments/environment/softwares/software/updateplan/configurationfile",
- "addConfigurationFile", "org.apache.kalumet.model.ConfigurationFile" );
-
- // software update plan database item
- digester.addObjectCreate( "kalumet/environments/environment/softwares/software/updateplan/database",
- "org.apache.kalumet.model.Database" );
- digester.addSetProperties( "kalumet/environments/environment/softwares/software/updateplan/database" );
- digester.addObjectCreate(
- "kalumet/environments/environment/softwares/software/updateplan/database/sqlscripts/sqlscript",
- "org.apache.kalumet.model.SqlScript" );
- digester.addSetProperties(
- "kalumet/environments/environment/softwares/software/updateplan/database/sqlscripts/sqlscript" );
- digester.addObjectCreate(
- "kalumet/environments/environment/softwares/software/updateplan/database/sqlscripts/sqlscript/mappings/mapping",
- "org.apache.kalumet.model.Mapping" );
- digester.addSetProperties(
- "kalumet/environments/environment/softwares/software/updateplan/database/sqlscripts/sqlscript/mappings/mapping" );
- digester.addSetNext(
- "kalumet/environments/environment/softwares/software/updateplan/database/sqlscripts/sqlscript/mappings/mapping",
- "addMapping", "org.apache.kalumet.model.Mapping" );
- digester.addSetNext(
- "kalumet/environments/environment/softwares/software/updateplan/database/sqlscripts/sqlscript", "addSqlScript",
- "org.apache.kalumet.model.SqlScript" );
- digester.addSetNext( "kalumet/environments/environment/softwares/software/updateplan/database", "addDatabase",
- "org.apache.kalumet.model.Database" );
-
- // add software to environment
- digester.addSetNext( "kalumet/environments/environment/softwares/software", "addSoftware",
- "org.apache.kalumet.model.Software" );
-
- // notifiers tag rules
- digester.addObjectCreate( "kalumet/environments/environment/notifiers", "org.apache.kalumet.model.Notifiers" );
- digester.addSetProperties( "kalumet/environments/environment/notifiers" );
-
- // email tag rules
- digester.addObjectCreate( "kalumet/environments/environment/notifiers/email", "org.apache.kalumet.model.Email" );
- digester.addSetProperties( "kalumet/environments/environment/notifiers/email" );
-
- // destination tag rules
- digester.addObjectCreate( "kalumet/environments/environment/notifiers/email/destinations/destination",
- "org.apache.kalumet.model.Destination" );
- digester.addSetProperties( "kalumet/environments/environment/notifiers/email/destinations/destination" );
-
- // add destination to email notifier
- digester.addSetNext( "kalumet/environments/environment/notifiers/email/destinations/destination",
- "addDestination", "org.apache.kalumet.model.Destination" );
-
- // add email to notifiers
- digester.addSetNext( "kalumet/environments/environment/notifiers/email", "addNotifier",
- "org.apache.kalumet.model.Email" );
-
- // add notifiers to environment
- digester.addSetNext( "kalumet/environments/environment/notifiers", "setNotifiers",
- "org.apache.kalumet.model.Notifiers" );
-
- // email publisher tag rules
- digester.addObjectCreate( "kalumet/environments/environment/publishers/email", "org.apache.kalumet.model.Email" );
- digester.addSetProperties( "kalumet/environments/environment/publishers/email" );
-
- // destination email publisher tag rules
- digester.addObjectCreate( "kalumet/environments/environment/publishers/email/destinations/destination",
- "org.apache.kalumet.model.Destination" );
- digester.addSetProperties( "kalumet/environments/environment/publishers/email/destinations/destination" );
-
- // add destination to email publisher
- digester.addSetNext( "kalumet/environments/environment/publishers/email/destinations/destination",
- "addDestination", "org.apache.kalumet.model.Destination" );
-
- // add email publisher to environment
- digester.addSetNext( "kalumet/environments/environment/publishers/email", "addPublisher",
- "org.apache.kalumet.model.Email" );
-
- // statistics tag rules
- digester.addObjectCreate( "kalumet/environments/environment/statistics", "org.apache.kalumet.model.Statistics" );
- digester.addSetProperties( "kalumet/environments/environment/statistics" );
-
- // add statistics to environment
- digester.addSetNext( "kalumet/environments/environment/statistics", "setStatistics",
- "org.apache.kalumet.model.Statistics" );
-
- // add environment to kalumet tag rule
- digester.addSetNext( "kalumet/environments/environment", "addEnvironment",
- "org.apache.kalumet.model.Environment" );
-
- // parse the XML file
- kalumet = (Kalumet) digester.parse( path );
+ if ( this.getEnvironment( environment.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "Environment name already exists in Kalumet configuration." );
+ }
+ this.environments.add( environment );
}
- catch ( Exception e )
+
+ /**
+ * Get the <code>Environment</code> list in the <code>Kalumet</code>
+ * container.
+ *
+ * @return the <code>Environment</code> list.
+ */
+ public List getEnvironments()
{
- throw new KalumetException( "Can't read Kalumet configuration.", e );
+ return this.environments;
}
- finally
- {
- lock.readLock().unlock();
- }
- return kalumet;
- }
- /**
- * Transform the <code>Kalumet</code> POJO to a DOM Element.
- *
- * @param document the XML core document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "kalumet" );
- // properties element
- ElementImpl properties = new ElementImpl( document, "properties" );
- // add property in properties container
- for ( Iterator propertyIterator = this.getProperties().iterator(); propertyIterator.hasNext(); )
+ /**
+ * Overwrite the <code>Environment</code> list in the
+ * <code>Kalumet</code> container.
+ *
+ * @param environments the new <code>Environment</code> list.
+ */
+ public void setEnvironments( LinkedList environments )
{
- Property property = (Property) propertyIterator.next();
- properties.appendChild( property.toDOMElement( document ) );
+ this.environments = environments;
}
- // add properties in kalumet
- element.appendChild( properties );
- // add security in kalumet
- element.appendChild( this.getSecurity().toDOMElement( document ) );
- // agents element
- ElementImpl agents = new ElementImpl( document, "agents" );
- // add agent in agents container
- for ( Iterator agentIterator = this.getAgents().iterator(); agentIterator.hasNext(); )
- {
- Agent agent = (Agent) agentIterator.next();
- agents.appendChild( agent.toDOMElement( document ) );
- }
- // add agents in kalumet
- element.appendChild( agents );
- // environments element
- ElementImpl environments = new ElementImpl( document, "environments" );
- // add environment in environments container
- for ( Iterator environmentIterator = this.getEnvironments().iterator(); environmentIterator.hasNext(); )
- {
- Environment environment = (Environment) environmentIterator.next();
- environments.appendChild( environment.toDOMElement( document ) );
- }
- // add environments in kalumet
- element.appendChild( environments );
- return element;
- }
- /*
- * (non-Javadoc)
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- Kalumet clone = new Kalumet();
- for ( Iterator propertyIterator = this.properties.iterator(); propertyIterator.hasNext(); )
+ /**
+ * Get the <code>Environment</code> identified by the given name in the
+ * <code>Kalumet</code> container.
+ *
+ * @param name the <code>Environment</code> name.
+ * @return the found <code>Environment</code> or null if no <code>Environment</code> found.
+ */
+ public Environment getEnvironment( String name )
{
- Property property = (Property) propertyIterator.next();
- clone.properties.add( (Property) property.clone() );
+ for ( Iterator environmentIterator = this.getEnvironments().iterator(); environmentIterator.hasNext(); )
+ {
+ Environment environment = (Environment) environmentIterator.next();
+ if ( environment.getName().equals( name ) )
+ {
+ return environment;
+ }
+ }
+ return null;
}
- clone.setSecurity( (Security) this.getSecurity().clone() );
- for ( Iterator agentIterator = this.agents.iterator(); agentIterator.hasNext(); )
- {
- Agent agent = (Agent) agentIterator.next();
- clone.agents.add( (Agent) agent.clone() );
- }
- for ( Iterator environmentIterator = this.environments.iterator(); environmentIterator.hasNext(); )
- {
- Environment environment = (Environment) environmentIterator.next();
- clone.environments.add( (Environment) environment.clone() );
- }
- return clone;
- }
- /**
- * Write a Kalumet XML file with the content of the in-memory
- * configuration.
- *
- * @param path the path to the file to write.
- * @param backup a flag indicated if a previous backup must be copied before writing.
- */
- public synchronized void writeXMLFile( String path, boolean backup )
- throws KalumetException
- {
- if ( backup )
+ /**
+ * Get the <code>Environment</code> map order by group.
+ *
+ * @return the groups/environments map.
+ */
+ public Map getEnvironmentsByGroups()
{
- this.backupXMLFile( path );
+ HashMap map = new HashMap();
+ for ( Iterator environmentIterator = environments.iterator(); environmentIterator.hasNext(); )
+ {
+ Environment current = (Environment) environmentIterator.next();
+ if ( !map.containsKey( current.getGroup() ) )
+ {
+ map.put( current.getGroup(), new LinkedList() );
+ }
+ ( (List) map.get( current.getGroup() ) ).add( current );
+ }
+ return map;
}
- try
- {
- lock.writeLock().lock();
- OutputFormat format = new OutputFormat();
- format.setLineWidth( 72 );
- format.setIndenting( true );
- format.setIndent( 3 );
- format.setEncoding( "ISO-8859-1" );
- if ( path.startsWith( "http:" ) || path.startsWith( "http:" ) )
- {
- throw new KalumetException( "Can't write Kalumet XML file over a HTTP URL." );
- }
- if ( path.startsWith( "file:" ) || path.startsWith( "FILE:" ) )
- {
- path = path.substring( 5 );
- }
- XMLSerializer serializer = new XMLSerializer( new FileOutputStream( path ), format );
- serializer.serialize( this.toDOMElement( new CoreDocumentImpl( true ) ) );
- }
- catch ( Exception e )
- {
- throw new KalumetException( "Can't write Kalumet XML file.", e );
- }
- finally
- {
- lock.writeLock().unlock();
- }
- }
- /**
- * Write a Kalumet XML file with the content of the in-memory
- * configuration.
- *
- * @param path the path to the file to write.
- */
- public void writeXMLFile( String path )
- throws KalumetException
- {
- this.writeXMLFile( path, false );
- }
-
- /**
- * Make a backup of the old Kalumet XML configuration to avoid file
- * corruption (for example when disk full).
- *
- * @param path the path to the Kalumet XML file.
- */
- public void backupXMLFile( String path )
- throws KalumetException
- {
- FileManipulator fileManipulator = null;
- try
+ /**
+ * Get the <code>Environment</code> list for a given <code>User</code> id.
+ *
+ * @param userid the <code>User</code> id.
+ * @return the <code>Environment</code> list of the user.
+ */
+ public List getUserEnvironments( String userid )
{
- fileManipulator = new FileManipulator();
- fileManipulator.copy( path, path + ".backup" );
+ LinkedList userEnvironments = new LinkedList();
+ Security security = this.getSecurity();
+ for ( Iterator environmentIterator = this.getEnvironments().iterator(); environmentIterator.hasNext(); )
+ {
+ Environment environment = (Environment) environmentIterator.next();
+ if ( security.checkEnvironmentUserAccess( environment, userid, null ) )
+ {
+ userEnvironments.add( environment );
+ }
+ }
+ return userEnvironments;
}
- finally
- {
- if ( fileManipulator != null )
- {
- fileManipulator.close();
- }
- }
- }
- public static void writeDefault( String path )
- throws KalumetException
- {
- Kalumet kalumet = new Kalumet();
- Security security = kalumet.getSecurity();
- User adminUser = new User();
- adminUser.setId( "admin" );
- adminUser.setName( "admin" );
- adminUser.setPassword( "21232f297a57a5a743894a0e4a801fc3" );
- Group adminGroup = new Group();
- adminGroup.setId( "admin" );
- adminGroup.setName( "admin" );
- adminGroup.addUser( adminUser );
- security.addGroup( adminGroup );
- security.addUser( adminUser );
- kalumet.writeXMLFile( path );
- }
+ /**
+ * Get the <code>Environment</code> user map order by group.
+ *
+ * @param userid the <code>User</code> id.
+ * @return the groups/environments user map.
+ */
+ public Map getUserEnvironmentsByGroups( String userid )
+ {
+ HashMap map = new HashMap();
+ for ( Iterator userEnvironmentIterator = this.getUserEnvironments( userid ).iterator();
+ userEnvironmentIterator.hasNext(); )
+ {
+ Environment environment = (Environment) userEnvironmentIterator.next();
+ if ( !map.containsKey( environment.getGroup() ) )
+ {
+ map.put( environment.getGroup(), new LinkedList() );
+ }
+ ( (List) map.get( environment.getGroup() ) ).add( environment );
+ }
+ return map;
+ }
+
+ /**
+ * Get the <code>Environment</code> list for a given <code>Agent</code> id.
+ *
+ * @param id the <code>Agent</code> id.
+ * @return the <code>Environment</code> list managed by the <code>Agent</code>.
+ */
+ public List getEnvironmentsByAgent( String id )
+ {
+ LinkedList list = new LinkedList();
+ for ( Iterator environmentIterator = this.getEnvironments().iterator(); environmentIterator.hasNext(); )
+ {
+ Environment current = (Environment) environmentIterator.next();
+ if ( current.getAgent().equals( id ) )
+ {
+ list.add( current );
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Digeste a given XML file and return the main kalumet root tag.
+ *
+ * @param path the Kalumet XML file to parse.
+ * @return the main <code>Kalumet</code> corresponding with the root tag.
+ */
+ public static Kalumet digeste( String path )
+ throws KalumetException
+ {
+ if ( !path.startsWith( "http:" ) && !path.startsWith( "HTTP:" ) && !path.startsWith( "file:" )
+ && !path.startsWith( "FILE:" ) )
+ {
+ path = "file:" + path;
+ }
+ Kalumet kalumet = null;
+ try
+ {
+ lock.readLock().lock();
+
+ // init the digester with no validation on the XML file (no DTD)
+ Digester digester = new Digester();
+ digester.setValidating( false );
+
+ // kalumet tag rules
+ digester.addObjectCreate( "kalumet", "org.apache.kalumet.model.Kalumet" );
+ digester.addSetProperties( "kalumet" );
+
+ // properties/property tag rules
+ digester.addObjectCreate( "kalumet/properties/property", "org.apache.kalumet.model.Property" );
+ digester.addSetProperties( "kalumet/properties/property" );
+
+ // add property in the kalumet tag rule
+ digester.addSetNext( "kalumet/properties/property", "addProperty", "org.apache.kalumet.model.Property" );
+
+ // security tag rules
+ digester.addObjectCreate( "kalumet/security", "org.apache.kalumet.model.Security" );
+ digester.addSetProperties( "kalumet/security" );
+
+ // user tag rules
+ digester.addObjectCreate( "kalumet/security/users/user", "org.apache.kalumet.model.User" );
+ digester.addSetProperties( "kalumet/security/users/user" );
+
+ // add user to security tag rule
+ digester.addSetNext( "kalumet/security/users/user", "addUser", "org.apache.kalumet.model.User" );
+
+ // group tag rules
+ digester.addObjectCreate( "kalumet/security/groups/group", "org.apache.kalumet.model.Group" );
+ digester.addSetProperties( "kalumet/security/groups/group" );
+
+ // user group tag rules
+ digester.addObjectCreate( "kalumet/security/groups/group/users/user", "org.apache.kalumet.model.User" );
+ digester.addSetProperties( "kalumet/security/groups/group/users/user" );
+
+ // add user in group tag rule
+ digester.addSetNext( "kalumet/security/groups/group/users/user", "addUser",
+ "org.apache.kalumet.model.User" );
+
+ // add group to security tag rule
+ digester.addSetNext( "kalumet/security/groups/group", "addGroup", "org.apache.kalumet.model.Group" );
+
+ // add security to kalumet tag rule
+ digester.addSetNext( "kalumet/security", "setSecurity", "org.apache.kalumet.model.Security" );
+
+ // agent tag rules
+ digester.addObjectCreate( "kalumet/agents/agent", "org.apache.kalumet.model.Agent" );
+ digester.addSetProperties( "kalumet/agents/agent" );
+
+ // add agent to kalumet tag rule
+ digester.addSetNext( "kalumet/agents/agent", "addAgent", "org.apache.kalumet.model.Agent" );
+
+ // environment tag rules
+ digester.addObjectCreate( "kalumet/environments/environment", "org.apache.kalumet.model.Environment" );
+ digester.addSetProperties( "kalumet/environments/environment" );
+
+ // variables tag rules
+ digester.addObjectCreate( "kalumet/environments/environment/variables/variable",
+ "org.apache.kalumet.model.Variable" );
+ digester.addSetProperties( "kalumet/environments/environment/variables/variable" );
+
+ // add variable to environment tag rule
+ digester.addSetNext( "kalumet/environments/environment/variables/variable", "addVariable",
+ "org.apache.kalumet.model.Variable" );
+
+ // freefield tag rules
+ digester.addObjectCreate( "kalumet/environments/environment/freefields/freefield",
+ "org.apache.kalumet.model.FreeField" );
+ digester.addSetProperties( "kalumet/environments/environment/freefields/freefield" );
+ // add freefield content
+ digester.addCallMethod( "kalumet/environments/environment/freefields/freefield", "setContent", 0 );
+
+ // add freefield to environment tag rule
+ digester.addSetNext( "kalumet/environments/environment/freefields/freefield", "addFreeField",
+ "org.apache.kalumet.model.FreeField" );
+
+ // access tag rules
+ digester.addObjectCreate( "kalumet/environments/environment/accesses/access",
+ "org.apache.kalumet.model.Access" );
+ digester.addSetProperties( "kalumet/environments/environment/accesses/access" );
+
+ // access properties rules
+ digester.addObjectCreate( "kalumet/environments/environment/accesses/access/properties/property",
+ "org.apache.kalumet.model.Property" );
+ digester.addSetProperties( "kalumet/environments/environment/accesses/access/properties/property" );
+
+ // add property in access tag rule
+ digester.addSetNext( "kalumet/environments/environment/accesses/access/properties/property", "addProperty",
+ "org.apache.kalumet.model.Property" );
+
+ // add access to environment tag rule
+ digester.addSetNext( "kalumet/environments/environment/accesses/access", "addAccess",
+ "org.apache.kalumet.model.Access" );
+
+ // environment notes and weblinks tag rules
+ digester.addCallMethod( "kalumet/environments/environment/notes", "setNotes", 0 );
+ digester.addCallMethod( "kalumet/environments/environment/weblinks", "setWeblinks", 0 );
+
+ // jeeapplicationservers tag rules
+ digester.addObjectCreate( "kalumet/environments/environment/jeeapplicationservers",
+ "org.apache.kalumet.model.JEEApplicationServers" );
+ digester.addSetProperties( "kalumet/environments/environment/jeeapplicationservers" );
+
+ // jeeapplicationserver tag rules
+ digester.addObjectCreate( "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver",
+ "org.apache.kalumet.model.JEEApplicationServer" );
+ digester.addSetProperties( "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver" );
+
+ // jeeapplicationserver startupcommand and shutdowncommand tag rules
+ digester.addCallMethod(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/startupcommand",
+ "setStartupcommand", 0 );
+ digester.addCallMethod(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/shutdowncommand",
+ "setShutdowncommand", 0 );
+
+ // jdbcconnectionpool tag rules
+ digester.addObjectCreate(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jdbcconnectionpools/jdbcconnectionpool",
+ "org.apache.kalumet.model.JDBCConnectionPool" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jdbcconnectionpools/jdbcconnectionpool" );
+
+ // add jdbcconnectionpool to jeeapplicationserver
+ digester.addSetNext(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jdbcconnectionpools/jdbcconnectionpool",
+ "addJDBCConnectionPool", "org.apache.kalumet.model.JDBCConnectionPool" );
+
+ // jdbcdatasource tag rules
+ digester.addObjectCreate(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jdbcdatasources/jdbcdatasource",
+ "org.apache.kalumet.model.JDBCDataSource" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jdbcdatasources/jdbcdatasource" );
+
+ // add jdbcdatasource to jeeapplicationserver
+ digester.addSetNext(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jdbcdatasources/jdbcdatasource",
+ "addJDBCDataSource", "org.apache.kalumet.model.JDBCDataSource" );
+
+ // jmsconnectionfactory tag rules
+ digester.addObjectCreate(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsconnectionfactories/jmsconnectionfactory",
+ "org.apache.kalumet.model.JMSConnectionFactory" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsconnectionfactories/jmsconnectionfactory" );
+
+ // add jmsconnectionfactory to jeeapplicationserver
+ digester.addSetNext(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsconnectionfactories/jmsconnectionfactory",
+ "addJMSConnectionFactory", "org.apache.kalumet.model.JMSConnectionFactory" );
+
+ // jmsserver tag rules
+ digester.addObjectCreate(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsservers/jmsserver",
+ "org.apache.kalumet.model.JMSServer" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsservers/jmsserver" );
+
+ // jmsqueue tag rules
+ digester.addObjectCreate(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsservers/jmsserver/jmsqueues/jmsqueue",
+ "org.apache.kalumet.model.JMSQueue" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsservers/jmsserver/jmsqueues/jmsqueue" );
+
+ // add jmsqueue to jmsserver
+ digester.addSetNext(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsservers/jmsserver/jmsqueues/jmsqueue",
+ "addJMSQueue", "org.apache.kalumet.model.JMSQueue" );
+
+ // jmstopic tag rules
+ digester.addObjectCreate(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsservers/jmsserver/jmstopics/jmstopic",
+ "org.apache.kalumet.model.JMSTopic" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsservers/jmsserver/jmstopics/jmstopic" );
+
+ // add jmstopic to jmsserver
+ digester.addSetNext(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsservers/jmsserver/jmstopics/jmstopic",
+ "addJMSTopic", "org.apache.kalumet.model.JMSTopic" );
+
+ // add jmsserver to jeeapplicationserver
+ digester.addSetNext(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jmsservers/jmsserver",
+ "addJMSServer", "org.apache.kalumet.model.JMSServer" );
+
+ // jndibinding tag rules
+ digester.addObjectCreate(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jndibindings/jndibinding",
+ "org.apache.kalumet.model.JNDIBinding" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jndibindings/jndibinding" );
+
+ // add jndibinding to jeeapplicationserver
+ digester.addSetNext(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jndibindings/jndibinding",
+ "addJNDIBinding", "org.apache.kalumet.model.JNDIBinding" );
+
+ // sharedlibrary tag rules
+ digester.addObjectCreate(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/sharedlibrairies/sharedlibrary",
+ "org.apache.kalumet.model.SharedLibrary" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/sharedlibrairies/sharedlibrary" );
+
+ // add sharedlibrary to jeeapplicationserver
+ digester.addSetNext(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/sharedlibrairies/sharedlibrary",
+ "addSharedLibrary", "org.apache.kalumet.model.SharedLibrary" );
+
+ // application tag rules
+ digester.addObjectCreate(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication",
+ "org.apache.kalumet.model.JEEApplication" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication" );
+
+ // archive tag rules
+ digester.addObjectCreate(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/archives/archive",
+ "org.apache.kalumet.model.Archive" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/archives/archive" );
+
+ // add archive archive to application
+ digester.addSetNext(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/archives/archive",
+ "addArchive", "org.apache.kalumet.model.Archive" );
+
+ // contentmanager tag rules
+ digester.addObjectCreate(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/contentmanagers/contentmanager",
+ "org.apache.kalumet.model.ContentManager" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/contentmanagers/contentmanager" );
+
+ // contentmanager property tag rules
+ digester.addObjectCreate(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/contentmanagers/contentmanager/properties/property",
+ "org.apache.kalumet.model.Property" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/contentmanagers/contentmanager/properties/property" );
+
+ // add property in contentmanager
+ digester.addSetNext(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/contentmanagers/contentmanager/properties/property",
+ "addProperty", "org.apache.kalumet.model.Property" );
+
+ // add contentmanager to application
+ digester.addSetNext(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/contentmanagers/contentmanager",
+ "addContentManager", "org.apache.kalumet.model.ContentManager" );
+
+ // configurationfile tag rules
+ digester.addObjectCreate(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/configurationfiles/configurationfile",
+ "org.apache.kalumet.model.ConfigurationFile" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/configurationfiles/configurationfile" );
+
+ // mapping tag rules
+ digester.addObjectCreate(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/configurationfiles/configurationfile/mappings/mapping",
+ "org.apache.kalumet.model.Mapping" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/configurationfiles/configurationfile/mappings/mapping" );
+
+ // add mapping to configurationfile
+ digester.addSetNext(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/configurationfiles/configurationfile/mappings/mapping",
+ "addMapping", "org.apache.kalumet.model.Mapping" );
+
+ // add configurationfile to application
+ digester.addSetNext(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/configurationfiles/configurationfile",
+ "addConfigurationFile", "org.apache.kalumet.model.ConfigurationFile" );
+
+ // database tag rules
+ digester.addObjectCreate(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/databases/database",
+ "org.apache.kalumet.model.Database" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/databases/database" );
+
+ // sqlscript tag rules
+ digester.addObjectCreate(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/databases/database/sqlscripts/sqlscript",
+ "org.apache.kalumet.model.SqlScript" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/databases/database/sqlscripts/sqlscript" );
+
+ // sqlscript mapping tag rules
+ digester.addObjectCreate(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/databases/database/sqlscripts/sqlscript/mappings/mapping",
+ "org.apache.kalumet.model.Mapping" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/databases/database/sqlscripts/sqlscript/mappings/mapping" );
+
+ // add mapping to sqlscript
+ digester.addSetNext(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/databases/database/sqlscripts/sqlscript/mappings/mapping",
+ "addMapping", "org.apache.kalumet.model.Mapping" );
+
+ // add sqlscript to database
+ digester.addSetNext(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/databases/database/sqlscripts/sqlscript",
+ "addSqlScript", "org.apache.kalumet.model.SqlScript" );
+
+ // add database to application
+ digester.addSetNext(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/jeeapplication/databases/database",
+ "addDatabase", "org.apache.kalumet.model.Database" );
+
+ // add application to applicationserver
+ digester.addSetNext(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/jeeapplications/application",
+ "addApplication", "org.apache.kalumet.model.JEEApplication" );
+
+ // cache tag rules
+ digester.addObjectCreate(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/caches/cache",
+ "org.apache.kalumet.model.Cache" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/caches/cache" );
+
+ // add cache to applicationserver
+ digester.addSetNext(
+ "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver/caches/cache", "addCache",
+ "org.apache.kalumet.model.Cache" );
+
+ // add applicationserver to applicationservers tag rule
+ digester.addSetNext( "kalumet/environments/environment/jeeapplicationservers/jeeapplicationserver",
+ "addJEEApplicationServer", "org.apache.kalumet.model.JEEApplicationServer" );
+
+ // add applicationservers to environment tag rule
+ digester.addSetNext( "kalumet/environments/environment/jeeapplicationservers", "setJEEApplicationServers",
+ "org.apache.kalumet.model.JEEApplicationServers" );
+
+ // logfile tag rules
+ digester.addObjectCreate( "kalumet/environments/environment/logfiles/logfile",
+ "org.apache.kalumet.model.LogFile" );
+ digester.addSetProperties( "kalumet/environments/environment/logfiles/logfile" );
+
+ // add logfile to environment tag rule
+ digester.addSetNext( "kalumet/environments/environment/logfiles/logfile", "addLogFile",
+ "org.apache.kalumet.model.LogFile" );
+
+ // software tag rules
+ digester.addObjectCreate( "kalumet/environments/environment/softwares/software",
+ "org.apache.kalumet.model.Software" );
+ digester.addSetProperties( "kalumet/environments/environment/softwares/software" );
+
+ // software update plan command item
+ digester.addObjectCreate( "kalumet/environments/environment/softwares/software/updateplan/command",
+ "org.apache.kalumet.model.Command" );
+ digester.addSetProperties( "kalumet/environments/environment/softwares/software/updateplan/command" );
+ digester.addCallMethod( "kalumet/environments/environment/softwares/software/updateplan/command",
+ "setCommand", 0 );
+ digester.addSetNext( "kalumet/environments/environment/softwares/software/updateplan/command", "addCommand",
+ "org.apache.kalumet.model.Command" );
+
+ // software update plan location item
+ digester.addObjectCreate( "kalumet/environments/environment/softwares/software/updateplan/location",
+ "org.apache.kalumet.model.Location" );
+ digester.addSetProperties( "kalumet/environments/environment/softwares/software/updateplan/location" );
+ digester.addSetNext( "kalumet/environments/environment/softwares/software/updateplan/location",
+ "addLocation", "org.apache.kalumet.model.Location" );
+
+ // software update plan configuration file item
+ digester.addObjectCreate(
+ "kalumet/environments/environment/softwares/software/updateplan/configurationfile",
+ "org.apache.kalumet.model.ConfigurationFile" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/softwares/software/updateplan/configurationfile" );
+ digester.addObjectCreate(
+ "kalumet/environments/environment/softwares/software/updateplan/configurationfile/mappings/mapping",
+ "org.apache.kalumet.model.Mapping" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/softwares/software/updateplan/configurationfile/mappings/mapping" );
+ digester.addSetNext(
+ "kalumet/environments/environment/softwares/software/updateplan/configurationfile/mappings/mapping",
+ "addMapping", "org.apache.kalumet.model.Mapping" );
+ digester.addSetNext( "kalumet/environments/environment/softwares/software/updateplan/configurationfile",
+ "addConfigurationFile", "org.apache.kalumet.model.ConfigurationFile" );
+
+ // software update plan database item
+ digester.addObjectCreate( "kalumet/environments/environment/softwares/software/updateplan/database",
+ "org.apache.kalumet.model.Database" );
+ digester.addSetProperties( "kalumet/environments/environment/softwares/software/updateplan/database" );
+ digester.addObjectCreate(
+ "kalumet/environments/environment/softwares/software/updateplan/database/sqlscripts/sqlscript",
+ "org.apache.kalumet.model.SqlScript" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/softwares/software/updateplan/database/sqlscripts/sqlscript" );
+ digester.addObjectCreate(
+ "kalumet/environments/environment/softwares/software/updateplan/database/sqlscripts/sqlscript/mappings/mapping",
+ "org.apache.kalumet.model.Mapping" );
+ digester.addSetProperties(
+ "kalumet/environments/environment/softwares/software/updateplan/database/sqlscripts/sqlscript/mappings/mapping" );
+ digester.addSetNext(
+ "kalumet/environments/environment/softwares/software/updateplan/database/sqlscripts/sqlscript/mappings/mapping",
+ "addMapping", "org.apache.kalumet.model.Mapping" );
+ digester.addSetNext(
+ "kalumet/environments/environment/softwares/software/updateplan/database/sqlscripts/sqlscript",
+ "addSqlScript", "org.apache.kalumet.model.SqlScript" );
+ digester.addSetNext( "kalumet/environments/environment/softwares/software/updateplan/database",
+ "addDatabase", "org.apache.kalumet.model.Database" );
+
+ // add software to environment
+ digester.addSetNext( "kalumet/environments/environment/softwares/software", "addSoftware",
+ "org.apache.kalumet.model.Software" );
+
+ // notifiers tag rules
+ digester.addObjectCreate( "kalumet/environments/environment/notifiers",
+ "org.apache.kalumet.model.Notifiers" );
+ digester.addSetProperties( "kalumet/environments/environment/notifiers" );
+
+ // email tag rules
+ digester.addObjectCreate( "kalumet/environments/environment/notifiers/email",
+ "org.apache.kalumet.model.Email" );
+ digester.addSetProperties( "kalumet/environments/environment/notifiers/email" );
+
+ // destination tag rules
+ digester.addObjectCreate( "kalumet/environments/environment/notifiers/email/destinations/destination",
+ "org.apache.kalumet.model.Destination" );
+ digester.addSetProperties( "kalumet/environments/environment/notifiers/email/destinations/destination" );
+
+ // add destination to email notifier
+ digester.addSetNext( "kalumet/environments/environment/notifiers/email/destinations/destination",
+ "addDestination", "org.apache.kalumet.model.Destination" );
+
+ // add email to notifiers
+ digester.addSetNext( "kalumet/environments/environment/notifiers/email", "addNotifier",
+ "org.apache.kalumet.model.Email" );
+
+ // add notifiers to environment
+ digester.addSetNext( "kalumet/environments/environment/notifiers", "setNotifiers",
+ "org.apache.kalumet.model.Notifiers" );
+
+ // email publisher tag rules
+ digester.addObjectCreate( "kalumet/environments/environment/publishers/email",
+ "org.apache.kalumet.model.Email" );
+ digester.addSetProperties( "kalumet/environments/environment/publishers/email" );
+
+ // destination email publisher tag rules
+ digester.addObjectCreate( "kalumet/environments/environment/publishers/email/destinations/destination",
+ "org.apache.kalumet.model.Destination" );
+ digester.addSetProperties( "kalumet/environments/environment/publishers/email/destinations/destination" );
+
+ // add destination to email publisher
+ digester.addSetNext( "kalumet/environments/environment/publishers/email/destinations/destination",
+ "addDestination", "org.apache.kalumet.model.Destination" );
+
+ // add email publisher to environment
+ digester.addSetNext( "kalumet/environments/environment/publishers/email", "addPublisher",
+ "org.apache.kalumet.model.Email" );
+
+ // statistics tag rules
+ digester.addObjectCreate( "kalumet/environments/environment/statistics",
+ "org.apache.kalumet.model.Statistics" );
+ digester.addSetProperties( "kalumet/environments/environment/statistics" );
+
+ // add statistics to environment
+ digester.addSetNext( "kalumet/environments/environment/statistics", "setStatistics",
+ "org.apache.kalumet.model.Statistics" );
+
+ // add environment to kalumet tag rule
+ digester.addSetNext( "kalumet/environments/environment", "addEnvironment",
+ "org.apache.kalumet.model.Environment" );
+
+ // parse the XML file
+ kalumet = (Kalumet) digester.parse( path );
+ }
+ catch ( Exception e )
+ {
+ throw new KalumetException( "Can't read Kalumet configuration.", e );
+ }
+ finally
+ {
+ lock.readLock().unlock();
+ }
+ return kalumet;
+ }
+
+ /**
+ * Transform the <code>Kalumet</code> POJO to a DOM Element.
+ *
+ * @param document the XML core document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "kalumet" );
+ // properties element
+ ElementImpl properties = new ElementImpl( document, "properties" );
+ // add property in properties container
+ for ( Iterator propertyIterator = this.getProperties().iterator(); propertyIterator.hasNext(); )
+ {
+ Property property = (Property) propertyIterator.next();
+ properties.appendChild( property.toDOMElement( document ) );
+ }
+ // add properties in kalumet
+ element.appendChild( properties );
+ // add security in kalumet
+ element.appendChild( this.getSecurity().toDOMElement( document ) );
+ // agents element
+ ElementImpl agents = new ElementImpl( document, "agents" );
+ // add agent in agents container
+ for ( Iterator agentIterator = this.getAgents().iterator(); agentIterator.hasNext(); )
+ {
+ Agent agent = (Agent) agentIterator.next();
+ agents.appendChild( agent.toDOMElement( document ) );
+ }
+ // add agents in kalumet
+ element.appendChild( agents );
+ // environments element
+ ElementImpl environments = new ElementImpl( document, "environments" );
+ // add environment in environments container
+ for ( Iterator environmentIterator = this.getEnvironments().iterator(); environmentIterator.hasNext(); )
+ {
+ Environment environment = (Environment) environmentIterator.next();
+ environments.appendChild( environment.toDOMElement( document ) );
+ }
+ // add environments in kalumet
+ element.appendChild( environments );
+ return element;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ Kalumet clone = new Kalumet();
+ for ( Iterator propertyIterator = this.properties.iterator(); propertyIterator.hasNext(); )
+ {
+ Property property = (Property) propertyIterator.next();
+ clone.properties.add( (Property) property.clone() );
+ }
+ clone.setSecurity( (Security) this.getSecurity().clone() );
+ for ( Iterator agentIterator = this.agents.iterator(); agentIterator.hasNext(); )
+ {
+ Agent agent = (Agent) agentIterator.next();
+ clone.agents.add( (Agent) agent.clone() );
+ }
+ for ( Iterator environmentIterator = this.environments.iterator(); environmentIterator.hasNext(); )
+ {
+ Environment environment = (Environment) environmentIterator.next();
+ clone.environments.add( (Environment) environment.clone() );
+ }
+ return clone;
+ }
+
+ /**
+ * Write a Kalumet XML file with the content of the in-memory
+ * configuration.
+ *
+ * @param path the path to the file to write.
+ * @param backup a flag indicated if a previous backup must be copied before writing.
+ */
+ public synchronized void writeXMLFile( String path, boolean backup )
+ throws KalumetException
+ {
+ if ( backup )
+ {
+ this.backupXMLFile( path );
+ }
+ try
+ {
+ lock.writeLock().lock();
+ OutputFormat format = new OutputFormat();
+ format.setLineWidth( 72 );
+ format.setIndenting( true );
+ format.setIndent( 3 );
+ format.setEncoding( "ISO-8859-1" );
+ if ( path.startsWith( "http:" ) || path.startsWith( "http:" ) )
+ {
+ throw new KalumetException( "Can't write Kalumet XML file over a HTTP URL." );
+ }
+ if ( path.startsWith( "file:" ) || path.startsWith( "FILE:" ) )
+ {
+ path = path.substring( 5 );
+ }
+ XMLSerializer serializer = new XMLSerializer( new FileOutputStream( path ), format );
+ serializer.serialize( this.toDOMElement( new CoreDocumentImpl( true ) ) );
+ }
+ catch ( Exception e )
+ {
+ throw new KalumetException( "Can't write Kalumet XML file.", e );
+ }
+ finally
+ {
+ lock.writeLock().unlock();
+ }
+ }
+
+ /**
+ * Write a Kalumet XML file with the content of the in-memory
+ * configuration.
+ *
+ * @param path the path to the file to write.
+ */
+ public void writeXMLFile( String path )
+ throws KalumetException
+ {
+ this.writeXMLFile( path, false );
+ }
+
+ /**
+ * Make a backup of the old Kalumet XML configuration to avoid file
+ * corruption (for example when disk full).
+ *
+ * @param path the path to the Kalumet XML file.
+ */
+ public void backupXMLFile( String path )
+ throws KalumetException
+ {
+ FileManipulator fileManipulator = null;
+ try
+ {
+ fileManipulator = new FileManipulator();
+ fileManipulator.copy( path, path + ".backup" );
+ }
+ finally
+ {
+ if ( fileManipulator != null )
+ {
+ fileManipulator.close();
+ }
+ }
+ }
+
+ public static void writeDefault( String path )
+ throws KalumetException
+ {
+ Kalumet kalumet = new Kalumet();
+ Security security = kalumet.getSecurity();
+ User adminUser = new User();
+ adminUser.setId( "admin" );
+ adminUser.setName( "admin" );
+ adminUser.setPassword( "21232f297a57a5a743894a0e4a801fc3" );
+ Group adminGroup = new Group();
+ adminGroup.setId( "admin" );
+ adminGroup.setName( "admin" );
+ adminGroup.addUser( adminUser );
+ security.addGroup( adminGroup );
+ security.addUser( adminUser );
+ kalumet.writeXMLFile( path );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Location.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Location.java
index 4c7d429..4ac5cd2 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Location.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Location.java
@@ -28,127 +28,127 @@
* A <code>location</code> is a general wrapper for files and directories.
*/
public class Location
- implements Cloneable, Serializable, Comparable
+ implements Cloneable, Serializable, Comparable
{
- private static final long serialVersionUID = 3632838715316673949L;
+ private static final long serialVersionUID = 3632838715316673949L;
- private String name;
+ private String name;
- private boolean active;
+ private boolean active;
- private boolean blocker;
+ private boolean blocker;
- private String uri;
+ private String uri;
- private String path;
+ private String path;
- private String agent;
+ private String agent;
- public Location()
- {
- }
+ public Location()
+ {
+ }
- public boolean isActive()
- {
- return active;
- }
+ public boolean isActive()
+ {
+ return active;
+ }
- public void setActive( boolean active )
- {
- this.active = active;
- }
+ public void setActive( boolean active )
+ {
+ this.active = active;
+ }
- public boolean isBlocker()
- {
- return blocker;
- }
+ public boolean isBlocker()
+ {
+ return blocker;
+ }
- public void setBlocker( boolean blocker )
- {
- this.blocker = blocker;
- }
+ public void setBlocker( boolean blocker )
+ {
+ this.blocker = blocker;
+ }
- public String getName()
- {
- return name;
- }
+ public String getName()
+ {
+ return name;
+ }
- public void setName( String name )
- {
- this.name = name;
- }
+ public void setName( String name )
+ {
+ this.name = name;
+ }
- public String getUri()
- {
- return uri;
- }
+ public String getUri()
+ {
+ return uri;
+ }
- public void setUri( String uri )
- {
- this.uri = uri;
- }
+ public void setUri( String uri )
+ {
+ this.uri = uri;
+ }
- public String getPath()
- {
- return path;
- }
+ public String getPath()
+ {
+ return path;
+ }
- public String getAgent()
- {
- return agent;
- }
+ public String getAgent()
+ {
+ return agent;
+ }
- public void setAgent( String agent )
- {
- this.agent = agent;
- }
+ public void setAgent( String agent )
+ {
+ this.agent = agent;
+ }
- public void setPath( String path )
- {
- this.path = path;
- }
+ public void setPath( String path )
+ {
+ this.path = path;
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- Location clone = new Location();
- clone.setActive( this.isActive() );
- clone.setBlocker( this.isBlocker() );
- clone.setName( this.getName() );
- clone.setUri( this.getUri() );
- clone.setPath( this.getPath() );
- clone.setAgent( this.getAgent() );
- return clone;
- }
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ Location clone = new Location();
+ clone.setActive( this.isActive() );
+ clone.setBlocker( this.isBlocker() );
+ clone.setName( this.getName() );
+ clone.setUri( this.getUri() );
+ clone.setPath( this.getPath() );
+ clone.setAgent( this.getAgent() );
+ return clone;
+ }
- /**
- * Transform a <code>location</code> into a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- public Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "location" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
- element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
- element.setAttribute( "uri", this.getUri() );
- element.setAttribute( "path", this.getPath() );
- element.setAttribute( "agent", this.getAgent() );
- return element;
- }
+ /**
+ * Transform a <code>location</code> into a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ public Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "location" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
+ element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
+ element.setAttribute( "uri", this.getUri() );
+ element.setAttribute( "path", this.getPath() );
+ element.setAttribute( "agent", this.getAgent() );
+ return element;
+ }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherLocation )
- {
- return this.getName().compareTo( ( (Location) anotherLocation ).getName() );
- }
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherLocation )
+ {
+ return this.getName().compareTo( ( (Location) anotherLocation ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/LogFile.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/LogFile.java
index 7e1ed51..9d168d5 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/LogFile.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/LogFile.java
@@ -28,85 +28,85 @@
* Define the access to a log file.
*/
public class LogFile
- implements Cloneable, Serializable, Comparable
+ implements Cloneable, Serializable, Comparable
{
- private static final long serialVersionUID = -544824580684870083L;
+ private static final long serialVersionUID = -544824580684870083L;
- private String name;
+ private String name;
- private String path;
+ private String path;
- private String agent;
+ private String agent;
- public LogFile()
- {
- }
+ public LogFile()
+ {
+ }
- public String getName()
- {
- return name;
- }
+ public String getName()
+ {
+ return name;
+ }
- public void setName( String name )
- {
- this.name = name;
- }
+ public void setName( String name )
+ {
+ this.name = name;
+ }
- public String getPath()
- {
- return path;
- }
+ public String getPath()
+ {
+ return path;
+ }
- public void setPath( String path )
- {
- this.path = path;
- }
+ public void setPath( String path )
+ {
+ this.path = path;
+ }
- public String getAgent()
- {
- return agent;
- }
+ public String getAgent()
+ {
+ return agent;
+ }
- public void setAgent( String agent )
- {
- this.agent = agent;
- }
+ public void setAgent( String agent )
+ {
+ this.agent = agent;
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- LogFile logFile = new LogFile();
- logFile.setAgent( this.getAgent() );
- logFile.setName( this.getName() );
- logFile.setPath( this.getPath() );
- return logFile;
- }
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ LogFile logFile = new LogFile();
+ logFile.setAgent( this.getAgent() );
+ logFile.setName( this.getName() );
+ logFile.setPath( this.getPath() );
+ return logFile;
+ }
- /**
- * Transform a <code>logfile</code> into a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- public Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "logfile" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "path", this.getPath() );
- element.setAttribute( "agent", this.getAgent() );
- return element;
- }
+ /**
+ * Transform a <code>logfile</code> into a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ public Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "logfile" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "path", this.getPath() );
+ element.setAttribute( "agent", this.getAgent() );
+ return element;
+ }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherLogFile )
- {
- return this.getName().compareTo( ( (LogFile) anotherLogFile ).getName() );
- }
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherLogFile )
+ {
+ return this.getName().compareTo( ( (LogFile) anotherLogFile ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Mapping.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Mapping.java
index 86c7661..0324996 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Mapping.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Mapping.java
@@ -28,71 +28,71 @@
* Represent the <code>mapping</code> tag in the Kalumet configuration DOM.
*/
public class Mapping
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = 6313869273116904013L;
+ private static final long serialVersionUID = 6313869273116904013L;
- private String key;
+ private String key;
- private String value;
+ private String value;
- public Mapping()
- {
- }
+ public Mapping()
+ {
+ }
- public String getKey()
- {
- return this.key;
- }
+ public String getKey()
+ {
+ return this.key;
+ }
- public void setKey( String key )
- {
- this.key = key;
- }
+ public void setKey( String key )
+ {
+ this.key = key;
+ }
- public String getValue()
- {
- return this.value;
- }
+ public String getValue()
+ {
+ return this.value;
+ }
- public void setValue( String value )
- {
- this.value = value;
- }
+ public void setValue( String value )
+ {
+ this.value = value;
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- Mapping clone = new Mapping();
- clone.setKey( this.getKey() );
- clone.setValue( this.getValue() );
- return clone;
- }
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ Mapping clone = new Mapping();
+ clone.setKey( this.getKey() );
+ clone.setValue( this.getValue() );
+ return clone;
+ }
- /**
- * Transform the <code>Mapping</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "mapping" );
- element.setAttribute( "key", this.getKey() );
- element.setAttribute( "value", this.getValue() );
- return element;
- }
+ /**
+ * Transform the <code>Mapping</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "mapping" );
+ element.setAttribute( "key", this.getKey() );
+ element.setAttribute( "value", this.getValue() );
+ return element;
+ }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherMapping )
- {
- return this.getKey().compareTo( ( (Mapping) anotherMapping ).getKey() );
- }
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherMapping )
+ {
+ return this.getKey().compareTo( ( (Mapping) anotherMapping ).getKey() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/ModelObjectAlreadyExistsException.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/ModelObjectAlreadyExistsException.java
index b5a569c..32d7160 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/ModelObjectAlreadyExistsException.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/ModelObjectAlreadyExistsException.java
@@ -25,40 +25,40 @@
* the Kalumet configuration.
*/
public final class ModelObjectAlreadyExistsException
- extends KalumetException
+ extends KalumetException
{
- private static final long serialVersionUID = -6461646659257275924L;
+ private static final long serialVersionUID = -6461646659257275924L;
- /**
- * Creates a <code>ModelObjectAlreadyExistsException</code> with an explanation message.
- *
- * @param message the explanation message.
- */
- public ModelObjectAlreadyExistsException( String message )
- {
- super( message );
- }
+ /**
+ * Creates a <code>ModelObjectAlreadyExistsException</code> with an explanation message.
+ *
+ * @param message the explanation message.
+ */
+ public ModelObjectAlreadyExistsException( String message )
+ {
+ super( message );
+ }
- /**
- * Creates a <code>ModelObjectAlreadyExistsException</code> with the underlying cause.
- *
- * @param cause the underlying cause.
- */
- public ModelObjectAlreadyExistsException( Throwable cause )
- {
- super( cause );
- }
+ /**
+ * Creates a <code>ModelObjectAlreadyExistsException</code> with the underlying cause.
+ *
+ * @param cause the underlying cause.
+ */
+ public ModelObjectAlreadyExistsException( Throwable cause )
+ {
+ super( cause );
+ }
- /**
- * Creates a <code>ModelObjectAlreadyExistsException</code> with an explanation message and the underlying cause.
- *
- * @param message the explanation message.
- * @param cause the underlying cause.
- */
- public ModelObjectAlreadyExistsException( String message, Throwable cause )
- {
- super( message, cause );
- }
+ /**
+ * Creates a <code>ModelObjectAlreadyExistsException</code> with an explanation message and the underlying cause.
+ *
+ * @param message the explanation message.
+ * @param cause the underlying cause.
+ */
+ public ModelObjectAlreadyExistsException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Notifiers.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Notifiers.java
index 69ddd9b..89e5db5 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Notifiers.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Notifiers.java
@@ -31,121 +31,121 @@
* Represent the <code>notifiers</code> tag in the Kalumet configuration DOM.
*/
public class Notifiers
- implements Serializable, Cloneable
+ implements Serializable, Cloneable
{
- private static final long serialVersionUID = -5087839972754579270L;
+ private static final long serialVersionUID = -5087839972754579270L;
- private int countdown;
+ private int countdown;
- private LinkedList notifiers;
+ private LinkedList notifiers;
- public Notifiers()
- {
- this.notifiers = new LinkedList();
- }
-
- public int getCountdown()
- {
- return this.countdown;
- }
-
- public void setCountdown( int countdown )
- {
- this.countdown = countdown;
- }
-
- /**
- * Add a new <code>Email</code> notifier in the <code>Notifiers</code>
- * notifiers container.
- *
- * @param email the <code>Email</code> to add.
- */
- public void addNotifier( Email email )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getNotifier( email.getMailhost() ) != null )
+ public Notifiers()
{
- throw new ModelObjectAlreadyExistsException( "Email notifier mailhost already exists in notifiers." );
+ this.notifiers = new LinkedList();
}
- this.notifiers.add( email );
- }
- /**
- * Get the <code>Email</code> notifier list in the <code>Notifiers</code>
- * notifiers container.
- *
- * @return the <code>Email</code> notifier list.
- */
- public List getNotifiers()
- {
- return this.notifiers;
- }
-
- /**
- * Set the <code>Email</code> notifier list in the
- * <code>Notifiers</code> notifiers container.
- *
- * @param notifiers the new <code>Email</code> notifier list.
- */
- public void setNotifiers( LinkedList notifiers )
- {
- this.notifiers = notifiers;
- }
-
- /**
- * Get the <code>Email</code> notifier identified by a given mail host in
- * the <code>Notifiers</code> notifiers container.
- *
- * @param mailhost the <code>Email</code> notifier mail host.
- * @return the <code>Email</code> found or null if not found.
- */
- public Email getNotifier( String mailhost )
- {
- for ( Iterator notifierIterator = this.getNotifiers().iterator(); notifierIterator.hasNext(); )
+ public int getCountdown()
{
- Email email = (Email) notifierIterator.next();
- if ( email.getMailhost().equals( mailhost ) )
- {
- return email;
- }
+ return this.countdown;
}
- return null;
- }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- Notifiers clone = new Notifiers();
- clone.setCountdown( this.getCountdown() );
- for ( Iterator notifierIterator = this.notifiers.iterator(); notifierIterator.hasNext(); )
+ public void setCountdown( int countdown )
{
- Email notifier = (Email) notifierIterator.next();
- clone.notifiers.add( (Email) notifier.clone() );
+ this.countdown = countdown;
}
- return clone;
- }
- /**
- * Transform the <code>Notifiers</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "notifiers" );
- element.setAttribute( "countdown", new Integer( this.getCountdown() ).toString() );
- // email notifier child nodes
- for ( Iterator notifierIterator = this.getNotifiers().iterator(); notifierIterator.hasNext(); )
+ /**
+ * Add a new <code>Email</code> notifier in the <code>Notifiers</code>
+ * notifiers container.
+ *
+ * @param email the <code>Email</code> to add.
+ */
+ public void addNotifier( Email email )
+ throws ModelObjectAlreadyExistsException
{
- Email email = (Email) notifierIterator.next();
- element.appendChild( email.toDOMElement( document ) );
+ if ( this.getNotifier( email.getMailhost() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "Email notifier mailhost already exists in notifiers." );
+ }
+ this.notifiers.add( email );
}
- return element;
- }
+
+ /**
+ * Get the <code>Email</code> notifier list in the <code>Notifiers</code>
+ * notifiers container.
+ *
+ * @return the <code>Email</code> notifier list.
+ */
+ public List getNotifiers()
+ {
+ return this.notifiers;
+ }
+
+ /**
+ * Set the <code>Email</code> notifier list in the
+ * <code>Notifiers</code> notifiers container.
+ *
+ * @param notifiers the new <code>Email</code> notifier list.
+ */
+ public void setNotifiers( LinkedList notifiers )
+ {
+ this.notifiers = notifiers;
+ }
+
+ /**
+ * Get the <code>Email</code> notifier identified by a given mail host in
+ * the <code>Notifiers</code> notifiers container.
+ *
+ * @param mailhost the <code>Email</code> notifier mail host.
+ * @return the <code>Email</code> found or null if not found.
+ */
+ public Email getNotifier( String mailhost )
+ {
+ for ( Iterator notifierIterator = this.getNotifiers().iterator(); notifierIterator.hasNext(); )
+ {
+ Email email = (Email) notifierIterator.next();
+ if ( email.getMailhost().equals( mailhost ) )
+ {
+ return email;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ Notifiers clone = new Notifiers();
+ clone.setCountdown( this.getCountdown() );
+ for ( Iterator notifierIterator = this.notifiers.iterator(); notifierIterator.hasNext(); )
+ {
+ Email notifier = (Email) notifierIterator.next();
+ clone.notifiers.add( (Email) notifier.clone() );
+ }
+ return clone;
+ }
+
+ /**
+ * Transform the <code>Notifiers</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "notifiers" );
+ element.setAttribute( "countdown", new Integer( this.getCountdown() ).toString() );
+ // email notifier child nodes
+ for ( Iterator notifierIterator = this.getNotifiers().iterator(); notifierIterator.hasNext(); )
+ {
+ Email email = (Email) notifierIterator.next();
+ element.appendChild( email.toDOMElement( document ) );
+ }
+ return element;
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Property.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Property.java
index 103ad34..e6e4062 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Property.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Property.java
@@ -28,71 +28,71 @@
* Represent a <code>property</code> tag in the Kalumet configuration DOM.
*/
public class Property
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = -1044229953052391950L;
+ private static final long serialVersionUID = -1044229953052391950L;
- private String name;
+ private String name;
- private String value;
+ private String value;
- public Property()
- {
- }
+ public Property()
+ {
+ }
- public void setName( String name )
- {
- this.name = name;
- }
+ public void setName( String name )
+ {
+ this.name = name;
+ }
- public String getName()
- {
- return this.name;
- }
+ public String getName()
+ {
+ return this.name;
+ }
- public void setValue( String value )
- {
- this.value = value;
- }
+ public void setValue( String value )
+ {
+ this.value = value;
+ }
- public String getValue()
- {
- return this.value;
- }
+ public String getValue()
+ {
+ return this.value;
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- Property clone = new Property();
- clone.setName( this.getName() );
- clone.setValue( this.getValue() );
- return clone;
- }
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ Property clone = new Property();
+ clone.setName( this.getName() );
+ clone.setValue( this.getValue() );
+ return clone;
+ }
- /**
- * Transform the <code>Property</code> POJO to a DOM Element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "property" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "value", this.getValue() );
- return element;
- }
+ /**
+ * Transform the <code>Property</code> POJO to a DOM Element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "property" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "value", this.getValue() );
+ return element;
+ }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherProperty )
- {
- return this.getName().compareTo( ( (Property) anotherProperty ).getName() );
- }
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherProperty )
+ {
+ return this.getName().compareTo( ( (Property) anotherProperty ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Security.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Security.java
index f354e44..c359bd0 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Security.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Security.java
@@ -32,293 +32,294 @@
* Represent the <code>security</code> tag in the Kalumet configuration DOM.
*/
public class Security
- implements Serializable, Cloneable
+ implements Serializable, Cloneable
{
- private static final long serialVersionUID = 1323976117053191122L;
+ private static final long serialVersionUID = 1323976117053191122L;
- private LinkedList users;
+ private LinkedList users;
- private LinkedList groups;
+ private LinkedList groups;
- public Security()
- {
- this.users = new LinkedList();
- this.groups = new LinkedList();
- }
-
- /**
- * Add a new <code>User</code> in the <code>Security</code> container.
- *
- * @param user the <code>User</code> to add.
- */
- public void addUser( User user )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getUser( user.getId() ) != null )
+ public Security()
{
- throw new ModelObjectAlreadyExistsException( "User id already exists in the security user configuration." );
+ this.users = new LinkedList();
+ this.groups = new LinkedList();
}
- this.users.add( user );
- }
- /**
- * Get the <code>User</code> list in the <code>Security</code>
- * container.
- *
- * @return the <code>User</code> list.
- */
- public List getUsers()
- {
- return this.users;
- }
-
- /**
- * Set the <code>User</code> list in the <code>Security</code>
- * container.
- *
- * @param users the new <code>User</code> list.
- */
- public void setUsers( LinkedList users )
- {
- this.users = users;
- }
-
- /**
- * Get the <code>User</code> identified by a given id in the
- * <code>Security</code> container.
- *
- * @param id the <code>User</code> id.
- * @return the found <code>User</code> or null if not found.
- */
- public User getUser( String id )
- {
- for ( Iterator userIterator = this.getUsers().iterator(); userIterator.hasNext(); )
+ /**
+ * Add a new <code>User</code> in the <code>Security</code> container.
+ *
+ * @param user the <code>User</code> to add.
+ */
+ public void addUser( User user )
+ throws ModelObjectAlreadyExistsException
{
- User user = (User) userIterator.next();
- if ( user.getId().equals( id ) )
- {
- return user;
- }
+ if ( this.getUser( user.getId() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "User id already exists in the security user configuration." );
+ }
+ this.users.add( user );
}
- return null;
- }
- /**
- * Identify a user.
- *
- * @param id the user id.
- * @param password the user password (in clear).
- * @return true if the user is identified, false else.
- */
- public boolean identifyUser( String id, String password )
- throws KalumetException
- {
- String encryptedPassword = User.md5PasswordCrypt( password );
- User user = this.getUser( id );
- if ( user == null )
+ /**
+ * Get the <code>User</code> list in the <code>Security</code>
+ * container.
+ *
+ * @return the <code>User</code> list.
+ */
+ public List getUsers()
{
- return false;
+ return this.users;
}
- if ( !user.getPassword().equals( encryptedPassword ) )
- {
- return false;
- }
- return true;
- }
- /**
- * Add a new <code>Group</code> in the <code>Security</code> container.
- *
- * @param group the <code>Group</code> to add.
- */
- public void addGroup( Group group )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getGroup( group.getId() ) != null )
+ /**
+ * Set the <code>User</code> list in the <code>Security</code>
+ * container.
+ *
+ * @param users the new <code>User</code> list.
+ */
+ public void setUsers( LinkedList users )
{
- throw new ModelObjectAlreadyExistsException( "Group id already exists in security definition." );
+ this.users = users;
}
- this.groups.add( group );
- }
- /**
- * Get the <code>Group</code> list in the <code>Security</code> container.
- *
- * @return the <code>Group</code> list.
- */
- public List getGroups()
- {
- return this.groups;
- }
-
- /**
- * Set the <code>Group</code> list in the <code>Security</code>
- * container.
- *
- * @param groups the new <code>Group</code>list.
- */
- public void setGroups( LinkedList groups )
- {
- this.groups = groups;
- }
-
- /**
- * Get a <code>Group</code> identified by a given id in the
- * <code>Security</code> container.
- *
- * @param id the <code>Group</code> id.
- * @return the found <code>Group</code> or null if not found.
- */
- public Group getGroup( String id )
- {
- for ( Iterator groupIterator = this.getGroups().iterator(); groupIterator.hasNext(); )
+ /**
+ * Get the <code>User</code> identified by a given id in the
+ * <code>Security</code> container.
+ *
+ * @param id the <code>User</code> id.
+ * @return the found <code>User</code> or null if not found.
+ */
+ public User getUser( String id )
{
- Group group = (Group) groupIterator.next();
- if ( group.getId().equals( id ) )
- {
- return group;
- }
+ for ( Iterator userIterator = this.getUsers().iterator(); userIterator.hasNext(); )
+ {
+ User user = (User) userIterator.next();
+ if ( user.getId().equals( id ) )
+ {
+ return user;
+ }
+ }
+ return null;
}
- return null;
- }
- /**
- * Get all groups of a user.
- *
- * @param userid the user id.
- * @return the user groups.
- */
- public List getUserGroups( String userid )
- {
- if ( userid.equals( "admin" ) )
+ /**
+ * Identify a user.
+ *
+ * @param id the user id.
+ * @param password the user password (in clear).
+ * @return true if the user is identified, false else.
+ */
+ public boolean identifyUser( String id, String password )
+ throws KalumetException
{
- return this.getGroups();
- }
- LinkedList userGroups = new LinkedList();
- for ( Iterator groupIterator = this.getGroups().iterator(); groupIterator.hasNext(); )
- {
- Group group = (Group) groupIterator.next();
- if ( group.getUser( userid ) != null )
- {
- userGroups.add( group );
- }
- }
- return userGroups;
- }
-
- /**
- * Check user in group.
- *
- * @param userid the user id.
- * @param groupid the group id.
- * @return true if the user is a member of the group, false else.
- */
- public boolean checkUserInGroup( String userid, String groupid )
- {
- if ( userid.equals( "admin" ) )
- {
- return true;
- }
- for ( Iterator userGroupIterator = this.getUserGroups( userid ).iterator(); userGroupIterator.hasNext(); )
- {
- Group group = (Group) userGroupIterator.next();
- if ( group.getId().equals( groupid ) )
- {
+ String encryptedPassword = User.md5PasswordCrypt( password );
+ User user = this.getUser( id );
+ if ( user == null )
+ {
+ return false;
+ }
+ if ( !user.getPassword().equals( encryptedPassword ) )
+ {
+ return false;
+ }
return true;
- }
}
- return false;
- }
- /**
- * Check if a user has an access to a given environment.
- *
- * @param environment the <code>Environment</code>.
- * @param userid the <code>User</code> id.
- * @param property the <code>Access</code> property.
- * @return true if the user has access to the environment, false else.
- */
- public boolean checkEnvironmentUserAccess( Environment environment, String userid, String property )
- {
- if ( this.checkUserInGroup( userid, "admin" ) )
+ /**
+ * Add a new <code>Group</code> in the <code>Security</code> container.
+ *
+ * @param group the <code>Group</code> to add.
+ */
+ public void addGroup( Group group )
+ throws ModelObjectAlreadyExistsException
{
- return true;
- }
- for ( Iterator accessIterator = environment.getAccesses().iterator(); accessIterator.hasNext(); )
- {
- Access access = (Access) accessIterator.next();
- if ( property == null )
- {
- if ( this.checkUserInGroup( userid, access.getGroup() ) )
+ if ( this.getGroup( group.getId() ) != null )
{
- return true;
+ throw new ModelObjectAlreadyExistsException( "Group id already exists in security definition." );
}
- }
- else
- {
- if ( access.getProperty( property ) != null && access.getProperty( property ).getValue().equals( "true" ) )
+ this.groups.add( group );
+ }
+
+ /**
+ * Get the <code>Group</code> list in the <code>Security</code> container.
+ *
+ * @return the <code>Group</code> list.
+ */
+ public List getGroups()
+ {
+ return this.groups;
+ }
+
+ /**
+ * Set the <code>Group</code> list in the <code>Security</code>
+ * container.
+ *
+ * @param groups the new <code>Group</code>list.
+ */
+ public void setGroups( LinkedList groups )
+ {
+ this.groups = groups;
+ }
+
+ /**
+ * Get a <code>Group</code> identified by a given id in the
+ * <code>Security</code> container.
+ *
+ * @param id the <code>Group</code> id.
+ * @return the found <code>Group</code> or null if not found.
+ */
+ public Group getGroup( String id )
+ {
+ for ( Iterator groupIterator = this.getGroups().iterator(); groupIterator.hasNext(); )
{
- if ( this.checkUserInGroup( userid, access.getGroup() ) )
- {
+ Group group = (Group) groupIterator.next();
+ if ( group.getId().equals( id ) )
+ {
+ return group;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get all groups of a user.
+ *
+ * @param userid the user id.
+ * @return the user groups.
+ */
+ public List getUserGroups( String userid )
+ {
+ if ( userid.equals( "admin" ) )
+ {
+ return this.getGroups();
+ }
+ LinkedList userGroups = new LinkedList();
+ for ( Iterator groupIterator = this.getGroups().iterator(); groupIterator.hasNext(); )
+ {
+ Group group = (Group) groupIterator.next();
+ if ( group.getUser( userid ) != null )
+ {
+ userGroups.add( group );
+ }
+ }
+ return userGroups;
+ }
+
+ /**
+ * Check user in group.
+ *
+ * @param userid the user id.
+ * @param groupid the group id.
+ * @return true if the user is a member of the group, false else.
+ */
+ public boolean checkUserInGroup( String userid, String groupid )
+ {
+ if ( userid.equals( "admin" ) )
+ {
return true;
- }
}
- }
+ for ( Iterator userGroupIterator = this.getUserGroups( userid ).iterator(); userGroupIterator.hasNext(); )
+ {
+ Group group = (Group) userGroupIterator.next();
+ if ( group.getId().equals( groupid ) )
+ {
+ return true;
+ }
+ }
+ return false;
}
- return false;
- }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- Security clone = new Security();
- for ( Iterator userIterator = this.users.iterator(); userIterator.hasNext(); )
+ /**
+ * Check if a user has an access to a given environment.
+ *
+ * @param environment the <code>Environment</code>.
+ * @param userid the <code>User</code> id.
+ * @param property the <code>Access</code> property.
+ * @return true if the user has access to the environment, false else.
+ */
+ public boolean checkEnvironmentUserAccess( Environment environment, String userid, String property )
{
- User user = (User) userIterator.next();
- clone.users.add( (User) user.clone() );
+ if ( this.checkUserInGroup( userid, "admin" ) )
+ {
+ return true;
+ }
+ for ( Iterator accessIterator = environment.getAccesses().iterator(); accessIterator.hasNext(); )
+ {
+ Access access = (Access) accessIterator.next();
+ if ( property == null )
+ {
+ if ( this.checkUserInGroup( userid, access.getGroup() ) )
+ {
+ return true;
+ }
+ }
+ else
+ {
+ if ( access.getProperty( property ) != null && access.getProperty( property ).getValue().equals(
+ "true" ) )
+ {
+ if ( this.checkUserInGroup( userid, access.getGroup() ) )
+ {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
}
- for ( Iterator groupIterator = this.groups.iterator(); groupIterator.hasNext(); )
- {
- Group group = (Group) groupIterator.next();
- clone.groups.add( (Group) group.clone() );
- }
- return clone;
- }
- /**
- * Transform the <code>Security</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "security" );
- // users element
- ElementImpl users = new ElementImpl( document, "users" );
- // add user in the users container
- for ( Iterator userIterator = this.getUsers().iterator(); userIterator.hasNext(); )
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
{
- User user = (User) userIterator.next();
- users.appendChild( user.toDOMElement( document ) );
+ Security clone = new Security();
+ for ( Iterator userIterator = this.users.iterator(); userIterator.hasNext(); )
+ {
+ User user = (User) userIterator.next();
+ clone.users.add( (User) user.clone() );
+ }
+ for ( Iterator groupIterator = this.groups.iterator(); groupIterator.hasNext(); )
+ {
+ Group group = (Group) groupIterator.next();
+ clone.groups.add( (Group) group.clone() );
+ }
+ return clone;
}
- // add users in security
- element.appendChild( users );
- // groups element
- ElementImpl groups = new ElementImpl( document, "groups" );
- // add group in the groups container
- for ( Iterator groupIterator = this.getGroups().iterator(); groupIterator.hasNext(); )
+
+ /**
+ * Transform the <code>Security</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
{
- Group group = (Group) groupIterator.next();
- groups.appendChild( group.toDOMElement( document ) );
+ ElementImpl element = new ElementImpl( document, "security" );
+ // users element
+ ElementImpl users = new ElementImpl( document, "users" );
+ // add user in the users container
+ for ( Iterator userIterator = this.getUsers().iterator(); userIterator.hasNext(); )
+ {
+ User user = (User) userIterator.next();
+ users.appendChild( user.toDOMElement( document ) );
+ }
+ // add users in security
+ element.appendChild( users );
+ // groups element
+ ElementImpl groups = new ElementImpl( document, "groups" );
+ // add group in the groups container
+ for ( Iterator groupIterator = this.getGroups().iterator(); groupIterator.hasNext(); )
+ {
+ Group group = (Group) groupIterator.next();
+ groups.appendChild( group.toDOMElement( document ) );
+ }
+ // add groups in security
+ element.appendChild( groups );
+ return element;
}
- // add groups in security
- element.appendChild( groups );
- return element;
- }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/SharedLibrary.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/SharedLibrary.java
index 0fea054..d79de21 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/SharedLibrary.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/SharedLibrary.java
@@ -28,99 +28,99 @@
* Represent the <code>sharedlibrary</code> tag in the Kalumet configuration DOM.
*/
public class SharedLibrary
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = -16763008144930653L;
+ private static final long serialVersionUID = -16763008144930653L;
- private String name;
+ private String name;
- private String classpath;
+ private String classpath;
- private boolean active;
+ private boolean active;
- private boolean blocker;
+ private boolean blocker;
- public SharedLibrary()
- {
- }
+ public SharedLibrary()
+ {
+ }
- public String getName()
- {
- return this.name;
- }
+ public String getName()
+ {
+ return this.name;
+ }
- public void setName( String name )
- {
- this.name = name;
- }
+ public void setName( String name )
+ {
+ this.name = name;
+ }
- public String getClasspath()
- {
- return this.classpath;
- }
+ public String getClasspath()
+ {
+ return this.classpath;
+ }
- public void setClasspath( String classpath )
- {
- this.classpath = classpath;
- }
+ public void setClasspath( String classpath )
+ {
+ this.classpath = classpath;
+ }
- public boolean isActive()
- {
- return this.active;
- }
+ public boolean isActive()
+ {
+ return this.active;
+ }
- public void setActive( boolean active )
- {
- this.active = active;
- }
+ public void setActive( boolean active )
+ {
+ this.active = active;
+ }
- public boolean isBlocker()
- {
- return this.blocker;
- }
+ public boolean isBlocker()
+ {
+ return this.blocker;
+ }
- public void setBlocker( boolean blocker )
- {
- this.blocker = blocker;
- }
+ public void setBlocker( boolean blocker )
+ {
+ this.blocker = blocker;
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- SharedLibrary clone = new SharedLibrary();
- clone.setName( this.getName() );
- clone.setClasspath( this.getClasspath() );
- clone.setActive( this.isActive() );
- clone.setBlocker( this.isBlocker() );
- return clone;
- }
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ SharedLibrary clone = new SharedLibrary();
+ clone.setName( this.getName() );
+ clone.setClasspath( this.getClasspath() );
+ clone.setActive( this.isActive() );
+ clone.setBlocker( this.isBlocker() );
+ return clone;
+ }
- /**
- * Transform the <code>SharedLibrary</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "sharedlibrary" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "classpath", this.getClasspath() );
- element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
- element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
- return element;
- }
+ /**
+ * Transform the <code>SharedLibrary</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "sharedlibrary" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "classpath", this.getClasspath() );
+ element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
+ element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
+ return element;
+ }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherSharedLibrary )
- {
- return this.getName().compareTo( ( (SharedLibrary) anotherSharedLibrary ).getName() );
- }
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherSharedLibrary )
+ {
+ return this.getName().compareTo( ( (SharedLibrary) anotherSharedLibrary ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Software.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Software.java
index 0220557..6c10f4e 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Software.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Software.java
@@ -30,365 +30,368 @@
* Represent the <code>software</code> tag in the Kalumet DOM.
*/
public class Software
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = 1464721106305749412L;
+ private static final long serialVersionUID = 1464721106305749412L;
- private String name;
+ private String name;
- private String uri;
+ private String uri;
- private String agent;
+ private String agent;
- private boolean active;
+ private boolean active;
- private boolean blocker;
+ private boolean blocker;
- private boolean beforejee;
+ private boolean beforejee;
- private LinkedList updatePlan;
+ private LinkedList updatePlan;
- public Software()
- {
- this.updatePlan = new LinkedList();
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public String getUri()
- {
- return uri;
- }
-
- public void setUri( String uri )
- {
- this.uri = uri;
- }
-
- public String getAgent()
- {
- return agent;
- }
-
- public void setAgent( String agent )
- {
- this.agent = agent;
- }
-
- public boolean isActive()
- {
- return active;
- }
-
- public void setActive( boolean active )
- {
- this.active = active;
- }
-
- public boolean isBlocker()
- {
- return blocker;
- }
-
- public void setBlocker( boolean blocker )
- {
- this.blocker = blocker;
- }
-
- public boolean isBeforejee()
- {
- return beforejee;
- }
-
- public void setBeforejee(boolean beforejee)
- {
- this.beforejee = beforejee;
- }
-
- public LinkedList getUpdatePlan()
- {
- return updatePlan;
- }
-
- public void setUpdatePlan( LinkedList updatePlan )
- {
- this.updatePlan = updatePlan;
- }
-
- /**
- * Get the software component with the given name.
- *
- * @param name the software component name.
- * @return the component <code>Object</code> or <code>null</code> if not found.
- */
- public Object getComponent( String name )
- {
- Object component = this.getLocation( name );
- if ( component != null )
+ public Software()
{
- return component;
+ this.updatePlan = new LinkedList();
}
- component = this.getCommand( name );
- if ( component != null )
- {
- return component;
- }
- component = this.getConfigurationFile( name );
- if ( component != null )
- {
- return component;
- }
- component = this.getDatabase( name );
- if ( component != null )
- {
- return component;
- }
- return null;
- }
- /**
- * Add a system command into the software update plan.
- *
- * @param command the system command
- */
- public void addCommand( Command command )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getComponent( command.getName() ) != null )
+ public String getName()
{
- throw new ModelObjectAlreadyExistsException( "Software component " + command.getName() + " already exists." );
+ return name;
}
- updatePlan.add( command );
- }
- /**
- * Get the command identified by <code>name</code> in the software update plan..
- *
- * @param name the command name.
- * @return the <code>Command</code> or <code>null</code> if not found.
- */
- public Command getCommand( String name )
- {
- for ( Iterator updatePlanIterator = updatePlan.iterator(); updatePlanIterator.hasNext(); )
+ public void setName( String name )
{
- Object item = updatePlanIterator.next();
- if ( item instanceof Command )
- {
- Command command = (Command) item;
- if ( command.getName().equals( name ) )
+ this.name = name;
+ }
+
+ public String getUri()
+ {
+ return uri;
+ }
+
+ public void setUri( String uri )
+ {
+ this.uri = uri;
+ }
+
+ public String getAgent()
+ {
+ return agent;
+ }
+
+ public void setAgent( String agent )
+ {
+ this.agent = agent;
+ }
+
+ public boolean isActive()
+ {
+ return active;
+ }
+
+ public void setActive( boolean active )
+ {
+ this.active = active;
+ }
+
+ public boolean isBlocker()
+ {
+ return blocker;
+ }
+
+ public void setBlocker( boolean blocker )
+ {
+ this.blocker = blocker;
+ }
+
+ public boolean isBeforejee()
+ {
+ return beforejee;
+ }
+
+ public void setBeforejee( boolean beforejee )
+ {
+ this.beforejee = beforejee;
+ }
+
+ public LinkedList getUpdatePlan()
+ {
+ return updatePlan;
+ }
+
+ public void setUpdatePlan( LinkedList updatePlan )
+ {
+ this.updatePlan = updatePlan;
+ }
+
+ /**
+ * Get the software component with the given name.
+ *
+ * @param name the software component name.
+ * @return the component <code>Object</code> or <code>null</code> if not found.
+ */
+ public Object getComponent( String name )
+ {
+ Object component = this.getLocation( name );
+ if ( component != null )
{
- return command;
+ return component;
}
- }
- }
- return null;
- }
-
- /**
- * Add a <code>Location</code> into the software update plan.
- *
- * @param location the files/directories location
- */
- public void addLocation( Location location )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getComponent( location.getName() ) != null )
- {
- throw new ModelObjectAlreadyExistsException( "Software component " + location.getName() + " already exists." );
- }
- updatePlan.add( location );
- }
-
- /**
- * Get the <code>Location</code> identified by <code>name</code> in the software update plan..
- *
- * @param name the location name.
- * @return the <code>Location</code> or <code>null</code> if not found.
- */
- public Location getLocation( String name )
- {
- for ( Iterator updatePlanIterator = updatePlan.iterator(); updatePlanIterator.hasNext(); )
- {
- Object item = updatePlanIterator.next();
- if ( item instanceof Location )
- {
- Location location = (Location) item;
- if ( location.getName().equals( name ) )
+ component = this.getCommand( name );
+ if ( component != null )
{
- return location;
+ return component;
}
- }
- }
- return null;
- }
-
- /**
- * Add a <code>ConfigurationFile</code> into the software update plan.
- *
- * @param configurationFile the configuration file.
- */
- public void addConfigurationFile( ConfigurationFile configurationFile )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getComponent( configurationFile.getName() ) != null )
- {
- throw new ModelObjectAlreadyExistsException(
- "Software component " + configurationFile.getName() + " already exists." );
- }
- updatePlan.add( configurationFile );
- }
-
- /**
- * Get the <code>ConfigurationFile</code> identified by <code>name</code> in the software update plan.
- *
- * @param name the configuration file name.
- * @return the <code>ConfigurationFile</code> or <code>null</code> if not found.
- */
- public ConfigurationFile getConfigurationFile( String name )
- {
- for ( Iterator updatePlanIterator = updatePlan.iterator(); updatePlanIterator.hasNext(); )
- {
- Object item = updatePlanIterator.next();
- if ( item instanceof ConfigurationFile )
- {
- ConfigurationFile configurationFile = (ConfigurationFile) item;
- if ( configurationFile.getName().equals( name ) )
+ component = this.getConfigurationFile( name );
+ if ( component != null )
{
- return configurationFile;
+ return component;
}
- }
- }
- return null;
- }
-
- /**
- * Add a database (including SQL scripts) into the software update plan.
- *
- * @param database the database
- */
- public void addDatabase( Database database )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getComponent( database.getName() ) != null )
- {
- throw new ModelObjectAlreadyExistsException( "Software component " + database.getName() + " already exists." );
- }
- updatePlan.add( database );
- }
-
- /**
- * Get the <code>Database</code> identified by <code>name</code> in the software update plan.
- *
- * @param name the database name.
- * @return the <code>Database</code> or <code>null</code> if not found.
- */
- public Database getDatabase( String name )
- {
- for ( Iterator updatePlanIterator = updatePlan.iterator(); updatePlanIterator.hasNext(); )
- {
- Object item = updatePlanIterator.next();
- if ( item instanceof Database )
- {
- Database database = (Database) item;
- if ( database.getName().equals( name ) )
+ component = this.getDatabase( name );
+ if ( component != null )
{
- return database;
+ return component;
}
- }
+ return null;
}
- return null;
- }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- Software clone = new Software();
- clone.setName( this.getName() );
- clone.setUri( this.getUri() );
- clone.setActive( this.isActive() );
- clone.setBlocker( this.isBlocker() );
- clone.setBeforejee(this.isBeforejee());
- for ( Iterator updatePlanIterator = this.getUpdatePlan().iterator(); updatePlanIterator.hasNext(); )
+ /**
+ * Add a system command into the software update plan.
+ *
+ * @param command the system command
+ */
+ public void addCommand( Command command )
+ throws ModelObjectAlreadyExistsException
{
- Object item = updatePlanIterator.next();
- if ( item instanceof Command )
- {
- clone.getUpdatePlan().add( ( (Command) item ).clone() );
- }
- if ( item instanceof Location )
- {
- clone.getUpdatePlan().add( ( (Location) item ).clone() );
- }
- if ( item instanceof ConfigurationFile )
- {
- clone.getUpdatePlan().add( ( (ConfigurationFile) item ).clone() );
- }
- if ( item instanceof Database )
- {
- clone.getUpdatePlan().add( ( (Database) item ).clone() );
- }
+ if ( this.getComponent( command.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException(
+ "Software component " + command.getName() + " already exists." );
+ }
+ updatePlan.add( command );
}
- return clone;
- }
- /**
- * Transform a <code>software</code> into a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "software" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "uri", this.getUri() );
- element.setAttribute( "agent", this.getAgent() );
- element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
- element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
- element.setAttribute( "beforejee", new Boolean( this.isBeforejee() ).toString() );
- ElementImpl updateplan = new ElementImpl( document, "updateplan" );
- element.appendChild( updateplan );
- for ( Iterator updatePlanIterator = this.getUpdatePlan().iterator(); updatePlanIterator.hasNext(); )
+ /**
+ * Get the command identified by <code>name</code> in the software update plan..
+ *
+ * @param name the command name.
+ * @return the <code>Command</code> or <code>null</code> if not found.
+ */
+ public Command getCommand( String name )
{
- Object item = updatePlanIterator.next();
- if ( item instanceof Command )
- {
- updateplan.appendChild( ( (Command) item ).toDOMElement( document ) );
- }
- if ( item instanceof Location )
- {
- updateplan.appendChild( ( (Location) item ).toDOMElement( document ) );
- }
- if ( item instanceof ConfigurationFile )
- {
- updateplan.appendChild( ( (ConfigurationFile) item ).toDOMElement( document ) );
- }
- if ( item instanceof Database )
- {
- updateplan.appendChild( ( (Database) item ).toDOMElement( document ) );
- }
+ for ( Iterator updatePlanIterator = updatePlan.iterator(); updatePlanIterator.hasNext(); )
+ {
+ Object item = updatePlanIterator.next();
+ if ( item instanceof Command )
+ {
+ Command command = (Command) item;
+ if ( command.getName().equals( name ) )
+ {
+ return command;
+ }
+ }
+ }
+ return null;
}
- return element;
- }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherSoftware )
- {
- return this.getName().compareTo( ( (Software) anotherSoftware ).getName() );
- }
+ /**
+ * Add a <code>Location</code> into the software update plan.
+ *
+ * @param location the files/directories location
+ */
+ public void addLocation( Location location )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getComponent( location.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException(
+ "Software component " + location.getName() + " already exists." );
+ }
+ updatePlan.add( location );
+ }
+
+ /**
+ * Get the <code>Location</code> identified by <code>name</code> in the software update plan..
+ *
+ * @param name the location name.
+ * @return the <code>Location</code> or <code>null</code> if not found.
+ */
+ public Location getLocation( String name )
+ {
+ for ( Iterator updatePlanIterator = updatePlan.iterator(); updatePlanIterator.hasNext(); )
+ {
+ Object item = updatePlanIterator.next();
+ if ( item instanceof Location )
+ {
+ Location location = (Location) item;
+ if ( location.getName().equals( name ) )
+ {
+ return location;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add a <code>ConfigurationFile</code> into the software update plan.
+ *
+ * @param configurationFile the configuration file.
+ */
+ public void addConfigurationFile( ConfigurationFile configurationFile )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getComponent( configurationFile.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException(
+ "Software component " + configurationFile.getName() + " already exists." );
+ }
+ updatePlan.add( configurationFile );
+ }
+
+ /**
+ * Get the <code>ConfigurationFile</code> identified by <code>name</code> in the software update plan.
+ *
+ * @param name the configuration file name.
+ * @return the <code>ConfigurationFile</code> or <code>null</code> if not found.
+ */
+ public ConfigurationFile getConfigurationFile( String name )
+ {
+ for ( Iterator updatePlanIterator = updatePlan.iterator(); updatePlanIterator.hasNext(); )
+ {
+ Object item = updatePlanIterator.next();
+ if ( item instanceof ConfigurationFile )
+ {
+ ConfigurationFile configurationFile = (ConfigurationFile) item;
+ if ( configurationFile.getName().equals( name ) )
+ {
+ return configurationFile;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add a database (including SQL scripts) into the software update plan.
+ *
+ * @param database the database
+ */
+ public void addDatabase( Database database )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getComponent( database.getName() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException(
+ "Software component " + database.getName() + " already exists." );
+ }
+ updatePlan.add( database );
+ }
+
+ /**
+ * Get the <code>Database</code> identified by <code>name</code> in the software update plan.
+ *
+ * @param name the database name.
+ * @return the <code>Database</code> or <code>null</code> if not found.
+ */
+ public Database getDatabase( String name )
+ {
+ for ( Iterator updatePlanIterator = updatePlan.iterator(); updatePlanIterator.hasNext(); )
+ {
+ Object item = updatePlanIterator.next();
+ if ( item instanceof Database )
+ {
+ Database database = (Database) item;
+ if ( database.getName().equals( name ) )
+ {
+ return database;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ Software clone = new Software();
+ clone.setName( this.getName() );
+ clone.setUri( this.getUri() );
+ clone.setActive( this.isActive() );
+ clone.setBlocker( this.isBlocker() );
+ clone.setBeforejee( this.isBeforejee() );
+ for ( Iterator updatePlanIterator = this.getUpdatePlan().iterator(); updatePlanIterator.hasNext(); )
+ {
+ Object item = updatePlanIterator.next();
+ if ( item instanceof Command )
+ {
+ clone.getUpdatePlan().add( ( (Command) item ).clone() );
+ }
+ if ( item instanceof Location )
+ {
+ clone.getUpdatePlan().add( ( (Location) item ).clone() );
+ }
+ if ( item instanceof ConfigurationFile )
+ {
+ clone.getUpdatePlan().add( ( (ConfigurationFile) item ).clone() );
+ }
+ if ( item instanceof Database )
+ {
+ clone.getUpdatePlan().add( ( (Database) item ).clone() );
+ }
+ }
+ return clone;
+ }
+
+ /**
+ * Transform a <code>software</code> into a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "software" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "uri", this.getUri() );
+ element.setAttribute( "agent", this.getAgent() );
+ element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
+ element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
+ element.setAttribute( "beforejee", new Boolean( this.isBeforejee() ).toString() );
+ ElementImpl updateplan = new ElementImpl( document, "updateplan" );
+ element.appendChild( updateplan );
+ for ( Iterator updatePlanIterator = this.getUpdatePlan().iterator(); updatePlanIterator.hasNext(); )
+ {
+ Object item = updatePlanIterator.next();
+ if ( item instanceof Command )
+ {
+ updateplan.appendChild( ( (Command) item ).toDOMElement( document ) );
+ }
+ if ( item instanceof Location )
+ {
+ updateplan.appendChild( ( (Location) item ).toDOMElement( document ) );
+ }
+ if ( item instanceof ConfigurationFile )
+ {
+ updateplan.appendChild( ( (ConfigurationFile) item ).toDOMElement( document ) );
+ }
+ if ( item instanceof Database )
+ {
+ updateplan.appendChild( ( (Database) item ).toDOMElement( document ) );
+ }
+ }
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherSoftware )
+ {
+ return this.getName().compareTo( ( (Software) anotherSoftware ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/SqlScript.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/SqlScript.java
index 3b36414..b793a64 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/SqlScript.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/SqlScript.java
@@ -31,187 +31,187 @@
* Represent the <code>sqlscript</code> tag in the Kalumet configuration DOM.
*/
public class SqlScript
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = 2997968132530345317L;
+ private static final long serialVersionUID = 2997968132530345317L;
- private String name;
+ private String name;
- private String uri;
+ private String uri;
- private boolean active;
+ private boolean active;
- private boolean blocker;
+ private boolean blocker;
- private boolean force;
+ private boolean force;
- private LinkedList mappings;
+ private LinkedList mappings;
- public SqlScript()
- {
- this.mappings = new LinkedList();
- }
-
- public String getName()
- {
- return this.name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public String getUri()
- {
- return this.uri;
- }
-
- public void setUri( String uri )
- {
- this.uri = uri;
- }
-
- public boolean isActive()
- {
- return this.active;
- }
-
- public void setActive( boolean active )
- {
- this.active = active;
- }
-
- public boolean isBlocker()
- {
- return this.blocker;
- }
-
- public void setBlocker( boolean blocker )
- {
- this.blocker = blocker;
- }
-
- public boolean isForce()
- {
- return this.force;
- }
-
- public void setForce( boolean force )
- {
- this.force = force;
- }
-
- /**
- * Add a new <code>Mapping</code> in the <code>SqlScript</code> mappings
- * container.
- *
- * @param mapping the <code>Mapping</code> to add.
- */
- public void addMapping( Mapping mapping )
- throws ModelObjectAlreadyExistsException
- {
- if ( this.getMapping( mapping.getKey() ) != null )
+ public SqlScript()
{
- throw new ModelObjectAlreadyExistsException( "Mapping key already exists in sqlscript." );
+ this.mappings = new LinkedList();
}
- this.mappings.add( mapping );
- }
- /**
- * Get the <code>Mapping</code> list in the <code>SqlScript</code>
- * mappings container.
- *
- * @return the <code>Mapping</code> list.
- */
- public List getMappings()
- {
- return this.mappings;
- }
-
- /**
- * Set the <code>Mapping</code> in the <code>SqlScript</code>
- * mappings container.
- *
- * @param mappings the new <code>Mapping</code> list.
- */
- public void setMappings( LinkedList mappings )
- {
- this.mappings = mappings;
- }
-
- /**
- * Get the <code>Mapping</code> identified by a given key in the
- * <code>SqlScript</code> mappings container.
- *
- * @param key the <code>Mapping</code> key.
- * @return the <code>Mapping</code> found or null if not found.
- */
- public Mapping getMapping( String key )
- {
- for ( Iterator mappingIterator = this.getMappings().iterator(); mappingIterator.hasNext(); )
+ public String getName()
{
- Mapping mapping = (Mapping) mappingIterator.next();
- if ( mapping.getKey().equals( key ) )
- {
- return mapping;
- }
+ return this.name;
}
- return null;
- }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- SqlScript clone = new SqlScript();
- clone.setName( this.getName() );
- clone.setUri( this.getUri() );
- clone.setActive( this.isActive() );
- clone.setBlocker( this.isBlocker() );
- clone.setForce( this.isForce() );
- for ( Iterator mappingIterator = this.mappings.iterator(); mappingIterator.hasNext(); )
+ public void setName( String name )
{
- Mapping mapping = (Mapping) mappingIterator.next();
- clone.mappings.add( (Mapping) mapping.clone() );
+ this.name = name;
}
- return clone;
- }
- /**
- * Transform the <code>SqlScript</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "sqlscript" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "uri", this.getUri() );
- element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
- element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
- element.setAttribute( "force", new Boolean( this.isForce() ).toString() );
- // mappings
- ElementImpl mappings = new ElementImpl( document, "mappings" );
- for ( Iterator mappingIterator = this.getMappings().iterator(); mappingIterator.hasNext(); )
+ public String getUri()
{
- Mapping mapping = (Mapping) mappingIterator.next();
- mappings.appendChild( mapping.toDOMElement( document ) );
+ return this.uri;
}
- element.appendChild( mappings );
- return element;
- }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherSqlScript )
- {
- return this.getName().compareTo( ( (SqlScript) anotherSqlScript ).getName() );
- }
+ public void setUri( String uri )
+ {
+ this.uri = uri;
+ }
+
+ public boolean isActive()
+ {
+ return this.active;
+ }
+
+ public void setActive( boolean active )
+ {
+ this.active = active;
+ }
+
+ public boolean isBlocker()
+ {
+ return this.blocker;
+ }
+
+ public void setBlocker( boolean blocker )
+ {
+ this.blocker = blocker;
+ }
+
+ public boolean isForce()
+ {
+ return this.force;
+ }
+
+ public void setForce( boolean force )
+ {
+ this.force = force;
+ }
+
+ /**
+ * Add a new <code>Mapping</code> in the <code>SqlScript</code> mappings
+ * container.
+ *
+ * @param mapping the <code>Mapping</code> to add.
+ */
+ public void addMapping( Mapping mapping )
+ throws ModelObjectAlreadyExistsException
+ {
+ if ( this.getMapping( mapping.getKey() ) != null )
+ {
+ throw new ModelObjectAlreadyExistsException( "Mapping key already exists in sqlscript." );
+ }
+ this.mappings.add( mapping );
+ }
+
+ /**
+ * Get the <code>Mapping</code> list in the <code>SqlScript</code>
+ * mappings container.
+ *
+ * @return the <code>Mapping</code> list.
+ */
+ public List getMappings()
+ {
+ return this.mappings;
+ }
+
+ /**
+ * Set the <code>Mapping</code> in the <code>SqlScript</code>
+ * mappings container.
+ *
+ * @param mappings the new <code>Mapping</code> list.
+ */
+ public void setMappings( LinkedList mappings )
+ {
+ this.mappings = mappings;
+ }
+
+ /**
+ * Get the <code>Mapping</code> identified by a given key in the
+ * <code>SqlScript</code> mappings container.
+ *
+ * @param key the <code>Mapping</code> key.
+ * @return the <code>Mapping</code> found or null if not found.
+ */
+ public Mapping getMapping( String key )
+ {
+ for ( Iterator mappingIterator = this.getMappings().iterator(); mappingIterator.hasNext(); )
+ {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ if ( mapping.getKey().equals( key ) )
+ {
+ return mapping;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ SqlScript clone = new SqlScript();
+ clone.setName( this.getName() );
+ clone.setUri( this.getUri() );
+ clone.setActive( this.isActive() );
+ clone.setBlocker( this.isBlocker() );
+ clone.setForce( this.isForce() );
+ for ( Iterator mappingIterator = this.mappings.iterator(); mappingIterator.hasNext(); )
+ {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ clone.mappings.add( (Mapping) mapping.clone() );
+ }
+ return clone;
+ }
+
+ /**
+ * Transform the <code>SqlScript</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "sqlscript" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "uri", this.getUri() );
+ element.setAttribute( "active", new Boolean( this.isActive() ).toString() );
+ element.setAttribute( "blocker", new Boolean( this.isBlocker() ).toString() );
+ element.setAttribute( "force", new Boolean( this.isForce() ).toString() );
+ // mappings
+ ElementImpl mappings = new ElementImpl( document, "mappings" );
+ for ( Iterator mappingIterator = this.getMappings().iterator(); mappingIterator.hasNext(); )
+ {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ mappings.appendChild( mapping.toDOMElement( document ) );
+ }
+ element.appendChild( mappings );
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherSqlScript )
+ {
+ return this.getName().compareTo( ( (SqlScript) anotherSqlScript ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Statistics.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Statistics.java
index 8a6ae4b..009873c 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Statistics.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Statistics.java
@@ -28,78 +28,78 @@
* Store environment statistics (number of update, etc).
*/
public class Statistics
- implements Serializable, Cloneable
+ implements Serializable, Cloneable
{
- private static final long serialVersionUID = -6110824574514994557L;
+ private static final long serialVersionUID = -6110824574514994557L;
- private int updateCount;
+ private int updateCount;
- private String lastUpdateDate;
+ private String lastUpdateDate;
- private String lastChangeDate;
+ private String lastChangeDate;
- public Statistics()
- {
- updateCount = 0;
- }
+ public Statistics()
+ {
+ updateCount = 0;
+ }
- public int getUpdateCount()
- {
- return updateCount;
- }
+ public int getUpdateCount()
+ {
+ return updateCount;
+ }
- public void setUpdateCount( int updateCount )
- {
- this.updateCount = updateCount;
- }
+ public void setUpdateCount( int updateCount )
+ {
+ this.updateCount = updateCount;
+ }
- public String getLastUpdateDate()
- {
- return lastUpdateDate;
- }
+ public String getLastUpdateDate()
+ {
+ return lastUpdateDate;
+ }
- public void setLastUpdateDate( String lastUpdateDate )
- {
- this.lastUpdateDate = lastUpdateDate;
- }
+ public void setLastUpdateDate( String lastUpdateDate )
+ {
+ this.lastUpdateDate = lastUpdateDate;
+ }
- public String getLastChangeDate()
- {
- return lastChangeDate;
- }
+ public String getLastChangeDate()
+ {
+ return lastChangeDate;
+ }
- public void setLastChangeDate( String lastChangeDate )
- {
- this.lastChangeDate = lastChangeDate;
- }
+ public void setLastChangeDate( String lastChangeDate )
+ {
+ this.lastChangeDate = lastChangeDate;
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- Statistics clone = new Statistics();
- clone.setUpdateCount( this.getUpdateCount() );
- clone.setLastChangeDate( this.getLastChangeDate() );
- clone.setLastUpdateDate( this.getLastUpdateDate() );
- return clone;
- }
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ Statistics clone = new Statistics();
+ clone.setUpdateCount( this.getUpdateCount() );
+ clone.setLastChangeDate( this.getLastChangeDate() );
+ clone.setLastUpdateDate( this.getLastUpdateDate() );
+ return clone;
+ }
- /**
- * Transform the <code>Statistics</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "statistics" );
- element.setAttribute( "updatecount", new Integer( this.getUpdateCount() ).toString() );
- element.setAttribute( "lastupdatedate", this.getLastUpdateDate() );
- element.setAttribute( "lastchangedate", this.getLastChangeDate() );
- return element;
- }
+ /**
+ * Transform the <code>Statistics</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "statistics" );
+ element.setAttribute( "updatecount", new Integer( this.getUpdateCount() ).toString() );
+ element.setAttribute( "lastupdatedate", this.getLastUpdateDate() );
+ element.setAttribute( "lastchangedate", this.getLastChangeDate() );
+ return element;
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/User.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/User.java
index b843c84..19e9c93 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/User.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/User.java
@@ -30,159 +30,159 @@
* Represent the <code>user</code> tag in the Kalumet configuration DOM.
*/
public class User
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = -1628759131745053332L;
+ private static final long serialVersionUID = -1628759131745053332L;
- private String id;
+ private String id;
- private String name;
+ private String name;
- private String email;
+ private String email;
- private String password;
+ private String password;
- public User()
- {
- }
-
- public String getId()
- {
- return this.id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- public String getName()
- {
- return this.name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public String getEmail()
- {
- return this.email;
- }
-
- public void setEmail( String email )
- {
- this.email = email;
- }
-
- /**
- * <b>Warning : this method returns the encrypted password</b>
- */
- public String getPassword()
- {
- return this.password;
- }
-
- /**
- * <b>Warning : this method is expecting for an encrypted password</b>
- */
- public void setPassword( String password )
- {
- this.password = password;
- }
-
- /**
- * Encrypts MD5 of a given password.
- *
- * @param password the password to encrypt.
- * @return the MD5 encrypted password.
- */
- public static String md5PasswordCrypt( String password )
- throws KalumetException
- {
- try
+ public User()
{
- byte[] hash = MessageDigest.getInstance( "MD5" ).digest( password.getBytes() );
- StringBuffer hashString = new StringBuffer();
- for ( int i = 0; i < hash.length; i++ )
- {
- String hex = Integer.toHexString( hash[i] );
- if ( hex.length() == 1 )
+ }
+
+ public String getId()
+ {
+ return this.id;
+ }
+
+ public void setId( String id )
+ {
+ this.id = id;
+ }
+
+ public String getName()
+ {
+ return this.name;
+ }
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ public String getEmail()
+ {
+ return this.email;
+ }
+
+ public void setEmail( String email )
+ {
+ this.email = email;
+ }
+
+ /**
+ * <b>Warning : this method returns the encrypted password</b>
+ */
+ public String getPassword()
+ {
+ return this.password;
+ }
+
+ /**
+ * <b>Warning : this method is expecting for an encrypted password</b>
+ */
+ public void setPassword( String password )
+ {
+ this.password = password;
+ }
+
+ /**
+ * Encrypts MD5 of a given password.
+ *
+ * @param password the password to encrypt.
+ * @return the MD5 encrypted password.
+ */
+ public static String md5PasswordCrypt( String password )
+ throws KalumetException
+ {
+ try
{
- hashString.append( '0' );
- hashString.append( hex.charAt( hex.length() - 1 ) );
+ byte[] hash = MessageDigest.getInstance( "MD5" ).digest( password.getBytes() );
+ StringBuffer hashString = new StringBuffer();
+ for ( int i = 0; i < hash.length; i++ )
+ {
+ String hex = Integer.toHexString( hash[i] );
+ if ( hex.length() == 1 )
+ {
+ hashString.append( '0' );
+ hashString.append( hex.charAt( hex.length() - 1 ) );
+ }
+ else
+ {
+ hashString.append( hex.substring( hex.length() - 2 ) );
+ }
+ }
+ return hashString.toString();
+ }
+ catch ( Exception e )
+ {
+ throw new KalumetException( "Cant' crypt password.", e );
+ }
+ }
+
+ /**
+ * Check if a given password match the <code>User</code> password.
+ *
+ * @param password the given password.
+ * @return true of the password match the <code>User</code> password, false else.
+ */
+ public boolean checkPassword( String password )
+ throws KalumetException
+ {
+ String crypt = User.md5PasswordCrypt( password );
+ if ( this.getPassword().equals( crypt ) )
+ {
+ return true;
}
else
{
- hashString.append( hex.substring( hex.length() - 2 ) );
+ return false;
}
- }
- return hashString.toString();
}
- catch ( Exception e )
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
{
- throw new KalumetException( "Cant' crypt password.", e );
+ User clone = new User();
+ clone.setId( this.getId() );
+ clone.setName( this.getName() );
+ clone.setEmail( this.getEmail() );
+ clone.setPassword( this.getPassword() );
+ return clone;
}
- }
- /**
- * Check if a given password match the <code>User</code> password.
- *
- * @param password the given password.
- * @return true of the password match the <code>User</code> password, false else.
- */
- public boolean checkPassword( String password )
- throws KalumetException
- {
- String crypt = User.md5PasswordCrypt( password );
- if ( this.getPassword().equals( crypt ) )
+ /**
+ * Transform the <code>User</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
{
- return true;
+ ElementImpl element = new ElementImpl( document, "user" );
+ element.setAttribute( "id", this.getId() );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "email", this.getEmail() );
+ element.setAttribute( "password", this.getPassword() );
+ return element;
}
- else
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherUser )
{
- return false;
+ return this.getId().compareTo( ( (User) anotherUser ).getId() );
}
- }
-
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- User clone = new User();
- clone.setId( this.getId() );
- clone.setName( this.getName() );
- clone.setEmail( this.getEmail() );
- clone.setPassword( this.getPassword() );
- return clone;
- }
-
- /**
- * Transform the <code>User</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "user" );
- element.setAttribute( "id", this.getId() );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "email", this.getEmail() );
- element.setAttribute( "password", this.getPassword() );
- return element;
- }
-
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherUser )
- {
- return this.getId().compareTo( ( (User) anotherUser ).getId() );
- }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Variable.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Variable.java
index cfb6119..20ed2bc 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Variable.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/Variable.java
@@ -28,71 +28,71 @@
* Represent a <code>variable</code> tag in the Kalumet configuration DOM.
*/
public class Variable
- implements Serializable, Cloneable, Comparable
+ implements Serializable, Cloneable, Comparable
{
- private static final long serialVersionUID = -7869565872871570323L;
+ private static final long serialVersionUID = -7869565872871570323L;
- private String name;
+ private String name;
- private String value;
+ private String value;
- public Variable()
- {
- }
+ public Variable()
+ {
+ }
- public void setName( String name )
- {
- this.name = name;
- }
+ public void setName( String name )
+ {
+ this.name = name;
+ }
- public String getName()
- {
- return this.name;
- }
+ public String getName()
+ {
+ return this.name;
+ }
- public void setValue( String value )
- {
- this.value = value;
- }
+ public void setValue( String value )
+ {
+ this.value = value;
+ }
- public String getValue()
- {
- return this.value;
- }
+ public String getValue()
+ {
+ return this.value;
+ }
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone()
- throws CloneNotSupportedException
- {
- Variable clone = new Variable();
- clone.setName( this.getName() );
- clone.setValue( this.getValue() );
- return clone;
- }
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ Variable clone = new Variable();
+ clone.setName( this.getName() );
+ clone.setValue( this.getValue() );
+ return clone;
+ }
- /**
- * Transform the <code>Variable</code> POJO to a DOM Element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "variable" );
- element.setAttribute( "name", this.getName() );
- element.setAttribute( "value", this.getValue() );
- return element;
- }
+ /**
+ * Transform the <code>Variable</code> POJO to a DOM Element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "variable" );
+ element.setAttribute( "name", this.getName() );
+ element.setAttribute( "value", this.getValue() );
+ return element;
+ }
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo( Object anotherVariable )
- {
- return this.getName().compareTo( ( (Variable) anotherVariable ).getName() );
- }
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Object anotherVariable )
+ {
+ return this.getName().compareTo( ( (Variable) anotherVariable ).getName() );
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/log/Event.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/log/Event.java
index e371968..bbfed65 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/log/Event.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/log/Event.java
@@ -29,73 +29,73 @@
public class Event
{
- private String date;
+ private String date;
- private String severity;
+ private String severity;
- private String author;
+ private String author;
- private String content;
+ private String content;
- public Event()
- {
- }
+ public Event()
+ {
+ }
- public String getDate()
- {
- return this.date;
- }
+ public String getDate()
+ {
+ return this.date;
+ }
- public void setDate( String date )
- {
- this.date = date;
- }
+ public void setDate( String date )
+ {
+ this.date = date;
+ }
- public String getSeverity()
- {
- return this.severity;
- }
+ public String getSeverity()
+ {
+ return this.severity;
+ }
- public void setSeverity( String severity )
- {
- this.severity = severity;
- }
+ public void setSeverity( String severity )
+ {
+ this.severity = severity;
+ }
- public String getAuthor()
- {
- return this.author;
- }
+ public String getAuthor()
+ {
+ return this.author;
+ }
- public void setAuthor( String author )
- {
- this.author = author;
- }
+ public void setAuthor( String author )
+ {
+ this.author = author;
+ }
- public String getContent()
- {
- return this.content;
- }
+ public String getContent()
+ {
+ return this.content;
+ }
- public void setContent( String content )
- {
- this.content = content;
- }
+ public void setContent( String content )
+ {
+ this.content = content;
+ }
- /**
- * Transforms the <code>Event</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "event" );
- element.setAttribute( "date", this.getDate() );
- element.setAttribute( "severity", this.getSeverity() );
- element.setAttribute( "author", this.getAuthor() );
- CDATASectionImpl content = new CDATASectionImpl( document, this.getContent() );
- element.appendChild( content );
- return element;
- }
+ /**
+ * Transforms the <code>Event</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "event" );
+ element.setAttribute( "date", this.getDate() );
+ element.setAttribute( "severity", this.getSeverity() );
+ element.setAttribute( "author", this.getAuthor() );
+ CDATASectionImpl content = new CDATASectionImpl( document, this.getContent() );
+ element.appendChild( content );
+ return element;
+ }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/log/Journal.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/log/Journal.java
index 6c54f7f..1bd8109 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/log/Journal.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/log/Journal.java
@@ -40,142 +40,142 @@
public class Journal
{
- private LinkedList events;
+ private LinkedList events;
- private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+ private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- public Journal()
- {
- this.events = new LinkedList();
- }
-
- /**
- * Adds a new <code>Event</code> in the <code>Journal</code> container.
- *
- * @param event the <code>Event</code> to add.
- */
- public void addEvent( Event event )
- {
- this.events.add( event );
- }
-
- /**
- * Gets the <code>Event</code> list in the <code>Journal</code>
- * container.
- *
- * @return the <code>Event</code> list.
- */
- public List getEvents()
- {
- return this.events;
- }
-
- /**
- * Transforms the <code>Journal</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "journal" );
- // events
- for ( Iterator eventIterator = this.getEvents().iterator(); eventIterator.hasNext(); )
+ public Journal()
{
- Event event = (Event) eventIterator.next();
- element.appendChild( event.toDOMElement( document ) );
+ this.events = new LinkedList();
}
- return element;
- }
- /**
- * Parses and loads a given XML log file and return the environment journal root tag.
- *
- * @param path the environment log XML to parse.
- * @return the environment <code>Journal</code> corresponding with the journal root tag.
- */
- public static Journal digeste( String path )
- throws KalumetException
- {
- if ( !path.startsWith( "http:" ) && !path.startsWith( "HTTP:" ) && !path.startsWith( "file:" ) && !path.startsWith(
- "FILE:" ) )
+ /**
+ * Adds a new <code>Event</code> in the <code>Journal</code> container.
+ *
+ * @param event the <code>Event</code> to add.
+ */
+ public void addEvent( Event event )
{
- path = "file:" + path;
+ this.events.add( event );
}
- Journal journal = null;
- try
+
+ /**
+ * Gets the <code>Event</code> list in the <code>Journal</code>
+ * container.
+ *
+ * @return the <code>Event</code> list.
+ */
+ public List getEvents()
{
-
- // init the digester with no validation on the XML file (no DTD)
- Digester digester = new Digester();
- digester.setValidating( false );
-
- // journal tag rules
- digester.addObjectCreate( "journal", "org.apache.kalumet.model.log.Journal" );
- digester.addSetProperties( "journal" );
-
- // event tag rules
- digester.addObjectCreate( "journal/event", "org.apache.kalumet.model.log.Event" );
- digester.addSetProperties( "journal/event" );
-
- // event content
- digester.addCallMethod( "journal/event", "setContent", 0 );
-
- // add event to journal
- digester.addSetNext( "journal/event", "addEvent", "org.apache.kalumet.model.log.Event" );
-
- // parse the XML file
- journal = (Journal) digester.parse( path );
+ return this.events;
}
- catch ( IOException ioException )
+
+ /**
+ * Transforms the <code>Journal</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
{
- // most of the time IOException occurs because the journal file path
- // doesn't exist, try to create it
- journal = new Journal();
- journal.writeXMLFile( path );
+ ElementImpl element = new ElementImpl( document, "journal" );
+ // events
+ for ( Iterator eventIterator = this.getEvents().iterator(); eventIterator.hasNext(); )
+ {
+ Event event = (Event) eventIterator.next();
+ element.appendChild( event.toDOMElement( document ) );
+ }
+ return element;
}
- catch ( Exception e )
- {
- throw new KalumetException( "Can't read journal", e );
- }
- return journal;
- }
- /**
- * Writes the environment journal log XML file with the in-memory DOM.
- *
- * @param path the path to the file to write.
- */
- public void writeXMLFile( String path )
- throws KalumetException
- {
- try
+ /**
+ * Parses and loads a given XML log file and return the environment journal root tag.
+ *
+ * @param path the environment log XML to parse.
+ * @return the environment <code>Journal</code> corresponding with the journal root tag.
+ */
+ public static Journal digeste( String path )
+ throws KalumetException
{
- lock.writeLock().lock();
- OutputFormat format = new OutputFormat();
- format.setLineWidth( 72 );
- format.setIndenting( true );
- format.setIndent( 3 );
- format.setEncoding( "ISO-8859-1" );
- if ( path.startsWith( "http:" ) || path.startsWith( "http:" ) )
- {
- throw new KalumetException( "Can't write journal file over a HTTP URL" );
- }
- if ( path.startsWith( "file:" ) || path.startsWith( "FILE:" ) )
- {
- path = path.substring( 5 );
- }
- XMLSerializer serializer = new XMLSerializer( new FileOutputStream( path ), format );
- serializer.serialize( this.toDOMElement( new CoreDocumentImpl( true ) ) );
+ if ( !path.startsWith( "http:" ) && !path.startsWith( "HTTP:" ) && !path.startsWith( "file:" )
+ && !path.startsWith( "FILE:" ) )
+ {
+ path = "file:" + path;
+ }
+ Journal journal = null;
+ try
+ {
+
+ // init the digester with no validation on the XML file (no DTD)
+ Digester digester = new Digester();
+ digester.setValidating( false );
+
+ // journal tag rules
+ digester.addObjectCreate( "journal", "org.apache.kalumet.model.log.Journal" );
+ digester.addSetProperties( "journal" );
+
+ // event tag rules
+ digester.addObjectCreate( "journal/event", "org.apache.kalumet.model.log.Event" );
+ digester.addSetProperties( "journal/event" );
+
+ // event content
+ digester.addCallMethod( "journal/event", "setContent", 0 );
+
+ // add event to journal
+ digester.addSetNext( "journal/event", "addEvent", "org.apache.kalumet.model.log.Event" );
+
+ // parse the XML file
+ journal = (Journal) digester.parse( path );
+ }
+ catch ( IOException ioException )
+ {
+ // most of the time IOException occurs because the journal file path
+ // doesn't exist, try to create it
+ journal = new Journal();
+ journal.writeXMLFile( path );
+ }
+ catch ( Exception e )
+ {
+ throw new KalumetException( "Can't read journal", e );
+ }
+ return journal;
}
- catch ( Exception e )
+
+ /**
+ * Writes the environment journal log XML file with the in-memory DOM.
+ *
+ * @param path the path to the file to write.
+ */
+ public void writeXMLFile( String path )
+ throws KalumetException
{
- throw new KalumetException( "Can't write journal", e );
+ try
+ {
+ lock.writeLock().lock();
+ OutputFormat format = new OutputFormat();
+ format.setLineWidth( 72 );
+ format.setIndenting( true );
+ format.setIndent( 3 );
+ format.setEncoding( "ISO-8859-1" );
+ if ( path.startsWith( "http:" ) || path.startsWith( "http:" ) )
+ {
+ throw new KalumetException( "Can't write journal file over a HTTP URL" );
+ }
+ if ( path.startsWith( "file:" ) || path.startsWith( "FILE:" ) )
+ {
+ path = path.substring( 5 );
+ }
+ XMLSerializer serializer = new XMLSerializer( new FileOutputStream( path ), format );
+ serializer.serialize( this.toDOMElement( new CoreDocumentImpl( true ) ) );
+ }
+ catch ( Exception e )
+ {
+ throw new KalumetException( "Can't write journal", e );
+ }
+ finally
+ {
+ lock.writeLock().unlock();
+ }
}
- finally
- {
- lock.writeLock().unlock();
- }
- }
}
\ No newline at end of file
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/update/UpdateLog.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/update/UpdateLog.java
index c3b5347..9f0f1f6 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/update/UpdateLog.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/update/UpdateLog.java
@@ -43,165 +43,165 @@
public class UpdateLog
{
- private final static transient Log LOG = LogFactory.getLog( UpdateLog.class );
+ private final static transient Log LOG = LogFactory.getLog( UpdateLog.class );
- public final static String MAIN_LOG_FILE = "log.xml";
+ public final static String MAIN_LOG_FILE = "log.xml";
- private String status;
+ private String status;
- private String time;
+ private String time;
- private String title;
+ private String title;
- private String basedir;
+ private String basedir;
- private boolean updated = false;
+ private boolean updated = false;
- private LinkedList updateMessages;
+ private LinkedList updateMessages;
- public UpdateLog()
- {
- this.updateMessages = new LinkedList();
- }
-
- /**
- * Create a <code>UpdateLog</code> defining basic attributes.
- *
- * @param status the status.
- * @param time the time.
- * @param title the title.
- * @param environment the environment associated to this update log.
- * @param updated the updated flag.
- */
- public UpdateLog( String status, String time, String title, Environment environment, boolean updated )
- throws KalumetException
- {
- this.updateMessages = new LinkedList();
- this.status = status;
- this.time = time;
- this.title = title;
- this.basedir = FileManipulator.createEnvironmentCacheDir( environment );
- this.updated = updated;
- }
-
- /**
- * Create a <code>UpdateLog</code>.
- *
- * @param status the current update log status.
- * @param title the current update log title.
- * @param environment the update log environment linked.
- * @throws KalumetException in case of update log creation failure.
- */
- public UpdateLog( String status, String title, Environment environment )
- throws KalumetException
- {
- this( status, ( (FastDateFormat) DateFormatUtils.ISO_DATETIME_FORMAT ).format( new Date() ), title, environment,
- false );
- }
-
- public String getStatus()
- {
- return this.status;
- }
-
- public void setStatus( String status )
- {
- this.status = status;
- }
-
- public String getTime()
- {
- return this.time;
- }
-
- public void setTime( String time )
- {
- this.time = time;
- }
-
- public String getTitle()
- {
- return this.title;
- }
-
- public void setTitle( String title )
- {
- this.title = title;
- }
-
- public boolean isUpdated()
- {
- return this.updated;
- }
-
- public void setUpdated( boolean updated )
- {
- this.updated = updated;
- }
-
- /**
- * Adds a new <code>UpdateMessage</code> in the <code>UpdateLog</code>.
- *
- * @param updateMessage the <code>UpdateMessage</code> to add.
- */
- public void addUpdateMessage( UpdateMessage updateMessage )
- {
- this.updateMessages.add( updateMessage );
- this.writeXMLFile();
- }
-
- /**
- * Gets <code>UpdateMessage</code> list in the <code>UpdateLog</code>.
- *
- * @return the <code>UpdateMessage</code> list.
- */
- public List getUpdateMessages()
- {
- return this.updateMessages;
- }
-
- /**
- * Transforms the <code>UpdateLog</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "updatelog" );
- element.setAttribute( "status", this.getStatus() );
- element.setAttribute( "time", this.getTime() );
- element.setAttribute( "title", this.getTitle() );
- element.setAttribute( "updated", new Boolean( this.isUpdated() ).toString() );
- // add update message child nodes
- for ( Iterator updateMessageIterator = this.getUpdateMessages().iterator(); updateMessageIterator.hasNext(); )
+ public UpdateLog()
{
- UpdateMessage updateMessage = (UpdateMessage) updateMessageIterator.next();
- element.appendChild( updateMessage.toDOMElement( document ) );
+ this.updateMessages = new LinkedList();
}
- return element;
- }
- /**
- * Writes the Kalumet agent XML log file using in-memory DOM.
- */
- public synchronized void writeXMLFile()
- {
- try
+ /**
+ * Create a <code>UpdateLog</code> defining basic attributes.
+ *
+ * @param status the status.
+ * @param time the time.
+ * @param title the title.
+ * @param environment the environment associated to this update log.
+ * @param updated the updated flag.
+ */
+ public UpdateLog( String status, String time, String title, Environment environment, boolean updated )
+ throws KalumetException
{
- OutputFormat format = new OutputFormat();
- format.setLineWidth( 72 );
- format.setIndenting( true );
- format.setIndent( 3 );
- format.setEncoding( "ISO-8859-1" );
- XMLSerializer serializer =
- new XMLSerializer( new FileOutputStream( this.basedir + "/" + MAIN_LOG_FILE ), format );
- serializer.serialize( this.toDOMElement( new CoreDocumentImpl( true ) ) );
+ this.updateMessages = new LinkedList();
+ this.status = status;
+ this.time = time;
+ this.title = title;
+ this.basedir = FileManipulator.createEnvironmentCacheDir( environment );
+ this.updated = updated;
}
- catch ( Exception e )
+
+ /**
+ * Create a <code>UpdateLog</code>.
+ *
+ * @param status the current update log status.
+ * @param title the current update log title.
+ * @param environment the update log environment linked.
+ * @throws KalumetException in case of update log creation failure.
+ */
+ public UpdateLog( String status, String title, Environment environment )
+ throws KalumetException
{
- LOG.error( "Can't write update log file.", e );
+ this( status, ( (FastDateFormat) DateFormatUtils.ISO_DATETIME_FORMAT ).format( new Date() ), title, environment,
+ false );
}
- }
+
+ public String getStatus()
+ {
+ return this.status;
+ }
+
+ public void setStatus( String status )
+ {
+ this.status = status;
+ }
+
+ public String getTime()
+ {
+ return this.time;
+ }
+
+ public void setTime( String time )
+ {
+ this.time = time;
+ }
+
+ public String getTitle()
+ {
+ return this.title;
+ }
+
+ public void setTitle( String title )
+ {
+ this.title = title;
+ }
+
+ public boolean isUpdated()
+ {
+ return this.updated;
+ }
+
+ public void setUpdated( boolean updated )
+ {
+ this.updated = updated;
+ }
+
+ /**
+ * Adds a new <code>UpdateMessage</code> in the <code>UpdateLog</code>.
+ *
+ * @param updateMessage the <code>UpdateMessage</code> to add.
+ */
+ public void addUpdateMessage( UpdateMessage updateMessage )
+ {
+ this.updateMessages.add( updateMessage );
+ this.writeXMLFile();
+ }
+
+ /**
+ * Gets <code>UpdateMessage</code> list in the <code>UpdateLog</code>.
+ *
+ * @return the <code>UpdateMessage</code> list.
+ */
+ public List getUpdateMessages()
+ {
+ return this.updateMessages;
+ }
+
+ /**
+ * Transforms the <code>UpdateLog</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "updatelog" );
+ element.setAttribute( "status", this.getStatus() );
+ element.setAttribute( "time", this.getTime() );
+ element.setAttribute( "title", this.getTitle() );
+ element.setAttribute( "updated", new Boolean( this.isUpdated() ).toString() );
+ // add update message child nodes
+ for ( Iterator updateMessageIterator = this.getUpdateMessages().iterator(); updateMessageIterator.hasNext(); )
+ {
+ UpdateMessage updateMessage = (UpdateMessage) updateMessageIterator.next();
+ element.appendChild( updateMessage.toDOMElement( document ) );
+ }
+ return element;
+ }
+
+ /**
+ * Writes the Kalumet agent XML log file using in-memory DOM.
+ */
+ public synchronized void writeXMLFile()
+ {
+ try
+ {
+ OutputFormat format = new OutputFormat();
+ format.setLineWidth( 72 );
+ format.setIndenting( true );
+ format.setIndent( 3 );
+ format.setEncoding( "ISO-8859-1" );
+ XMLSerializer serializer =
+ new XMLSerializer( new FileOutputStream( this.basedir + "/" + MAIN_LOG_FILE ), format );
+ serializer.serialize( this.toDOMElement( new CoreDocumentImpl( true ) ) );
+ }
+ catch ( Exception e )
+ {
+ LOG.error( "Can't write update log file.", e );
+ }
+ }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/update/UpdateMessage.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/update/UpdateMessage.java
index 72c4e40..a1785f9 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/model/update/UpdateMessage.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/model/update/UpdateMessage.java
@@ -29,59 +29,59 @@
public class UpdateMessage
{
- private String priority;
+ private String priority;
- private String message;
+ private String message;
- public UpdateMessage()
- {
- }
+ public UpdateMessage()
+ {
+ }
- /**
- * Creates a UpdateMessage with a defined message content.
- *
- * @param priority the message priority (info, error, ...).
- * @param message the message content.
- */
- public UpdateMessage( String priority, String message )
- {
- this.priority = priority;
- this.message = message;
- }
+ /**
+ * Creates a UpdateMessage with a defined message content.
+ *
+ * @param priority the message priority (info, error, ...).
+ * @param message the message content.
+ */
+ public UpdateMessage( String priority, String message )
+ {
+ this.priority = priority;
+ this.message = message;
+ }
- public String getPriority()
- {
- return this.priority;
- }
+ public String getPriority()
+ {
+ return this.priority;
+ }
- public void setPriority( String priority )
- {
- this.priority = priority;
- }
+ public void setPriority( String priority )
+ {
+ this.priority = priority;
+ }
- public String getMessage()
- {
- return this.message;
- }
+ public String getMessage()
+ {
+ return this.message;
+ }
- public void setMessage( String message )
- {
- this.message = message;
- }
+ public void setMessage( String message )
+ {
+ this.message = message;
+ }
- /**
- * Transforms the <code>UpdateMessage</code> POJO to a DOM element.
- *
- * @param document the DOM document.
- * @return the DOM element.
- */
- protected Element toDOMElement( CoreDocumentImpl document )
- {
- ElementImpl element = new ElementImpl( document, "updatemessage" );
- element.setAttribute( "priority", this.getPriority() );
- CDATASectionImpl message = new CDATASectionImpl( document, this.getMessage() );
- element.appendChild( message );
- return element;
- }
+ /**
+ * Transforms the <code>UpdateMessage</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement( CoreDocumentImpl document )
+ {
+ ElementImpl element = new ElementImpl( document, "updatemessage" );
+ element.setAttribute( "priority", this.getPriority() );
+ CDATASectionImpl message = new CDATASectionImpl( document, this.getMessage() );
+ element.appendChild( message );
+ return element;
+ }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/AbstractClient.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/AbstractClient.java
index 036b89d..c880a9c 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/AbstractClient.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/AbstractClient.java
@@ -29,22 +29,22 @@
public abstract class AbstractClient
{
- protected Call call;
+ protected Call call;
- public AbstractClient( String url )
- throws ClientException
- {
- try
+ public AbstractClient( String url )
+ throws ClientException
{
- Service service = new Service();
- this.call = (Call) service.createCall();
- call.setTimeout( new Integer( Integer.MAX_VALUE ) );
- call.setTargetEndpointAddress( new URL( url ) );
+ try
+ {
+ Service service = new Service();
+ this.call = (Call) service.createCall();
+ call.setTimeout( new Integer( Integer.MAX_VALUE ) );
+ call.setTargetEndpointAddress( new URL( url ) );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "Can't to the Kalumet agent WS server", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "Can't to the Kalumet agent WS server", e );
- }
- }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/AgentClient.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/AgentClient.java
index 9610701..ff990b6 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/AgentClient.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/AgentClient.java
@@ -22,43 +22,43 @@
* WebService client dedicated to Kalumet agent operations.
*/
public class AgentClient
- extends AbstractClient
+ extends AbstractClient
{
- /**
- * Default constructor.
- *
- * @param host the hostname or IP address of the Kalumet agent WS server.
- * @param port the port number of the Kalumet agent WS server.
- * @throws ClientException in case of connection failure.
- */
- public AgentClient( String host, int port )
- throws ClientException
- {
- super( "http://" + host + ":" + port + "/axis/services/AgentService" );
- }
-
- /**
- * Wrapper method to the get agent version.
- *
- * @return the agent version.
- * @throws ClientException in case of communication failure.
- */
- public String getVersion()
- throws ClientException
- {
- String version = null;
- try
+ /**
+ * Default constructor.
+ *
+ * @param host the hostname or IP address of the Kalumet agent WS server.
+ * @param port the port number of the Kalumet agent WS server.
+ * @throws ClientException in case of connection failure.
+ */
+ public AgentClient( String host, int port )
+ throws ClientException
{
- version = (String) call.invoke( "getVersion", null );
+ super( "http://" + host + ":" + port + "/axis/services/AgentService" );
}
- catch ( Exception e )
- {
- throw new ClientException( "Can't get agent version", e );
- }
- return version;
- }
- // TODO update method to fully update an agent
+ /**
+ * Wrapper method to the get agent version.
+ *
+ * @return the agent version.
+ * @throws ClientException in case of communication failure.
+ */
+ public String getVersion()
+ throws ClientException
+ {
+ String version = null;
+ try
+ {
+ version = (String) call.invoke( "getVersion", null );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "Can't get agent version", e );
+ }
+ return version;
+ }
+
+ // TODO update method to fully update an agent
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/ArchiveClient.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/ArchiveClient.java
index 3d41ef4..d1f1f89 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/ArchiveClient.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/ArchiveClient.java
@@ -22,73 +22,73 @@
* Archive WS client.
*/
public class ArchiveClient
- extends AbstractClient
+ extends AbstractClient
{
- /**
- * Default constructor.
- *
- * @param host the hostname or IP address of the Kalumet agent WS server.
- * @param port the port number of the Kalumet agent WS server.
- * @throws ClientException in case of communication failure.
- */
- public ArchiveClient( String host, int port )
- throws ClientException
- {
- super( "http://" + host + ":" + port + "/axis/services/JEEApplicationArchiveService" );
- }
+ /**
+ * Default constructor.
+ *
+ * @param host the hostname or IP address of the Kalumet agent WS server.
+ * @param port the port number of the Kalumet agent WS server.
+ * @throws ClientException in case of communication failure.
+ */
+ public ArchiveClient( String host, int port )
+ throws ClientException
+ {
+ super( "http://" + host + ":" + port + "/axis/services/JEEApplicationArchiveService" );
+ }
- /**
- * Wrapper method to call archive update.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param applicationName the target JEE application name.
- * @param archiveName the target archive name.
- * @param delegation true if this call is a delegation from another agent, false else.
- * @throws ClientException in case of communication failure.
- */
- public void update( String environmentName, String applicationServerName, String applicationName, String archiveName,
- boolean delegation )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to call archive update.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param applicationName the target JEE application name.
+ * @param archiveName the target archive name.
+ * @param delegation true if this call is a delegation from another agent, false else.
+ * @throws ClientException in case of communication failure.
+ */
+ public void update( String environmentName, String applicationServerName, String applicationName,
+ String archiveName, boolean delegation )
+ throws ClientException
{
- call.invoke( "update", new Object[]{ environmentName, applicationServerName, applicationName, archiveName,
- new Boolean( delegation ) } );
+ try
+ {
+ call.invoke( "update", new Object[]{ environmentName, applicationServerName, applicationName, archiveName,
+ new Boolean( delegation ) } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "JEE archive " + archiveName + " update failed", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "JEE archive " + archiveName + " update failed", e );
- }
- }
- /**
- * Wrapper method to call archive check.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param applicationName the target JEE application name.
- * @param archiveName the target archive name.
- * @return true if the JEE application archive is up to date, false else.
- * @throws ClientException in case of communication failure.
- */
- public boolean check( String environmentName, String applicationServerName, String applicationName,
- String archiveName )
- throws ClientException
- {
- boolean upToDate = false;
- try
+ /**
+ * Wrapper method to call archive check.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param applicationName the target JEE application name.
+ * @param archiveName the target archive name.
+ * @return true if the JEE application archive is up to date, false else.
+ * @throws ClientException in case of communication failure.
+ */
+ public boolean check( String environmentName, String applicationServerName, String applicationName,
+ String archiveName )
+ throws ClientException
{
- upToDate = ( (Boolean) call.invoke( "check",
- new Object[]{ environmentName, applicationServerName, applicationName,
- archiveName } ) ).booleanValue();
+ boolean upToDate = false;
+ try
+ {
+ upToDate = ( (Boolean) call.invoke( "check",
+ new Object[]{ environmentName, applicationServerName, applicationName,
+ archiveName } ) ).booleanValue();
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "JEE archive " + archiveName + " check status failed", e );
+ }
+ return upToDate;
}
- catch ( Exception e )
- {
- throw new ClientException( "JEE archive " + archiveName + " check status failed", e );
- }
- return upToDate;
- }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/ClientException.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/ClientException.java
index aff6efc..529eea5 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/ClientException.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/ClientException.java
@@ -24,38 +24,38 @@
* WebService client exception wrapper.
*/
public class ClientException
- extends KalumetException
+ extends KalumetException
{
- /**
- * Create a WebService client exception with the explanation message.
- *
- * @param message the explanation message.
- */
- public ClientException( String message )
- {
- super( message );
- }
+ /**
+ * Create a WebService client exception with the explanation message.
+ *
+ * @param message the explanation message.
+ */
+ public ClientException( String message )
+ {
+ super( message );
+ }
- /**
- * Create a WebService client exception with the cause.
- *
- * @param cause the cause.
- */
- public ClientException( Throwable cause )
- {
- super( cause );
- }
+ /**
+ * Create a WebService client exception with the cause.
+ *
+ * @param cause the cause.
+ */
+ public ClientException( Throwable cause )
+ {
+ super( cause );
+ }
- /**
- * Create a WebService client exception with the explanation message and the cause.
- *
- * @param message the explanation message.
- * @param cause the cause.
- */
- public ClientException( String message, Throwable cause )
- {
- super( message, cause );
- }
+ /**
+ * Create a WebService client exception with the explanation message and the cause.
+ *
+ * @param message the explanation message.
+ * @param cause the cause.
+ */
+ public ClientException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/CommandClient.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/CommandClient.java
index d0198cd..fa6f145 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/CommandClient.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/CommandClient.java
@@ -22,42 +22,42 @@
* Command WS client.
*/
public class CommandClient
- extends AbstractClient
+ extends AbstractClient
{
- /**
- * Default constructor.
- *
- * @param host hostname or IP address of the Kalumet agent WS server.
- * @param port port number of the Kalumet agent WS server.
- * @throws ClientException in case of communication failure.
- */
- public CommandClient( String host, int port )
- throws ClientException
- {
- super( "http://" + host + ":" + port + "/axis/services/CommandService" );
- }
+ /**
+ * Default constructor.
+ *
+ * @param host hostname or IP address of the Kalumet agent WS server.
+ * @param port port number of the Kalumet agent WS server.
+ * @throws ClientException in case of communication failure.
+ */
+ public CommandClient( String host, int port )
+ throws ClientException
+ {
+ super( "http://" + host + ":" + port + "/axis/services/CommandService" );
+ }
- /**
- * Wrapper method to execute a command.
- *
- * @param command the command to execute.
- * @return the command output.
- * @throws ClientException in case of communication failure.
- */
- public String execute( String command )
- throws ClientException
- {
- String output = null;
- try
+ /**
+ * Wrapper method to execute a command.
+ *
+ * @param command the command to execute.
+ * @return the command output.
+ * @throws ClientException in case of communication failure.
+ */
+ public String execute( String command )
+ throws ClientException
{
- output = (String) call.invoke( "execute", new Object[]{ command } );
+ String output = null;
+ try
+ {
+ output = (String) call.invoke( "execute", new Object[]{ command } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "Command " + command + " execute failed", e );
+ }
+ return output;
}
- catch ( Exception e )
- {
- throw new ClientException( "Command " + command + " execute failed", e );
- }
- return output;
- }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/ConfigurationFileClient.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/ConfigurationFileClient.java
index 71f9bcd..722e72d 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/ConfigurationFileClient.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/ConfigurationFileClient.java
@@ -22,75 +22,76 @@
* ConfigurationFIle WS client.
*/
public class ConfigurationFileClient
- extends AbstractClient
+ extends AbstractClient
{
- /**
- * Default constructor.
- *
- * @param host the hostname or IP address of the Kalumet agent WS server.
- * @param port the port number of the Kalumet agent WS server.
- * @throws ClientException in case of communication failure.
- */
- public ConfigurationFileClient( String host, int port )
- throws ClientException
- {
- super( "http://" + host + ":" + port + "/axis/services/JEEApplicationConfigurationFileService" );
- }
+ /**
+ * Default constructor.
+ *
+ * @param host the hostname or IP address of the Kalumet agent WS server.
+ * @param port the port number of the Kalumet agent WS server.
+ * @throws ClientException in case of communication failure.
+ */
+ public ConfigurationFileClient( String host, int port )
+ throws ClientException
+ {
+ super( "http://" + host + ":" + port + "/axis/services/JEEApplicationConfigurationFileService" );
+ }
- /**
- * Wrapper method to update a JEE application configuration file.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param applicationName the target JEE application name.
- * @param configurationFileName the target configuration file name.
- * @param delegation true if the call is a delegation from another agent, false else.
- * @throws ClientException in case of communication failure.
- */
- public void update( String environmentName, String applicationServerName, String applicationName,
- String configurationFileName, boolean delegation )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to update a JEE application configuration file.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param applicationName the target JEE application name.
+ * @param configurationFileName the target configuration file name.
+ * @param delegation true if the call is a delegation from another agent, false else.
+ * @throws ClientException in case of communication failure.
+ */
+ public void update( String environmentName, String applicationServerName, String applicationName,
+ String configurationFileName, boolean delegation )
+ throws ClientException
{
- call.invoke( "update",
- new Object[]{ environmentName, applicationServerName, applicationName, configurationFileName,
- new Boolean( delegation ) } );
+ try
+ {
+ call.invoke( "update",
+ new Object[]{ environmentName, applicationServerName, applicationName, configurationFileName,
+ new Boolean( delegation ) } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "JEE application configuration file " + configurationFileName + " update failed",
+ e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "JEE application configuration file " + configurationFileName + " update failed", e );
- }
- }
- /**
- * Wrapper method to check if the JEE application configuration file is up to date.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param applicationName the target JEE application name.
- * @param configurationFileName the target configuration file name.
- * @return true if the configuration file is up to date, false else.
- * @throws ClientException in case of communication failure.
- */
- public boolean check( String environmentName, String applicationServerName, String applicationName,
- String configurationFileName )
- throws ClientException
- {
- boolean upToDate = false;
- try
+ /**
+ * Wrapper method to check if the JEE application configuration file is up to date.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param applicationName the target JEE application name.
+ * @param configurationFileName the target configuration file name.
+ * @return true if the configuration file is up to date, false else.
+ * @throws ClientException in case of communication failure.
+ */
+ public boolean check( String environmentName, String applicationServerName, String applicationName,
+ String configurationFileName )
+ throws ClientException
{
- upToDate = ( (Boolean) call.invoke( "check",
- new Object[]{ environmentName, applicationServerName, applicationName,
- configurationFileName } ) ).booleanValue();
+ boolean upToDate = false;
+ try
+ {
+ upToDate = ( (Boolean) call.invoke( "check",
+ new Object[]{ environmentName, applicationServerName, applicationName,
+ configurationFileName } ) ).booleanValue();
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException(
+ "JEE application configuration file " + configurationFileName + " status check failed", e );
+ }
+ return upToDate;
}
- catch ( Exception e )
- {
- throw new ClientException(
- "JEE application configuration file " + configurationFileName + " status check failed", e );
- }
- return upToDate;
- }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/ContentManagerClient.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/ContentManagerClient.java
index a64fd51..6cfa916 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/ContentManagerClient.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/ContentManagerClient.java
@@ -22,45 +22,46 @@
* Content manager WS client.
*/
public class ContentManagerClient
- extends AbstractClient
+ extends AbstractClient
{
- /**
- * Default constructor.
- *
- * @param host the hostname or UP address of the Kalumet agent WS server.
- * @param port the port number of the Kalumet agent WS server.
- * @throws ClientException in case of communication failure.
- */
- public ContentManagerClient( String host, int port )
- throws ClientException
- {
- super( "http://" + host + ":" + port + "/axis/services/JEEApplicationContentManagerService" );
- }
+ /**
+ * Default constructor.
+ *
+ * @param host the hostname or UP address of the Kalumet agent WS server.
+ * @param port the port number of the Kalumet agent WS server.
+ * @throws ClientException in case of communication failure.
+ */
+ public ContentManagerClient( String host, int port )
+ throws ClientException
+ {
+ super( "http://" + host + ":" + port + "/axis/services/JEEApplicationContentManagerService" );
+ }
- /**
- * Wrapper method to update a JEE application content manager.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param applicationName the target JEE application name.
- * @param contentManagerName the target content manager name.
- * @param delegation true if the call is a delegation from another agent, false else.
- * @throws ClientException
- */
- public void update( String environmentName, String applicationServerName, String applicationName,
- String contentManagerName, boolean delegation )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to update a JEE application content manager.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param applicationName the target JEE application name.
+ * @param contentManagerName the target content manager name.
+ * @param delegation true if the call is a delegation from another agent, false else.
+ * @throws ClientException
+ */
+ public void update( String environmentName, String applicationServerName, String applicationName,
+ String contentManagerName, boolean delegation )
+ throws ClientException
{
- call.invoke( "update", new Object[]{ environmentName, applicationServerName, applicationName, contentManagerName,
- new Boolean( delegation ) } );
+ try
+ {
+ call.invoke( "update",
+ new Object[]{ environmentName, applicationServerName, applicationName, contentManagerName,
+ new Boolean( delegation ) } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "Content manager " + contentManagerName + " update failed", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "Content manager " + contentManagerName + " update failed", e );
- }
- }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/DatabaseClient.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/DatabaseClient.java
index 5cb8961..8dfaa96 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/DatabaseClient.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/DatabaseClient.java
@@ -22,45 +22,45 @@
* Database WS client.
*/
public class DatabaseClient
- extends AbstractClient
+ extends AbstractClient
{
- /**
- * Default constructor.
- *
- * @param host the hostname or IP address of the Kalumet agent WS server.
- * @param port the port number of the Kalumet agent WS server.
- * @throws ClientException in case of communication failure.
- */
- public DatabaseClient( String host, int port )
- throws ClientException
- {
- super( "http://" + host + ":" + port + "/axis/services/JEEApplicationDatabaseService" );
- }
+ /**
+ * Default constructor.
+ *
+ * @param host the hostname or IP address of the Kalumet agent WS server.
+ * @param port the port number of the Kalumet agent WS server.
+ * @throws ClientException in case of communication failure.
+ */
+ public DatabaseClient( String host, int port )
+ throws ClientException
+ {
+ super( "http://" + host + ":" + port + "/axis/services/JEEApplicationDatabaseService" );
+ }
- /**
- * Wrapper method to update a database.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param applicationName the target JEE application name.
- * @param databaseName the target database name.
- * @param delegation if true, the call is a delegation from another agent, false else.
- * @throws ClientException in case of communication failure.
- */
- public void update( String environmentName, String applicationServerName, String applicationName, String databaseName,
- boolean delegation )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to update a database.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param applicationName the target JEE application name.
+ * @param databaseName the target database name.
+ * @param delegation if true, the call is a delegation from another agent, false else.
+ * @throws ClientException in case of communication failure.
+ */
+ public void update( String environmentName, String applicationServerName, String applicationName,
+ String databaseName, boolean delegation )
+ throws ClientException
{
- call.invoke( "update", new Object[]{ environmentName, applicationServerName, applicationName, databaseName,
- new Boolean( delegation ) } );
+ try
+ {
+ call.invoke( "update", new Object[]{ environmentName, applicationServerName, applicationName, databaseName,
+ new Boolean( delegation ) } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "Database " + databaseName + " update failed", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "Database " + databaseName + " update failed", e );
- }
- }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/EnvironmentClient.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/EnvironmentClient.java
index 2c6572f..5a37be8 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/EnvironmentClient.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/EnvironmentClient.java
@@ -22,39 +22,39 @@
* Environment WS client.
*/
public class EnvironmentClient
- extends AbstractClient
+ extends AbstractClient
{
- /**
- * Default constructor.
- *
- * @param host the hostname or IP address of the Kalumet agent WS server.
- * @param port the port number of the Kalumet agent WS server.
- * @throws AbstractClient in case of communication failure.
- */
- public EnvironmentClient( String host, int port )
- throws ClientException
- {
- super( "http://" + host + ":" + port + "/axis/services/EnvironmentService" );
- }
+ /**
+ * Default constructor.
+ *
+ * @param host the hostname or IP address of the Kalumet agent WS server.
+ * @param port the port number of the Kalumet agent WS server.
+ * @throws AbstractClient in case of communication failure.
+ */
+ public EnvironmentClient( String host, int port )
+ throws ClientException
+ {
+ super( "http://" + host + ":" + port + "/axis/services/EnvironmentService" );
+ }
- /**
- * Wrapper method to update an environment.
- *
- * @param environmentName the target environment name.
- * @throws ClientException in case of update failure.
- */
- public void update( String environmentName )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to update an environment.
+ *
+ * @param environmentName the target environment name.
+ * @throws ClientException in case of update failure.
+ */
+ public void update( String environmentName )
+ throws ClientException
{
- call.invoke( "update", new Object[]{ environmentName } );
+ try
+ {
+ call.invoke( "update", new Object[]{ environmentName } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "Environment " + environmentName + " update failed", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "Environment " + environmentName + " update failed", e );
- }
- }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/FileClient.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/FileClient.java
index 955db56..939bcb9 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/FileClient.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/FileClient.java
@@ -27,60 +27,60 @@
* File WS client.
*/
public class FileClient
- extends AbstractClient
+ extends AbstractClient
{
- /**
- * Default constructor.
- *
- * @param host the hostname or IP address of the Kalumet agent WS server.
- * @param port the port number of the Kalumet agent WS server.
- * @throws ClientException in case of communication failure.
- */
- public FileClient( String host, int port )
- throws ClientException
- {
- super( "http://" + host + ":" + port + "/axis/services/FileService" );
- }
+ /**
+ * Default constructor.
+ *
+ * @param host the hostname or IP address of the Kalumet agent WS server.
+ * @param port the port number of the Kalumet agent WS server.
+ * @throws ClientException in case of communication failure.
+ */
+ public FileClient( String host, int port )
+ throws ClientException
+ {
+ super( "http://" + host + ":" + port + "/axis/services/FileService" );
+ }
- /**
- * Wrapper method to view the content of a VFS file.
- *
- * @param path the VFS path.
- * @return the file content.
- * @throws ClientException in case of viewing failure.
- */
- public String view( String path )
- throws ClientException
- {
- String content = null;
- try
+ /**
+ * Wrapper method to view the content of a VFS file.
+ *
+ * @param path the VFS path.
+ * @return the file content.
+ * @throws ClientException in case of viewing failure.
+ */
+ public String view( String path )
+ throws ClientException
{
- content = ( (String) call.invoke( "view", new Object[]{ path } ) );
+ String content = null;
+ try
+ {
+ content = ( (String) call.invoke( "view", new Object[]{ path } ) );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "Can't view the file " + path + " content", e );
+ }
+ return content;
}
- catch ( Exception e )
- {
- throw new ClientException( "Can't view the file " + path + " content", e );
- }
- return content;
- }
- public SimplifiedFileObject[] browse( String path )
- throws ClientException
- {
- call.registerTypeMapping( SimplifiedFileObject.class,
- new QName( "http://kalumet.apache.org", "SimplifiedFileObject" ),
- BeanSerializerFactory.class, BeanDeserializerFactory.class );
- SimplifiedFileObject[] children = null;
- try
+ public SimplifiedFileObject[] browse( String path )
+ throws ClientException
{
- children = ( (SimplifiedFileObject[]) call.invoke( "browse", new Object[]{ path } ) );
+ call.registerTypeMapping( SimplifiedFileObject.class,
+ new QName( "http://kalumet.apache.org", "SimplifiedFileObject" ),
+ BeanSerializerFactory.class, BeanDeserializerFactory.class );
+ SimplifiedFileObject[] children = null;
+ try
+ {
+ children = ( (SimplifiedFileObject[]) call.invoke( "browse", new Object[]{ path } ) );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "Can't browse " + path, e );
+ }
+ return children;
}
- catch ( Exception e )
- {
- throw new ClientException( "Can't browse " + path, e );
- }
- return children;
- }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JDBCConnectionPoolClient.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JDBCConnectionPoolClient.java
index ec16cf3..9ce3269 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JDBCConnectionPoolClient.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JDBCConnectionPoolClient.java
@@ -22,66 +22,66 @@
* JEE application server JDBC connection pool WS client.
*/
public class JDBCConnectionPoolClient
- extends AbstractClient
+ extends AbstractClient
{
- /**
- * Default constructor.
- *
- * @param host hostname or IP address of the Kalumet agent WS server.
- * @param port port number of the Kalumet agent WS server.
- * @throws ClientException in case of communication failure.
- */
- public JDBCConnectionPoolClient( String host, int port )
- throws ClientException
- {
- super( "http://" + host + ":" + port + "/axis/services/JDBCConnectionPoolService" );
- }
+ /**
+ * Default constructor.
+ *
+ * @param host hostname or IP address of the Kalumet agent WS server.
+ * @param port port number of the Kalumet agent WS server.
+ * @throws ClientException in case of communication failure.
+ */
+ public JDBCConnectionPoolClient( String host, int port )
+ throws ClientException
+ {
+ super( "http://" + host + ":" + port + "/axis/services/JDBCConnectionPoolService" );
+ }
- /**
- * Wrapper method to update a JDBC connection pool.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param connectionPoolName the target connection pool name.
- * @throws ClientException in case of communication failure.
- */
- public void update( String environmentName, String applicationServerName, String connectionPoolName )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to update a JDBC connection pool.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param connectionPoolName the target connection pool name.
+ * @throws ClientException in case of communication failure.
+ */
+ public void update( String environmentName, String applicationServerName, String connectionPoolName )
+ throws ClientException
{
- call.invoke( "update", new Object[]{ environmentName, applicationServerName, connectionPoolName } );
+ try
+ {
+ call.invoke( "update", new Object[]{ environmentName, applicationServerName, connectionPoolName } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "JDBC connection pool " + connectionPoolName + " update failed", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "JDBC connection pool " + connectionPoolName + " update failed", e );
- }
- }
- /**
- * Wrapper method to check if a JDBC connection pool is up to date or not.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param connectionPoolName the target connection pool name.
- * @return true if the connection pool is up to date, false else.
- * @throws ClientException in case of communication failure.
- */
- public boolean check( String environmentName, String applicationServerName, String connectionPoolName )
- throws ClientException
- {
- boolean upToDate = false;
- try
+ /**
+ * Wrapper method to check if a JDBC connection pool is up to date or not.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param connectionPoolName the target connection pool name.
+ * @return true if the connection pool is up to date, false else.
+ * @throws ClientException in case of communication failure.
+ */
+ public boolean check( String environmentName, String applicationServerName, String connectionPoolName )
+ throws ClientException
{
- upToDate = ( (Boolean) call.invoke( "check", new Object[]{ environmentName, applicationServerName,
- connectionPoolName } ) ).booleanValue();
+ boolean upToDate = false;
+ try
+ {
+ upToDate = ( (Boolean) call.invoke( "check", new Object[]{ environmentName, applicationServerName,
+ connectionPoolName } ) ).booleanValue();
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "JDBC connection pool " + connectionPoolName + " status check failed", e );
+ }
+ return upToDate;
}
- catch ( Exception e )
- {
- throw new ClientException( "JDBC connection pool " + connectionPoolName + " status check failed", e );
- }
- return upToDate;
- }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JDBCDataSourceClient.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JDBCDataSourceClient.java
index 5efc15a..9c8ae75 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JDBCDataSourceClient.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JDBCDataSourceClient.java
@@ -22,66 +22,66 @@
* JDBCDataSource WS client.
*/
public class JDBCDataSourceClient
- extends AbstractClient
+ extends AbstractClient
{
- /**
- * Default constructor.
- *
- * @param host the hostname or IP address of the Kalumet agent WS server.
- * @param port the port number of the Kalumet agent WS server.
- * @throws ClientException in case of communication failure.
- */
- public JDBCDataSourceClient( String host, int port )
- throws ClientException
- {
- super( "http://" + host + ":" + port + "/axis/services/JDBCDataSourceService" );
- }
+ /**
+ * Default constructor.
+ *
+ * @param host the hostname or IP address of the Kalumet agent WS server.
+ * @param port the port number of the Kalumet agent WS server.
+ * @throws ClientException in case of communication failure.
+ */
+ public JDBCDataSourceClient( String host, int port )
+ throws ClientException
+ {
+ super( "http://" + host + ":" + port + "/axis/services/JDBCDataSourceService" );
+ }
- /**
- * Wrapper method to update a JDBC data source.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param dataSourceName the target data source name.
- * @throws ClientException in case of update failure.
- */
- public void update( String environmentName, String applicationServerName, String dataSourceName )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to update a JDBC data source.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param dataSourceName the target data source name.
+ * @throws ClientException in case of update failure.
+ */
+ public void update( String environmentName, String applicationServerName, String dataSourceName )
+ throws ClientException
{
- call.invoke( "update", new Object[]{ environmentName, applicationServerName, dataSourceName } );
+ try
+ {
+ call.invoke( "update", new Object[]{ environmentName, applicationServerName, dataSourceName } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "JDBC data source " + dataSourceName + " update failed", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "JDBC data source " + dataSourceName + " update failed", e );
- }
- }
- /**
- * Wrapper method to check if a JDBC data source is up to date or not.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param dataSourceName the target data source name.
- * @return true if the data source is up to date, false else.
- * @throws ClientException in case of check failure.
- */
- public boolean check( String environmentName, String applicationServerName, String dataSourceName )
- throws ClientException
- {
- boolean upToDate = false;
- try
+ /**
+ * Wrapper method to check if a JDBC data source is up to date or not.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param dataSourceName the target data source name.
+ * @return true if the data source is up to date, false else.
+ * @throws ClientException in case of check failure.
+ */
+ public boolean check( String environmentName, String applicationServerName, String dataSourceName )
+ throws ClientException
{
- upToDate = ( (Boolean) call.invoke( "check", new Object[]{ environmentName, applicationServerName,
- dataSourceName } ) ).booleanValue();
+ boolean upToDate = false;
+ try
+ {
+ upToDate = ( (Boolean) call.invoke( "check", new Object[]{ environmentName, applicationServerName,
+ dataSourceName } ) ).booleanValue();
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "JDBC data source " + dataSourceName + " status check failed", e );
+ }
+ return upToDate;
}
- catch ( Exception e )
- {
- throw new ClientException( "JDBC data source " + dataSourceName + " status check failed", e );
- }
- return upToDate;
- }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JEEApplicationClient.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JEEApplicationClient.java
index f186a9f..57c8e26 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JEEApplicationClient.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JEEApplicationClient.java
@@ -23,43 +23,44 @@
* JEEApplication WS client.
*/
public class JEEApplicationClient
- extends AbstractClient
+ extends AbstractClient
{
- /**
- * Default constructor.
- *
- * @param host hostname or IP address of the Kalumet agent WS server.
- * @param port port number of the Kalumet agent WS server.
- * @throws ClientException in case of communication failure.
- */
- public JEEApplicationClient(String host, int port)
- throws ClientException
- {
- super( "http://" + host + ":" + port + "/axis/services/JEEApplicationService" );
- }
+ /**
+ * Default constructor.
+ *
+ * @param host hostname or IP address of the Kalumet agent WS server.
+ * @param port port number of the Kalumet agent WS server.
+ * @throws ClientException in case of communication failure.
+ */
+ public JEEApplicationClient( String host, int port )
+ throws ClientException
+ {
+ super( "http://" + host + ":" + port + "/axis/services/JEEApplicationService" );
+ }
- /**
- * Wrapper method to update a JEE application.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param applicationName
- * @param delegation
- * @throws ClientException
- */
- public void update( String environmentName, String applicationServerName, String applicationName, boolean delegation )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to update a JEE application.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param applicationName
+ * @param delegation
+ * @throws ClientException
+ */
+ public void update( String environmentName, String applicationServerName, String applicationName,
+ boolean delegation )
+ throws ClientException
{
- call.invoke( "update",
- new Object[]{ environmentName, applicationServerName, applicationName, new Boolean( delegation ) } );
+ try
+ {
+ call.invoke( "update", new Object[]{ environmentName, applicationServerName, applicationName,
+ new Boolean( delegation ) } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "JEE application " + applicationName + " update failed", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "JEE application " + applicationName + " update failed", e );
- }
- }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JEEApplicationServerClient.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JEEApplicationServerClient.java
index 47605f3..b3aa723 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JEEApplicationServerClient.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JEEApplicationServerClient.java
@@ -22,104 +22,104 @@
* JEE application server WS client.
*/
public class JEEApplicationServerClient
- extends AbstractClient
+ extends AbstractClient
{
- /**
- * Default constructor.
- *
- * @param host the hostname or IP address of the Kalumet agent WS server.
- * @param port the port number of the Kalumet agent WS server.
- * @throws ClientException in case of communication failure.
- */
- public JEEApplicationServerClient(String host, int port)
- throws ClientException
- {
- super( "http://" + host + ":" + port + "/axis/services/JEEApplicationServerService" );
- }
+ /**
+ * Default constructor.
+ *
+ * @param host the hostname or IP address of the Kalumet agent WS server.
+ * @param port the port number of the Kalumet agent WS server.
+ * @throws ClientException in case of communication failure.
+ */
+ public JEEApplicationServerClient( String host, int port )
+ throws ClientException
+ {
+ super( "http://" + host + ":" + port + "/axis/services/JEEApplicationServerService" );
+ }
- /**
- * Wrapper method to stop a JEE application server.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @throws ClientException in case of stop failure.
- */
- public void stop( String environmentName, String applicationServerName )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to stop a JEE application server.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @throws ClientException in case of stop failure.
+ */
+ public void stop( String environmentName, String applicationServerName )
+ throws ClientException
{
- call.invoke( "stop", new Object[]{ environmentName, applicationServerName } );
+ try
+ {
+ call.invoke( "stop", new Object[]{ environmentName, applicationServerName } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "JEE application server " + applicationServerName + " stop failed", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "JEE application server " + applicationServerName + " stop failed", e );
- }
- }
- /**
- * Wrapper method to start a JEE application server.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @throws ClientException in case of stop failure.
- */
- public void start( String environmentName, String applicationServerName )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to start a JEE application server.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @throws ClientException in case of stop failure.
+ */
+ public void start( String environmentName, String applicationServerName )
+ throws ClientException
{
- call.invoke( "start", new Object[]{ environmentName, applicationServerName } );
+ try
+ {
+ call.invoke( "start", new Object[]{ environmentName, applicationServerName } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "JEE application server " + applicationServerName + " start failed", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "JEE application server " + applicationServerName + " start failed", e );
- }
- }
- /**
- * Wrapper method to check the status of a JEE application server.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @return the current status of the JEE application server.
- * @throws ClientException in case of status check failure.
- */
- public String status( String environmentName, String applicationServerName )
- throws ClientException
- {
- String status = null;
- try
+ /**
+ * Wrapper method to check the status of a JEE application server.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @return the current status of the JEE application server.
+ * @throws ClientException in case of status check failure.
+ */
+ public String status( String environmentName, String applicationServerName )
+ throws ClientException
{
- status = (String) call.invoke( "status", new Object[]{ environmentName, applicationServerName } );
+ String status = null;
+ try
+ {
+ status = (String) call.invoke( "status", new Object[]{ environmentName, applicationServerName } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "JEE application server " + applicationServerName + " status check failed", e );
+ }
+ return status;
}
- catch ( Exception e )
- {
- throw new ClientException( "JEE application server " + applicationServerName + " status check failed", e );
- }
- return status;
- }
- /**
- * Wrapper method to update a JEE application server.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param delegation if true, the call is a delegation from another agent, false else.
- * @throws ClientException in case of update failure.
- */
- public void update( String environmentName, String applicationServerName, boolean delegation )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to update a JEE application server.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param delegation if true, the call is a delegation from another agent, false else.
+ * @throws ClientException in case of update failure.
+ */
+ public void update( String environmentName, String applicationServerName, boolean delegation )
+ throws ClientException
{
- call.invoke( "update", new Object[]{ environmentName, applicationServerName, new Boolean( delegation ) } );
+ try
+ {
+ call.invoke( "update", new Object[]{ environmentName, applicationServerName, new Boolean( delegation ) } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "JEE application server " + applicationServerName + " update failed", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "JEE application server " + applicationServerName + " update failed", e );
- }
- }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JMSConnectionFactoryClient.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JMSConnectionFactoryClient.java
index 6d18558..6187b08 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JMSConnectionFactoryClient.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JMSConnectionFactoryClient.java
@@ -22,66 +22,66 @@
* JMS connection factory WS client.
*/
public class JMSConnectionFactoryClient
- extends AbstractClient
+ extends AbstractClient
{
- /**
- * Default constructor.
- *
- * @param host the hostname or IP address of the Kalumet agent WS server.
- * @param port the port number of the Kalumet agent WS server.
- * @throws ClientException in case of communication failure.
- */
- public JMSConnectionFactoryClient( String host, int port )
- throws ClientException
- {
- super( "http://" + host + ":" + port + "/axis/services/JMSConnectionFactoryService" );
- }
+ /**
+ * Default constructor.
+ *
+ * @param host the hostname or IP address of the Kalumet agent WS server.
+ * @param port the port number of the Kalumet agent WS server.
+ * @throws ClientException in case of communication failure.
+ */
+ public JMSConnectionFactoryClient( String host, int port )
+ throws ClientException
+ {
+ super( "http://" + host + ":" + port + "/axis/services/JMSConnectionFactoryService" );
+ }
- /**
- * Wrapper method to update a JMS connection factory.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param connectionFactoryName the target JMS connection factory.
- * @throws ClientException in case of update failure.
- */
- public void update( String environmentName, String applicationServerName, String connectionFactoryName )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to update a JMS connection factory.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param connectionFactoryName the target JMS connection factory.
+ * @throws ClientException in case of update failure.
+ */
+ public void update( String environmentName, String applicationServerName, String connectionFactoryName )
+ throws ClientException
{
- call.invoke( "update", new Object[]{ environmentName, applicationServerName, connectionFactoryName } );
+ try
+ {
+ call.invoke( "update", new Object[]{ environmentName, applicationServerName, connectionFactoryName } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "JMS connection factory " + connectionFactoryName + " update failed", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "JMS connection factory " + connectionFactoryName + " update failed", e );
- }
- }
- /**
- * Wrapper method to check if a JMS connection factory is up to date or not.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param connectionFactoryName the target JMS connection factory name.
- * @return true if the JMS connection factory is up to date, false else.
- * @throws ClientException in case of status check failure.
- */
- public boolean check( String environmentName, String applicationServerName, String connectionFactoryName )
- throws ClientException
- {
- boolean upToDate = false;
- try
+ /**
+ * Wrapper method to check if a JMS connection factory is up to date or not.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param connectionFactoryName the target JMS connection factory name.
+ * @return true if the JMS connection factory is up to date, false else.
+ * @throws ClientException in case of status check failure.
+ */
+ public boolean check( String environmentName, String applicationServerName, String connectionFactoryName )
+ throws ClientException
{
- upToDate = ( (Boolean) call.invoke( "check", new Object[]{ environmentName, applicationServerName,
- connectionFactoryName } ) ).booleanValue();
+ boolean upToDate = false;
+ try
+ {
+ upToDate = ( (Boolean) call.invoke( "check", new Object[]{ environmentName, applicationServerName,
+ connectionFactoryName } ) ).booleanValue();
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "JMS connection factory " + connectionFactoryName + " status check failed", e );
+ }
+ return upToDate;
}
- catch ( Exception e )
- {
- throw new ClientException( "JMS connection factory " + connectionFactoryName + " status check failed", e );
- }
- return upToDate;
- }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JMSServerClient.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JMSServerClient.java
index 5d3e20b..d19b078 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JMSServerClient.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JMSServerClient.java
@@ -22,66 +22,66 @@
* JMS server WS client.
*/
public class JMSServerClient
- extends AbstractClient
+ extends AbstractClient
{
- /**
- * Default constructor.
- *
- * @param host the hostname or IP address of the Kalumet agent WS server.
- * @param port the port number of the Kalumet agent WS server.
- * @throws ClientException in case of communication failure.
- */
- public JMSServerClient( String host, int port )
- throws ClientException
- {
- super( "http://" + host + ":" + port + "/axis/services/JMSServerService" );
- }
+ /**
+ * Default constructor.
+ *
+ * @param host the hostname or IP address of the Kalumet agent WS server.
+ * @param port the port number of the Kalumet agent WS server.
+ * @throws ClientException in case of communication failure.
+ */
+ public JMSServerClient( String host, int port )
+ throws ClientException
+ {
+ super( "http://" + host + ":" + port + "/axis/services/JMSServerService" );
+ }
- /**
- * Wrapper method to update a JMS server.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param jmsServerName the target JMS server name.
- * @throws ClientException in case of update failure.
- */
- public void update( String environmentName, String applicationServerName, String jmsServerName )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to update a JMS server.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param jmsServerName the target JMS server name.
+ * @throws ClientException in case of update failure.
+ */
+ public void update( String environmentName, String applicationServerName, String jmsServerName )
+ throws ClientException
{
- call.invoke( "update", new Object[]{ environmentName, applicationServerName, jmsServerName } );
+ try
+ {
+ call.invoke( "update", new Object[]{ environmentName, applicationServerName, jmsServerName } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "JMS server " + jmsServerName + " update failed", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "JMS server " + jmsServerName + " update failed", e );
- }
- }
- /**
- * Wrapper method to check if a JMS server is up to date or not.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param jmsServerName the target JMS server name.
- * @return true if the JMS server is up to date, false else.
- * @throws ClientException in case of status check failure.
- */
- public boolean check( String environmentName, String applicationServerName, String jmsServerName )
- throws ClientException
- {
- boolean upToDate = false;
- try
+ /**
+ * Wrapper method to check if a JMS server is up to date or not.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param jmsServerName the target JMS server name.
+ * @return true if the JMS server is up to date, false else.
+ * @throws ClientException in case of status check failure.
+ */
+ public boolean check( String environmentName, String applicationServerName, String jmsServerName )
+ throws ClientException
{
- upToDate = ( (Boolean) call.invoke( "check", new Object[]{ environmentName, applicationServerName,
- jmsServerName } ) ).booleanValue();
+ boolean upToDate = false;
+ try
+ {
+ upToDate = ( (Boolean) call.invoke( "check", new Object[]{ environmentName, applicationServerName,
+ jmsServerName } ) ).booleanValue();
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "JMS server " + jmsServerName + " status check failed", e );
+ }
+ return upToDate;
}
- catch ( Exception e )
- {
- throw new ClientException( "JMS server " + jmsServerName + " status check failed", e );
- }
- return upToDate;
- }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JNDIBindingClient.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JNDIBindingClient.java
index 9ca8809..6b2e181 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JNDIBindingClient.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/JNDIBindingClient.java
@@ -22,66 +22,66 @@
* JNDI binding WS client.
*/
public class JNDIBindingClient
- extends AbstractClient
+ extends AbstractClient
{
- /**
- * Default constructor.
- *
- * @param host the hostname or IP address of the Kalumet agent WS server.
- * @param port the port number of the Kalumet agent WS server.
- * @throws ClientException in case of communication failure.
- */
- public JNDIBindingClient( String host, int port )
- throws ClientException
- {
- super( "http://" + host + ":" + port + "/axis/services/JNDIBindingService" );
- }
+ /**
+ * Default constructor.
+ *
+ * @param host the hostname or IP address of the Kalumet agent WS server.
+ * @param port the port number of the Kalumet agent WS server.
+ * @throws ClientException in case of communication failure.
+ */
+ public JNDIBindingClient( String host, int port )
+ throws ClientException
+ {
+ super( "http://" + host + ":" + port + "/axis/services/JNDIBindingService" );
+ }
- /**
- * Wrapper method to update a JNDI binding.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param jndiBindingName the target JNDI binding name.
- * @throws ClientException in case of update failure.
- */
- public void update( String environmentName, String applicationServerName, String jndiBindingName )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to update a JNDI binding.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param jndiBindingName the target JNDI binding name.
+ * @throws ClientException in case of update failure.
+ */
+ public void update( String environmentName, String applicationServerName, String jndiBindingName )
+ throws ClientException
{
- call.invoke( "update", new Object[]{ environmentName, applicationServerName, jndiBindingName } );
+ try
+ {
+ call.invoke( "update", new Object[]{ environmentName, applicationServerName, jndiBindingName } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "JNDI binding " + jndiBindingName + " update failed", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "JNDI binding " + jndiBindingName + " update failed", e );
- }
- }
- /**
- * Wrapper method to check if a JNDI binding is up to date or not.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param jndiBindingName the target JNDI binding name.
- * @return true of the JNDI binding is up to date, false else.
- * @throws ClientException in case of status check failure.
- */
- public boolean check( String environmentName, String applicationServerName, String jndiBindingName )
- throws ClientException
- {
- boolean upToDate = false;
- try
+ /**
+ * Wrapper method to check if a JNDI binding is up to date or not.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param jndiBindingName the target JNDI binding name.
+ * @return true of the JNDI binding is up to date, false else.
+ * @throws ClientException in case of status check failure.
+ */
+ public boolean check( String environmentName, String applicationServerName, String jndiBindingName )
+ throws ClientException
{
- upToDate = ( (Boolean) call.invoke( "check", new Object[]{ environmentName, applicationServerName,
- jndiBindingName } ) ).booleanValue();
+ boolean upToDate = false;
+ try
+ {
+ upToDate = ( (Boolean) call.invoke( "check", new Object[]{ environmentName, applicationServerName,
+ jndiBindingName } ) ).booleanValue();
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "JNDI binding " + jndiBindingName + " status check failed", e );
+ }
+ return upToDate;
}
- catch ( Exception e )
- {
- throw new ClientException( "JNDI binding " + jndiBindingName + " status check failed", e );
- }
- return upToDate;
- }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/SharedLibraryClient.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/SharedLibraryClient.java
index 6c2a5eb..759cb84 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/SharedLibraryClient.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/SharedLibraryClient.java
@@ -22,66 +22,66 @@
* Shared library WS client.
*/
public class SharedLibraryClient
- extends AbstractClient
+ extends AbstractClient
{
- /**
- * Default constructor.
- *
- * @param host the hostname or IP address of the Kalumet agent WS server.
- * @param port the port number of the Kalumet agent WS server.
- * @throws ClientException in case of communication failure.
- */
- public SharedLibraryClient( String host, int port )
- throws ClientException
- {
- super( "http://" + host + ":" + port + "/axis/services/SharedLibraryService" );
- }
+ /**
+ * Default constructor.
+ *
+ * @param host the hostname or IP address of the Kalumet agent WS server.
+ * @param port the port number of the Kalumet agent WS server.
+ * @throws ClientException in case of communication failure.
+ */
+ public SharedLibraryClient( String host, int port )
+ throws ClientException
+ {
+ super( "http://" + host + ":" + port + "/axis/services/SharedLibraryService" );
+ }
- /**
- * Wrapper method to update a shared library.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param sharedLibraryName the target shared library name.
- * @throws ClientException in case of update failure.
- */
- public void update( String environmentName, String applicationServerName, String sharedLibraryName )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to update a shared library.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param sharedLibraryName the target shared library name.
+ * @throws ClientException in case of update failure.
+ */
+ public void update( String environmentName, String applicationServerName, String sharedLibraryName )
+ throws ClientException
{
- call.invoke( "update", new Object[]{ environmentName, applicationServerName, sharedLibraryName } );
+ try
+ {
+ call.invoke( "update", new Object[]{ environmentName, applicationServerName, sharedLibraryName } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "Shared library " + sharedLibraryName + " update failed", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "Shared library " + sharedLibraryName + " update failed", e );
- }
- }
- /**
- * Wrapper method to check if a shared library is up to date or not.
- *
- * @param environmentName the target environment name.
- * @param applicationServerName the target JEE application server name.
- * @param sharedLibraryName the target shared library name.
- * @return true if the shared library is up to date, false else.
- * @throws ClientException in case of status check failure.
- */
- public boolean check( String environmentName, String applicationServerName, String sharedLibraryName )
- throws ClientException
- {
- boolean upToDate = false;
- try
+ /**
+ * Wrapper method to check if a shared library is up to date or not.
+ *
+ * @param environmentName the target environment name.
+ * @param applicationServerName the target JEE application server name.
+ * @param sharedLibraryName the target shared library name.
+ * @return true if the shared library is up to date, false else.
+ * @throws ClientException in case of status check failure.
+ */
+ public boolean check( String environmentName, String applicationServerName, String sharedLibraryName )
+ throws ClientException
{
- upToDate = ( (Boolean) call.invoke( "check", new Object[]{ environmentName, applicationServerName,
- sharedLibraryName } ) ).booleanValue();
+ boolean upToDate = false;
+ try
+ {
+ upToDate = ( (Boolean) call.invoke( "check", new Object[]{ environmentName, applicationServerName,
+ sharedLibraryName } ) ).booleanValue();
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "Shared library " + sharedLibraryName + " status check failed", e );
+ }
+ return upToDate;
}
- catch ( Exception e )
- {
- throw new ClientException( "Shared library " + sharedLibraryName + " status check failed", e );
- }
- return upToDate;
- }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/SimplifiedFileObject.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/SimplifiedFileObject.java
index df1d390..5563192 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/SimplifiedFileObject.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/SimplifiedFileObject.java
@@ -25,67 +25,67 @@
* Simplified VFS file object to be used via WS.
*/
public class SimplifiedFileObject
- implements Serializable
+ implements Serializable
{
- private String name;
+ private String name;
- private String path;
+ private String path;
- private boolean file;
+ private boolean file;
- private long size;
+ private long size;
- private Date lastModificationDate;
+ private Date lastModificationDate;
- public String getName()
- {
- return this.name;
- }
+ public String getName()
+ {
+ return this.name;
+ }
- public void setName( String name )
- {
- this.name = name;
- }
+ public void setName( String name )
+ {
+ this.name = name;
+ }
- public String getPath()
- {
- return this.path;
- }
+ public String getPath()
+ {
+ return this.path;
+ }
- public void setPath( String path )
- {
- this.path = path;
- }
+ public void setPath( String path )
+ {
+ this.path = path;
+ }
- public boolean isFile()
- {
- return this.file;
- }
+ public boolean isFile()
+ {
+ return this.file;
+ }
- public void setFile( boolean file )
- {
- this.file = file;
- }
+ public void setFile( boolean file )
+ {
+ this.file = file;
+ }
- public Date getLastModificationDate()
- {
- return this.lastModificationDate;
- }
+ public Date getLastModificationDate()
+ {
+ return this.lastModificationDate;
+ }
- public void setLastModificationDate( Date lastModificationDate )
- {
- this.lastModificationDate = lastModificationDate;
- }
+ public void setLastModificationDate( Date lastModificationDate )
+ {
+ this.lastModificationDate = lastModificationDate;
+ }
- public long getSize()
- {
- return this.size;
- }
+ public long getSize()
+ {
+ return this.size;
+ }
- public void setSize( long size )
- {
- this.size = size;
- }
+ public void setSize( long size )
+ {
+ this.size = size;
+ }
}
diff --git a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/SoftwareClient.java b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/SoftwareClient.java
index 0b2e31d..290cfc0 100644
--- a/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/SoftwareClient.java
+++ b/kalumet-modules/common/src/main/java/org/apache/kalumet/ws/client/SoftwareClient.java
@@ -22,134 +22,134 @@
* Software WS client.
*/
public class SoftwareClient
- extends AbstractClient
+ extends AbstractClient
{
- /**
- * Default constructor.
- *
- * @param host the hostname or IP address of the Kalumet agent WS server.
- * @param port the port number of the Kalumet agent WS server.
- * @throws ClientException in case of communication failure.
- */
- public SoftwareClient( String host, int port )
- throws ClientException
- {
- super( "http://" + host + ":" + port + "/axis/services/SoftwareService" );
- }
+ /**
+ * Default constructor.
+ *
+ * @param host the hostname or IP address of the Kalumet agent WS server.
+ * @param port the port number of the Kalumet agent WS server.
+ * @throws ClientException in case of communication failure.
+ */
+ public SoftwareClient( String host, int port )
+ throws ClientException
+ {
+ super( "http://" + host + ":" + port + "/axis/services/SoftwareService" );
+ }
- /**
- * Wrapper method to update a software.
- *
- * @param environmentName the target environment name.
- * @param softwareName the target software name.
- * @param delegation true if the call is performed by another agent, false else.
- * @throws ClientException in case of update failure.
- */
- public void update( String environmentName, String softwareName, boolean delegation )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to update a software.
+ *
+ * @param environmentName the target environment name.
+ * @param softwareName the target software name.
+ * @param delegation true if the call is performed by another agent, false else.
+ * @throws ClientException in case of update failure.
+ */
+ public void update( String environmentName, String softwareName, boolean delegation )
+ throws ClientException
{
- call.invoke( "update", new Object[]{ environmentName, softwareName, new Boolean( delegation ) } );
+ try
+ {
+ call.invoke( "update", new Object[]{ environmentName, softwareName, new Boolean( delegation ) } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "Software " + softwareName + " update failed", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "Software " + softwareName + " update failed", e );
- }
- }
- /**
- * Wrapper method to execute a command.
- *
- * @param environmentName the target environment name.
- * @param softwareName the target software name.
- * @param commandName the target command name.
- * @param delegation true if the call is performed by another agent, false else.
- * @throws ClientException in case of command execution failure.
- */
- public void executeCommand( String environmentName, String softwareName, String commandName, boolean delegation )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to execute a command.
+ *
+ * @param environmentName the target environment name.
+ * @param softwareName the target software name.
+ * @param commandName the target command name.
+ * @param delegation true if the call is performed by another agent, false else.
+ * @throws ClientException in case of command execution failure.
+ */
+ public void executeCommand( String environmentName, String softwareName, String commandName, boolean delegation )
+ throws ClientException
{
- call.invoke( "executeCommand",
- new Object[]{ environmentName, softwareName, commandName, new Boolean( delegation ) } );
+ try
+ {
+ call.invoke( "executeCommand",
+ new Object[]{ environmentName, softwareName, commandName, new Boolean( delegation ) } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "Command " + commandName + " execution failed", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "Command " + commandName + " execution failed", e );
- }
- }
- /**
- * Wrapper method to update a location.
- *
- * @param environmentName the target environment name.
- * @param softwareName the target software name.
- * @param locationName the target location name.
- * @param delegation true if the call is performed by another agent, false else.
- * @throws ClientException in case of location update failure.
- */
- public void updateLocation( String environmentName, String softwareName, String locationName, boolean delegation )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to update a location.
+ *
+ * @param environmentName the target environment name.
+ * @param softwareName the target software name.
+ * @param locationName the target location name.
+ * @param delegation true if the call is performed by another agent, false else.
+ * @throws ClientException in case of location update failure.
+ */
+ public void updateLocation( String environmentName, String softwareName, String locationName, boolean delegation )
+ throws ClientException
{
- call.invoke( "updateLocation",
- new Object[]{ environmentName, softwareName, locationName, new Boolean( delegation ) } );
+ try
+ {
+ call.invoke( "updateLocation",
+ new Object[]{ environmentName, softwareName, locationName, new Boolean( delegation ) } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "Location " + locationName + " update failed", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "Location " + locationName + " update failed", e );
- }
- }
- /**
- * Wrapper method to update a configuration file.
- *
- * @param environmentName the target environment name.
- * @param softwareName the target software name.
- * @param configurationFileName the target configuration file name.
- * @param delegation true if the call is performed by another agent, false else.
- * @throws ClientException in case of configuration file update failure.
- */
- public void updateConfigurationFile( String environmentName, String softwareName, String configurationFileName,
- boolean delegation )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to update a configuration file.
+ *
+ * @param environmentName the target environment name.
+ * @param softwareName the target software name.
+ * @param configurationFileName the target configuration file name.
+ * @param delegation true if the call is performed by another agent, false else.
+ * @throws ClientException in case of configuration file update failure.
+ */
+ public void updateConfigurationFile( String environmentName, String softwareName, String configurationFileName,
+ boolean delegation )
+ throws ClientException
{
- call.invoke( "updateConfigurationFile",
- new Object[]{ environmentName, softwareName, configurationFileName, new Boolean( delegation ) } );
+ try
+ {
+ call.invoke( "updateConfigurationFile", new Object[]{ environmentName, softwareName, configurationFileName,
+ new Boolean( delegation ) } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "Configuration file " + configurationFileName + " update failed", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "Configuration file " + configurationFileName + " update failed", e );
- }
- }
- /**
- * Wrapper method to update a database.
- *
- * @param environmentName the target environment name.
- * @param softwareName the target software name.
- * @param databaseName the target database name.
- * @param delegation true if the call is performed by another agent, false else.
- * @throws ClientException in case of database update failure.
- */
- public void updateDatabase( String environmentName, String softwareName, String databaseName, boolean delegation )
- throws ClientException
- {
- try
+ /**
+ * Wrapper method to update a database.
+ *
+ * @param environmentName the target environment name.
+ * @param softwareName the target software name.
+ * @param databaseName the target database name.
+ * @param delegation true if the call is performed by another agent, false else.
+ * @throws ClientException in case of database update failure.
+ */
+ public void updateDatabase( String environmentName, String softwareName, String databaseName, boolean delegation )
+ throws ClientException
{
- call.invoke( "updateDatabase",
- new Object[]{ environmentName, softwareName, databaseName, new Boolean( delegation ) } );
+ try
+ {
+ call.invoke( "updateDatabase",
+ new Object[]{ environmentName, softwareName, databaseName, new Boolean( delegation ) } );
+ }
+ catch ( Exception e )
+ {
+ throw new ClientException( "Database " + databaseName + " update failed", e );
+ }
}
- catch ( Exception e )
- {
- throw new ClientException( "Database " + databaseName + " update failed", e );
- }
- }
}
diff --git a/kalumet-modules/common/src/test/java/org/apache/kalumet/model/KalumetTest.java b/kalumet-modules/common/src/test/java/org/apache/kalumet/model/KalumetTest.java
index 184db03..c07b027 100644
--- a/kalumet-modules/common/src/test/java/org/apache/kalumet/model/KalumetTest.java
+++ b/kalumet-modules/common/src/test/java/org/apache/kalumet/model/KalumetTest.java
@@ -31,279 +31,282 @@
public class KalumetTest
{
- private final static transient Logger LOGGER = LoggerFactory.getLogger( KalumetTest.class );
+ private final static transient Logger LOGGER = LoggerFactory.getLogger( KalumetTest.class );
- private Kalumet kalumetModel;
+ private Kalumet kalumetModel;
- @Before
- public void setUp()
- throws Exception
- {
- kalumetModel = Kalumet.digeste( "file:./src/test/resources/kalumet.xml" );
- }
+ @Before
+ public void setUp()
+ throws Exception
+ {
+ kalumetModel = Kalumet.digeste( "file:./src/test/resources/kalumet.xml" );
+ }
- @Test
- public void testPropertiesUnmarshalling()
- {
- LOGGER.info( "Get Kalumet test property" );
- Property testProperty = kalumetModel.getProperty( "test" );
- assertEquals( "test", testProperty.getValue() );
- }
+ @Test
+ public void testPropertiesUnmarshalling()
+ {
+ LOGGER.info( "Get Kalumet test property" );
+ Property testProperty = kalumetModel.getProperty( "test" );
+ assertEquals( "test", testProperty.getValue() );
+ }
- @Test
- public void testUserUnmarshalling()
- {
- LOGGER.info( "Get Kalumet test user" );
- User user = kalumetModel.getSecurity().getUser( "test" );
- assertEquals( "test", user.getId() );
- assertEquals( "Test Test", user.getName() );
- assertEquals( "test@example.com", user.getEmail() );
- }
+ @Test
+ public void testUserUnmarshalling()
+ {
+ LOGGER.info( "Get Kalumet test user" );
+ User user = kalumetModel.getSecurity().getUser( "test" );
+ assertEquals( "test", user.getId() );
+ assertEquals( "Test Test", user.getName() );
+ assertEquals( "test@example.com", user.getEmail() );
+ }
- @Test
- public void testGroupUnmarshalling()
- {
- LOGGER.info( "Get Kalumet test group" );
- Group group = kalumetModel.getSecurity().getGroup( "test" );
- assertEquals( "Test Group", group.getName() );
- assertEquals( "test", group.getUser( "test" ).getId() );
- }
+ @Test
+ public void testGroupUnmarshalling()
+ {
+ LOGGER.info( "Get Kalumet test group" );
+ Group group = kalumetModel.getSecurity().getGroup( "test" );
+ assertEquals( "Test Group", group.getName() );
+ assertEquals( "test", group.getUser( "test" ).getId() );
+ }
- @Test
- public void testAgentUnmarshalling()
- {
- LOGGER.info( "Get Kalumet test agent" );
- Agent agent = kalumetModel.getAgent( "test" );
- assertEquals( "localhost", agent.getHostname() );
- assertEquals( 5000, agent.getPort() );
- assertEquals( "0 * * * * *", agent.getCron() );
- assertEquals( 5, agent.getMaxmanagedenvironments() );
- assertEquals( 3, agent.getMaxjeeapplicationserversstarted() );
- }
+ @Test
+ public void testAgentUnmarshalling()
+ {
+ LOGGER.info( "Get Kalumet test agent" );
+ Agent agent = kalumetModel.getAgent( "test" );
+ assertEquals( "localhost", agent.getHostname() );
+ assertEquals( 5000, agent.getPort() );
+ assertEquals( "0 * * * * *", agent.getCron() );
+ assertEquals( 5, agent.getMaxmanagedenvironments() );
+ assertEquals( 3, agent.getMaxjeeapplicationserversstarted() );
+ }
- @Test
- public void testEnvironmentUnmarshalling()
- {
- LOGGER.info( "Get Kalumet test_auto environment" );
- Environment environment = kalumetModel.getEnvironment( "test_auto" );
- assertEquals( "test_auto", environment.getName() );
- assertEquals( "TEST", environment.getGroup() );
- assertEquals( "test", environment.getTag() );
- assertEquals( false, environment.isAutoupdate() );
- assertEquals( "test", environment.getAgent() );
- assertEquals( "test", environment.getLock() );
- assertEquals( "ftp://remote/release/${RELEASE_VERSION}", environment.getReleaseLocation() );
- assertEquals( "Notes test.", environment.getNotes() );
- assertEquals( "Weblinks test.", environment.getWeblinks() );
- }
+ @Test
+ public void testEnvironmentUnmarshalling()
+ {
+ LOGGER.info( "Get Kalumet test_auto environment" );
+ Environment environment = kalumetModel.getEnvironment( "test_auto" );
+ assertEquals( "test_auto", environment.getName() );
+ assertEquals( "TEST", environment.getGroup() );
+ assertEquals( "test", environment.getTag() );
+ assertEquals( false, environment.isAutoupdate() );
+ assertEquals( "test", environment.getAgent() );
+ assertEquals( "test", environment.getLock() );
+ assertEquals( "ftp://remote/release/${RELEASE_VERSION}", environment.getReleaseLocation() );
+ assertEquals( "Notes test.", environment.getNotes() );
+ assertEquals( "Weblinks test.", environment.getWeblinks() );
+ }
- @Test
- public void testVariableUnmarshalling()
- {
- LOGGER.info( "Get Kalumet test_auto environment RELEASE_VERSION variable" );
- Variable variable = kalumetModel.getEnvironment( "test_auto" ).getVariable( "RELEASE_VERSION" );
- assertEquals( "test", variable.getValue() );
- }
+ @Test
+ public void testVariableUnmarshalling()
+ {
+ LOGGER.info( "Get Kalumet test_auto environment RELEASE_VERSION variable" );
+ Variable variable = kalumetModel.getEnvironment( "test_auto" ).getVariable( "RELEASE_VERSION" );
+ assertEquals( "test", variable.getValue() );
+ }
- @Test
- public void testFreeFieldUnmarshalling()
- {
- LOGGER.info( "Get Kalumet test_auto environment FREE freefield" );
- FreeField freeField = kalumetModel.getEnvironment( "test_auto" ).getFreeField( "FREE" );
- assertEquals( "field", freeField.getContent() );
- }
+ @Test
+ public void testFreeFieldUnmarshalling()
+ {
+ LOGGER.info( "Get Kalumet test_auto environment FREE freefield" );
+ FreeField freeField = kalumetModel.getEnvironment( "test_auto" ).getFreeField( "FREE" );
+ assertEquals( "field", freeField.getContent() );
+ }
- @Test
- public void testAccessUnmarshalling()
- {
- LOGGER.info( "Get Kalumet test_auto environment access for the test group" );
- Access access = kalumetModel.getEnvironment( "test_auto" ).getAccess( "test" );
- assertEquals( "false", access.getProperty( "admin" ).getValue() );
- assertEquals( "true", access.getProperty( "update" ).getValue() );
- assertEquals( "true", access.getProperty( "jee_application_servers_change" ).getValue() );
- assertEquals( "true", access.getProperty( "jee_application_servers_update" ).getValue() );
- assertEquals( "true", access.getProperty( "jee_application_servers_control" ).getValue() );
- assertEquals( "true", access.getProperty( "jee_resources_change" ).getValue() );
- assertEquals( "true", access.getProperty( "jee_resources_update" ).getValue() );
- assertEquals( "true", access.getProperty( "jee_applications_change" ).getValue() );
- assertEquals( "true", access.getProperty( "jee_applications_update" ).getValue() );
- assertEquals( "true", access.getProperty( "softwares_change" ).getValue() );
- assertEquals( "true", access.getProperty( "softwares_update" ).getValue() );
- assertEquals( "true", access.getProperty( "release" ).getValue() );
- assertEquals( "true", access.getProperty( "shell" ).getValue() );
- assertEquals( "true", access.getProperty( "browser" ).getValue() );
- assertEquals( "true", access.getProperty( "homepage" ).getValue() );
- }
+ @Test
+ public void testAccessUnmarshalling()
+ {
+ LOGGER.info( "Get Kalumet test_auto environment access for the test group" );
+ Access access = kalumetModel.getEnvironment( "test_auto" ).getAccess( "test" );
+ assertEquals( "false", access.getProperty( "admin" ).getValue() );
+ assertEquals( "true", access.getProperty( "update" ).getValue() );
+ assertEquals( "true", access.getProperty( "jee_application_servers_change" ).getValue() );
+ assertEquals( "true", access.getProperty( "jee_application_servers_update" ).getValue() );
+ assertEquals( "true", access.getProperty( "jee_application_servers_control" ).getValue() );
+ assertEquals( "true", access.getProperty( "jee_resources_change" ).getValue() );
+ assertEquals( "true", access.getProperty( "jee_resources_update" ).getValue() );
+ assertEquals( "true", access.getProperty( "jee_applications_change" ).getValue() );
+ assertEquals( "true", access.getProperty( "jee_applications_update" ).getValue() );
+ assertEquals( "true", access.getProperty( "softwares_change" ).getValue() );
+ assertEquals( "true", access.getProperty( "softwares_update" ).getValue() );
+ assertEquals( "true", access.getProperty( "release" ).getValue() );
+ assertEquals( "true", access.getProperty( "shell" ).getValue() );
+ assertEquals( "true", access.getProperty( "browser" ).getValue() );
+ assertEquals( "true", access.getProperty( "homepage" ).getValue() );
+ }
- @Test
- public void testLogFileUnmarshalling()
- {
- LOGGER.info( "Get Kalumet test_auto environment test log file" );
- LogFile logFile = kalumetModel.getEnvironment( "test_auto" ).getLogFile( "test" );
- assertEquals( "test", logFile.getName() );
- assertEquals( "/tmp", logFile.getPath() );
- assertEquals( "test", logFile.getAgent() );
- }
+ @Test
+ public void testLogFileUnmarshalling()
+ {
+ LOGGER.info( "Get Kalumet test_auto environment test log file" );
+ LogFile logFile = kalumetModel.getEnvironment( "test_auto" ).getLogFile( "test" );
+ assertEquals( "test", logFile.getName() );
+ assertEquals( "/tmp", logFile.getPath() );
+ assertEquals( "test", logFile.getAgent() );
+ }
- @Test
- public void testJEEApplicationServersUnmarshalling()
- {
- LOGGER.info( "Get Kalumet test_auto environment JEE application servers" );
- JEEApplicationServers applicationServers = kalumetModel.getEnvironment( "test_auto" ).getJEEApplicationServers();
- assertEquals( false, applicationServers.isCluster() );
- }
+ @Test
+ public void testJEEApplicationServersUnmarshalling()
+ {
+ LOGGER.info( "Get Kalumet test_auto environment JEE application servers" );
+ JEEApplicationServers applicationServers =
+ kalumetModel.getEnvironment( "test_auto" ).getJEEApplicationServers();
+ assertEquals( false, applicationServers.isCluster() );
+ }
- @Test
- public void testJEEApplicationServerUnmarshalling()
- {
- LOGGER.info( "Get Kalumet test_auto environment as_test JEE application server" );
- JEEApplicationServer applicationServer =
- kalumetModel.getEnvironment( "test_auto" ).getJEEApplicationServers().getJEEApplicationServer("as_test");
- assertEquals( "org.apache.kalumet.jmx.plugins.DummyPlugin", applicationServer.getClassname() );
- assertEquals( "dummy://localhost:1099", applicationServer.getJmxurl() );
- assertEquals( "admin_user", applicationServer.getAdminuser() );
- assertEquals( "admin_password", applicationServer.getAdminpassword() );
- assertEquals( true, applicationServer.isUpdateRequireRestart() );
- assertEquals( true, applicationServer.isUpdateRequireCacheCleaning() );
- assertEquals( false, applicationServer.isUsejmxstop() );
- assertEquals( false, applicationServer.isDeletecomponents() );
- assertEquals( "test", applicationServer.getAgent() );
- assertEquals( "echo \"Startup\"", applicationServer.getStartupcommand() );
- assertEquals( "echo \"Shutdown\"", applicationServer.getShutdowncommand() );
- }
+ @Test
+ public void testJEEApplicationServerUnmarshalling()
+ {
+ LOGGER.info( "Get Kalumet test_auto environment as_test JEE application server" );
+ JEEApplicationServer applicationServer =
+ kalumetModel.getEnvironment( "test_auto" ).getJEEApplicationServers().getJEEApplicationServer( "as_test" );
+ assertEquals( "org.apache.kalumet.jmx.plugins.DummyPlugin", applicationServer.getClassname() );
+ assertEquals( "dummy://localhost:1099", applicationServer.getJmxurl() );
+ assertEquals( "admin_user", applicationServer.getAdminuser() );
+ assertEquals( "admin_password", applicationServer.getAdminpassword() );
+ assertEquals( true, applicationServer.isUpdateRequireRestart() );
+ assertEquals( true, applicationServer.isUpdateRequireCacheCleaning() );
+ assertEquals( false, applicationServer.isUsejmxstop() );
+ assertEquals( false, applicationServer.isDeletecomponents() );
+ assertEquals( "test", applicationServer.getAgent() );
+ assertEquals( "echo \"Startup\"", applicationServer.getStartupcommand() );
+ assertEquals( "echo \"Shutdown\"", applicationServer.getShutdowncommand() );
+ }
- @Test
- public void testJDBCConnectionPoolUnmarshalling()
- {
- LOGGER.info( "Get Kalumet test_auto environment, as_test JEE application server, JDBC connection pool test" );
- JDBCConnectionPool connectionPool =
- kalumetModel.getEnvironment( "test_auto" ).getJEEApplicationServers().getJEEApplicationServer(
- "as_test").getJDBCConnectionPool( "test" );
- assertEquals( "test", connectionPool.getName() );
- }
+ @Test
+ public void testJDBCConnectionPoolUnmarshalling()
+ {
+ LOGGER.info( "Get Kalumet test_auto environment, as_test JEE application server, JDBC connection pool test" );
+ JDBCConnectionPool connectionPool =
+ kalumetModel.getEnvironment( "test_auto" ).getJEEApplicationServers().getJEEApplicationServer(
+ "as_test" ).getJDBCConnectionPool( "test" );
+ assertEquals( "test", connectionPool.getName() );
+ }
- @Test
- public void testJDBCDataSourceUnmarshalling()
- {
- LOGGER.info( "Get Kalumet test_auto environment, as_test JEE application server, JDBC data source test" );
- JDBCDataSource dataSource =
- kalumetModel.getEnvironment( "test_auto" ).getJEEApplicationServers().getJEEApplicationServer(
- "as_test").getJDBCDataSource( "test" );
- assertEquals( "test", dataSource.getName() );
- }
+ @Test
+ public void testJDBCDataSourceUnmarshalling()
+ {
+ LOGGER.info( "Get Kalumet test_auto environment, as_test JEE application server, JDBC data source test" );
+ JDBCDataSource dataSource =
+ kalumetModel.getEnvironment( "test_auto" ).getJEEApplicationServers().getJEEApplicationServer(
+ "as_test" ).getJDBCDataSource( "test" );
+ assertEquals( "test", dataSource.getName() );
+ }
- @Test
- public void testSoftwareUnmarshalling()
- {
- LOGGER.info( "Get Kalumet test_auto environment test software" );
- Software software = kalumetModel.getEnvironment( "test_auto" ).getSoftware( "test" );
- assertEquals( "test", software.getName() );
- assertEquals( "http://www.example.com/software", software.getUri() );
- assertEquals( "test", software.getAgent() );
- assertEquals( true, software.isActive() );
- assertEquals( false, software.isBlocker() );
- assertEquals( false, software.isBeforejee() );
- }
+ @Test
+ public void testSoftwareUnmarshalling()
+ {
+ LOGGER.info( "Get Kalumet test_auto environment test software" );
+ Software software = kalumetModel.getEnvironment( "test_auto" ).getSoftware( "test" );
+ assertEquals( "test", software.getName() );
+ assertEquals( "http://www.example.com/software", software.getUri() );
+ assertEquals( "test", software.getAgent() );
+ assertEquals( true, software.isActive() );
+ assertEquals( false, software.isBlocker() );
+ assertEquals( false, software.isBeforejee() );
+ }
- @Test
- public void testSoftwareUpdatePlanCommandUnmarshalling()
- {
- LOGGER.info( "Get Kalumet test_auto environment test software, command_test command" );
- Command command = kalumetModel.getEnvironment( "test_auto" ).getSoftware( "test" ).getCommand( "command_test" );
- assertEquals( "command_test", command.getName() );
- assertEquals( true, command.isActive() );
- assertEquals( false, command.isBlocker() );
- assertEquals( "ls /tmp", command.getCommand() );
- assertEquals( "test", command.getAgent() );
- }
+ @Test
+ public void testSoftwareUpdatePlanCommandUnmarshalling()
+ {
+ LOGGER.info( "Get Kalumet test_auto environment test software, command_test command" );
+ Command command = kalumetModel.getEnvironment( "test_auto" ).getSoftware( "test" ).getCommand( "command_test" );
+ assertEquals( "command_test", command.getName() );
+ assertEquals( true, command.isActive() );
+ assertEquals( false, command.isBlocker() );
+ assertEquals( "ls /tmp", command.getCommand() );
+ assertEquals( "test", command.getAgent() );
+ }
- @Test
- public void testSoftwareUpdatePlanLocationUnmarshalling()
- {
- LOGGER.info( "Get Kalumet test_auto environment test software, location_test location" );
- Location location = kalumetModel.getEnvironment( "test_auto" ).getSoftware( "test" ).getLocation( "location_test" );
- assertEquals( "location_test", location.getName() );
- assertEquals( true, location.isActive() );
- assertEquals( false, location.isBlocker() );
- assertEquals( "http://www.example.com/location", location.getUri() );
- assertEquals( "/tmp/location", location.getPath() );
- assertEquals( "test", location.getAgent() );
- }
+ @Test
+ public void testSoftwareUpdatePlanLocationUnmarshalling()
+ {
+ LOGGER.info( "Get Kalumet test_auto environment test software, location_test location" );
+ Location location =
+ kalumetModel.getEnvironment( "test_auto" ).getSoftware( "test" ).getLocation( "location_test" );
+ assertEquals( "location_test", location.getName() );
+ assertEquals( true, location.isActive() );
+ assertEquals( false, location.isBlocker() );
+ assertEquals( "http://www.example.com/location", location.getUri() );
+ assertEquals( "/tmp/location", location.getPath() );
+ assertEquals( "test", location.getAgent() );
+ }
- @Test
- public void testSoftwareUpdatePlanConfigurationFileUnmarshalling()
- {
- LOGGER.info( "Get Kalumet test_auto environment test software, configurationfile_test configuration file" );
- ConfigurationFile configurationFile =
- kalumetModel.getEnvironment( "test_auto" ).getSoftware( "test" ).getConfigurationFile( "configurationfile_test" );
- assertEquals( "configurationfile_test", configurationFile.getName() );
- assertEquals( "http://www.example.com/configurationfile", configurationFile.getUri() );
- assertEquals( "/tmp/configurationfile", configurationFile.getPath() );
- assertEquals( true, configurationFile.isActive() );
- assertEquals( false, configurationFile.isBlocker() );
- assertEquals( "test", configurationFile.getAgent() );
- }
+ @Test
+ public void testSoftwareUpdatePlanConfigurationFileUnmarshalling()
+ {
+ LOGGER.info( "Get Kalumet test_auto environment test software, configurationfile_test configuration file" );
+ ConfigurationFile configurationFile =
+ kalumetModel.getEnvironment( "test_auto" ).getSoftware( "test" ).getConfigurationFile(
+ "configurationfile_test" );
+ assertEquals( "configurationfile_test", configurationFile.getName() );
+ assertEquals( "http://www.example.com/configurationfile", configurationFile.getUri() );
+ assertEquals( "/tmp/configurationfile", configurationFile.getPath() );
+ assertEquals( true, configurationFile.isActive() );
+ assertEquals( false, configurationFile.isBlocker() );
+ assertEquals( "test", configurationFile.getAgent() );
+ }
- @Test
- public void testSoftwareUpdatePlanDatabaseUnmarshaling()
- {
- LOGGER.info( "Get Kalumet environment test_auto test software db_test database update plan item." );
- Database database = kalumetModel.getEnvironment( "test_auto" ).getSoftware( "test" ).getDatabase( "db_test" );
- assertEquals( "db_test", database.getName() );
- assertEquals( true, database.isActive() );
- assertEquals( false, database.isBlocker() );
- assertEquals( "com.example.test.Driver", database.getDriver() );
- assertEquals( "user_test", database.getUser() );
- assertEquals( "password_test", database.getPassword() );
- assertEquals( "jdbc://example.com:3306/test", database.getJdbcurl() );
- assertEquals( "test", database.getAgent() );
- assertEquals( "", database.getSqlCommand() );
- assertEquals( "", database.getConnectionPool() );
- }
+ @Test
+ public void testSoftwareUpdatePlanDatabaseUnmarshaling()
+ {
+ LOGGER.info( "Get Kalumet environment test_auto test software db_test database update plan item." );
+ Database database = kalumetModel.getEnvironment( "test_auto" ).getSoftware( "test" ).getDatabase( "db_test" );
+ assertEquals( "db_test", database.getName() );
+ assertEquals( true, database.isActive() );
+ assertEquals( false, database.isBlocker() );
+ assertEquals( "com.example.test.Driver", database.getDriver() );
+ assertEquals( "user_test", database.getUser() );
+ assertEquals( "password_test", database.getPassword() );
+ assertEquals( "jdbc://example.com:3306/test", database.getJdbcurl() );
+ assertEquals( "test", database.getAgent() );
+ assertEquals( "", database.getSqlCommand() );
+ assertEquals( "", database.getConnectionPool() );
+ }
- @Test
- public void testSoftwareUpdatePlanDatabaseSqlScriptUnmarshaling()
- {
- LOGGER.info(
- "Get Kalumet environment test_auto test software db_test database update plan sqlscript_test SQL script." );
- SqlScript sqlScript =
- kalumetModel.getEnvironment( "test_auto" ).getSoftware( "test" ).getDatabase( "db_test" ).getSqlScript(
- "sqlscript_test" );
- assertEquals( "sqlscript_test", sqlScript.getName() );
- assertEquals( true, sqlScript.isActive() );
- assertEquals( false, sqlScript.isBlocker() );
- assertEquals( true, sqlScript.isForce() );
- assertEquals( "http://www.example.com/sqlscript", sqlScript.getUri() );
- }
+ @Test
+ public void testSoftwareUpdatePlanDatabaseSqlScriptUnmarshaling()
+ {
+ LOGGER.info(
+ "Get Kalumet environment test_auto test software db_test database update plan sqlscript_test SQL script." );
+ SqlScript sqlScript =
+ kalumetModel.getEnvironment( "test_auto" ).getSoftware( "test" ).getDatabase( "db_test" ).getSqlScript(
+ "sqlscript_test" );
+ assertEquals( "sqlscript_test", sqlScript.getName() );
+ assertEquals( true, sqlScript.isActive() );
+ assertEquals( false, sqlScript.isBlocker() );
+ assertEquals( true, sqlScript.isForce() );
+ assertEquals( "http://www.example.com/sqlscript", sqlScript.getUri() );
+ }
- @Test
- public void testKalumetMarshalling()
- throws Exception
- {
- Kalumet kalumet = new Kalumet();
- Property testProperty = new Property();
- testProperty.setName( "test" );
- testProperty.setValue( "test" );
- kalumet.getProperties().add( testProperty );
- Environment environment = new Environment();
- environment.setName( "test" );
- environment.setNotes( "Only for test" );
- environment.setWeblinks( "Only for test" );
- Software software = new Software();
- software.setName( "test" );
- software.setUri( "http://www.example.com/test?test=test&other=other" );
- environment.addSoftware( software );
- kalumet.addEnvironment( environment );
- kalumet.writeXMLFile( "file:./target/kalumet.xml" );
- }
+ @Test
+ public void testKalumetMarshalling()
+ throws Exception
+ {
+ Kalumet kalumet = new Kalumet();
+ Property testProperty = new Property();
+ testProperty.setName( "test" );
+ testProperty.setValue( "test" );
+ kalumet.getProperties().add( testProperty );
+ Environment environment = new Environment();
+ environment.setName( "test" );
+ environment.setNotes( "Only for test" );
+ environment.setWeblinks( "Only for test" );
+ Software software = new Software();
+ software.setName( "test" );
+ software.setUri( "http://www.example.com/test?test=test&other=other" );
+ environment.addSoftware( software );
+ kalumet.addEnvironment( environment );
+ kalumet.writeXMLFile( "file:./target/kalumet.xml" );
+ }
- @Test
- public void testKalumetUnmarshalling()
- throws Exception
- {
- Kalumet kalumet = Kalumet.digeste( "file:./target/kalumet.xml" );
- Software software = kalumet.getEnvironment( "test" ).getSoftware( "test" );
- assertEquals( "http://www.example.com/test?test=test&other=other", software.getUri() );
- }
+ @Test
+ public void testKalumetUnmarshalling()
+ throws Exception
+ {
+ Kalumet kalumet = Kalumet.digeste( "file:./target/kalumet.xml" );
+ Software software = kalumet.getEnvironment( "test" ).getSoftware( "test" );
+ assertEquals( "http://www.example.com/test?test=test&other=other", software.getUri() );
+ }
}
diff --git a/kalumet-modules/common/src/test/resources/kalumet.xml b/kalumet-modules/common/src/test/resources/kalumet.xml
index 461b66f..d4c73af 100644
--- a/kalumet-modules/common/src/test/resources/kalumet.xml
+++ b/kalumet-modules/common/src/test/resources/kalumet.xml
@@ -90,9 +90,9 @@
</logfiles>
<jeeapplicationservers cluster="false">
<jeeapplicationserver name="as_test" classname="org.apache.kalumet.jmx.plugins.DummyPlugin"
- jmxurl="dummy://localhost:1099" adminuser="admin_user" adminpassword="admin_password"
- updateRequireRestart="true" updateRequireCacheCleaning="true" usejmxstop="false"
- deletecomponents="false" agent="test">
+ jmxurl="dummy://localhost:1099" adminuser="admin_user" adminpassword="admin_password"
+ updateRequireRestart="true" updateRequireCacheCleaning="true" usejmxstop="false"
+ deletecomponents="false" agent="test">
<startupcommand>
<![CDATA[
echo "Startup"
diff --git a/kalumet-modules/console/pom.xml b/kalumet-modules/console/pom.xml
index decd8e0..6ea976c 100644
--- a/kalumet-modules/console/pom.xml
+++ b/kalumet-modules/console/pom.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--
@@ -158,7 +159,8 @@
</goals>
<configuration>
<tasks>
- <copy overwrite="true" file="${basedir}/src/test/tomcat/log4j.xml" todir="${project.build.outputDirectory}" />
+ <copy overwrite="true" file="${basedir}/src/test/tomcat/log4j.xml"
+ todir="${project.build.outputDirectory}"/>
</tasks>
</configuration>
</execution>
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AboutWindow.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AboutWindow.java
index 23c77e8..9ecbbaf 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AboutWindow.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AboutWindow.java
@@ -32,94 +32,93 @@
* About window.
*/
public class AboutWindow
- extends WindowPane
+ extends WindowPane
{
- /**
- * Create a new <code>AboutWindow</code>.
- */
- public AboutWindow()
- {
- super();
-
- setTitle( Messages.getString( "about" ) );
- setIcon( Styles.INFORMATION );
- setStyleName( "about" );
- setId( "aboutwindow" );
- setModal( true );
- setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
-
- Label label;
-
- // split pane to put control
- SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
- add( splitPane );
-
- // control row
- Row controlRow = new Row();
- controlRow.setStyleName( "control" );
- splitPane.add( controlRow );
-
- // close button
- Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
- closeButton.setStyleName( "control" );
- closeButton.addActionListener( new ActionListener()
+ /**
+ * Create a new <code>AboutWindow</code>.
+ */
+ public AboutWindow()
{
+ super();
- private static final long serialVersionUID = 8624164259974769878L;
+ setTitle( Messages.getString( "about" ) );
+ setIcon( Styles.INFORMATION );
+ setStyleName( "about" );
+ setId( "aboutwindow" );
+ setModal( true );
+ setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
- public void actionPerformed( ActionEvent e )
- {
- AboutWindow.this.userClose();
- }
- } );
- controlRow.add( closeButton );
+ Label label;
- // define a column to store the several labels
- Column column = new Column();
- column.setStyleName( "about" );
- column.setCellSpacing( new Extent( 5 ) );
+ // split pane to put control
+ SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
+ add( splitPane );
- // define the title label
- label = new Label( Messages.getString( "kalumet.console" ) );
- label.setStyleName( "about.title" );
- column.add( label );
+ // control row
+ Row controlRow = new Row();
+ controlRow.setStyleName( "control" );
+ splitPane.add( controlRow );
- // define version label if possible
- Package p = Package.getPackage( "org.apache.kalumet.console" );
- if ( p != null && p.getImplementationVersion() != null )
- {
- label = new Label( "Version: " + p.getImplementationVersion() );
+ // close button
+ Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
+ closeButton.setStyleName( "control" );
+ closeButton.addActionListener( new ActionListener()
+ {
+
+ private static final long serialVersionUID = 8624164259974769878L;
+
+ public void actionPerformed( ActionEvent e )
+ {
+ AboutWindow.this.userClose();
+ }
+ } );
+ controlRow.add( closeButton );
+
+ // define a column to store the several labels
+ Column column = new Column();
+ column.setStyleName( "about" );
+ column.setCellSpacing( new Extent( 5 ) );
+
+ // define the title label
+ label = new Label( Messages.getString( "kalumet.console" ) );
+ label.setStyleName( "about.title" );
+ column.add( label );
+
+ // define version label if possible
+ Package p = Package.getPackage( "org.apache.kalumet.console" );
+ if ( p != null && p.getImplementationVersion() != null )
+ {
+ label = new Label( "Version: " + p.getImplementationVersion() );
+ }
+ else
+ {
+ label = new Label( "" );
+ }
+ label.setStyleName( "default" );
+ column.add( label );
+
+ // define the jvm label
+ label = new Label(
+ "JVM: " + System.getProperty( "java.vm.vendor" ) + " " + System.getProperty( "java.vm.name" ) + " "
+ + System.getProperty( "java.vm.version" ) );
+ label.setStyleName( "default" );
+ column.add( label );
+
+ // define the os label
+ label = new Label( "Host: " + System.getProperty( "os.arch" ) + " " + System.getProperty( "os.name" ) + " "
+ + System.getProperty( "os.version" ) );
+ label.setStyleName( "default" );
+ column.add( label );
+
+ // define the copyright label
+ label = new Label( "Apache 2.0 License" );
+ label.setStyleName( "default" );
+ column.add( label );
+
+ // add the column to the split pane
+ splitPane.add( column );
+
}
- else
- {
- label = new Label( "" );
- }
- label.setStyleName( "default" );
- column.add( label );
-
- // define the jvm label
- label = new Label(
- "JVM: " + System.getProperty( "java.vm.vendor" ) + " " + System.getProperty( "java.vm.name" ) + " "
- + System.getProperty( "java.vm.version" ) );
- label.setStyleName( "default" );
- column.add( label );
-
- // define the os label
- label = new Label(
- "Host: " + System.getProperty( "os.arch" ) + " " + System.getProperty( "os.name" ) + " " + System.getProperty(
- "os.version" ) );
- label.setStyleName( "default" );
- column.add( label );
-
- // define the copyright label
- label = new Label( "Apache 2.0 License" );
- label.setStyleName( "default" );
- column.add( label );
-
- // add the column to the split pane
- splitPane.add( column );
-
- }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ActionPane.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ActionPane.java
index 2d2e080..a62b027 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ActionPane.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ActionPane.java
@@ -34,259 +34,264 @@
* Environment updater pane.
*/
public class ActionPane
- extends ContentPane
+ extends ContentPane
{
- private EnvironmentWindow parent;
+ private EnvironmentWindow parent;
- // update thread
- class UpdateThread
- extends Thread
- {
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // update thread
+ class UpdateThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
- if ( agent == null )
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
- }
- // call the webservice
- EnvironmentClient webServiceClient = new EnvironmentClient( agent.getHostname(), agent.getPort() );
- webServiceClient.update( parent.getEnvironmentName() );
- }
- catch ( Exception e )
- {
- message = "Environment " + parent.getEnvironmentName() + " update failed: " + e.getMessage();
- failure = true;
- }
- finally
- {
- ended = true;
- }
- }
-
- }
-
- // update
- private ActionListener update = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the lock
- if ( !parent.getEnvironment().getLock().equals( KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.locked" ) );
- return;
- }
- // check if no modifications are in progress
- if ( parent.isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ) );
- return;
- }
- // check if the user can launch the update
- if ( !parent.adminPermission && !parent.updatePermission )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ) );
- return;
- }
-
- // add confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // put message in the action events column
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- parent.getEnvironmentName() + " update in progress ...", parent.getEnvironmentName() );
- // launch the asynchronous task
- final UpdateThread updateThread = new UpdateThread();
- updateThread.start();
- // synchro
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ try
{
- public void run()
- {
- if ( updateThread.ended )
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
+ if ( agent == null )
{
- if ( updateThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( updateThread.message,
- parent.getEnvironmentName() );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "Environment " + parent.getEnvironmentName() + " updated.", parent.getEnvironmentName() );
- }
+ throw new IllegalArgumentException( "agent not found." );
}
- else
+ // call the webservice
+ EnvironmentClient webServiceClient = new EnvironmentClient( agent.getHostname(), agent.getPort() );
+ webServiceClient.update( parent.getEnvironmentName() );
+ }
+ catch ( Exception e )
+ {
+ message = "Environment " + parent.getEnvironmentName() + " update failed: " + e.getMessage();
+ failure = true;
+ }
+ finally
+ {
+ ended = true;
+ }
+ }
+
+ }
+
+ // update
+ private ActionListener update = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !parent.getEnvironment().getLock().equals( KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ) );
+ return;
+ }
+ // check if no modifications are in progress
+ if ( parent.isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ) );
+ return;
+ }
+ // check if the user can launch the update
+ if ( !parent.adminPermission && !parent.updatePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ) );
+ return;
+ }
+
+ // add confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
{
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
- } );
- }
- } ) );
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ // put message in the action events column
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ parent.getEnvironmentName() + " update in progress ...", parent.getEnvironmentName() );
+ // launch the asynchronous task
+ final UpdateThread updateThread = new UpdateThread();
+ updateThread.start();
+ // synchro
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( updateThread.ended )
+ {
+ if ( updateThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ updateThread.message, parent.getEnvironmentName() );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ "Environment " + parent.getEnvironmentName() + " updated.",
+ parent.getEnvironmentName() );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ } ) );
+ }
+ };
- // publish release
- private ActionListener publishRelease = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // publish release
+ private ActionListener publishRelease = new ActionListener()
{
- // check if the user has the lock
- if ( !parent.getEnvironment().getLock().equals( KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.warn.locked" ) );
- return;
- }
- // check if the user has the permission to publish a release
- if ( !parent.adminPermission && !parent.releasePermission )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ) );
- return;
- }
- // check if no modifications are in progress
- if ( parent.isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ) );
- return;
- }
- if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
- "publishreleasewindow_" + parent.getEnvironmentName() ) == null )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new PublishReleaseWindow( parent ) );
- }
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !parent.getEnvironment().getLock().equals( KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.warn.locked" ) );
+ return;
+ }
+ // check if the user has the permission to publish a release
+ if ( !parent.adminPermission && !parent.releasePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ) );
+ return;
+ }
+ // check if no modifications are in progress
+ if ( parent.isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ) );
+ return;
+ }
+ if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
+ "publishreleasewindow_" + parent.getEnvironmentName() ) == null )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new PublishReleaseWindow( parent ) );
+ }
+ }
+ };
- // publish home page
- private ActionListener publishHomePage = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // publish home page
+ private ActionListener publishHomePage = new ActionListener()
{
- // check if the user has the lock
- if ( !parent.getEnvironment().getLock().equals( KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.warn.locked" ) );
- return;
- }
- // check if the user can publish homepage
- if ( !parent.adminPermission && !parent.homepagePermission )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ) );
- return;
- }
- // check if no modifications are in progress
- if ( parent.isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ) );
- return;
- }
- if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
- "homepagewindow_" + parent.getEnvironmentName() ) == null )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add( new HomePageWindow( parent ) );
- }
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !parent.getEnvironment().getLock().equals( KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.warn.locked" ) );
+ return;
+ }
+ // check if the user can publish homepage
+ if ( !parent.adminPermission && !parent.homepagePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ) );
+ return;
+ }
+ // check if no modifications are in progress
+ if ( parent.isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ) );
+ return;
+ }
+ if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
+ "homepagewindow_" + parent.getEnvironmentName() ) == null )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new HomePageWindow( parent ) );
+ }
+ }
+ };
- /**
- * Create a new <code>UpdaterPane</code>.
- *
- * @param parent the parent <code>EnvironmentWindow</code>.
- */
- public ActionPane( EnvironmentWindow parent )
- {
- super();
- setStyleName( "tab.content" );
-
- // update parent
- this.parent = parent;
-
- Grid layout = new Grid( 2 );
- layout.setStyleName( "border.grid" );
- layout.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
- add( layout );
-
- // add environment grid header
- Label environmentActionHeader = new Label( " " );
- environmentActionHeader.setStyleName( "grid.header" );
- layout.add( environmentActionHeader );
- Label environmentHeader = new Label( Messages.getString( "environment" ) );
- environmentHeader.setStyleName( "grid.header" );
- layout.add( environmentHeader );
-
- if ( parent.adminPermission || parent.updatePermission )
+ /**
+ * Create a new <code>UpdaterPane</code>.
+ *
+ * @param parent the parent <code>EnvironmentWindow</code>.
+ */
+ public ActionPane( EnvironmentWindow parent )
{
- // update button
- Button updateButton = new Button( Styles.COG );
- updateButton.addActionListener( update );
- layout.add( updateButton );
- Button updateLabel = new Button( Messages.getString( "update" ) );
- updateLabel.setStyleName( "default" );
- updateLabel.addActionListener( update );
- layout.add( updateLabel );
+ super();
+ setStyleName( "tab.content" );
+
+ // update parent
+ this.parent = parent;
+
+ Grid layout = new Grid( 2 );
+ layout.setStyleName( "border.grid" );
+ layout.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
+ add( layout );
+
+ // add environment grid header
+ Label environmentActionHeader = new Label( " " );
+ environmentActionHeader.setStyleName( "grid.header" );
+ layout.add( environmentActionHeader );
+ Label environmentHeader = new Label( Messages.getString( "environment" ) );
+ environmentHeader.setStyleName( "grid.header" );
+ layout.add( environmentHeader );
+
+ if ( parent.adminPermission || parent.updatePermission )
+ {
+ // update button
+ Button updateButton = new Button( Styles.COG );
+ updateButton.addActionListener( update );
+ layout.add( updateButton );
+ Button updateLabel = new Button( Messages.getString( "update" ) );
+ updateLabel.setStyleName( "default" );
+ updateLabel.addActionListener( update );
+ layout.add( updateLabel );
+ }
+
+ if ( parent.adminPermission || parent.releasePermission )
+ {
+ // release button
+ Button releaseButton = new Button( Styles.LORRY );
+ releaseButton.addActionListener( publishRelease );
+ layout.add( releaseButton );
+ Button releaseLabel = new Button( Messages.getString( "release" ) );
+ releaseLabel.setStyleName( "default" );
+ releaseLabel.addActionListener( publishRelease );
+ layout.add( releaseLabel );
+ }
+
+ if ( parent.adminPermission || parent.homepagePermission )
+ {
+ // homepage button
+ Button homePageButton = new Button( Styles.DRIVE_WEB );
+ homePageButton.addActionListener( publishHomePage );
+ layout.add( homePageButton );
+ Button homePageLabel = new Button( Messages.getString( "homepage" ) );
+ homePageLabel.setStyleName( "default" );
+ homePageLabel.addActionListener( publishHomePage );
+ layout.add( homePageLabel );
+ }
+
+ // update this pane
+ update();
}
- if ( parent.adminPermission || parent.releasePermission )
+ /**
+ * Update the pane.
+ */
+ public void update()
{
- // release button
- Button releaseButton = new Button( Styles.LORRY );
- releaseButton.addActionListener( publishRelease );
- layout.add( releaseButton );
- Button releaseLabel = new Button( Messages.getString( "release" ) );
- releaseLabel.setStyleName( "default" );
- releaseLabel.addActionListener( publishRelease );
- layout.add( releaseLabel );
+ // nothing to do
}
- if ( parent.adminPermission || parent.homepagePermission )
- {
- // homepage button
- Button homePageButton = new Button( Styles.DRIVE_WEB );
- homePageButton.addActionListener( publishHomePage );
- layout.add( homePageButton );
- Button homePageLabel = new Button( Messages.getString( "homepage" ) );
- homePageLabel.setStyleName( "default" );
- homePageLabel.addActionListener( publishHomePage );
- layout.add( homePageLabel );
- }
-
- // update this pane
- update();
- }
-
- /**
- * Update the pane.
- */
- public void update()
- {
- // nothing to do
- }
-
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminAgentWindow.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminAgentWindow.java
index 22a3ae2..d0f09df 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminAgentWindow.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminAgentWindow.java
@@ -41,470 +41,473 @@
* Admin agent window.
*/
public class AdminAgentWindow
- extends WindowPane
+ extends WindowPane
{
- // attributes
- private String agentId;
+ // attributes
+ private String agentId;
- private Agent agent;
+ private Agent agent;
- private AdminAgentsWindow parent;
+ private AdminAgentsWindow parent;
- private TextField idField;
+ private TextField idField;
- private TextField hostnameField;
+ private TextField hostnameField;
- private TextField portField;
+ private TextField portField;
- private TextField cronField;
+ private TextField cronField;
- private TextField maxEnvironmentsField;
+ private TextField maxEnvironmentsField;
- private TextField maxActiveApplicationServersField;
+ private TextField maxActiveApplicationServersField;
- // status thread
- class StatusThread
- extends Thread
- {
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // status thread
+ class StatusThread
+ extends Thread
{
- try
- {
- // call the WebService client
- AgentClient client = new AgentClient( agent.getHostname(), agent.getPort() );
- message = "Agent " + agentId + " version " + client.getVersion() + " started.";
- }
- catch ( Exception e )
- {
- failure = true;
- message = "Agent " + agentId + " status check failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
- }
- }
- // close
- private ActionListener close = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- AdminAgentWindow.this.userClose();
- }
- };
+ public boolean ended = false;
- // refresh
- private ActionListener refresh = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- for ( Iterator agentIterator = parent.getAgents().iterator(); agentIterator.hasNext(); )
- {
- Agent current = (Agent) agentIterator.next();
- if ( agent.getId().equals( agentId ) )
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- agent = current;
- break;
+ try
+ {
+ // call the WebService client
+ AgentClient client = new AgentClient( agent.getHostname(), agent.getPort() );
+ message = "Agent " + agentId + " version " + client.getVersion() + " started.";
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "Agent " + agentId + " status check failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- }
- if ( agent == null )
- {
- agent = new Agent();
- }
- update();
}
- };
- // apply
- private ActionListener apply = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // close
+ private ActionListener close = new ActionListener()
{
- // check if the user is the admin
- if ( !KalumetConsoleApplication.getApplication().getUserid().equals( "admin" ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "agents.restricted" ) );
- return;
- }
-
- String newId = idField.getText().trim();
- String newHostname = hostnameField.getText().trim();
- String newPort = portField.getText().trim();
- String newCron = cronField.getText().trim();
- String newMaxEnvironments = maxEnvironmentsField.getText().trim();
- String newMaxEnvironmentsActive = maxActiveApplicationServersField.getText().trim();
-
- // check fields
- if ( newId.length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "agent.mandatory" ) );
- return;
- }
- // if the admin change the agent id or if it's a new agent, check if
- // the id is not already used
- if ( agentId == null || agentId.trim().length() < 1 || ( ( agentId != null ) && ( agentId.trim().length() > 0 )
- && ( !newId.equals( agentId ) ) ) )
- {
- for ( Iterator agentIterator = parent.getAgents().iterator(); agentIterator.hasNext(); )
+ public void actionPerformed( ActionEvent event )
{
- Agent current = (Agent) agentIterator.next();
- if ( current.getId().equals( newId ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "agent.exists" ) );
- return;
- }
+ AdminAgentWindow.this.userClose();
}
- }
+ };
- // update the current agent
- agent.setId( newId );
- agent.setHostname( newHostname );
- agent.setPort( new Integer( newPort ).intValue() );
- if ( newCron.length() < 1 )
- {
- newCron = "0 0 0 * * ?";
- }
- agent.setCron( newCron );
- agent.setMaxmanagedenvironments( new Integer( newMaxEnvironments ).intValue() );
- agent.setMaxjeeapplicationserversstarted(new Integer(newMaxEnvironmentsActive).intValue());
- if ( agentId == null || agentId.trim().length() < 1 )
- {
- // it's a new agent
- parent.getAgents().add( agent );
- }
- setTitle( Messages.getString( "agent" ) + " " + agent.getId() );
- setId( "agentwindow_" + agent.getId() );
- agentId = agent.getId();
- parent.update();
- }
- };
-
- // paste
- public ActionListener paste = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // refresh
+ private ActionListener refresh = new ActionListener()
{
- // get the copy component
- Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
- if ( copy == null || !( copy instanceof Agent ) )
- {
- return;
- }
- Agent clone = (Agent) copy;
- idField.setText( clone.getId() );
- hostnameField.setText( clone.getHostname() );
- portField.setText( new Integer( clone.getPort() ).toString() );
- cronField.setText( clone.getCron() );
- maxEnvironmentsField.setText( new Integer( clone.getMaxmanagedenvironments() ).toString() );
- maxActiveApplicationServersField.setText( new Integer( clone.getMaxjeeapplicationserversstarted() ).toString() );
- }
- };
-
- // delete
- public ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // display a confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- // looking for the agent to remove
- Agent agentToRemove = null;
for ( Iterator agentIterator = parent.getAgents().iterator(); agentIterator.hasNext(); )
{
- Agent agent = (Agent) agentIterator.next();
- if ( agent.getId().equals( agentId ) )
- {
- agentToRemove = agent;
- break;
- }
+ Agent current = (Agent) agentIterator.next();
+ if ( agent.getId().equals( agentId ) )
+ {
+ agent = current;
+ break;
+ }
}
- parent.getAgents().remove( agentToRemove );
+ if ( agent == null )
+ {
+ agent = new Agent();
+ }
+ update();
+ }
+ };
+
+ // apply
+ private ActionListener apply = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user is the admin
+ if ( !KalumetConsoleApplication.getApplication().getUserid().equals( "admin" ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "agents.restricted" ) );
+ return;
+ }
+
+ String newId = idField.getText().trim();
+ String newHostname = hostnameField.getText().trim();
+ String newPort = portField.getText().trim();
+ String newCron = cronField.getText().trim();
+ String newMaxEnvironments = maxEnvironmentsField.getText().trim();
+ String newMaxEnvironmentsActive = maxActiveApplicationServersField.getText().trim();
+
+ // check fields
+ if ( newId.length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "agent.mandatory" ) );
+ return;
+ }
+ // if the admin change the agent id or if it's a new agent, check if
+ // the id is not already used
+ if ( agentId == null || agentId.trim().length() < 1 || ( ( agentId != null ) && ( agentId.trim().length()
+ > 0 ) && ( !newId.equals( agentId ) ) ) )
+ {
+ for ( Iterator agentIterator = parent.getAgents().iterator(); agentIterator.hasNext(); )
+ {
+ Agent current = (Agent) agentIterator.next();
+ if ( current.getId().equals( newId ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "agent.exists" ) );
+ return;
+ }
+ }
+ }
+
+ // update the current agent
+ agent.setId( newId );
+ agent.setHostname( newHostname );
+ agent.setPort( new Integer( newPort ).intValue() );
+ if ( newCron.length() < 1 )
+ {
+ newCron = "0 0 0 * * ?";
+ }
+ agent.setCron( newCron );
+ agent.setMaxmanagedenvironments( new Integer( newMaxEnvironments ).intValue() );
+ agent.setMaxjeeapplicationserversstarted( new Integer( newMaxEnvironmentsActive ).intValue() );
+ if ( agentId == null || agentId.trim().length() < 1 )
+ {
+ // it's a new agent
+ parent.getAgents().add( agent );
+ }
+ setTitle( Messages.getString( "agent" ) + " " + agent.getId() );
+ setId( "agentwindow_" + agent.getId() );
+ agentId = agent.getId();
+ parent.update();
+ }
+ };
+
+ // paste
+ public ActionListener paste = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // get the copy component
+ Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+ if ( copy == null || !( copy instanceof Agent ) )
+ {
+ return;
+ }
+ Agent clone = (Agent) copy;
+ idField.setText( clone.getId() );
+ hostnameField.setText( clone.getHostname() );
+ portField.setText( new Integer( clone.getPort() ).toString() );
+ cronField.setText( clone.getCron() );
+ maxEnvironmentsField.setText( new Integer( clone.getMaxmanagedenvironments() ).toString() );
+ maxActiveApplicationServersField.setText(
+ new Integer( clone.getMaxjeeapplicationserversstarted() ).toString() );
+ }
+ };
+
+ // delete
+ public ActionListener delete = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // display a confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // looking for the agent to remove
+ Agent agentToRemove = null;
+ for ( Iterator agentIterator = parent.getAgents().iterator(); agentIterator.hasNext(); )
+ {
+ Agent agent = (Agent) agentIterator.next();
+ if ( agent.getId().equals( agentId ) )
+ {
+ agentToRemove = agent;
+ break;
+ }
+ }
+ parent.getAgents().remove( agentToRemove );
+ AdminAgentWindow.this.userClose();
+ }
+ } ) );
+ }
+ };
+
+ // status
+ public ActionListener status = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // add an event
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "Agent " + agentId + " status check in progress ..." );
+ // start the status thread
+ final StatusThread statusThread = new StatusThread();
+ statusThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( statusThread.ended )
+ {
+ if ( statusThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError( statusThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm( statusThread.message );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ };
+
+ /**
+ * Create a new <code>AdminAgentWindow</code>.
+ *
+ * @param parent the <code>AdminAgentsWindow</code> parent.
+ * @param agentId the <code>Agent</code> ID.
+ */
+ public AdminAgentWindow( AdminAgentsWindow parent, String agentId )
+ {
+ super();
+
+ // check if the user that try to access this window is the admin
+ if ( !KalumetConsoleApplication.getApplication().getUserid().equals( "admin" ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "agents.restricted" ) );
AdminAgentWindow.this.userClose();
- }
- } ) );
- }
- };
+ return;
+ }
- // status
- public ActionListener status = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // update the original agent id and parent admin agents window
+ this.parent = parent;
+ this.agentId = agentId;
+
+ // update the agent object from agents parent list
+ for ( Iterator agentIterator = parent.getAgents().iterator(); agentIterator.hasNext(); )
+ {
+ Agent current = (Agent) agentIterator.next();
+ if ( current.getId().equals( agentId ) )
+ {
+ this.agent = current;
+ break;
+ }
+ }
+ if ( this.agent == null )
+ {
+ this.agent = new Agent();
+ }
+
+ if ( agentId == null )
+ {
+ setTitle( Messages.getString( "agent" ) );
+ }
+ else
+ {
+ setTitle( Messages.getString( "agent" ) + " " + agentId );
+ }
+ setIcon( Styles.COG );
+ setId( "agentwindow_" + agentId );
+ setStyleName( "agent" );
+ setModal( false );
+ setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
+
+ // create a split pane for the control buttons
+ SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
+ add( splitPane );
+
+ // add the control pane
+ Row controlRow = new Row();
+ controlRow.setStyleName( "control" );
+ splitPane.add( controlRow );
+ // add the refresh button
+ Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
+ refreshButton.setStyleName( "control" );
+ refreshButton.addActionListener( refresh );
+ controlRow.add( refreshButton );
+ // add the delete button
+ Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
+ deleteButton.setStyleName( "control" );
+ deleteButton.addActionListener( delete );
+ controlRow.add( deleteButton );
+ // add the paste button
+ Button pasteButton = new Button( Messages.getString( "paste" ), Styles.PAGE_PASTE );
+ pasteButton.setStyleName( "control" );
+ pasteButton.addActionListener( paste );
+ controlRow.add( pasteButton );
+ // add the status button
+ Button statusButton = new Button( Messages.getString( "status" ), Styles.INFORMATION );
+ statusButton.setStyleName( "control" );
+ statusButton.addActionListener( status );
+ controlRow.add( statusButton );
+ // add the apply button
+ Button applyButton = new Button( Messages.getString( "apply" ), Styles.ACCEPT );
+ applyButton.setStyleName( "control" );
+ applyButton.addActionListener( apply );
+ controlRow.add( applyButton );
+ // add the close button
+ Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
+ closeButton.setStyleName( "control" );
+ closeButton.addActionListener( close );
+ controlRow.add( closeButton );
+
+ // add the main tab pane
+ TabPane tabPane = new TabPane();
+ tabPane.setStyleName( "default" );
+ splitPane.add( tabPane );
+
+ // add the general tab
+ TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "general" ) );
+ ContentPane generalTab = new ContentPane();
+ generalTab.setStyleName( "tab.content" );
+ generalTab.setLayoutData( tabLayoutData );
+ tabPane.add( generalTab );
+
+ // add the general grid layout
+ Grid generalGridLayout = new Grid( 2 );
+ generalGridLayout.setStyleName( "agent" );
+ generalGridLayout.setWidth( new Extent( 100, Extent.PERCENT ) );
+ generalGridLayout.setColumnWidth( 0, new Extent( 10, Extent.PERCENT ) );
+ generalGridLayout.setColumnWidth( 1, new Extent( 90, Extent.PERCENT ) );
+ generalTab.add( generalGridLayout );
+
+ // add the agent id field
+ Label agentIdLabel = new Label( Messages.getString( "id" ) );
+ agentIdLabel.setStyleName( "default" );
+ generalGridLayout.add( agentIdLabel );
+ idField = new TextField();
+ idField.setStyleName( "default" );
+ idField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ generalGridLayout.add( idField );
+
+ // add the agent hostname field
+ Label agentHostnameLabel = new Label( Messages.getString( "hostname" ) );
+ agentHostnameLabel.setStyleName( "default" );
+ generalGridLayout.add( agentHostnameLabel );
+ hostnameField = new TextField();
+ hostnameField.setStyleName( "default" );
+ hostnameField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ generalGridLayout.add( hostnameField );
+
+ // add the agent port field
+ Label agentPortLabel = new Label( Messages.getString( "port" ) );
+ agentPortLabel.setStyleName( "default" );
+ generalGridLayout.add( agentPortLabel );
+ portField = new TextField();
+ portField.setStyleName( "default" );
+ portField.setWidth( new Extent( 15, Extent.EX ) );
+ generalGridLayout.add( portField );
+
+ // add the scheduler tab
+ tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "scheduler" ) );
+ ContentPane schedulerTab = new ContentPane();
+ schedulerTab.setLayoutData( tabLayoutData );
+ schedulerTab.setStyleName( "tab.content" );
+ tabPane.add( schedulerTab );
+
+ // add the scheduler grid layout
+ Grid schedulerGridLayout = new Grid( 2 );
+ schedulerGridLayout.setStyleName( "agent" );
+ schedulerGridLayout.setWidth( new Extent( 100, Extent.PERCENT ) );
+ schedulerGridLayout.setColumnWidth( 0, new Extent( 10, Extent.PERCENT ) );
+ schedulerGridLayout.setColumnWidth( 1, new Extent( 90, Extent.PERCENT ) );
+ schedulerTab.add( schedulerGridLayout );
+
+ // add the cron field
+ Label cronLabel = new Label( Messages.getString( "cron" ) );
+ cronLabel.setStyleName( "default" );
+ schedulerGridLayout.add( cronLabel );
+ cronField = new TextField();
+ cronField.setStyleName( "default" );
+ cronField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ schedulerGridLayout.add( cronField );
+
+ // add the cron examples
+ Label cronExamplesLabel = new Label( Messages.getString( "examples" ) );
+ cronExamplesLabel.setStyleName( "grid.cell" );
+ schedulerGridLayout.add( cronExamplesLabel );
+ TextArea cronExamples = new TextArea();
+ cronExamples.setStyleName( "default" );
+ cronExamples.setWidth( new Extent( 100, Extent.PERCENT ) );
+ cronExamples.setHeight( new Extent( 20, Extent.EX ) );
+ cronExamples.setText( Messages.getString( "cron.examples" ) );
+ cronExamples.setEnabled( false );
+ schedulerGridLayout.add( cronExamples );
+
+ // add the capacity tab
+ tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "capacity" ) );
+ ContentPane capacityTab = new ContentPane();
+ capacityTab.setLayoutData( tabLayoutData );
+ capacityTab.setStyleName( "tab.content" );
+ tabPane.add( capacityTab );
+
+ // add the capacity grid layout
+ Grid capacityGridLayout = new Grid( 2 );
+ capacityGridLayout.setStyleName( "agent" );
+ capacityGridLayout.setWidth( new Extent( 100, Extent.PERCENT ) );
+ capacityGridLayout.setColumnWidth( 0, new Extent( 10, Extent.PERCENT ) );
+ capacityGridLayout.setColumnWidth( 1, new Extent( 90, Extent.PERCENT ) );
+ capacityTab.add( capacityGridLayout );
+
+ // add the max environments field
+ Label agentMaxEnvironmentsLabel = new Label( Messages.getString( "agent.maxenvironments" ) );
+ agentMaxEnvironmentsLabel.setStyleName( "default" );
+ capacityGridLayout.add( agentMaxEnvironmentsLabel );
+ maxEnvironmentsField = new TextField();
+ maxEnvironmentsField.setStyleName( "default" );
+ maxEnvironmentsField.setWidth( new Extent( 15, Extent.EX ) );
+ capacityGridLayout.add( maxEnvironmentsField );
+
+ // add the max active environments field
+ Label agentMaxActiveEnvironmentsLabel = new Label( Messages.getString( "agent.maxactiveapplicationservers" ) );
+ agentMaxActiveEnvironmentsLabel.setStyleName( "default" );
+ capacityGridLayout.add( agentMaxActiveEnvironmentsLabel );
+ maxActiveApplicationServersField = new TextField();
+ maxActiveApplicationServersField.setStyleName( "default" );
+ maxActiveApplicationServersField.setWidth( new Extent( 15, Extent.EX ) );
+ capacityGridLayout.add( maxActiveApplicationServersField );
+
+ // update the view
+ update();
+ }
+
+ /**
+ * Update the fields value.
+ */
+ protected void update()
{
- // add an event
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "Agent " + agentId + " status check in progress ..." );
- // start the status thread
- final StatusThread statusThread = new StatusThread();
- statusThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask( KalumetConsoleApplication.getApplication().getTaskQueue(),
- new Runnable()
- {
- public void run()
- {
- if ( statusThread.ended )
- {
- if ( statusThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- statusThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- statusThread.message );
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(),
- this );
- }
- }
- } );
+ // update fields
+ idField.setText( agent.getId() );
+ hostnameField.setText( agent.getHostname() );
+ portField.setText( new Integer( agent.getPort() ).toString() );
+ cronField.setText( agent.getCron() );
+ maxEnvironmentsField.setText( new Integer( agent.getMaxmanagedenvironments() ).toString() );
+ maxActiveApplicationServersField.setText(
+ new Integer( agent.getMaxjeeapplicationserversstarted() ).toString() );
}
- };
-
- /**
- * Create a new <code>AdminAgentWindow</code>.
- *
- * @param parent the <code>AdminAgentsWindow</code> parent.
- * @param agentId the <code>Agent</code> ID.
- */
- public AdminAgentWindow( AdminAgentsWindow parent, String agentId )
- {
- super();
-
- // check if the user that try to access this window is the admin
- if ( !KalumetConsoleApplication.getApplication().getUserid().equals( "admin" ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "agents.restricted" ) );
- AdminAgentWindow.this.userClose();
- return;
- }
-
- // update the original agent id and parent admin agents window
- this.parent = parent;
- this.agentId = agentId;
-
- // update the agent object from agents parent list
- for ( Iterator agentIterator = parent.getAgents().iterator(); agentIterator.hasNext(); )
- {
- Agent current = (Agent) agentIterator.next();
- if ( current.getId().equals( agentId ) )
- {
- this.agent = current;
- break;
- }
- }
- if ( this.agent == null )
- {
- this.agent = new Agent();
- }
-
- if ( agentId == null )
- {
- setTitle( Messages.getString( "agent" ) );
- }
- else
- {
- setTitle( Messages.getString( "agent" ) + " " + agentId );
- }
- setIcon( Styles.COG );
- setId( "agentwindow_" + agentId );
- setStyleName( "agent" );
- setModal( false );
- setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
-
- // create a split pane for the control buttons
- SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
- add( splitPane );
-
- // add the control pane
- Row controlRow = new Row();
- controlRow.setStyleName( "control" );
- splitPane.add( controlRow );
- // add the refresh button
- Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
- refreshButton.setStyleName( "control" );
- refreshButton.addActionListener( refresh );
- controlRow.add( refreshButton );
- // add the delete button
- Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
- deleteButton.setStyleName( "control" );
- deleteButton.addActionListener( delete );
- controlRow.add( deleteButton );
- // add the paste button
- Button pasteButton = new Button( Messages.getString( "paste" ), Styles.PAGE_PASTE );
- pasteButton.setStyleName( "control" );
- pasteButton.addActionListener( paste );
- controlRow.add( pasteButton );
- // add the status button
- Button statusButton = new Button( Messages.getString( "status" ), Styles.INFORMATION );
- statusButton.setStyleName( "control" );
- statusButton.addActionListener( status );
- controlRow.add( statusButton );
- // add the apply button
- Button applyButton = new Button( Messages.getString( "apply" ), Styles.ACCEPT );
- applyButton.setStyleName( "control" );
- applyButton.addActionListener( apply );
- controlRow.add( applyButton );
- // add the close button
- Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
- closeButton.setStyleName( "control" );
- closeButton.addActionListener( close );
- controlRow.add( closeButton );
-
- // add the main tab pane
- TabPane tabPane = new TabPane();
- tabPane.setStyleName( "default" );
- splitPane.add( tabPane );
-
- // add the general tab
- TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "general" ) );
- ContentPane generalTab = new ContentPane();
- generalTab.setStyleName( "tab.content" );
- generalTab.setLayoutData( tabLayoutData );
- tabPane.add( generalTab );
-
- // add the general grid layout
- Grid generalGridLayout = new Grid( 2 );
- generalGridLayout.setStyleName( "agent" );
- generalGridLayout.setWidth( new Extent( 100, Extent.PERCENT ) );
- generalGridLayout.setColumnWidth( 0, new Extent( 10, Extent.PERCENT ) );
- generalGridLayout.setColumnWidth( 1, new Extent( 90, Extent.PERCENT ) );
- generalTab.add( generalGridLayout );
-
- // add the agent id field
- Label agentIdLabel = new Label( Messages.getString( "id" ) );
- agentIdLabel.setStyleName( "default" );
- generalGridLayout.add( agentIdLabel );
- idField = new TextField();
- idField.setStyleName( "default" );
- idField.setWidth( new Extent( 100, Extent.PERCENT ) );
- generalGridLayout.add( idField );
-
- // add the agent hostname field
- Label agentHostnameLabel = new Label( Messages.getString( "hostname" ) );
- agentHostnameLabel.setStyleName( "default" );
- generalGridLayout.add( agentHostnameLabel );
- hostnameField = new TextField();
- hostnameField.setStyleName( "default" );
- hostnameField.setWidth( new Extent( 100, Extent.PERCENT ) );
- generalGridLayout.add( hostnameField );
-
- // add the agent port field
- Label agentPortLabel = new Label( Messages.getString( "port" ) );
- agentPortLabel.setStyleName( "default" );
- generalGridLayout.add( agentPortLabel );
- portField = new TextField();
- portField.setStyleName( "default" );
- portField.setWidth( new Extent( 15, Extent.EX ) );
- generalGridLayout.add( portField );
-
- // add the scheduler tab
- tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "scheduler" ) );
- ContentPane schedulerTab = new ContentPane();
- schedulerTab.setLayoutData( tabLayoutData );
- schedulerTab.setStyleName( "tab.content" );
- tabPane.add( schedulerTab );
-
- // add the scheduler grid layout
- Grid schedulerGridLayout = new Grid( 2 );
- schedulerGridLayout.setStyleName( "agent" );
- schedulerGridLayout.setWidth( new Extent( 100, Extent.PERCENT ) );
- schedulerGridLayout.setColumnWidth( 0, new Extent( 10, Extent.PERCENT ) );
- schedulerGridLayout.setColumnWidth( 1, new Extent( 90, Extent.PERCENT ) );
- schedulerTab.add( schedulerGridLayout );
-
- // add the cron field
- Label cronLabel = new Label( Messages.getString( "cron" ) );
- cronLabel.setStyleName( "default" );
- schedulerGridLayout.add( cronLabel );
- cronField = new TextField();
- cronField.setStyleName( "default" );
- cronField.setWidth( new Extent( 100, Extent.PERCENT ) );
- schedulerGridLayout.add( cronField );
-
- // add the cron examples
- Label cronExamplesLabel = new Label( Messages.getString( "examples" ) );
- cronExamplesLabel.setStyleName( "grid.cell" );
- schedulerGridLayout.add( cronExamplesLabel );
- TextArea cronExamples = new TextArea();
- cronExamples.setStyleName( "default" );
- cronExamples.setWidth( new Extent( 100, Extent.PERCENT ) );
- cronExamples.setHeight( new Extent( 20, Extent.EX ) );
- cronExamples.setText( Messages.getString( "cron.examples" ) );
- cronExamples.setEnabled( false );
- schedulerGridLayout.add( cronExamples );
-
- // add the capacity tab
- tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "capacity" ) );
- ContentPane capacityTab = new ContentPane();
- capacityTab.setLayoutData( tabLayoutData );
- capacityTab.setStyleName( "tab.content" );
- tabPane.add( capacityTab );
-
- // add the capacity grid layout
- Grid capacityGridLayout = new Grid( 2 );
- capacityGridLayout.setStyleName( "agent" );
- capacityGridLayout.setWidth( new Extent( 100, Extent.PERCENT ) );
- capacityGridLayout.setColumnWidth( 0, new Extent( 10, Extent.PERCENT ) );
- capacityGridLayout.setColumnWidth( 1, new Extent( 90, Extent.PERCENT ) );
- capacityTab.add( capacityGridLayout );
-
- // add the max environments field
- Label agentMaxEnvironmentsLabel = new Label( Messages.getString( "agent.maxenvironments" ) );
- agentMaxEnvironmentsLabel.setStyleName( "default" );
- capacityGridLayout.add( agentMaxEnvironmentsLabel );
- maxEnvironmentsField = new TextField();
- maxEnvironmentsField.setStyleName( "default" );
- maxEnvironmentsField.setWidth( new Extent( 15, Extent.EX ) );
- capacityGridLayout.add( maxEnvironmentsField );
-
- // add the max active environments field
- Label agentMaxActiveEnvironmentsLabel = new Label( Messages.getString( "agent.maxactiveapplicationservers" ) );
- agentMaxActiveEnvironmentsLabel.setStyleName( "default" );
- capacityGridLayout.add( agentMaxActiveEnvironmentsLabel );
- maxActiveApplicationServersField = new TextField();
- maxActiveApplicationServersField.setStyleName( "default" );
- maxActiveApplicationServersField.setWidth( new Extent( 15, Extent.EX ) );
- capacityGridLayout.add( maxActiveApplicationServersField );
-
- // update the view
- update();
- }
-
- /**
- * Update the fields value.
- */
- protected void update()
- {
- // update fields
- idField.setText( agent.getId() );
- hostnameField.setText( agent.getHostname() );
- portField.setText( new Integer( agent.getPort() ).toString() );
- cronField.setText( agent.getCron() );
- maxEnvironmentsField.setText( new Integer( agent.getMaxmanagedenvironments() ).toString() );
- maxActiveApplicationServersField.setText( new Integer( agent.getMaxjeeapplicationserversstarted() ).toString() );
- }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminAgentsWindow.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminAgentsWindow.java
index 9ab6d0c..e40c492 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminAgentsWindow.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminAgentsWindow.java
@@ -43,396 +43,394 @@
* Admin agents window.
*/
public class AdminAgentsWindow
- extends WindowPane
+ extends WindowPane
{
- // attributes
- private List agents;
+ // attributes
+ private List agents;
- private Grid agentsGrid;
+ private Grid agentsGrid;
- // status thread
- class StatusThread
- extends Thread
- {
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String id;
-
- public String message;
-
- public void run()
+ // status thread
+ class StatusThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( id );
- if ( agent == null )
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String id;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent " + id + " not found." );
- }
- // call the WebService
- AgentClient client = new AgentClient( agent.getHostname(), agent.getPort() );
- message = "Agent " + id + " version " + client.getVersion() + " started.";
- }
- catch ( Exception e )
- {
- failure = true;
- message = "Agent " + id + " status check failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
- }
- }
-
- // close action listener
- private ActionListener closeActionListener = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- AdminAgentsWindow.this.userClose();
- }
- };
-
- // refresh action listener
- private ActionListener refreshActionListener = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- Kalumet kalumet = null;
- try
- {
- kalumet = ConfigurationManager.loadStore();
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage() );
- return;
- }
- agents = kalumet.getAgents();
- update();
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- Messages.getString( "agents" ) + " " + Messages.getString( "reloaded" ) );
- }
- };
-
- // delete action listener
- private ActionListener deleteActionListener = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- final String agentId = event.getActionCommand();
- // display a confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // looking for the agent to remove
- Agent agentToRemove = null;
- for ( Iterator agentIterator = agents.iterator(); agentIterator.hasNext(); )
+ try
{
- Agent agent = (Agent) agentIterator.next();
- if ( agent.getId().equals( agentId ) )
- {
- agentToRemove = agent;
- break;
- }
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent( id );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent " + id + " not found." );
+ }
+ // call the WebService
+ AgentClient client = new AgentClient( agent.getHostname(), agent.getPort() );
+ message = "Agent " + id + " version " + client.getVersion() + " started.";
}
- // remove the agnet
- agents.remove( agentToRemove );
- // update the window
- update();
- }
- } ) );
- }
- };
-
- // save action listener
- private ActionListener saveActionListener = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- Kalumet kalumet = null;
- // load Kalumet configuration
- try
- {
- kalumet = ConfigurationManager.loadStore();
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage() );
- return;
- }
- kalumet.setAgents( (LinkedList) agents );
- try
- {
- ConfigurationManager.writeStore( kalumet );
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.write" ) + ": " + e.getMessage() );
- return;
- }
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm( Messages.getString( "agents.saved" ) );
- }
- };
-
- // edit action listener
- private ActionListener editActionListener = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getComponent(
- "agentwindow_" + event.getActionCommand() ) == null )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new AdminAgentWindow( AdminAgentsWindow.this, event.getActionCommand() ) );
- }
- }
- };
-
- // add action listener
- private ActionListener addActionListener = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new AdminAgentWindow( AdminAgentsWindow.this, null ) );
- }
- };
-
- // copy
- private ActionListener copy = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // get the agent id
- String agentId = event.getActionCommand();
- // load Kalumet configuration
- Kalumet kalumet = null;
- try
- {
- kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( agentId );
- if ( agent == null )
- {
- return;
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "Agent " + id + " status check failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- // store an agent clone in the copy component
- KalumetConsoleApplication.getApplication().setCopyComponent( agent.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
}
- };
- // status
- private ActionListener status = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // close action listener
+ private ActionListener closeActionListener = new ActionListener()
{
- // add an event
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "Agent " + event.getActionCommand() + " status check in progress ..." );
- // start the status thread
- final StatusThread statusThread = new StatusThread();
- statusThread.id = event.getActionCommand();
- statusThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask( KalumetConsoleApplication.getApplication().getTaskQueue(),
- new Runnable()
- {
- public void run()
- {
- if ( statusThread.ended )
- {
- if ( statusThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- statusThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- statusThread.message );
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(),
- this );
- }
- }
- } );
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ AdminAgentsWindow.this.userClose();
+ }
+ };
- /**
- * Create a new <code>AdminAgentsWindow</code>.
- */
- public AdminAgentsWindow()
- {
- super();
-
- // check if the user that try to access this window is the admin
- if ( !KalumetConsoleApplication.getApplication().getUserid().equals( "admin" ) )
+ // refresh action listener
+ private ActionListener refreshActionListener = new ActionListener()
{
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "agents.restricted" ) );
- AdminAgentsWindow.this.userClose();
- return;
- }
+ public void actionPerformed( ActionEvent event )
+ {
+ Kalumet kalumet = null;
+ try
+ {
+ kalumet = ConfigurationManager.loadStore();
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage() );
+ return;
+ }
+ agents = kalumet.getAgents();
+ update();
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ Messages.getString( "agents" ) + " " + Messages.getString( "reloaded" ) );
+ }
+ };
- // load Kalumet configuration
- Kalumet kalumet = null;
- try
+ // delete action listener
+ private ActionListener deleteActionListener = new ActionListener()
{
- kalumet = ConfigurationManager.loadStore();
- }
- catch ( Exception e )
+ public void actionPerformed( ActionEvent event )
+ {
+ final String agentId = event.getActionCommand();
+ // display a confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // looking for the agent to remove
+ Agent agentToRemove = null;
+ for ( Iterator agentIterator = agents.iterator(); agentIterator.hasNext(); )
+ {
+ Agent agent = (Agent) agentIterator.next();
+ if ( agent.getId().equals( agentId ) )
+ {
+ agentToRemove = agent;
+ break;
+ }
+ }
+ // remove the agnet
+ agents.remove( agentToRemove );
+ // update the window
+ update();
+ }
+ } ) );
+ }
+ };
+
+ // save action listener
+ private ActionListener saveActionListener = new ActionListener()
{
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage() );
- return;
- }
- this.agents = kalumet.getAgents();
- Collections.sort( this.agents );
+ public void actionPerformed( ActionEvent event )
+ {
+ Kalumet kalumet = null;
+ // load Kalumet configuration
+ try
+ {
+ kalumet = ConfigurationManager.loadStore();
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage() );
+ return;
+ }
+ kalumet.setAgents( (LinkedList) agents );
+ try
+ {
+ ConfigurationManager.writeStore( kalumet );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.write" ) + ": " + e.getMessage() );
+ return;
+ }
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm( Messages.getString( "agents.saved" ) );
+ }
+ };
- setTitle( Messages.getString( "agents" ) );
- setIcon( Styles.COG );
- setStyleName( "agents" );
- setId( "agentswindow" );
- setModal( false );
- setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
-
- // create a split pane for the control buttons
- SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
- add( splitPane );
-
- // add the control pane
- Row controlRow = new Row();
- controlRow.setStyleName( "control" );
- splitPane.add( controlRow );
- // add the refresh button
- Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
- refreshButton.setStyleName( "control" );
- refreshButton.addActionListener( refreshActionListener );
- controlRow.add( refreshButton );
- // add the save button
- Button saveButton = new Button( Messages.getString( "save" ), Styles.DATABASE_SAVE );
- saveButton.setStyleName( "control" );
- saveButton.addActionListener( saveActionListener );
- controlRow.add( saveButton );
- // add the close button
- Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
- closeButton.setStyleName( "control" );
- closeButton.addActionListener( closeActionListener );
- controlRow.add( closeButton );
-
- // add the column main pane
- Column content = new Column();
- content.setStyleName( "agents" );
- splitPane.add( content );
-
- // add button
- Button addButton = new Button( Messages.getString( "agent.add" ), Styles.ADD );
- addButton.addActionListener( addActionListener );
- content.add( addButton );
-
- // add the agents list grid
- agentsGrid = new Grid( 3 );
- agentsGrid.setStyleName( "border.grid" );
- agentsGrid.setColumnWidth( 0, new Extent( 18, Extent.PX ) );
- agentsGrid.setColumnWidth( 1, new Extent( 50, Extent.PERCENT ) );
- agentsGrid.setColumnWidth( 2, new Extent( 50, Extent.PERCENT ) );
- content.add( agentsGrid );
-
- // update agents grid
- update();
- }
-
- /**
- *
- *
- */
- protected void update()
- {
- // delete all agents grid child
- agentsGrid.removeAll();
-
- // add grid headers
- Label agentActionHeader = new Label( " " );
- agentActionHeader.setStyleName( "grid.header" );
- agentsGrid.add( agentActionHeader );
- Label agentIdHeader = new Label( Messages.getString( "id" ) );
- agentIdHeader.setStyleName( "grid.header" );
- agentsGrid.add( agentIdHeader );
- Label agentHostnameHeader = new Label( Messages.getString( "hostname" ) );
- agentHostnameHeader.setStyleName( "grid.header" );
- agentsGrid.add( agentHostnameHeader );
-
- // add agents in grid
- for ( Iterator agentIterator = agents.iterator(); agentIterator.hasNext(); )
+ // edit action listener
+ private ActionListener editActionListener = new ActionListener()
{
- Agent agent = (Agent) agentIterator.next();
- // action row with agent id
- Row row = new Row();
- row.setInsets( new Insets( 2 ) );
- row.setCellSpacing( new Extent( 2 ) );
- agentsGrid.add( row );
- // copy button
- Button copyButton = new Button( Styles.PAGE_COPY );
- copyButton.addActionListener( copy );
- copyButton.setActionCommand( agent.getId() );
- copyButton.setToolTipText( Messages.getString( "copy" ) );
- row.add( copyButton );
- // delete button
- Button deleteButton = new Button( Styles.DELETE );
- deleteButton.addActionListener( deleteActionListener );
- deleteButton.setActionCommand( agent.getId() );
- deleteButton.setToolTipText( Messages.getString( "delete" ) );
- row.add( deleteButton );
- // status button
- Button statusButton = new Button( Styles.INFORMATION );
- statusButton.setActionCommand( agent.getId() );
- statusButton.addActionListener( status );
- statusButton.setToolTipText( Messages.getString( "status" ) );
- row.add( statusButton );
+ public void actionPerformed( ActionEvent event )
+ {
+ if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getComponent(
+ "agentwindow_" + event.getActionCommand() ) == null )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new AdminAgentWindow( AdminAgentsWindow.this, event.getActionCommand() ) );
+ }
+ }
+ };
- Button idButton = new Button( agent.getId() );
- idButton.addActionListener( editActionListener );
- idButton.setActionCommand( agent.getId() );
- agentsGrid.add( idButton );
+ // add action listener
+ private ActionListener addActionListener = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new AdminAgentWindow( AdminAgentsWindow.this, null ) );
+ }
+ };
- // hostname label
- Label hostnameLabel = new Label( agent.getHostname() + ":" + agent.getPort() );
- hostnameLabel.setStyleName( "default" );
- agentsGrid.add( hostnameLabel );
+ // copy
+ private ActionListener copy = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // get the agent id
+ String agentId = event.getActionCommand();
+ // load Kalumet configuration
+ Kalumet kalumet = null;
+ try
+ {
+ kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent( agentId );
+ if ( agent == null )
+ {
+ return;
+ }
+ // store an agent clone in the copy component
+ KalumetConsoleApplication.getApplication().setCopyComponent( agent.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
+
+ // status
+ private ActionListener status = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // add an event
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "Agent " + event.getActionCommand() + " status check in progress ..." );
+ // start the status thread
+ final StatusThread statusThread = new StatusThread();
+ statusThread.id = event.getActionCommand();
+ statusThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( statusThread.ended )
+ {
+ if ( statusThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError( statusThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm( statusThread.message );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ };
+
+ /**
+ * Create a new <code>AdminAgentsWindow</code>.
+ */
+ public AdminAgentsWindow()
+ {
+ super();
+
+ // check if the user that try to access this window is the admin
+ if ( !KalumetConsoleApplication.getApplication().getUserid().equals( "admin" ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "agents.restricted" ) );
+ AdminAgentsWindow.this.userClose();
+ return;
+ }
+
+ // load Kalumet configuration
+ Kalumet kalumet = null;
+ try
+ {
+ kalumet = ConfigurationManager.loadStore();
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage() );
+ return;
+ }
+ this.agents = kalumet.getAgents();
+ Collections.sort( this.agents );
+
+ setTitle( Messages.getString( "agents" ) );
+ setIcon( Styles.COG );
+ setStyleName( "agents" );
+ setId( "agentswindow" );
+ setModal( false );
+ setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
+
+ // create a split pane for the control buttons
+ SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
+ add( splitPane );
+
+ // add the control pane
+ Row controlRow = new Row();
+ controlRow.setStyleName( "control" );
+ splitPane.add( controlRow );
+ // add the refresh button
+ Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
+ refreshButton.setStyleName( "control" );
+ refreshButton.addActionListener( refreshActionListener );
+ controlRow.add( refreshButton );
+ // add the save button
+ Button saveButton = new Button( Messages.getString( "save" ), Styles.DATABASE_SAVE );
+ saveButton.setStyleName( "control" );
+ saveButton.addActionListener( saveActionListener );
+ controlRow.add( saveButton );
+ // add the close button
+ Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
+ closeButton.setStyleName( "control" );
+ closeButton.addActionListener( closeActionListener );
+ controlRow.add( closeButton );
+
+ // add the column main pane
+ Column content = new Column();
+ content.setStyleName( "agents" );
+ splitPane.add( content );
+
+ // add button
+ Button addButton = new Button( Messages.getString( "agent.add" ), Styles.ADD );
+ addButton.addActionListener( addActionListener );
+ content.add( addButton );
+
+ // add the agents list grid
+ agentsGrid = new Grid( 3 );
+ agentsGrid.setStyleName( "border.grid" );
+ agentsGrid.setColumnWidth( 0, new Extent( 18, Extent.PX ) );
+ agentsGrid.setColumnWidth( 1, new Extent( 50, Extent.PERCENT ) );
+ agentsGrid.setColumnWidth( 2, new Extent( 50, Extent.PERCENT ) );
+ content.add( agentsGrid );
+
+ // update agents grid
+ update();
}
- }
- /**
- * Get the agents list
- *
- * @return the agents list
- */
- protected List getAgents()
- {
- return this.agents;
- }
+ /**
+ *
+ *
+ */
+ protected void update()
+ {
+ // delete all agents grid child
+ agentsGrid.removeAll();
+
+ // add grid headers
+ Label agentActionHeader = new Label( " " );
+ agentActionHeader.setStyleName( "grid.header" );
+ agentsGrid.add( agentActionHeader );
+ Label agentIdHeader = new Label( Messages.getString( "id" ) );
+ agentIdHeader.setStyleName( "grid.header" );
+ agentsGrid.add( agentIdHeader );
+ Label agentHostnameHeader = new Label( Messages.getString( "hostname" ) );
+ agentHostnameHeader.setStyleName( "grid.header" );
+ agentsGrid.add( agentHostnameHeader );
+
+ // add agents in grid
+ for ( Iterator agentIterator = agents.iterator(); agentIterator.hasNext(); )
+ {
+ Agent agent = (Agent) agentIterator.next();
+ // action row with agent id
+ Row row = new Row();
+ row.setInsets( new Insets( 2 ) );
+ row.setCellSpacing( new Extent( 2 ) );
+ agentsGrid.add( row );
+ // copy button
+ Button copyButton = new Button( Styles.PAGE_COPY );
+ copyButton.addActionListener( copy );
+ copyButton.setActionCommand( agent.getId() );
+ copyButton.setToolTipText( Messages.getString( "copy" ) );
+ row.add( copyButton );
+ // delete button
+ Button deleteButton = new Button( Styles.DELETE );
+ deleteButton.addActionListener( deleteActionListener );
+ deleteButton.setActionCommand( agent.getId() );
+ deleteButton.setToolTipText( Messages.getString( "delete" ) );
+ row.add( deleteButton );
+ // status button
+ Button statusButton = new Button( Styles.INFORMATION );
+ statusButton.setActionCommand( agent.getId() );
+ statusButton.addActionListener( status );
+ statusButton.setToolTipText( Messages.getString( "status" ) );
+ row.add( statusButton );
+
+ Button idButton = new Button( agent.getId() );
+ idButton.addActionListener( editActionListener );
+ idButton.setActionCommand( agent.getId() );
+ agentsGrid.add( idButton );
+
+ // hostname label
+ Label hostnameLabel = new Label( agent.getHostname() + ":" + agent.getPort() );
+ hostnameLabel.setStyleName( "default" );
+ agentsGrid.add( hostnameLabel );
+ }
+ }
+
+ /**
+ * Get the agents list
+ *
+ * @return the agents list
+ */
+ protected List getAgents()
+ {
+ return this.agents;
+ }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminConfigurationWindow.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminConfigurationWindow.java
index 7ebe096..5578b25 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminConfigurationWindow.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminConfigurationWindow.java
@@ -37,420 +37,421 @@
* Admin configuration window.
*/
public class AdminConfigurationWindow
- extends WindowPane
+ extends WindowPane
{
- private TextField consoleLocationField;
+ private TextField consoleLocationField;
- private SelectField ldapAuthenticationField;
+ private SelectField ldapAuthenticationField;
- private TextField ldapServerField;
+ private TextField ldapServerField;
- private TextField ldapBaseDNField;
+ private TextField ldapBaseDNField;
- private TextField ldapUidAttributeField;
+ private TextField ldapUidAttributeField;
- private TextField ldapMailAttributeField;
+ private TextField ldapMailAttributeField;
- private TextField ldapCnAttributeField;
+ private TextField ldapCnAttributeField;
- // close
- private ActionListener close = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // close
+ private ActionListener close = new ActionListener()
{
- AdminConfigurationWindow.this.userClose();
+ public void actionPerformed( ActionEvent event )
+ {
+ AdminConfigurationWindow.this.userClose();
+ }
+ };
+
+ // refresh
+ private ActionListener refresh = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ update();
+ }
+ };
+
+ // save
+ private ActionListener save = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ String logEventAppender = consoleLocationField.getText();
+ int ldapAuthentification = ldapAuthenticationField.getSelectedIndex();
+ String ldapServer = ldapServerField.getText();
+ String ldapBaseDN = ldapBaseDNField.getText();
+ String ldapUidAttribute = ldapUidAttributeField.getText();
+ String ldapMailAttribute = ldapMailAttributeField.getText();
+ String ldapCnAttribute = ldapCnAttributeField.getText();
+
+ // check if the user is allowed to do it
+ if ( !KalumetConsoleApplication.getApplication().getUserid().equals( "admin" ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "configuration.restricted" ) );
+ return;
+ }
+
+ // load Kalumet configuration
+ Kalumet kalumet = null;
+ try
+ {
+ kalumet = ConfigurationManager.loadStore();
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage() );
+ return;
+ }
+
+ // log event appender
+ Property logEventAppenderProperty = kalumet.getProperty( "LogEventAppender" );
+ if ( logEventAppenderProperty == null )
+ {
+ logEventAppenderProperty = new Property();
+ logEventAppenderProperty.setName( "LogEventAppender" );
+ try
+ {
+ kalumet.addProperty( logEventAppenderProperty );
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+ kalumet.getProperty( "LogEventAppender" ).setValue( logEventAppender );
+ // ldap authentification
+ Property ldapAuthentificationProperty = kalumet.getProperty( "LdapAuthentication" );
+ if ( ldapAuthentificationProperty == null )
+ {
+ ldapAuthentificationProperty = new Property();
+ ldapAuthentificationProperty.setName( "LdapAuthentication" );
+ try
+ {
+ kalumet.addProperty( ldapAuthentificationProperty );
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+ if ( ldapAuthentification == 0 )
+ {
+ kalumet.getProperty( "LdapAuthentication" ).setValue( "true" );
+ }
+ else
+ {
+ kalumet.getProperty( "LdapAuthentication" ).setValue( "false" );
+ }
+ // ldap server
+ Property ldapServerProperty = kalumet.getProperty( "LdapServer" );
+ if ( ldapServerProperty == null )
+ {
+ ldapServerProperty = new Property();
+ ldapServerProperty.setName( "LdapServer" );
+ try
+ {
+ kalumet.addProperty( ldapServerProperty );
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+ kalumet.getProperty( "LdapServer" ).setValue( ldapServer );
+ // ldap base DN
+ Property ldapBaseDNProperty = kalumet.getProperty( "LdapBaseDN" );
+ if ( ldapBaseDNProperty == null )
+ {
+ ldapBaseDNProperty = new Property();
+ ldapBaseDNProperty.setName( "LdapBaseDN" );
+ try
+ {
+ kalumet.addProperty( ldapBaseDNProperty );
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+ kalumet.getProperty( "LdapBaseDN" ).setValue( ldapBaseDN );
+ // ldap uid attribute
+ Property ldapUidAttributeProperty = kalumet.getProperty( "LdapUidAttribute" );
+ if ( ldapUidAttributeProperty == null )
+ {
+ ldapUidAttributeProperty = new Property();
+ ldapUidAttributeProperty.setName( "LdapUidAttribute" );
+ try
+ {
+ kalumet.addProperty( ldapUidAttributeProperty );
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+ kalumet.getProperty( "LdapUidAttribute" ).setValue( ldapUidAttribute );
+ // ldap mail attribute
+ Property ldapMailAttributeProperty = kalumet.getProperty( "LdapMailAttribute" );
+ if ( ldapMailAttributeProperty == null )
+ {
+ ldapMailAttributeProperty = new Property();
+ ldapMailAttributeProperty.setName( "LdapMailAttribute" );
+ try
+ {
+ kalumet.addProperty( ldapMailAttributeProperty );
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+ kalumet.getProperty( "LdapMailAttribute" ).setValue( ldapMailAttribute );
+ // ldap cn attribute
+ Property ldapCnAttributeProperty = kalumet.getProperty( "LdapCnAttribute" );
+ if ( ldapCnAttributeProperty == null )
+ {
+ ldapCnAttributeProperty = new Property();
+ ldapCnAttributeProperty.setName( "LdapCnAttribute" );
+ try
+ {
+ kalumet.addProperty( ldapCnAttributeProperty );
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+
+ // save Kalumet configuration
+ try
+ {
+ ConfigurationManager.writeStore( kalumet );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.write" ) + ": " + e.getMessage() );
+ return;
+ }
+
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ Messages.getString( "configuration.saved" ) );
+ }
+
+ };
+
+ /**
+ * Create a new <code>AdminConfigurationWindow</code>.
+ */
+ public AdminConfigurationWindow()
+ {
+ super();
+
+ // check if the user that try to access this window is the admin
+ if ( !KalumetConsoleApplication.getApplication().getUserid().equals( "admin" ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "configuration.restricted" ) );
+ AdminConfigurationWindow.this.userClose();
+ return;
+ }
+
+ setTitle( Messages.getString( "configuration" ) );
+ setIcon( Styles.COMPUTER_EDIT );
+ setId( "configurationwindow" );
+ setStyleName( "configuration" );
+ setModal( false );
+ setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
+
+ // create a split pane for the control buttons
+ SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
+ add( splitPane );
+
+ // add the control pane
+ Row controlRow = new Row();
+ controlRow.setStyleName( "control" );
+ splitPane.add( controlRow );
+ // add the refresh button
+ Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
+ refreshButton.addActionListener( refresh );
+ refreshButton.setStyleName( "control" );
+ controlRow.add( refreshButton );
+ // add the save button
+ Button saveButton = new Button( Messages.getString( "save" ), Styles.DATABASE_SAVE );
+ saveButton.addActionListener( save );
+ saveButton.setStyleName( "control" );
+ controlRow.add( saveButton );
+ // add the close button
+ Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
+ closeButton.addActionListener( close );
+ closeButton.setStyleName( "control" );
+ controlRow.add( closeButton );
+
+ // define a grid layout
+ Grid content = new Grid( 2 );
+ content.setStyleName( "default" );
+ content.setWidth( new Extent( 100, Extent.PERCENT ) );
+ content.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
+ content.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
+ splitPane.add( content );
+
+ // create the log event appender field
+ Label logEventAppenderLabel = new Label( Messages.getString( "configuration.journal.location" ) );
+ logEventAppenderLabel.setStyleName( "default" );
+ content.add( logEventAppenderLabel );
+ consoleLocationField = new TextField();
+ consoleLocationField.setStyleName( "default" );
+ consoleLocationField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ content.add( consoleLocationField );
+
+ // create the ldap authentication field
+ Label ldapAuthenticationLabel = new Label( Messages.getString( "configuration.ldap.authentication" ) );
+ ldapAuthenticationLabel.setStyleName( "default" );
+ content.add( ldapAuthenticationLabel );
+ ldapAuthenticationField = new SelectField( MainScreen.LABELS );
+ ldapAuthenticationField.setStyleName( "default" );
+ content.add( ldapAuthenticationField );
+
+ // create the ldap server field
+ Label ldapServerLabel = new Label( Messages.getString( "configuration.ldap.server" ) );
+ ldapServerLabel.setStyleName( "default" );
+ content.add( ldapServerLabel );
+ ldapServerField = new TextField();
+ ldapServerField.setStyleName( "default" );
+ ldapServerField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ content.add( ldapServerField );
+
+ // create the ldap base dn field
+ Label ldapBaseDNLabel = new Label( Messages.getString( "configuration.ldap.basedn" ) );
+ ldapBaseDNLabel.setStyleName( "default" );
+ content.add( ldapBaseDNLabel );
+ ldapBaseDNField = new TextField();
+ ldapBaseDNField.setStyleName( "default" );
+ ldapBaseDNField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ content.add( ldapBaseDNField );
+
+ // create the ldap uid attribute field
+ Label ldapUidAttributeLabel = new Label( Messages.getString( "configuration.ldap.uid" ) );
+ ldapUidAttributeLabel.setStyleName( "default" );
+ content.add( ldapUidAttributeLabel );
+ ldapUidAttributeField = new TextField();
+ ldapUidAttributeField.setStyleName( "default" );
+ ldapUidAttributeField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ content.add( ldapUidAttributeField );
+
+ // create the ldap mail attribute field
+ Label ldapMailAttributeLabel = new Label( Messages.getString( "configuration.ldap.mail" ) );
+ ldapMailAttributeLabel.setStyleName( "default" );
+ content.add( ldapMailAttributeLabel );
+ ldapMailAttributeField = new TextField();
+ ldapMailAttributeField.setStyleName( "default" );
+ ldapMailAttributeField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ content.add( ldapMailAttributeField );
+
+ // create the ldap cn attribute field
+ Label ldapCnAttributeLabel = new Label( Messages.getString( "configuration.ldap.cn" ) );
+ ldapCnAttributeLabel.setStyleName( "default" );
+ content.add( ldapCnAttributeLabel );
+ ldapCnAttributeField = new TextField();
+ ldapCnAttributeField.setStyleName( "default" );
+ ldapCnAttributeField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ content.add( ldapCnAttributeField );
+
+ update();
}
- };
- // refresh
- private ActionListener refresh = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ /**
+ * Update the window content.
+ */
+ public void update()
{
- update();
- }
- };
-
- // save
- private ActionListener save = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- String logEventAppender = consoleLocationField.getText();
- int ldapAuthentification = ldapAuthenticationField.getSelectedIndex();
- String ldapServer = ldapServerField.getText();
- String ldapBaseDN = ldapBaseDNField.getText();
- String ldapUidAttribute = ldapUidAttributeField.getText();
- String ldapMailAttribute = ldapMailAttributeField.getText();
- String ldapCnAttribute = ldapCnAttributeField.getText();
-
- // check if the user is allowed to do it
- if ( !KalumetConsoleApplication.getApplication().getUserid().equals( "admin" ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "configuration.restricted" ) );
- return;
- }
-
- // load Kalumet configuration
- Kalumet kalumet = null;
- try
- {
- kalumet = ConfigurationManager.loadStore();
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage() );
- return;
- }
-
- // log event appender
- Property logEventAppenderProperty = kalumet.getProperty( "LogEventAppender" );
- if ( logEventAppenderProperty == null )
- {
- logEventAppenderProperty = new Property();
- logEventAppenderProperty.setName( "LogEventAppender" );
+ // load Kalumet configuration
+ Kalumet kalumet = null;
try
{
- kalumet.addProperty( logEventAppenderProperty );
+ kalumet = ConfigurationManager.loadStore();
}
catch ( Exception e )
{
- // ignore
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage() );
+ return;
}
- }
- kalumet.getProperty( "LogEventAppender" ).setValue( logEventAppender );
- // ldap authentification
- Property ldapAuthentificationProperty = kalumet.getProperty( "LdapAuthentication" );
- if ( ldapAuthentificationProperty == null )
- {
- ldapAuthentificationProperty = new Property();
- ldapAuthentificationProperty.setName( "LdapAuthentication" );
- try
+
+ Property logEventAppenderProperty = kalumet.getProperty( "LogEventAppender" );
+ if ( logEventAppenderProperty != null )
{
- kalumet.addProperty( ldapAuthentificationProperty );
+ consoleLocationField.setText( logEventAppenderProperty.getValue() );
}
- catch ( Exception e )
+ else
{
- // ignore
+ consoleLocationField.setText( null );
}
- }
- if ( ldapAuthentification == 0 )
- {
- kalumet.getProperty( "LdapAuthentication" ).setValue( "true" );
- }
- else
- {
- kalumet.getProperty( "LdapAuthentication" ).setValue( "false" );
- }
- // ldap server
- Property ldapServerProperty = kalumet.getProperty( "LdapServer" );
- if ( ldapServerProperty == null )
- {
- ldapServerProperty = new Property();
- ldapServerProperty.setName( "LdapServer" );
- try
+
+ Property ldapAuthentificationProperty = kalumet.getProperty( "LdapAuthentication" );
+ if ( ldapAuthentificationProperty != null )
{
- kalumet.addProperty( ldapServerProperty );
+ if ( ldapAuthentificationProperty.getValue().equals( "true" ) )
+ {
+ ldapAuthenticationField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ ldapAuthenticationField.setSelectedIndex( 1 );
+ }
}
- catch ( Exception e )
+ else
{
- // ignore
+ ldapAuthenticationField.setSelectedIndex( 1 );
}
- }
- kalumet.getProperty( "LdapServer" ).setValue( ldapServer );
- // ldap base DN
- Property ldapBaseDNProperty = kalumet.getProperty( "LdapBaseDN" );
- if ( ldapBaseDNProperty == null )
- {
- ldapBaseDNProperty = new Property();
- ldapBaseDNProperty.setName( "LdapBaseDN" );
- try
+ Property ldapServerProperty = kalumet.getProperty( "LdapServer" );
+ if ( ldapServerProperty != null )
{
- kalumet.addProperty( ldapBaseDNProperty );
+ ldapServerField.setText( ldapServerProperty.getValue() );
}
- catch ( Exception e )
+ else
{
- // ignore
+ ldapServerField.setText( null );
}
- }
- kalumet.getProperty( "LdapBaseDN" ).setValue( ldapBaseDN );
- // ldap uid attribute
- Property ldapUidAttributeProperty = kalumet.getProperty( "LdapUidAttribute" );
- if ( ldapUidAttributeProperty == null )
- {
- ldapUidAttributeProperty = new Property();
- ldapUidAttributeProperty.setName( "LdapUidAttribute" );
- try
+ Property ldapBaseDNProperty = kalumet.getProperty( "LdapBaseDN" );
+ if ( ldapBaseDNProperty != null )
{
- kalumet.addProperty( ldapUidAttributeProperty );
+ ldapBaseDNField.setText( ldapBaseDNProperty.getValue() );
}
- catch ( Exception e )
+ else
{
- // ignore
+ ldapBaseDNField.setText( null );
}
- }
- kalumet.getProperty( "LdapUidAttribute" ).setValue( ldapUidAttribute );
- // ldap mail attribute
- Property ldapMailAttributeProperty = kalumet.getProperty( "LdapMailAttribute" );
- if ( ldapMailAttributeProperty == null )
- {
- ldapMailAttributeProperty = new Property();
- ldapMailAttributeProperty.setName( "LdapMailAttribute" );
- try
+ Property ldapUidAttributeProperty = kalumet.getProperty( "LdapUidAttribute" );
+ if ( ldapUidAttributeProperty != null )
{
- kalumet.addProperty( ldapMailAttributeProperty );
+ ldapUidAttributeField.setText( ldapUidAttributeProperty.getValue() );
}
- catch ( Exception e )
+ else
{
- // ignore
+ ldapUidAttributeField.setText( null );
}
- }
- kalumet.getProperty( "LdapMailAttribute" ).setValue( ldapMailAttribute );
- // ldap cn attribute
- Property ldapCnAttributeProperty = kalumet.getProperty( "LdapCnAttribute" );
- if ( ldapCnAttributeProperty == null )
- {
- ldapCnAttributeProperty = new Property();
- ldapCnAttributeProperty.setName( "LdapCnAttribute" );
- try
+ Property ldapMailAttributeProperty = kalumet.getProperty( "LdapMailAttribute" );
+ if ( ldapMailAttributeProperty != null )
{
- kalumet.addProperty( ldapCnAttributeProperty );
+ ldapMailAttributeField.setText( ldapMailAttributeProperty.getValue() );
}
- catch ( Exception e )
+ else
{
- // ignore
+ ldapMailAttributeField.setText( null );
}
- }
-
- // save Kalumet configuration
- try
- {
- ConfigurationManager.writeStore( kalumet );
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.write" ) + ": " + e.getMessage() );
- return;
- }
-
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm( Messages.getString( "configuration.saved" ) );
+ Property ldapCnAttributeProperty = kalumet.getProperty( "LdapCnAttribute" );
+ if ( ldapCnAttributeProperty != null )
+ {
+ ldapCnAttributeField.setText( ldapCnAttributeProperty.getValue() );
+ }
+ else
+ {
+ ldapCnAttributeField.setText( null );
+ }
}
- };
-
- /**
- * Create a new <code>AdminConfigurationWindow</code>.
- */
- public AdminConfigurationWindow()
- {
- super();
-
- // check if the user that try to access this window is the admin
- if ( !KalumetConsoleApplication.getApplication().getUserid().equals( "admin" ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "configuration.restricted" ) );
- AdminConfigurationWindow.this.userClose();
- return;
- }
-
- setTitle( Messages.getString( "configuration" ) );
- setIcon( Styles.COMPUTER_EDIT );
- setId( "configurationwindow" );
- setStyleName( "configuration" );
- setModal( false );
- setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
-
- // create a split pane for the control buttons
- SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
- add( splitPane );
-
- // add the control pane
- Row controlRow = new Row();
- controlRow.setStyleName( "control" );
- splitPane.add( controlRow );
- // add the refresh button
- Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
- refreshButton.addActionListener( refresh );
- refreshButton.setStyleName( "control" );
- controlRow.add( refreshButton );
- // add the save button
- Button saveButton = new Button( Messages.getString( "save" ), Styles.DATABASE_SAVE );
- saveButton.addActionListener( save );
- saveButton.setStyleName( "control" );
- controlRow.add( saveButton );
- // add the close button
- Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
- closeButton.addActionListener( close );
- closeButton.setStyleName( "control" );
- controlRow.add( closeButton );
-
- // define a grid layout
- Grid content = new Grid( 2 );
- content.setStyleName( "default" );
- content.setWidth( new Extent( 100, Extent.PERCENT ) );
- content.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
- content.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
- splitPane.add( content );
-
- // create the log event appender field
- Label logEventAppenderLabel = new Label( Messages.getString( "configuration.journal.location" ) );
- logEventAppenderLabel.setStyleName( "default" );
- content.add( logEventAppenderLabel );
- consoleLocationField = new TextField();
- consoleLocationField.setStyleName( "default" );
- consoleLocationField.setWidth( new Extent( 100, Extent.PERCENT ) );
- content.add( consoleLocationField );
-
- // create the ldap authentication field
- Label ldapAuthenticationLabel = new Label( Messages.getString( "configuration.ldap.authentication" ) );
- ldapAuthenticationLabel.setStyleName( "default" );
- content.add( ldapAuthenticationLabel );
- ldapAuthenticationField = new SelectField( MainScreen.LABELS );
- ldapAuthenticationField.setStyleName( "default" );
- content.add( ldapAuthenticationField );
-
- // create the ldap server field
- Label ldapServerLabel = new Label( Messages.getString( "configuration.ldap.server" ) );
- ldapServerLabel.setStyleName( "default" );
- content.add( ldapServerLabel );
- ldapServerField = new TextField();
- ldapServerField.setStyleName( "default" );
- ldapServerField.setWidth( new Extent( 100, Extent.PERCENT ) );
- content.add( ldapServerField );
-
- // create the ldap base dn field
- Label ldapBaseDNLabel = new Label( Messages.getString( "configuration.ldap.basedn" ) );
- ldapBaseDNLabel.setStyleName( "default" );
- content.add( ldapBaseDNLabel );
- ldapBaseDNField = new TextField();
- ldapBaseDNField.setStyleName( "default" );
- ldapBaseDNField.setWidth( new Extent( 100, Extent.PERCENT ) );
- content.add( ldapBaseDNField );
-
- // create the ldap uid attribute field
- Label ldapUidAttributeLabel = new Label( Messages.getString( "configuration.ldap.uid" ) );
- ldapUidAttributeLabel.setStyleName( "default" );
- content.add( ldapUidAttributeLabel );
- ldapUidAttributeField = new TextField();
- ldapUidAttributeField.setStyleName( "default" );
- ldapUidAttributeField.setWidth( new Extent( 100, Extent.PERCENT ) );
- content.add( ldapUidAttributeField );
-
- // create the ldap mail attribute field
- Label ldapMailAttributeLabel = new Label( Messages.getString( "configuration.ldap.mail" ) );
- ldapMailAttributeLabel.setStyleName( "default" );
- content.add( ldapMailAttributeLabel );
- ldapMailAttributeField = new TextField();
- ldapMailAttributeField.setStyleName( "default" );
- ldapMailAttributeField.setWidth( new Extent( 100, Extent.PERCENT ) );
- content.add( ldapMailAttributeField );
-
- // create the ldap cn attribute field
- Label ldapCnAttributeLabel = new Label( Messages.getString( "configuration.ldap.cn" ) );
- ldapCnAttributeLabel.setStyleName( "default" );
- content.add( ldapCnAttributeLabel );
- ldapCnAttributeField = new TextField();
- ldapCnAttributeField.setStyleName( "default" );
- ldapCnAttributeField.setWidth( new Extent( 100, Extent.PERCENT ) );
- content.add( ldapCnAttributeField );
-
- update();
- }
-
- /**
- * Update the window content.
- */
- public void update()
- {
- // load Kalumet configuration
- Kalumet kalumet = null;
- try
- {
- kalumet = ConfigurationManager.loadStore();
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage() );
- return;
- }
-
- Property logEventAppenderProperty = kalumet.getProperty( "LogEventAppender" );
- if ( logEventAppenderProperty != null )
- {
- consoleLocationField.setText( logEventAppenderProperty.getValue() );
- }
- else
- {
- consoleLocationField.setText( null );
- }
-
- Property ldapAuthentificationProperty = kalumet.getProperty( "LdapAuthentication" );
- if ( ldapAuthentificationProperty != null )
- {
- if ( ldapAuthentificationProperty.getValue().equals( "true" ) )
- {
- ldapAuthenticationField.setSelectedIndex( 0 );
- }
- else
- {
- ldapAuthenticationField.setSelectedIndex( 1 );
- }
- }
- else
- {
- ldapAuthenticationField.setSelectedIndex( 1 );
- }
- Property ldapServerProperty = kalumet.getProperty( "LdapServer" );
- if ( ldapServerProperty != null )
- {
- ldapServerField.setText( ldapServerProperty.getValue() );
- }
- else
- {
- ldapServerField.setText( null );
- }
- Property ldapBaseDNProperty = kalumet.getProperty( "LdapBaseDN" );
- if ( ldapBaseDNProperty != null )
- {
- ldapBaseDNField.setText( ldapBaseDNProperty.getValue() );
- }
- else
- {
- ldapBaseDNField.setText( null );
- }
- Property ldapUidAttributeProperty = kalumet.getProperty( "LdapUidAttribute" );
- if ( ldapUidAttributeProperty != null )
- {
- ldapUidAttributeField.setText( ldapUidAttributeProperty.getValue() );
- }
- else
- {
- ldapUidAttributeField.setText( null );
- }
- Property ldapMailAttributeProperty = kalumet.getProperty( "LdapMailAttribute" );
- if ( ldapMailAttributeProperty != null )
- {
- ldapMailAttributeField.setText( ldapMailAttributeProperty.getValue() );
- }
- else
- {
- ldapMailAttributeField.setText( null );
- }
- Property ldapCnAttributeProperty = kalumet.getProperty( "LdapCnAttribute" );
- if ( ldapCnAttributeProperty != null )
- {
- ldapCnAttributeField.setText( ldapCnAttributeProperty.getValue() );
- }
- else
- {
- ldapCnAttributeField.setText( null );
- }
- }
-
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminGroupWindow.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminGroupWindow.java
index 5e63cfa..1b6b16a 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminGroupWindow.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminGroupWindow.java
@@ -43,441 +43,442 @@
* Admin group window.
*/
public class AdminGroupWindow
- extends WindowPane
+ extends WindowPane
{
- // attributes
- private String groupId;
+ // attributes
+ private String groupId;
- private Group group = null;
+ private Group group = null;
- private AdminGroupsWindow parent;
+ private AdminGroupsWindow parent;
- private TextField idField;
+ private TextField idField;
- private TextField nameField;
+ private TextField nameField;
- private ListBox membersBox;
+ private ListBox membersBox;
- private ListBox usersBox;
+ private ListBox usersBox;
- // close
- private ActionListener close = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // close
+ private ActionListener close = new ActionListener()
{
- AdminGroupWindow.this.userClose();
- }
- };
-
- // refresh action listener
- private ActionListener refreshActionListener = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // update the group from the parent list
- for ( Iterator groupIterator = parent.getGroups().iterator(); groupIterator.hasNext(); )
- {
- Group current = (Group) groupIterator.next();
- if ( current.getId().equals( groupId ) )
+ public void actionPerformed( ActionEvent event )
{
- group = current;
- break;
+ AdminGroupWindow.this.userClose();
}
- }
- if ( group == null )
- {
- group = new Group();
- }
- update();
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- groupId + " " + Messages.getString( "reloaded" ) );
- }
- };
+ };
- // add member action listener
- private ActionListener addMemberActionListener = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // refresh action listener
+ private ActionListener refreshActionListener = new ActionListener()
{
- // check if the users box is not empty
- if ( usersBox.getModel().size() < 1 )
- {
- return;
- }
- // check if the user has selected a user
- if ( usersBox.getSelectedValue() == null )
- {
- return;
- }
- // load Kalumet configuration
- Kalumet kalumet = null;
- try
- {
- kalumet = ConfigurationManager.loadStore();
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage() );
- return;
- }
- // get the user object and add the user to the group members
- User found = null;
- for ( Iterator userIterator = kalumet.getSecurity().getUsers().iterator(); userIterator.hasNext(); )
- {
- User user = (User) userIterator.next();
- if ( user.getId().equals( (String) usersBox.getSelectedValue() ) )
+ public void actionPerformed( ActionEvent event )
{
- found = user;
- }
- }
- // check if the user has been found
- if ( found == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "group.warn.user.notfound" ) );
- return;
- }
- try
- {
- group.addUser( found );
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "group.warn.user.alreadymember" ) );
- return;
- }
- // update view
- update();
- parent.update();
- }
- };
-
- // delete member action listener
- private ActionListener deleteMemberActionListener = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the members box is not empty
- if ( membersBox.getModel().size() < 1 )
- {
- return;
- }
- // check if the user has selected a member
- if ( membersBox.getSelectedValue() == null )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ErrorWindow( Messages.getString( "AdminGroupWindow.Error.Delete" ),
- Messages.getString( "AdminGroupWindow.Error.Delete.Select" ) ) );
- return;
- }
- // get the member object
- User found = null;
- for ( Iterator memberIterator = group.getUsers().iterator(); memberIterator.hasNext(); )
- {
- User member = (User) memberIterator.next();
- if ( member.getId().equals( membersBox.getSelectedValue() ) )
- {
- found = member;
- }
- }
- // check if the member is found
- if ( found == null )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ErrorWindow( Messages.getString( "AdminGroupWindow.Error.Delete" ),
- Messages.getString( "AdminGroupWindow.Error.Delete.NotFound" ) ) );
- return;
- }
- group.getUsers().remove( found );
- // update view
- update();
- parent.update();
- }
- };
-
- // apply action listener
- private ActionListener applyActionListener = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- String groupNewId = idField.getText().trim();
- String groupName = nameField.getText().trim();
-
- // check fields
- // group id is mandatory
- if ( groupNewId.length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "group.warn.empty" ) );
- return;
- }
- // if the admin change the group id or if it's a new group, check if
- // the id is not already used
- if ( groupId == null || groupId.trim().length() < 1 || ( ( groupId != null ) && ( groupId.trim().length() > 0 )
- && ( !groupNewId.equals( groupId ) ) ) )
- {
- for ( Iterator groupIterator = parent.getGroups().iterator(); groupIterator.hasNext(); )
- {
- Group current = (Group) groupIterator.next();
- if ( current.getId().equals( groupNewId ) )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ErrorWindow( Messages.getString( "AdminGroupWindow.Error.Save" ),
- Messages.getString( "AdminGroupWindow.Error.GroupIdAlreadyExists" ) ) );
- return;
- }
- }
- }
-
- // update the current group
- group.setId( groupNewId );
- group.setName( groupName );
- if ( groupId == null || groupId.trim().length() < 1 )
- {
- // it's a new group
- parent.getGroups().add( group );
- }
- setTitle( Messages.getString( "AdminGroupWindow.Title" ) + " " + group.getId() );
- setId( "adminwindow_" + group.getId() );
- groupId = group.getId();
- parent.update();
- }
- };
-
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // display a confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // looking for the agent to remove
- Group groupToRemove = null;
+ // update the group from the parent list
for ( Iterator groupIterator = parent.getGroups().iterator(); groupIterator.hasNext(); )
{
- Group group = (Group) groupIterator.next();
- if ( group.getId().equals( groupId ) )
- {
- groupToRemove = group;
- break;
- }
+ Group current = (Group) groupIterator.next();
+ if ( current.getId().equals( groupId ) )
+ {
+ group = current;
+ break;
+ }
}
- parent.getGroups().remove( groupToRemove );
- AdminGroupWindow.this.userClose();
- parent.update();
- }
- } ) );
- }
- };
-
- /**
- * Create a new <code>AdminGroupWindow</code>.
- *
- * @param parent the <code>AdminGroupsWindow</code> parent.
- * @param groupId the <code>Group</code> ID.
- */
- public AdminGroupWindow( AdminGroupsWindow parent, String groupId )
- {
- super();
-
- // check if the user that try to access this window is the admin
- if ( !KalumetConsoleApplication.getApplication().getUserid().equals( "admin" ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "groups.warn.restricted" ) );
- return;
- }
-
- // update the original group id and parent admin groups window
- this.parent = parent;
- this.groupId = groupId;
-
- // update the group object from groups parent list
- for ( Iterator groupIterator = parent.getGroups().iterator(); groupIterator.hasNext(); )
- {
- Group current = (Group) groupIterator.next();
- if ( current.getId().equals( groupId ) )
- {
- this.group = current;
- break;
- }
- }
- if ( this.group == null )
- {
- this.group = new Group();
- }
-
- if ( groupId == null )
- {
- setTitle( Messages.getString( "group" ) );
- }
- else
- {
- setTitle( Messages.getString( "group" ) + " " + groupId );
- }
- setIcon( Styles.GROUP );
- setId( "groupwindow_" + groupId );
- setStyleName( "group" );
- setModal( false );
- setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
-
- // create a split pane for the control buttons
- SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
- add( splitPane );
-
- // add the control pane
- Row controlRow = new Row();
- controlRow.setStyleName( "control" );
- splitPane.add( controlRow );
- // add the refresh button
- Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
- refreshButton.setStyleName( "control" );
- refreshButton.addActionListener( refreshActionListener );
- controlRow.add( refreshButton );
- // add the delete button
- Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
- deleteButton.setStyleName( "control" );
- deleteButton.addActionListener( delete );
- controlRow.add( deleteButton );
- // add the apply button
- Button applyButton = new Button( Messages.getString( "apply" ), Styles.DATABASE_GO );
- applyButton.setStyleName( "control" );
- applyButton.addActionListener( applyActionListener );
- controlRow.add( applyButton );
- // add the close button
- Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
- closeButton.setStyleName( "control" );
- closeButton.addActionListener( close );
- controlRow.add( closeButton );
-
- // content column pane
- Column content = new Column();
- content.setStyleName( "group" );
- splitPane.add( content );
-
- // layout grid
- Grid layoutGrid = new Grid( 2 );
- layoutGrid.setStyleName( "default" );
- layoutGrid.setColumnWidth( 0, new Extent( 15, Extent.PERCENT ) );
- layoutGrid.setColumnWidth( 1, new Extent( 85, Extent.PERCENT ) );
- content.add( layoutGrid );
-
- // add the group id field
- Label idLabel = new Label( Messages.getString( "id" ) );
- idLabel.setStyleName( "default" );
- layoutGrid.add( idLabel );
- idField = new TextField();
- idField.setStyleName( "default" );
- idField.setWidth( new Extent( 100, Extent.PERCENT ) );
- layoutGrid.add( idField );
-
- // add the group name field
- Label nameLabel = new Label( Messages.getString( "name" ) );
- nameLabel.setStyleName( "default" );
- layoutGrid.add( nameLabel );
- nameField = new TextField();
- nameField.setStyleName( "default" );
- nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
- layoutGrid.add( nameField );
-
- // add the members header
- Label membersHeader = new Label( Messages.getString( "members" ) );
- membersHeader.setStyleName( "default" );
- layoutGrid.add( membersHeader );
-
- // grid members
- Grid membersGrid = new Grid( 2 );
- membersGrid.setStyleName( "default" );
- membersGrid.setWidth( new Extent( 100, Extent.PERCENT ) );
- membersGrid.setColumnWidth( 0, new Extent( 50, Extent.PERCENT ) );
- membersGrid.setColumnWidth( 1, new Extent( 50, Extent.PERCENT ) );
- content.add( membersGrid );
-
- // membersBox
- membersBox = new ListBox();
- membersBox.setStyleName( "default" );
- membersBox.setHeight( new Extent( 200, Extent.PX ) );
- membersBox.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
- membersGrid.add( membersBox );
- // usersBox
- usersBox = new ListBox();
- usersBox.setStyleName( "default" );
- usersBox.setHeight( new Extent( 200, Extent.PX ) );
- usersBox.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
- membersGrid.add( usersBox );
- // add user member button
- Button addMemberButton = new Button( Styles.ARROW_LEFT );
- addMemberButton.setStyleName( "group.member.add" );
- addMemberButton.addActionListener( addMemberActionListener );
- membersGrid.add( addMemberButton );
- // add delete member button
- Button deleteMemberButton = new Button( Styles.ARROW_RIGHT );
- deleteMemberButton.setStyleName( "group.member.delete" );
- deleteMemberButton.addActionListener( deleteMemberActionListener );
- membersGrid.add( deleteMemberButton );
-
- // update fields/boxes value
- update();
- }
-
- /**
- * Update the group fields/boxes
- */
- public void update()
- {
- idField.setText( group.getId() );
- nameField.setText( group.getName() );
-
- // update the members box
- DefaultListModel membersBoxModel = (DefaultListModel) membersBox.getModel();
- membersBoxModel.removeAll();
- for ( Iterator memberIterator = group.getUsers().iterator(); memberIterator.hasNext(); )
- {
- User member = (User) memberIterator.next();
- membersBoxModel.add( member.getId() );
- }
-
- // update the users box
- DefaultListModel usersBoxModel = (DefaultListModel) usersBox.getModel();
- usersBoxModel.removeAll();
-
- // load Kalumet configuration
- Kalumet kalumet = null;
- try
- {
- kalumet = ConfigurationManager.loadStore();
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage() );
- return;
- }
-
- for ( Iterator userIterator = kalumet.getSecurity().getUsers().iterator(); userIterator.hasNext(); )
- {
- User user = (User) userIterator.next();
- // check if the user is not already a group member
- boolean find = false;
- for ( Iterator memberIterator = group.getUsers().iterator(); memberIterator.hasNext(); )
- {
- User member = (User) memberIterator.next();
- if ( member.getId().equals( user.getId() ) )
- {
- find = true;
+ if ( group == null )
+ {
+ group = new Group();
+ }
+ update();
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ groupId + " " + Messages.getString( "reloaded" ) );
}
- }
- if ( !find )
- {
- usersBoxModel.add( user.getId() );
- }
+ };
+
+ // add member action listener
+ private ActionListener addMemberActionListener = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the users box is not empty
+ if ( usersBox.getModel().size() < 1 )
+ {
+ return;
+ }
+ // check if the user has selected a user
+ if ( usersBox.getSelectedValue() == null )
+ {
+ return;
+ }
+ // load Kalumet configuration
+ Kalumet kalumet = null;
+ try
+ {
+ kalumet = ConfigurationManager.loadStore();
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage() );
+ return;
+ }
+ // get the user object and add the user to the group members
+ User found = null;
+ for ( Iterator userIterator = kalumet.getSecurity().getUsers().iterator(); userIterator.hasNext(); )
+ {
+ User user = (User) userIterator.next();
+ if ( user.getId().equals( (String) usersBox.getSelectedValue() ) )
+ {
+ found = user;
+ }
+ }
+ // check if the user has been found
+ if ( found == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "group.warn.user.notfound" ) );
+ return;
+ }
+ try
+ {
+ group.addUser( found );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "group.warn.user.alreadymember" ) );
+ return;
+ }
+ // update view
+ update();
+ parent.update();
+ }
+ };
+
+ // delete member action listener
+ private ActionListener deleteMemberActionListener = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the members box is not empty
+ if ( membersBox.getModel().size() < 1 )
+ {
+ return;
+ }
+ // check if the user has selected a member
+ if ( membersBox.getSelectedValue() == null )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ErrorWindow( Messages.getString( "AdminGroupWindow.Error.Delete" ),
+ Messages.getString( "AdminGroupWindow.Error.Delete.Select" ) ) );
+ return;
+ }
+ // get the member object
+ User found = null;
+ for ( Iterator memberIterator = group.getUsers().iterator(); memberIterator.hasNext(); )
+ {
+ User member = (User) memberIterator.next();
+ if ( member.getId().equals( membersBox.getSelectedValue() ) )
+ {
+ found = member;
+ }
+ }
+ // check if the member is found
+ if ( found == null )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ErrorWindow( Messages.getString( "AdminGroupWindow.Error.Delete" ),
+ Messages.getString( "AdminGroupWindow.Error.Delete.NotFound" ) ) );
+ return;
+ }
+ group.getUsers().remove( found );
+ // update view
+ update();
+ parent.update();
+ }
+ };
+
+ // apply action listener
+ private ActionListener applyActionListener = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ String groupNewId = idField.getText().trim();
+ String groupName = nameField.getText().trim();
+
+ // check fields
+ // group id is mandatory
+ if ( groupNewId.length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "group.warn.empty" ) );
+ return;
+ }
+ // if the admin change the group id or if it's a new group, check if
+ // the id is not already used
+ if ( groupId == null || groupId.trim().length() < 1 || ( ( groupId != null ) && ( groupId.trim().length()
+ > 0 ) && ( !groupNewId.equals( groupId ) ) ) )
+ {
+ for ( Iterator groupIterator = parent.getGroups().iterator(); groupIterator.hasNext(); )
+ {
+ Group current = (Group) groupIterator.next();
+ if ( current.getId().equals( groupNewId ) )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ErrorWindow( Messages.getString( "AdminGroupWindow.Error.Save" ),
+ Messages.getString( "AdminGroupWindow.Error.GroupIdAlreadyExists" ) ) );
+ return;
+ }
+ }
+ }
+
+ // update the current group
+ group.setId( groupNewId );
+ group.setName( groupName );
+ if ( groupId == null || groupId.trim().length() < 1 )
+ {
+ // it's a new group
+ parent.getGroups().add( group );
+ }
+ setTitle( Messages.getString( "AdminGroupWindow.Title" ) + " " + group.getId() );
+ setId( "adminwindow_" + group.getId() );
+ groupId = group.getId();
+ parent.update();
+ }
+ };
+
+ // delete
+ private ActionListener delete = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // display a confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // looking for the agent to remove
+ Group groupToRemove = null;
+ for ( Iterator groupIterator = parent.getGroups().iterator(); groupIterator.hasNext(); )
+ {
+ Group group = (Group) groupIterator.next();
+ if ( group.getId().equals( groupId ) )
+ {
+ groupToRemove = group;
+ break;
+ }
+ }
+ parent.getGroups().remove( groupToRemove );
+ AdminGroupWindow.this.userClose();
+ parent.update();
+ }
+ } ) );
+ }
+ };
+
+ /**
+ * Create a new <code>AdminGroupWindow</code>.
+ *
+ * @param parent the <code>AdminGroupsWindow</code> parent.
+ * @param groupId the <code>Group</code> ID.
+ */
+ public AdminGroupWindow( AdminGroupsWindow parent, String groupId )
+ {
+ super();
+
+ // check if the user that try to access this window is the admin
+ if ( !KalumetConsoleApplication.getApplication().getUserid().equals( "admin" ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "groups.warn.restricted" ) );
+ return;
+ }
+
+ // update the original group id and parent admin groups window
+ this.parent = parent;
+ this.groupId = groupId;
+
+ // update the group object from groups parent list
+ for ( Iterator groupIterator = parent.getGroups().iterator(); groupIterator.hasNext(); )
+ {
+ Group current = (Group) groupIterator.next();
+ if ( current.getId().equals( groupId ) )
+ {
+ this.group = current;
+ break;
+ }
+ }
+ if ( this.group == null )
+ {
+ this.group = new Group();
+ }
+
+ if ( groupId == null )
+ {
+ setTitle( Messages.getString( "group" ) );
+ }
+ else
+ {
+ setTitle( Messages.getString( "group" ) + " " + groupId );
+ }
+ setIcon( Styles.GROUP );
+ setId( "groupwindow_" + groupId );
+ setStyleName( "group" );
+ setModal( false );
+ setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
+
+ // create a split pane for the control buttons
+ SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
+ add( splitPane );
+
+ // add the control pane
+ Row controlRow = new Row();
+ controlRow.setStyleName( "control" );
+ splitPane.add( controlRow );
+ // add the refresh button
+ Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
+ refreshButton.setStyleName( "control" );
+ refreshButton.addActionListener( refreshActionListener );
+ controlRow.add( refreshButton );
+ // add the delete button
+ Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
+ deleteButton.setStyleName( "control" );
+ deleteButton.addActionListener( delete );
+ controlRow.add( deleteButton );
+ // add the apply button
+ Button applyButton = new Button( Messages.getString( "apply" ), Styles.DATABASE_GO );
+ applyButton.setStyleName( "control" );
+ applyButton.addActionListener( applyActionListener );
+ controlRow.add( applyButton );
+ // add the close button
+ Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
+ closeButton.setStyleName( "control" );
+ closeButton.addActionListener( close );
+ controlRow.add( closeButton );
+
+ // content column pane
+ Column content = new Column();
+ content.setStyleName( "group" );
+ splitPane.add( content );
+
+ // layout grid
+ Grid layoutGrid = new Grid( 2 );
+ layoutGrid.setStyleName( "default" );
+ layoutGrid.setColumnWidth( 0, new Extent( 15, Extent.PERCENT ) );
+ layoutGrid.setColumnWidth( 1, new Extent( 85, Extent.PERCENT ) );
+ content.add( layoutGrid );
+
+ // add the group id field
+ Label idLabel = new Label( Messages.getString( "id" ) );
+ idLabel.setStyleName( "default" );
+ layoutGrid.add( idLabel );
+ idField = new TextField();
+ idField.setStyleName( "default" );
+ idField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ layoutGrid.add( idField );
+
+ // add the group name field
+ Label nameLabel = new Label( Messages.getString( "name" ) );
+ nameLabel.setStyleName( "default" );
+ layoutGrid.add( nameLabel );
+ nameField = new TextField();
+ nameField.setStyleName( "default" );
+ nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ layoutGrid.add( nameField );
+
+ // add the members header
+ Label membersHeader = new Label( Messages.getString( "members" ) );
+ membersHeader.setStyleName( "default" );
+ layoutGrid.add( membersHeader );
+
+ // grid members
+ Grid membersGrid = new Grid( 2 );
+ membersGrid.setStyleName( "default" );
+ membersGrid.setWidth( new Extent( 100, Extent.PERCENT ) );
+ membersGrid.setColumnWidth( 0, new Extent( 50, Extent.PERCENT ) );
+ membersGrid.setColumnWidth( 1, new Extent( 50, Extent.PERCENT ) );
+ content.add( membersGrid );
+
+ // membersBox
+ membersBox = new ListBox();
+ membersBox.setStyleName( "default" );
+ membersBox.setHeight( new Extent( 200, Extent.PX ) );
+ membersBox.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
+ membersGrid.add( membersBox );
+ // usersBox
+ usersBox = new ListBox();
+ usersBox.setStyleName( "default" );
+ usersBox.setHeight( new Extent( 200, Extent.PX ) );
+ usersBox.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
+ membersGrid.add( usersBox );
+ // add user member button
+ Button addMemberButton = new Button( Styles.ARROW_LEFT );
+ addMemberButton.setStyleName( "group.member.add" );
+ addMemberButton.addActionListener( addMemberActionListener );
+ membersGrid.add( addMemberButton );
+ // add delete member button
+ Button deleteMemberButton = new Button( Styles.ARROW_RIGHT );
+ deleteMemberButton.setStyleName( "group.member.delete" );
+ deleteMemberButton.addActionListener( deleteMemberActionListener );
+ membersGrid.add( deleteMemberButton );
+
+ // update fields/boxes value
+ update();
}
- }
+
+ /**
+ * Update the group fields/boxes
+ */
+ public void update()
+ {
+ idField.setText( group.getId() );
+ nameField.setText( group.getName() );
+
+ // update the members box
+ DefaultListModel membersBoxModel = (DefaultListModel) membersBox.getModel();
+ membersBoxModel.removeAll();
+ for ( Iterator memberIterator = group.getUsers().iterator(); memberIterator.hasNext(); )
+ {
+ User member = (User) memberIterator.next();
+ membersBoxModel.add( member.getId() );
+ }
+
+ // update the users box
+ DefaultListModel usersBoxModel = (DefaultListModel) usersBox.getModel();
+ usersBoxModel.removeAll();
+
+ // load Kalumet configuration
+ Kalumet kalumet = null;
+ try
+ {
+ kalumet = ConfigurationManager.loadStore();
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage() );
+ return;
+ }
+
+ for ( Iterator userIterator = kalumet.getSecurity().getUsers().iterator(); userIterator.hasNext(); )
+ {
+ User user = (User) userIterator.next();
+ // check if the user is not already a group member
+ boolean find = false;
+ for ( Iterator memberIterator = group.getUsers().iterator(); memberIterator.hasNext(); )
+ {
+ User member = (User) memberIterator.next();
+ if ( member.getId().equals( user.getId() ) )
+ {
+ find = true;
+ }
+ }
+ if ( !find )
+ {
+ usersBoxModel.add( user.getId() );
+ }
+ }
+ }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminGroupsWindow.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminGroupsWindow.java
index e6bd700..6e7c302 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminGroupsWindow.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminGroupsWindow.java
@@ -42,289 +42,291 @@
* Admin groups window.
*/
public class AdminGroupsWindow
- extends WindowPane
+ extends WindowPane
{
- // attributes
- private List groups;
+ // attributes
+ private List groups;
- private Grid groupsGrid;
+ private Grid groupsGrid;
- // close
- private ActionListener close = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // close
+ private ActionListener close = new ActionListener()
{
- AdminGroupsWindow.this.userClose();
- }
- };
-
- // refresh
- private ActionListener refresh = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // load Kalumet configuration
- Kalumet kalumet = null;
- try
- {
- kalumet = ConfigurationManager.loadStore();
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage() );
- return;
- }
- groups = kalumet.getSecurity().getGroups();
- update();
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- Messages.getString( "groups" ) + " " + Messages.getString( "reloaded" ) );
- }
- };
-
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- if ( event.getActionCommand().equals( "admin" ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "groups.admin" ) );
- return;
- }
- // display a confirm window
- final String groupId = event.getActionCommand();
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- Group groupToRemove = null;
- for ( Iterator groupIterator = groups.iterator(); groupIterator.hasNext(); )
+ AdminGroupsWindow.this.userClose();
+ }
+ };
+
+ // refresh
+ private ActionListener refresh = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = null;
+ try
{
- Group current = (Group) groupIterator.next();
- if ( current.getId().equals( groupId ) )
- {
- groupToRemove = current;
- break;
- }
+ kalumet = ConfigurationManager.loadStore();
}
- groups.remove( groupToRemove );
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage() );
+ return;
+ }
+ groups = kalumet.getSecurity().getGroups();
update();
- }
- } ) );
- }
- };
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ Messages.getString( "groups" ) + " " + Messages.getString( "reloaded" ) );
+ }
+ };
- // save
- private ActionListener save = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // delete
+ private ActionListener delete = new ActionListener()
{
- // load Kalumet configuration
- Kalumet kalumet = null;
- try
- {
- kalumet = ConfigurationManager.loadStore();
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage() );
- return;
- }
- // update the groups list in Kalumet
- kalumet.getSecurity().setGroups( (LinkedList) groups );
- // write the XML file
- try
- {
- ConfigurationManager.writeStore( kalumet );
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.write" ) + ": " + e.getMessage() );
- return;
- }
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm( Messages.getString( "groups.saved" ) );
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ if ( event.getActionCommand().equals( "admin" ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "groups.admin" ) );
+ return;
+ }
+ // display a confirm window
+ final String groupId = event.getActionCommand();
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ Group groupToRemove = null;
+ for ( Iterator groupIterator = groups.iterator(); groupIterator.hasNext(); )
+ {
+ Group current = (Group) groupIterator.next();
+ if ( current.getId().equals( groupId ) )
+ {
+ groupToRemove = current;
+ break;
+ }
+ }
+ groups.remove( groupToRemove );
+ update();
+ }
+ } ) );
+ }
+ };
- // edit
- private ActionListener edit = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // save
+ private ActionListener save = new ActionListener()
{
- if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getComponent(
- "groupwindow_" + event.getActionCommand() ) == null )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new AdminGroupWindow( AdminGroupsWindow.this, event.getActionCommand() ) );
- }
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = null;
+ try
+ {
+ kalumet = ConfigurationManager.loadStore();
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage() );
+ return;
+ }
+ // update the groups list in Kalumet
+ kalumet.getSecurity().setGroups( (LinkedList) groups );
+ // write the XML file
+ try
+ {
+ ConfigurationManager.writeStore( kalumet );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.write" ) + ": " + e.getMessage() );
+ return;
+ }
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm( Messages.getString( "groups.saved" ) );
+ }
+ };
- // create
- private ActionListener create = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // edit
+ private ActionListener edit = new ActionListener()
{
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new AdminGroupWindow( AdminGroupsWindow.this, null ) );
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getComponent(
+ "groupwindow_" + event.getActionCommand() ) == null )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new AdminGroupWindow( AdminGroupsWindow.this, event.getActionCommand() ) );
+ }
+ }
+ };
- /**
- * Create a new <code>AdminGroupsWindow</code>.
- */
- public AdminGroupsWindow()
- {
- super();
-
- // check if the user that try to access this window is the admin
- if ( !KalumetConsoleApplication.getApplication().getUserid().equals( "admin" ) )
+ // create
+ private ActionListener create = new ActionListener()
{
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "groups.restricted" ) );
- this.userClose();
- return;
- }
+ public void actionPerformed( ActionEvent event )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new AdminGroupWindow( AdminGroupsWindow.this, null ) );
+ }
+ };
- // load Kalumet configuration
- Kalumet kalumet = null;
- try
+ /**
+ * Create a new <code>AdminGroupsWindow</code>.
+ */
+ public AdminGroupsWindow()
{
- kalumet = ConfigurationManager.loadStore();
+ super();
+
+ // check if the user that try to access this window is the admin
+ if ( !KalumetConsoleApplication.getApplication().getUserid().equals( "admin" ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "groups.restricted" ) );
+ this.userClose();
+ return;
+ }
+
+ // load Kalumet configuration
+ Kalumet kalumet = null;
+ try
+ {
+ kalumet = ConfigurationManager.loadStore();
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage() );
+ this.userClose();
+ return;
+ }
+ this.groups = kalumet.getSecurity().getGroups();
+ Collections.sort( this.groups );
+
+ setTitle( Messages.getString( "groups" ) );
+ setIcon( Styles.GROUP );
+ setStyleName( "groups" );
+ setId( "groupswindow" );
+ setModal( false );
+ setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
+
+ // create a split pane for the control buttons
+ SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
+ add( splitPane );
+
+ // add the control pane
+ Row controlRow = new Row();
+ controlRow.setStyleName( "control" );
+ splitPane.add( controlRow );
+ // add the refresh button
+ Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
+ refreshButton.addActionListener( refresh );
+ refreshButton.setStyleName( "control" );
+ controlRow.add( refreshButton );
+ // add the save button
+ Button saveButton = new Button( Messages.getString( "save" ), Styles.DATABASE_SAVE );
+ saveButton.addActionListener( save );
+ saveButton.setStyleName( "control" );
+ controlRow.add( saveButton );
+ // add the close button
+ Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
+ closeButton.addActionListener( close );
+ closeButton.setStyleName( "control" );
+ controlRow.add( closeButton );
+
+ // add the column main pane
+ Column content = new Column();
+ content.setStyleName( "groups" );
+ splitPane.add( content );
+
+ // add a create group button
+ Row row = new Row();
+ content.add( row );
+ Button createGroupButton = new Button( Messages.getString( "group.add" ), Styles.GROUP_ADD );
+ createGroupButton.setToolTipText( Messages.getString( "add" ) );
+ createGroupButton.addActionListener( create );
+ row.add( createGroupButton );
+
+ // add the groups list grid
+ groupsGrid = new Grid( 4 );
+ groupsGrid.setStyleName( "border.grid" );
+ groupsGrid.setColumnWidth( 0, new Extent( 18, Extent.PX ) );
+ groupsGrid.setColumnWidth( 1, new Extent( 33, Extent.PERCENT ) );
+ groupsGrid.setColumnWidth( 2, new Extent( 33, Extent.PERCENT ) );
+ groupsGrid.setColumnWidth( 3, new Extent( 33, Extent.PERCENT ) );
+ content.add( groupsGrid );
+
+ // update groups grid
+ update();
}
- catch ( Exception e )
+
+ /**
+ * Update the pane.
+ */
+ protected void update()
{
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage() );
- this.userClose();
- return;
+ // delete all groups grid child
+ groupsGrid.removeAll();
+
+ // add grid headers
+ Label groupActionHeader = new Label( " " );
+ groupActionHeader.setStyleName( "grid.header" );
+ groupsGrid.add( groupActionHeader );
+ Label groupIdHeader = new Label( Messages.getString( "id" ) );
+ groupIdHeader.setStyleName( "grid.header" );
+ groupsGrid.add( groupIdHeader );
+ Label groupNameHeader = new Label( Messages.getString( "name" ) );
+ groupNameHeader.setStyleName( "grid.header" );
+ groupsGrid.add( groupNameHeader );
+ Label groupMembersHeader = new Label( Messages.getString( "members" ) );
+ groupMembersHeader.setStyleName( "grid.header" );
+ groupsGrid.add( groupMembersHeader );
+
+ // add groups
+ for ( Iterator groupIterator = groups.iterator(); groupIterator.hasNext(); )
+ {
+ Group currentGroup = (Group) groupIterator.next();
+ // action row with group id
+ Row row = new Row();
+ row.setStyleName( "grid.cell" );
+ groupsGrid.add( row );
+ Button deleteButton = new Button( Styles.GROUP_DELETE );
+ deleteButton.addActionListener( delete );
+ deleteButton.setActionCommand( currentGroup.getId() );
+ deleteButton.setToolTipText( Messages.getString( "delete" ) );
+ row.add( deleteButton );
+ // id
+ Button groupId = new Button( currentGroup.getId() );
+ groupId.addActionListener( edit );
+ groupId.setActionCommand( currentGroup.getId() );
+ groupId.setStyleName( "grid.cell" );
+ groupsGrid.add( groupId );
+ // group name
+ Label groupNameLabel = new Label( currentGroup.getName() );
+ groupNameLabel.setStyleName( "grid.cell" );
+ groupsGrid.add( groupNameLabel );
+ // group members
+ Column membersPane = new Column();
+ membersPane.setStyleName( "grid.cell" );
+ groupsGrid.add( membersPane );
+ for ( Iterator userIterator = currentGroup.getUsers().iterator(); userIterator.hasNext(); )
+ {
+ User currentUser = (User) userIterator.next();
+ Label member = new Label( currentUser.getName() + " (" + currentUser.getId() + ")" );
+ member.setStyleName( "default" );
+ membersPane.add( member );
+ }
+ }
}
- this.groups = kalumet.getSecurity().getGroups();
- Collections.sort( this.groups );
- setTitle( Messages.getString( "groups" ) );
- setIcon( Styles.GROUP );
- setStyleName( "groups" );
- setId( "groupswindow" );
- setModal( false );
- setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
-
- // create a split pane for the control buttons
- SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
- add( splitPane );
-
- // add the control pane
- Row controlRow = new Row();
- controlRow.setStyleName( "control" );
- splitPane.add( controlRow );
- // add the refresh button
- Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
- refreshButton.addActionListener( refresh );
- refreshButton.setStyleName( "control" );
- controlRow.add( refreshButton );
- // add the save button
- Button saveButton = new Button( Messages.getString( "save" ), Styles.DATABASE_SAVE );
- saveButton.addActionListener( save );
- saveButton.setStyleName( "control" );
- controlRow.add( saveButton );
- // add the close button
- Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
- closeButton.addActionListener( close );
- closeButton.setStyleName( "control" );
- controlRow.add( closeButton );
-
- // add the column main pane
- Column content = new Column();
- content.setStyleName( "groups" );
- splitPane.add( content );
-
- // add a create group button
- Row row = new Row();
- content.add( row );
- Button createGroupButton = new Button( Messages.getString( "group.add" ), Styles.GROUP_ADD );
- createGroupButton.setToolTipText( Messages.getString( "add" ) );
- createGroupButton.addActionListener( create );
- row.add( createGroupButton );
-
- // add the groups list grid
- groupsGrid = new Grid( 4 );
- groupsGrid.setStyleName( "border.grid" );
- groupsGrid.setColumnWidth( 0, new Extent( 18, Extent.PX ) );
- groupsGrid.setColumnWidth( 1, new Extent( 33, Extent.PERCENT ) );
- groupsGrid.setColumnWidth( 2, new Extent( 33, Extent.PERCENT ) );
- groupsGrid.setColumnWidth( 3, new Extent( 33, Extent.PERCENT ) );
- content.add( groupsGrid );
-
- // update groups grid
- update();
- }
-
- /**
- * Update the pane.
- */
- protected void update()
- {
- // delete all groups grid child
- groupsGrid.removeAll();
-
- // add grid headers
- Label groupActionHeader = new Label( " " );
- groupActionHeader.setStyleName( "grid.header" );
- groupsGrid.add( groupActionHeader );
- Label groupIdHeader = new Label( Messages.getString( "id" ) );
- groupIdHeader.setStyleName( "grid.header" );
- groupsGrid.add( groupIdHeader );
- Label groupNameHeader = new Label( Messages.getString( "name" ) );
- groupNameHeader.setStyleName( "grid.header" );
- groupsGrid.add( groupNameHeader );
- Label groupMembersHeader = new Label( Messages.getString( "members" ) );
- groupMembersHeader.setStyleName( "grid.header" );
- groupsGrid.add( groupMembersHeader );
-
- // add groups
- for ( Iterator groupIterator = groups.iterator(); groupIterator.hasNext(); )
+ protected List getGroups()
{
- Group currentGroup = (Group) groupIterator.next();
- // action row with group id
- Row row = new Row();
- row.setStyleName( "grid.cell" );
- groupsGrid.add( row );
- Button deleteButton = new Button( Styles.GROUP_DELETE );
- deleteButton.addActionListener( delete );
- deleteButton.setActionCommand( currentGroup.getId() );
- deleteButton.setToolTipText( Messages.getString( "delete" ) );
- row.add( deleteButton );
- // id
- Button groupId = new Button( currentGroup.getId() );
- groupId.addActionListener( edit );
- groupId.setActionCommand( currentGroup.getId() );
- groupId.setStyleName( "grid.cell" );
- groupsGrid.add( groupId );
- // group name
- Label groupNameLabel = new Label( currentGroup.getName() );
- groupNameLabel.setStyleName( "grid.cell" );
- groupsGrid.add( groupNameLabel );
- // group members
- Column membersPane = new Column();
- membersPane.setStyleName( "grid.cell" );
- groupsGrid.add( membersPane );
- for ( Iterator userIterator = currentGroup.getUsers().iterator(); userIterator.hasNext(); )
- {
- User currentUser = (User) userIterator.next();
- Label member = new Label( currentUser.getName() + " (" + currentUser.getId() + ")" );
- member.setStyleName( "default" );
- membersPane.add( member );
- }
+ return this.groups;
}
- }
-
- protected List getGroups()
- {
- return this.groups;
- }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminUserWindow.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminUserWindow.java
index 64e2591..8726a5b 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminUserWindow.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminUserWindow.java
@@ -37,313 +37,314 @@
* Admin user window.
*/
public class AdminUserWindow
- extends WindowPane
+ extends WindowPane
{
- // attributes
- private String userId;
+ // attributes
+ private String userId;
- private User user = null;
+ private User user = null;
- private AdminUsersWindow parent;
+ private AdminUsersWindow parent;
- private TextField userIdField;
+ private TextField userIdField;
- private TextField userNameField;
+ private TextField userNameField;
- private TextField userEmailField;
+ private TextField userEmailField;
- private PasswordField userPasswordField;
+ private PasswordField userPasswordField;
- private PasswordField userConfirmPasswordField;
+ private PasswordField userConfirmPasswordField;
- // close action listener
- private ActionListener closeActionListener = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // close action listener
+ private ActionListener closeActionListener = new ActionListener()
{
- AdminUserWindow.this.userClose();
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ AdminUserWindow.this.userClose();
+ }
+ };
- // refresh action listener
- private ActionListener refreshActionListener = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // refresh action listener
+ private ActionListener refreshActionListener = new ActionListener()
{
- for ( Iterator userIterator = parent.getUsers().iterator(); userIterator.hasNext(); )
- {
- User current = (User) userIterator.next();
- if ( current.getId().equals( userId ) )
+ public void actionPerformed( ActionEvent event )
{
- user = current;
- break;
- }
- }
- if ( user == null )
- {
- user = new User();
- }
- update();
- }
- };
-
- // apply action listener
- private ActionListener applyActionListener = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- String userNewId = userIdField.getText().trim();
- String userName = userNameField.getText().trim();
- String userEmail = userEmailField.getText().trim();
- String userPassword = userPasswordField.getText().trim();
- String userConfirmPassword = userConfirmPasswordField.getText().trim();
- String userPasswordCrypted = null;
-
- // check fields
- // user id mandatory
- if ( userNewId.length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ErrorWindow( Messages.getString( "AdminUserWindow.Error.Save" ),
- Messages.getString( "AdminUserWindow.Error.EmptyUserId" ) ) );
- return;
- }
- // password must match confirm password is not empty
- if ( userPassword.length() > 0 && !userPassword.equals( userConfirmPassword ) )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ErrorWindow( Messages.getString( "AdminUserWindow.Error.Save" ),
- Messages.getString( "AdminUserWindow.Error.PasswordMatch" ) ) );
- return;
- }
- // crypt password
- if ( userPassword.length() > 0 )
- {
- try
- {
- userPasswordCrypted = User.md5PasswordCrypt( userPassword );
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ErrorWindow( Messages.getString( "AdminUserWindow.Error.PasswordCrypt" ), e.getMessage() ) );
- return;
- }
- }
- // if the admin change the user id or if it's a new user, check if the
- // id is not already used
- if ( userId == null || userId.trim().length() < 1 || ( ( userId != null ) && ( userId.trim().length() > 0 )
- && ( !userNewId.equals( userId ) ) ) )
- {
- for ( Iterator userIterator = parent.getUsers().iterator(); userIterator.hasNext(); )
- {
- User current = (User) userIterator.next();
- if ( current.getId().equals( userNewId ) )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ErrorWindow( Messages.getString( "AdminUserWindow.Error.Add" ),
- Messages.getString( "AdminUserWindow.Error.UserIdAlreadyExists" ) ) );
- return;
- }
- }
- }
-
- // update the current user
- user.setId( userNewId );
- user.setName( userName );
- user.setEmail( userEmail );
- if ( userPasswordCrypted != null )
- {
- user.setPassword( userPasswordCrypted );
- }
- if ( userId == null || userId.trim().length() < 1 )
- {
- // it's a new user
- parent.getUsers().add( user );
- }
- setTitle( Messages.getString( "AdminUserWindow.Title" ) + " " + user.getId() );
- setId( "adminUserWindow_" + user.getId() );
- userId = user.getId();
- parent.update();
- }
- };
-
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // display a confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // looking for the agent to remove
- User userToRemove = null;
for ( Iterator userIterator = parent.getUsers().iterator(); userIterator.hasNext(); )
{
- User user = (User) userIterator.next();
- if ( user.getId().equals( userId ) )
- {
- userToRemove = user;
- break;
- }
+ User current = (User) userIterator.next();
+ if ( current.getId().equals( userId ) )
+ {
+ user = current;
+ break;
+ }
}
- parent.getUsers().remove( userToRemove );
- AdminUserWindow.this.userClose();
+ if ( user == null )
+ {
+ user = new User();
+ }
+ update();
+ }
+ };
+
+ // apply action listener
+ private ActionListener applyActionListener = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ String userNewId = userIdField.getText().trim();
+ String userName = userNameField.getText().trim();
+ String userEmail = userEmailField.getText().trim();
+ String userPassword = userPasswordField.getText().trim();
+ String userConfirmPassword = userConfirmPasswordField.getText().trim();
+ String userPasswordCrypted = null;
+
+ // check fields
+ // user id mandatory
+ if ( userNewId.length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ErrorWindow( Messages.getString( "AdminUserWindow.Error.Save" ),
+ Messages.getString( "AdminUserWindow.Error.EmptyUserId" ) ) );
+ return;
+ }
+ // password must match confirm password is not empty
+ if ( userPassword.length() > 0 && !userPassword.equals( userConfirmPassword ) )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ErrorWindow( Messages.getString( "AdminUserWindow.Error.Save" ),
+ Messages.getString( "AdminUserWindow.Error.PasswordMatch" ) ) );
+ return;
+ }
+ // crypt password
+ if ( userPassword.length() > 0 )
+ {
+ try
+ {
+ userPasswordCrypted = User.md5PasswordCrypt( userPassword );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ErrorWindow( Messages.getString( "AdminUserWindow.Error.PasswordCrypt" ),
+ e.getMessage() ) );
+ return;
+ }
+ }
+ // if the admin change the user id or if it's a new user, check if the
+ // id is not already used
+ if ( userId == null || userId.trim().length() < 1 || ( ( userId != null ) && ( userId.trim().length() > 0 )
+ && ( !userNewId.equals( userId ) ) ) )
+ {
+ for ( Iterator userIterator = parent.getUsers().iterator(); userIterator.hasNext(); )
+ {
+ User current = (User) userIterator.next();
+ if ( current.getId().equals( userNewId ) )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ErrorWindow( Messages.getString( "AdminUserWindow.Error.Add" ),
+ Messages.getString( "AdminUserWindow.Error.UserIdAlreadyExists" ) ) );
+ return;
+ }
+ }
+ }
+
+ // update the current user
+ user.setId( userNewId );
+ user.setName( userName );
+ user.setEmail( userEmail );
+ if ( userPasswordCrypted != null )
+ {
+ user.setPassword( userPasswordCrypted );
+ }
+ if ( userId == null || userId.trim().length() < 1 )
+ {
+ // it's a new user
+ parent.getUsers().add( user );
+ }
+ setTitle( Messages.getString( "AdminUserWindow.Title" ) + " " + user.getId() );
+ setId( "adminUserWindow_" + user.getId() );
+ userId = user.getId();
parent.update();
- }
- } ) );
- }
- };
+ }
+ };
- /**
- * Create a new <code>AdminUserWindow</code>.
- *
- * @param parent the <code>AdminUsersWindow</code> parent.
- * @param userId the <code>User</code> ID.
- */
- public AdminUserWindow( AdminUsersWindow parent, String userId )
- {
- super();
-
- // check if the user that try to access this window is the admin
- if ( !KalumetConsoleApplication.getApplication().getUserid().equals( "admin" ) )
+ // delete
+ private ActionListener delete = new ActionListener()
{
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "uses.warn.restricted" ) );
- return;
- }
+ public void actionPerformed( ActionEvent event )
+ {
+ // display a confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // looking for the agent to remove
+ User userToRemove = null;
+ for ( Iterator userIterator = parent.getUsers().iterator(); userIterator.hasNext(); )
+ {
+ User user = (User) userIterator.next();
+ if ( user.getId().equals( userId ) )
+ {
+ userToRemove = user;
+ break;
+ }
+ }
+ parent.getUsers().remove( userToRemove );
+ AdminUserWindow.this.userClose();
+ parent.update();
+ }
+ } ) );
+ }
+ };
- // update the original user id and parent admin users window
- this.parent = parent;
- this.userId = userId;
-
- // update the user object from users parent list
- for ( Iterator userIterator = parent.getUsers().iterator(); userIterator.hasNext(); )
+ /**
+ * Create a new <code>AdminUserWindow</code>.
+ *
+ * @param parent the <code>AdminUsersWindow</code> parent.
+ * @param userId the <code>User</code> ID.
+ */
+ public AdminUserWindow( AdminUsersWindow parent, String userId )
{
- User current = (User) userIterator.next();
- if ( current.getId().equals( userId ) )
- {
- this.user = current;
- break;
- }
+ super();
+
+ // check if the user that try to access this window is the admin
+ if ( !KalumetConsoleApplication.getApplication().getUserid().equals( "admin" ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "uses.warn.restricted" ) );
+ return;
+ }
+
+ // update the original user id and parent admin users window
+ this.parent = parent;
+ this.userId = userId;
+
+ // update the user object from users parent list
+ for ( Iterator userIterator = parent.getUsers().iterator(); userIterator.hasNext(); )
+ {
+ User current = (User) userIterator.next();
+ if ( current.getId().equals( userId ) )
+ {
+ this.user = current;
+ break;
+ }
+ }
+ if ( this.user == null )
+ {
+ this.user = new User();
+ }
+
+ if ( userId == null )
+ {
+ setTitle( Messages.getString( "user" ) );
+ }
+ else
+ {
+ setTitle( Messages.getString( "user" ) + " " + userId );
+ }
+ setId( "user_" + userId );
+ setStyleName( "user" );
+ setModal( false );
+ setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
+
+ // create a split pane for the control buttons
+ SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
+ add( splitPane );
+
+ // add the control pane
+ Row controlRow = new Row();
+ controlRow.setStyleName( "control" );
+ splitPane.add( controlRow );
+ // add the refresh button
+ Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
+ refreshButton.setStyleName( "control" );
+ refreshButton.addActionListener( refreshActionListener );
+ controlRow.add( refreshButton );
+ // add the delete button
+ Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
+ deleteButton.setStyleName( "control" );
+ deleteButton.addActionListener( delete );
+ controlRow.add( deleteButton );
+ // add the apply button
+ Button applyButton = new Button( Messages.getString( "apply" ), Styles.DATABASE_GO );
+ applyButton.setStyleName( "control" );
+ applyButton.addActionListener( applyActionListener );
+ controlRow.add( applyButton );
+ // add the close button
+ Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
+ closeButton.setStyleName( "control" );
+ closeButton.addActionListener( closeActionListener );
+ controlRow.add( closeButton );
+
+ // layout grid
+ Grid layoutGrid = new Grid( 2 );
+ layoutGrid.setStyleName( "default" );
+ layoutGrid.setColumnWidth( 0, new Extent( 15, Extent.PERCENT ) );
+ layoutGrid.setColumnWidth( 1, new Extent( 85, Extent.PERCENT ) );
+ splitPane.add( layoutGrid );
+
+ // add the user id field
+ Label userIdLabel = new Label( Messages.getString( "id" ) );
+ userIdLabel.setStyleName( "default" );
+ layoutGrid.add( userIdLabel );
+ userIdField = new TextField();
+ userIdField.setStyleName( "default" );
+ userIdField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ layoutGrid.add( userIdField );
+
+ // add the user name field
+ Label userNameLabel = new Label( Messages.getString( "name" ) );
+ userNameLabel.setStyleName( "default" );
+ layoutGrid.add( userNameLabel );
+ userNameField = new TextField();
+ userNameField.setStyleName( "default" );
+ userNameField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ layoutGrid.add( userNameField );
+
+ // add the user e-mail field
+ Label userEmailLabel = new Label( Messages.getString( "email" ) );
+ userEmailLabel.setStyleName( "default" );
+ layoutGrid.add( userEmailLabel );
+ userEmailField = new TextField();
+ userEmailField.setStyleName( "default" );
+ userEmailField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ layoutGrid.add( userEmailField );
+
+ // add the user password field
+ Label userPasswordLabel = new Label( Messages.getString( "password" ) );
+ userPasswordLabel.setStyleName( "default" );
+ layoutGrid.add( userPasswordLabel );
+ userPasswordField = new PasswordField();
+ userPasswordField.setStyleName( "default" );
+ userPasswordField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ layoutGrid.add( userPasswordField );
+
+ // add the user confirm password field
+ Label userConfirmPasswordLabel = new Label( Messages.getString( "confirm" ) );
+ userConfirmPasswordLabel.setStyleName( "default" );
+ layoutGrid.add( userConfirmPasswordLabel );
+ userConfirmPasswordField = new PasswordField();
+ userConfirmPasswordField.setStyleName( "default" );
+ userConfirmPasswordField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ layoutGrid.add( userConfirmPasswordField );
+
+ // update fields value
+ update();
}
- if ( this.user == null )
+
+ /**
+ * Update the fields value
+ */
+ protected void update()
{
- this.user = new User();
+ userIdField.setText( user.getId() );
+ userNameField.setText( user.getName() );
+ userEmailField.setText( user.getEmail() );
+ userPasswordField.setText( null );
+ userConfirmPasswordField.setText( null );
}
- if ( userId == null )
- {
- setTitle( Messages.getString( "user" ) );
- }
- else
- {
- setTitle( Messages.getString( "user" ) + " " + userId );
- }
- setId( "user_" + userId );
- setStyleName( "user" );
- setModal( false );
- setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
-
- // create a split pane for the control buttons
- SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
- add( splitPane );
-
- // add the control pane
- Row controlRow = new Row();
- controlRow.setStyleName( "control" );
- splitPane.add( controlRow );
- // add the refresh button
- Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
- refreshButton.setStyleName( "control" );
- refreshButton.addActionListener( refreshActionListener );
- controlRow.add( refreshButton );
- // add the delete button
- Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
- deleteButton.setStyleName( "control" );
- deleteButton.addActionListener( delete );
- controlRow.add( deleteButton );
- // add the apply button
- Button applyButton = new Button( Messages.getString( "apply" ), Styles.DATABASE_GO );
- applyButton.setStyleName( "control" );
- applyButton.addActionListener( applyActionListener );
- controlRow.add( applyButton );
- // add the close button
- Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
- closeButton.setStyleName( "control" );
- closeButton.addActionListener( closeActionListener );
- controlRow.add( closeButton );
-
- // layout grid
- Grid layoutGrid = new Grid( 2 );
- layoutGrid.setStyleName( "default" );
- layoutGrid.setColumnWidth( 0, new Extent( 15, Extent.PERCENT ) );
- layoutGrid.setColumnWidth( 1, new Extent( 85, Extent.PERCENT ) );
- splitPane.add( layoutGrid );
-
- // add the user id field
- Label userIdLabel = new Label( Messages.getString( "id" ) );
- userIdLabel.setStyleName( "default" );
- layoutGrid.add( userIdLabel );
- userIdField = new TextField();
- userIdField.setStyleName( "default" );
- userIdField.setWidth( new Extent( 100, Extent.PERCENT ) );
- layoutGrid.add( userIdField );
-
- // add the user name field
- Label userNameLabel = new Label( Messages.getString( "name" ) );
- userNameLabel.setStyleName( "default" );
- layoutGrid.add( userNameLabel );
- userNameField = new TextField();
- userNameField.setStyleName( "default" );
- userNameField.setWidth( new Extent( 100, Extent.PERCENT ) );
- layoutGrid.add( userNameField );
-
- // add the user e-mail field
- Label userEmailLabel = new Label( Messages.getString( "email" ) );
- userEmailLabel.setStyleName( "default" );
- layoutGrid.add( userEmailLabel );
- userEmailField = new TextField();
- userEmailField.setStyleName( "default" );
- userEmailField.setWidth( new Extent( 100, Extent.PERCENT ) );
- layoutGrid.add( userEmailField );
-
- // add the user password field
- Label userPasswordLabel = new Label( Messages.getString( "password" ) );
- userPasswordLabel.setStyleName( "default" );
- layoutGrid.add( userPasswordLabel );
- userPasswordField = new PasswordField();
- userPasswordField.setStyleName( "default" );
- userPasswordField.setWidth( new Extent( 100, Extent.PERCENT ) );
- layoutGrid.add( userPasswordField );
-
- // add the user confirm password field
- Label userConfirmPasswordLabel = new Label( Messages.getString( "confirm" ) );
- userConfirmPasswordLabel.setStyleName( "default" );
- layoutGrid.add( userConfirmPasswordLabel );
- userConfirmPasswordField = new PasswordField();
- userConfirmPasswordField.setStyleName( "default" );
- userConfirmPasswordField.setWidth( new Extent( 100, Extent.PERCENT ) );
- layoutGrid.add( userConfirmPasswordField );
-
- // update fields value
- update();
- }
-
- /**
- * Update the fields value
- */
- protected void update()
- {
- userIdField.setText( user.getId() );
- userNameField.setText( user.getName() );
- userEmailField.setText( user.getEmail() );
- userPasswordField.setText( null );
- userConfirmPasswordField.setText( null );
- }
-
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminUsersWindow.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminUsersWindow.java
index 441b6a3..03af8a9 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminUsersWindow.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/AdminUsersWindow.java
@@ -43,285 +43,285 @@
* @author onofre
*/
public class AdminUsersWindow
- extends WindowPane
+ extends WindowPane
{
- // attributes
- private List users;
+ // attributes
+ private List users;
- private Grid usersGrid;
+ private Grid usersGrid;
- // close action listener
- private ActionListener closeActionListener = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // close action listener
+ private ActionListener closeActionListener = new ActionListener()
{
- AdminUsersWindow.this.userClose();
- }
- };
-
- // refresh action listener
- private ActionListener refreshActionListener = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // load Kalumet configuration
- Kalumet kalumet = null;
- try
- {
- kalumet = ConfigurationManager.loadStore();
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage() );
- return;
- }
- users = kalumet.getSecurity().getUsers();
- update();
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- Messages.getString( "users" ) + " " + Messages.getString( "reloaded" ) );
- }
- };
-
- // delete action listener
- private ActionListener deleteActionListener = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- if ( event.getActionCommand().equals( "admin" ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "users.warn.admin" ) );
- return;
- }
- final String userId = event.getActionCommand();
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- User userToRemove = null;
- for ( Iterator userIterator = users.iterator(); userIterator.hasNext(); )
+ AdminUsersWindow.this.userClose();
+ }
+ };
+
+ // refresh action listener
+ private ActionListener refreshActionListener = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = null;
+ try
{
- User current = (User) userIterator.next();
- if ( current.getId().equals( userId ) )
- {
- userToRemove = current;
- break;
- }
+ kalumet = ConfigurationManager.loadStore();
}
- users.remove( userToRemove );
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage() );
+ return;
+ }
+ users = kalumet.getSecurity().getUsers();
update();
- }
- } ) );
- }
- };
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ Messages.getString( "users" ) + " " + Messages.getString( "reloaded" ) );
+ }
+ };
- // save action listener
- private ActionListener saveActionListener = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // delete action listener
+ private ActionListener deleteActionListener = new ActionListener()
{
- // load Kalumet configuration
- Kalumet kalumet = null;
- try
- {
- kalumet = ConfigurationManager.loadStore();
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage() );
- return;
- }
- // update the users list in Kalumet
- kalumet.getSecurity().setUsers( (LinkedList) users );
- // write the XML file
- try
- {
- ConfigurationManager.writeStore( kalumet );
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.write" ) + ": " + e.getMessage() );
- return;
- }
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm( Messages.getString( "users.saved" ) );
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ if ( event.getActionCommand().equals( "admin" ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "users.warn.admin" ) );
+ return;
+ }
+ final String userId = event.getActionCommand();
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ User userToRemove = null;
+ for ( Iterator userIterator = users.iterator(); userIterator.hasNext(); )
+ {
+ User current = (User) userIterator.next();
+ if ( current.getId().equals( userId ) )
+ {
+ userToRemove = current;
+ break;
+ }
+ }
+ users.remove( userToRemove );
+ update();
+ }
+ } ) );
+ }
+ };
- // edit action listener
- private ActionListener editActionListener = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // save action listener
+ private ActionListener saveActionListener = new ActionListener()
{
- if (
- KalumetConsoleApplication.getApplication().getDefaultWindow().getComponent( "user_" + event.getActionCommand() )
- == null )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new AdminUserWindow( AdminUsersWindow.this, event.getActionCommand() ) );
- }
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = null;
+ try
+ {
+ kalumet = ConfigurationManager.loadStore();
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage() );
+ return;
+ }
+ // update the users list in Kalumet
+ kalumet.getSecurity().setUsers( (LinkedList) users );
+ // write the XML file
+ try
+ {
+ ConfigurationManager.writeStore( kalumet );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.write" ) + ": " + e.getMessage() );
+ return;
+ }
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm( Messages.getString( "users.saved" ) );
+ }
+ };
- // add action listener
- private ActionListener addActionListener = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // edit action listener
+ private ActionListener editActionListener = new ActionListener()
{
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new AdminUserWindow( AdminUsersWindow.this, null ) );
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getComponent(
+ "user_" + event.getActionCommand() ) == null )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new AdminUserWindow( AdminUsersWindow.this, event.getActionCommand() ) );
+ }
+ }
+ };
- /**
- * Create a new <code>WindowPane</code>.
- */
- public AdminUsersWindow()
- {
- super();
-
- // check if the user that try to access this window is the admin
- if ( !KalumetConsoleApplication.getApplication().getUserid().equals( "admin" ) )
+ // add action listener
+ private ActionListener addActionListener = new ActionListener()
{
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "users.warn.restricted" ) );
- this.userClose();
- return;
- }
+ public void actionPerformed( ActionEvent event )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new AdminUserWindow( AdminUsersWindow.this, null ) );
+ }
+ };
- // load Kalumet configuration
- Kalumet kalumet = null;
- try
+ /**
+ * Create a new <code>WindowPane</code>.
+ */
+ public AdminUsersWindow()
{
- kalumet = ConfigurationManager.loadStore();
+ super();
+
+ // check if the user that try to access this window is the admin
+ if ( !KalumetConsoleApplication.getApplication().getUserid().equals( "admin" ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "users.warn.restricted" ) );
+ this.userClose();
+ return;
+ }
+
+ // load Kalumet configuration
+ Kalumet kalumet = null;
+ try
+ {
+ kalumet = ConfigurationManager.loadStore();
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage() );
+ this.userClose();
+ return;
+ }
+ this.users = kalumet.getSecurity().getUsers();
+ Collections.sort( this.users );
+
+ setTitle( Messages.getString( "users" ) );
+ setStyleName( "users" );
+ setIcon( Styles.USER );
+ setId( "userswindow" );
+ setModal( false );
+ setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
+
+ // create a split pane for the control buttons
+ SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
+ add( splitPane );
+
+ // add the control pane
+ Row controlRow = new Row();
+ controlRow.setStyleName( "control" );
+ splitPane.add( controlRow );
+ // add the refresh button
+ Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
+ refreshButton.setStyleName( "control" );
+ refreshButton.addActionListener( refreshActionListener );
+ controlRow.add( refreshButton );
+ // add the save button
+ Button saveButton = new Button( Messages.getString( "save" ), Styles.DATABASE_SAVE );
+ saveButton.setStyleName( "control" );
+ saveButton.addActionListener( saveActionListener );
+ controlRow.add( saveButton );
+ // add the close button
+ Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
+ closeButton.setStyleName( "control" );
+ closeButton.addActionListener( closeActionListener );
+ controlRow.add( closeButton );
+
+ // add the column main pane
+ Column content = new Column();
+ content.setStyleName( "users" );
+ splitPane.add( content );
+
+ // add button
+ Row row = new Row();
+ content.add( row );
+ Button addButton = new Button( Messages.getString( "user.add" ), Styles.USER_ADD );
+ addButton.addActionListener( addActionListener );
+ row.add( addButton );
+
+ // add the users list grid
+ usersGrid = new Grid( 4 );
+ usersGrid.setStyleName( "border.grid" );
+ usersGrid.setColumnWidth( 0, new Extent( 18, Extent.PX ) );
+ usersGrid.setColumnWidth( 1, new Extent( 33, Extent.PERCENT ) );
+ usersGrid.setColumnWidth( 2, new Extent( 33, Extent.PERCENT ) );
+ usersGrid.setColumnWidth( 3, new Extent( 33, Extent.PERCENT ) );
+ content.add( usersGrid );
+
+ // update users grid
+ update();
}
- catch ( Exception e )
+
+ protected void update()
{
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage() );
- this.userClose();
- return;
+ // delete all users grid child
+ usersGrid.removeAll();
+
+ // add grid headers
+ Label userActionHeader = new Label( " " );
+ userActionHeader.setStyleName( "grid.header" );
+ usersGrid.add( userActionHeader );
+ Label userIdHeader = new Label( Messages.getString( "id" ) );
+ userIdHeader.setStyleName( "grid.header" );
+ usersGrid.add( userIdHeader );
+ Label userNameHeader = new Label( Messages.getString( "name" ) );
+ userNameHeader.setStyleName( "grid.header" );
+ usersGrid.add( userNameHeader );
+ Label userEmailHeader = new Label( Messages.getString( "email" ) );
+ userEmailHeader.setStyleName( "grid.header" );
+ usersGrid.add( userEmailHeader );
+
+ // add users
+ for ( Iterator userIterator = users.iterator(); userIterator.hasNext(); )
+ {
+ User current = (User) userIterator.next();
+ // action row with user id
+ Row row = new Row();
+ row.setStyleName( "grid.cell" );
+ usersGrid.add( row );
+ Button deleteButton = new Button( Styles.USER_DELETE );
+ deleteButton.addActionListener( deleteActionListener );
+ deleteButton.setActionCommand( current.getId() );
+ deleteButton.setToolTipText( Messages.getString( "delete" ) );
+ row.add( deleteButton );
+ // id
+ Button userId = new Button( current.getId() );
+ userId.addActionListener( editActionListener );
+ userId.setActionCommand( current.getId() );
+ userId.setStyleName( "default" );
+ usersGrid.add( userId );
+ // user name
+ Label userNameLabel = new Label( current.getName() );
+ userNameLabel.setStyleName( "default" );
+ usersGrid.add( userNameLabel );
+ // user email
+ Label userEmailLabel = new Label( current.getEmail() );
+ userEmailLabel.setStyleName( "default" );
+ usersGrid.add( userEmailLabel );
+ }
}
- this.users = kalumet.getSecurity().getUsers();
- Collections.sort( this.users );
- setTitle( Messages.getString( "users" ) );
- setStyleName( "users" );
- setIcon( Styles.USER );
- setId( "userswindow" );
- setModal( false );
- setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
-
- // create a split pane for the control buttons
- SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
- add( splitPane );
-
- // add the control pane
- Row controlRow = new Row();
- controlRow.setStyleName( "control" );
- splitPane.add( controlRow );
- // add the refresh button
- Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
- refreshButton.setStyleName( "control" );
- refreshButton.addActionListener( refreshActionListener );
- controlRow.add( refreshButton );
- // add the save button
- Button saveButton = new Button( Messages.getString( "save" ), Styles.DATABASE_SAVE );
- saveButton.setStyleName( "control" );
- saveButton.addActionListener( saveActionListener );
- controlRow.add( saveButton );
- // add the close button
- Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
- closeButton.setStyleName( "control" );
- closeButton.addActionListener( closeActionListener );
- controlRow.add( closeButton );
-
- // add the column main pane
- Column content = new Column();
- content.setStyleName( "users" );
- splitPane.add( content );
-
- // add button
- Row row = new Row();
- content.add( row );
- Button addButton = new Button( Messages.getString( "user.add" ), Styles.USER_ADD );
- addButton.addActionListener( addActionListener );
- row.add( addButton );
-
- // add the users list grid
- usersGrid = new Grid( 4 );
- usersGrid.setStyleName( "border.grid" );
- usersGrid.setColumnWidth( 0, new Extent( 18, Extent.PX ) );
- usersGrid.setColumnWidth( 1, new Extent( 33, Extent.PERCENT ) );
- usersGrid.setColumnWidth( 2, new Extent( 33, Extent.PERCENT ) );
- usersGrid.setColumnWidth( 3, new Extent( 33, Extent.PERCENT ) );
- content.add( usersGrid );
-
- // update users grid
- update();
- }
-
- protected void update()
- {
- // delete all users grid child
- usersGrid.removeAll();
-
- // add grid headers
- Label userActionHeader = new Label( " " );
- userActionHeader.setStyleName( "grid.header" );
- usersGrid.add( userActionHeader );
- Label userIdHeader = new Label( Messages.getString( "id" ) );
- userIdHeader.setStyleName( "grid.header" );
- usersGrid.add( userIdHeader );
- Label userNameHeader = new Label( Messages.getString( "name" ) );
- userNameHeader.setStyleName( "grid.header" );
- usersGrid.add( userNameHeader );
- Label userEmailHeader = new Label( Messages.getString( "email" ) );
- userEmailHeader.setStyleName( "grid.header" );
- usersGrid.add( userEmailHeader );
-
- // add users
- for ( Iterator userIterator = users.iterator(); userIterator.hasNext(); )
+ /**
+ * Get the users list.
+ *
+ * @return the users list.
+ */
+ protected List getUsers()
{
- User current = (User) userIterator.next();
- // action row with user id
- Row row = new Row();
- row.setStyleName( "grid.cell" );
- usersGrid.add( row );
- Button deleteButton = new Button( Styles.USER_DELETE );
- deleteButton.addActionListener( deleteActionListener );
- deleteButton.setActionCommand( current.getId() );
- deleteButton.setToolTipText( Messages.getString( "delete" ) );
- row.add( deleteButton );
- // id
- Button userId = new Button( current.getId() );
- userId.addActionListener( editActionListener );
- userId.setActionCommand( current.getId() );
- userId.setStyleName( "default" );
- usersGrid.add( userId );
- // user name
- Label userNameLabel = new Label( current.getName() );
- userNameLabel.setStyleName( "default" );
- usersGrid.add( userNameLabel );
- // user email
- Label userEmailLabel = new Label( current.getEmail() );
- userEmailLabel.setStyleName( "default" );
- usersGrid.add( userEmailLabel );
+ return this.users;
}
- }
-
- /**
- * Get the users list.
- *
- * @return the users list.
- */
- protected List getUsers()
- {
- return this.users;
- }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationArchiveWindow.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationArchiveWindow.java
index 967020e..7bbfe28 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationArchiveWindow.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationArchiveWindow.java
@@ -45,827 +45,837 @@
* JEE application archive <code>WindowPane</code>.
*/
public class ApplicationArchiveWindow
- extends WindowPane
+ extends WindowPane
{
- private static String[] CLASSLOADER_ORDER =
- new String[]{ Messages.getString( "parentlast" ), Messages.getString( "parentfirst" ) };
+ private static String[] CLASSLOADER_ORDER =
+ new String[]{ Messages.getString( "parentlast" ), Messages.getString( "parentfirst" ) };
- private static String[] CLASSLOADER_POLICY =
- new String[]{ Messages.getString( "single" ), Messages.getString( "multiple" ) };
+ private static String[] CLASSLOADER_POLICY =
+ new String[]{ Messages.getString( "single" ), Messages.getString( "multiple" ) };
- private String archiveName;
+ private String archiveName;
- private Archive archive;
+ private Archive archive;
- private ApplicationArchivesPane parent;
+ private ApplicationArchivesPane parent;
- private TextField nameField;
+ private TextField nameField;
- private SelectField activeField;
+ private SelectField activeField;
- private SelectField blockerField;
+ private SelectField blockerField;
- private TextField uriField;
+ private TextField uriField;
- private TextField pathField;
+ private TextField pathField;
- private SelectField agentField;
+ private SelectField agentField;
- private SelectField classloaderOrderField;
+ private SelectField classloaderOrderField;
- private SelectField classloaderPolicyField;
+ private SelectField classloaderPolicyField;
- private TextField contextRootField;
+ private TextField contextRootField;
- private TextField virtualHostField;
+ private TextField virtualHostField;
- // status thread
- class StatusThread
- extends Thread
- {
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // status thread
+ class StatusThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent =
- kalumet.getAgent( parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
- if ( agent == null )
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent(
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the web service
+ ArchiveClient client = new ArchiveClient( agent.getHostname(), agent.getPort() );
+ boolean uptodate =
+ client.check( parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName(),
+ parent.getParentPane().getServerName(), parent.getParentPane().getApplicationName(),
+ archiveName );
+ if ( uptodate )
+ {
+ message =
+ "JEE application " + parent.getParentPane().getApplicationName() + " archive " + archiveName
+ + " is up to date.";
+ }
+ else
+ {
+ failure = true;
+ message =
+ "JEE appliction " + parent.getParentPane().getApplicationName() + " archive " + archiveName
+ + " is not up to date.";
+ }
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JEE application " + parent.getParentPane().getApplicationName() + " archive " + archiveName
+ + " status check failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- // call the web service
- ArchiveClient client = new ArchiveClient( agent.getHostname(), agent.getPort() );
- boolean uptodate =
- client.check( parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName(),
- parent.getParentPane().getServerName(), parent.getParentPane().getApplicationName(),
- archiveName );
- if ( uptodate )
+ }
+
+ // update thread
+ class UpdateThread
+ extends Thread
+ {
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- message = "JEE application " + parent.getParentPane().getApplicationName() + " archive " + archiveName
- + " is up to date.";
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent(
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the web service
+ ArchiveClient client = new ArchiveClient( agent.getHostname(), agent.getPort() );
+ client.update( parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName(),
+ parent.getParentPane().getServerName(), parent.getParentPane().getApplicationName(),
+ archiveName, false );
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JEE application " + parent.getParentPane().getApplicationName() + " archive " + archiveName
+ + " update failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- else
+ }
+
+ // refresh
+ private ActionListener refresh = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
{
- failure = true;
- message = "JEE appliction " + parent.getParentPane().getApplicationName() + " archive " + archiveName
- + " is not up to date.";
+ // looking for the archive object
+ ApplicationArchiveWindow.this.archive = parent.getParentPane().getApplication().getArchive( archiveName );
+ if ( ApplicationArchiveWindow.this.archive == null )
+ {
+ ApplicationArchiveWindow.this.archive = new Archive();
+ }
+ // update the window
+ update();
}
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JEE application " + parent.getParentPane().getApplicationName() + " archive " + archiveName
- + " status check failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
- }
- }
+ };
- // update thread
- class UpdateThread
- extends Thread
- {
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // close
+ private ActionListener close = new ActionListener()
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent =
- kalumet.getAgent( parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
- if ( agent == null )
+ public void actionPerformed( ActionEvent event )
{
- throw new IllegalArgumentException( "agent not found." );
+ ApplicationArchiveWindow.this.userClose();
}
- // call the web service
- ArchiveClient client = new ArchiveClient( agent.getHostname(), agent.getPort() );
- client.update( parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName(),
- parent.getParentPane().getServerName(), parent.getParentPane().getApplicationName(), archiveName,
- false );
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JEE application " + parent.getParentPane().getApplicationName() + " archive " + archiveName
- + " update failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
- }
- }
+ };
- // refresh
- private ActionListener refresh = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // delete
+ private ActionListener delete = new ActionListener()
{
- // looking for the archive object
- ApplicationArchiveWindow.this.archive = parent.getParentPane().getApplication().getArchive( archiveName );
- if ( ApplicationArchiveWindow.this.archive == null )
- {
- ApplicationArchiveWindow.this.archive = new Archive();
- }
- // update the window
- update();
- }
- };
-
- // close
- private ActionListener close = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- ApplicationArchiveWindow.this.userClose();
- }
- };
-
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- // delete the archive
- parent.getParentPane().getApplication().getArchives().remove( archive );
- // add a change events
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Delete JEE application archive " + archive.getName() );
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // delete the archive
+ parent.getParentPane().getApplication().getArchives().remove( archive );
+ // add a change events
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Delete JEE application archive " + archive.getName() );
+ // change the updated flag
+ parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the parent pane
+ parent.update();
+ // close the window
+ ApplicationArchiveWindow.this.userClose();
+ }
+ } ) );
+ }
+ };
+
+ // apply
+ private ActionListener apply = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get the fields value
+ String nameFieldValue = nameField.getText();
+ int activeFieldIndex = activeField.getSelectedIndex();
+ int blockerFieldIndex = blockerField.getSelectedIndex();
+ String uriFieldValue = uriField.getText();
+ String pathFieldValue = pathField.getText();
+ int classloaderOrderFieldIndex = classloaderOrderField.getSelectedIndex();
+ int classloaderPolicyFieldIndex = classloaderPolicyField.getSelectedIndex();
+ String contextRootFieldValue = contextRootField.getText();
+ String virtualHostFieldValue = virtualHostField.getText();
+ String agentFieldValue = (String) agentField.getSelectedItem();
+ // check fields
+ if ( nameFieldValue == null || nameFieldValue.trim().length() < 1 || uriFieldValue == null
+ || uriFieldValue.trim().length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "archive.mandatory" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // if the user change the archive name, check if the new name doesn't
+ // already exist
+ if ( archiveName == null || ( archiveName != null && !archiveName.equals( nameFieldValue ) ) )
+ {
+ if ( parent.getParentPane().getApplication().getArchive( nameFieldValue ) != null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "archive.exists" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ }
+ // add a change event
+ if ( archiveName != null )
+ {
+ String change = "Modify JEE application archive " + nameFieldValue;
+ if ( !archive.getUri().equals( uriFieldValue ) )
+ {
+ change += " URI from " + archive.getUri() + " to " + uriFieldValue;
+ }
+ if ( !archive.getPath().equals( pathFieldValue ) )
+ {
+ change += " path from " + archive.getPath() + " to " + pathFieldValue;
+ }
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add( change );
+ }
+ // update the archive object
+ archive.setName( nameFieldValue );
+ if ( activeFieldIndex == 0 )
+ {
+ archive.setActive( true );
+ }
+ else
+ {
+ archive.setActive( false );
+ }
+ if ( blockerFieldIndex == 0 )
+ {
+ archive.setBlocker( true );
+ }
+ else
+ {
+ archive.setBlocker( false );
+ }
+ archive.setUri( uriFieldValue );
+ archive.setPath( pathFieldValue );
+ archive.setAgent( agentFieldValue );
+ if ( classloaderOrderFieldIndex == 0 )
+ {
+ archive.setClassloaderorder( "PARENT_LAST" );
+ }
+ else
+ {
+ archive.setClassloaderorder( "PARENT_FIRST" );
+ }
+ if ( classloaderPolicyFieldIndex == 0 )
+ {
+ archive.setClassloaderpolicy( "SINGLE" );
+ }
+ else
+ {
+ archive.setClassloaderpolicy( "MULTIPLE" );
+ }
+ archive.setContext( contextRootFieldValue );
+ archive.setVhost( virtualHostFieldValue );
+ // add the archive object if needed
+ if ( archiveName == null )
+ {
+ try
+ {
+ parent.getParentPane().getApplication().addArchive( archive );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Add JEE application archive " + archive.getName() );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "archive.exists" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ }
+ // update the window definition
+ setTitle( Messages.getString( "archive" ) + " " + archive.getName() );
+ setId( "archivewindow_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
+ + "_" + parent.getParentPane().getServerName() + "_"
+ + parent.getParentPane().getApplicationName() + "_" + archive.getName() );
+ archiveName = archive.getName();
// change the updated flag
parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
// update the journal log tab pane
parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the parent window
+ parent.update();
+ // update the window
+ update();
+ }
+ };
+
+ // copy
+ private ActionListener copy = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ try
+ {
+ KalumetConsoleApplication.getApplication().setCopyComponent( archive.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
+
+ // paste
+ private ActionListener paste = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+ // check if the copy is correct
+ if ( copy == null || !( copy instanceof Archive ) )
+ {
+ return;
+ }
+ archive = (Archive) copy;
+ archiveName = null;
// update the parent pane
parent.update();
- // close the window
- ApplicationArchiveWindow.this.userClose();
- }
- } ) );
- }
- };
+ // update the window
+ update();
+ }
+ };
- // apply
- private ActionListener apply = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // status
+ private ActionListener status = new ActionListener()
{
- // check if the user has the environment lock
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get the fields value
- String nameFieldValue = nameField.getText();
- int activeFieldIndex = activeField.getSelectedIndex();
- int blockerFieldIndex = blockerField.getSelectedIndex();
- String uriFieldValue = uriField.getText();
- String pathFieldValue = pathField.getText();
- int classloaderOrderFieldIndex = classloaderOrderField.getSelectedIndex();
- int classloaderPolicyFieldIndex = classloaderPolicyField.getSelectedIndex();
- String contextRootFieldValue = contextRootField.getText();
- String virtualHostFieldValue = virtualHostField.getText();
- String agentFieldValue = (String) agentField.getSelectedItem();
- // check fields
- if ( nameFieldValue == null || nameFieldValue.trim().length() < 1 || uriFieldValue == null
- || uriFieldValue.trim().length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "archive.mandatory" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // if the user change the archive name, check if the new name doesn't
- // already exist
- if ( archiveName == null || ( archiveName != null && !archiveName.equals( nameFieldValue ) ) )
- {
- if ( parent.getParentPane().getApplication().getArchive( nameFieldValue ) != null )
+ public void actionPerformed( ActionEvent event )
{
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "archive.exists" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
+ // check if some change has not yet been saved
+ if ( parent.getParentPane().getParentPane().getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // add a message into the log pane and the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application " + parent.getParentPane().getApplicationName() + " archive " + archiveName
+ + " status check in progress...",
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + parent.getParentPane().getApplicationName() + " archive " + archiveName
+ + " status check requested." );
+ // launch the status thread
+ final StatusThread statusThread = new StatusThread();
+ statusThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( statusThread.ended )
+ {
+ if ( statusThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning( statusThread.message,
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo( statusThread.message,
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ }
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ statusThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
}
- }
- // add a change event
- if ( archiveName != null )
- {
- String change = "Modify JEE application archive " + nameFieldValue;
- if ( !archive.getUri().equals( uriFieldValue ) )
+ };
+
+ // update
+ private ActionListener update = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
{
- change += " URI from " + archive.getUri() + " to " + uriFieldValue;
+ // check if the user has the lock
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if there is no pending change
+ if ( parent.getParentPane().getParentPane().getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // add a message in the log pane and the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application " + parent.getParentPane().getApplicationName() + " archive " + archiveName
+ + " update in progress...",
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + parent.getParentPane().getApplicationName() + " archive " + archiveName
+ + " update requested." );
+ // start the update thread
+ final UpdateThread updateThread = new UpdateThread();
+ updateThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( updateThread.ended )
+ {
+ if ( updateThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ updateThread.message,
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ updateThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ "JEE application " + parent.getParentPane().getApplicationName()
+ + " archive " + archiveName + " updated.",
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + parent.getParentPane().getApplicationName()
+ + " archive " + archiveName + " updated." );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ } ) );
}
- if ( !archive.getPath().equals( pathFieldValue ) )
+ };
+
+ /**
+ * Create a new <code>ApplicationArchiveWindow</code>.
+ *
+ * @param parent the <code>ApplicationArchivesPane</code>.
+ * @param archiveName the original <code>Archive</code> name.
+ */
+ public ApplicationArchiveWindow( ApplicationArchivesPane parent, String archiveName )
+ {
+ super();
+
+ // update the parent pane
+ this.parent = parent;
+
+ // update the archive name
+ this.archiveName = archiveName;
+
+ // update the archive object from the parent pane
+ this.archive = parent.getParentPane().getApplication().getArchive( archiveName );
+ if ( this.archive == null )
{
- change += " path from " + archive.getPath() + " to " + pathFieldValue;
+ this.archive = new Archive();
}
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add( change );
- }
- // update the archive object
- archive.setName( nameFieldValue );
- if ( activeFieldIndex == 0 )
- {
- archive.setActive( true );
- }
- else
- {
- archive.setActive( false );
- }
- if ( blockerFieldIndex == 0 )
- {
- archive.setBlocker( true );
- }
- else
- {
- archive.setBlocker( false );
- }
- archive.setUri( uriFieldValue );
- archive.setPath( pathFieldValue );
- archive.setAgent( agentFieldValue );
- if ( classloaderOrderFieldIndex == 0 )
- {
- archive.setClassloaderorder( "PARENT_LAST" );
- }
- else
- {
- archive.setClassloaderorder( "PARENT_FIRST" );
- }
- if ( classloaderPolicyFieldIndex == 0 )
- {
- archive.setClassloaderpolicy( "SINGLE" );
- }
- else
- {
- archive.setClassloaderpolicy( "MULTIPLE" );
- }
- archive.setContext( contextRootFieldValue );
- archive.setVhost( virtualHostFieldValue );
- // add the archive object if needed
- if ( archiveName == null )
- {
+
+ if ( archiveName == null )
+ {
+ setTitle( Messages.getString( "archive" ) );
+ }
+ else
+ {
+ setTitle( Messages.getString( "archive" ) + " " + archiveName );
+ }
+ setId(
+ "archivewindow_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
+ + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
+ + archiveName );
+ setStyleName( "default" );
+ setWidth( new Extent( 450, Extent.PX ) );
+ setHeight( new Extent( 300, Extent.PX ) );
+ setModal( false );
+ setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
+
+ // create a split pane for the control buttons
+ SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
+ add( splitPane );
+
+ // add the control pane
+ Row controlRow = new Row();
+ controlRow.setStyleName( "control" );
+ splitPane.add( controlRow );
+ // add the refresh button
+ Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
+ refreshButton.setStyleName( "control" );
+ refreshButton.addActionListener( refresh );
+ controlRow.add( refreshButton );
+ // add the copy button
+ Button copyButton = new Button( Messages.getString( "copy" ), Styles.PAGE_COPY );
+ copyButton.setStyleName( "control" );
+ copyButton.addActionListener( copy );
+ controlRow.add( copyButton );
+ if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // add the paste button
+ Button pasteButton = new Button( Messages.getString( "paste" ), Styles.PAGE_PASTE );
+ pasteButton.setStyleName( "control" );
+ pasteButton.addActionListener( paste );
+ controlRow.add( pasteButton );
+ }
+ // status
+ Button statusButton = new Button( Messages.getString( "status" ), Styles.INFORMATION );
+ statusButton.setStyleName( "control" );
+ statusButton.addActionListener( status );
+ controlRow.add( statusButton );
+ if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ // update
+ Button updateButton = new Button( Messages.getString( "update" ), Styles.COG );
+ updateButton.setStyleName( "control" );
+ updateButton.addActionListener( update );
+ controlRow.add( updateButton );
+ }
+ if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // add the apply button
+ Button applyButton = new Button( Messages.getString( "apply" ), Styles.ACCEPT );
+ applyButton.setStyleName( "control" );
+ applyButton.addActionListener( apply );
+ controlRow.add( applyButton );
+ // add the delete button
+ Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
+ deleteButton.setStyleName( "control" );
+ deleteButton.addActionListener( delete );
+ controlRow.add( deleteButton );
+ }
+ // add the close button
+ Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
+ closeButton.setStyleName( "control" );
+ closeButton.addActionListener( close );
+ controlRow.add( closeButton );
+
+ // add the main tab pane
+ TabPane tabPane = new TabPane();
+ tabPane.setStyleName( "default" );
+ splitPane.add( tabPane );
+
+ // add the general tab
+ TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
+
+ tabLayoutData.setTitle( Messages.getString( "general" ) );
+ ContentPane generalTabPane = new ContentPane();
+ generalTabPane.setStyleName( "tab.content" );
+ generalTabPane.setLayoutData( tabLayoutData );
+ tabPane.add( generalTabPane );
+
+ Grid generalLayoutGrid = new Grid( 2 );
+ generalLayoutGrid.setStyleName( "default" );
+ generalLayoutGrid.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
+ generalLayoutGrid.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
+ generalTabPane.add( generalLayoutGrid );
+ // name
+ Label nameLabel = new Label( Messages.getString( "name" ) );
+ nameLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( nameLabel );
+ nameField = new TextField();
+ nameField.setStyleName( "default" );
+ nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ generalLayoutGrid.add( nameField );
+ // active
+ Label activeLabel = new Label( Messages.getString( "active" ) );
+ activeLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( activeLabel );
+ activeField = new SelectField( MainScreen.LABELS );
+ activeField.setStyleName( "default" );
+ activeField.setWidth( new Extent( 10, Extent.EX ) );
+ activeField.setSelectedIndex( 0 );
+ generalLayoutGrid.add( activeField );
+ // blocker
+ Label blockerLabel = new Label( Messages.getString( "blocker" ) );
+ blockerLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( blockerLabel );
+ blockerField = new SelectField( MainScreen.LABELS );
+ blockerField.setStyleName( "default" );
+ blockerField.setWidth( new Extent( 10, Extent.EX ) );
+ blockerField.setSelectedIndex( 1 );
+ generalLayoutGrid.add( blockerField );
+ // URI
+ Label uriLabel = new Label( Messages.getString( "uri" ) );
+ uriLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( uriLabel );
+ uriField = new TextField();
+ uriField.setStyleName( "default" );
+ uriField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ generalLayoutGrid.add( uriField );
+ // path
+ Label pathLabel = new Label( Messages.getString( "path" ) );
+ pathLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( pathLabel );
+ pathField = new TextField();
+ pathField.setStyleName( "default" );
+ pathField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ generalLayoutGrid.add( pathField );
+ // agent
+ Label agentLabel = new Label( Messages.getString( "agent" ) );
+ agentLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( agentLabel );
+ agentField = new SelectField();
+ agentField.setStyleName( "default" );
+ agentField.setWidth( new Extent( 50, Extent.EX ) );
+ generalLayoutGrid.add( agentField );
+
+ // add the deployment tab
+ tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "deployment" ) );
+ ContentPane deploymentTabPane = new ContentPane();
+ deploymentTabPane.setStyleName( "tab.content" );
+ deploymentTabPane.setLayoutData( tabLayoutData );
+ tabPane.add( deploymentTabPane );
+ Grid deploymentLayoutGrid = new Grid( 2 );
+ deploymentLayoutGrid.setStyleName( "default" );
+ deploymentLayoutGrid.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
+ deploymentLayoutGrid.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
+ deploymentTabPane.add( deploymentLayoutGrid );
+ // classloader mode
+ Label archiveClassloaderOrderLabel = new Label( Messages.getString( "classloader.order" ) );
+ archiveClassloaderOrderLabel.setStyleName( "grid.cell" );
+ deploymentLayoutGrid.add( archiveClassloaderOrderLabel );
+ classloaderOrderField = new SelectField( ApplicationArchiveWindow.CLASSLOADER_ORDER );
+ classloaderOrderField.setStyleName( "default" );
+ classloaderOrderField.setSelectedIndex( 0 );
+ classloaderOrderField.setWidth( new Extent( 50, Extent.EX ) );
+ deploymentLayoutGrid.add( classloaderOrderField );
+ // classloader policy
+ Label archiveClassLoaderPolicyLabel = new Label( Messages.getString( "classloader.policy" ) );
+ archiveClassLoaderPolicyLabel.setStyleName( "grid.cell" );
+ deploymentLayoutGrid.add( archiveClassLoaderPolicyLabel );
+ classloaderPolicyField = new SelectField( ApplicationArchiveWindow.CLASSLOADER_POLICY );
+ classloaderPolicyField.setStyleName( "default" );
+ classloaderPolicyField.setSelectedIndex( 0 );
+ classloaderPolicyField.setWidth( new Extent( 50, Extent.EX ) );
+ deploymentLayoutGrid.add( classloaderPolicyField );
+ // context root
+ Label archiveContextLabel = new Label( Messages.getString( "contextroot" ) );
+ archiveContextLabel.setStyleName( "grid.cell" );
+ deploymentLayoutGrid.add( archiveContextLabel );
+ contextRootField = new TextField();
+ contextRootField.setStyleName( "default" );
+ contextRootField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ deploymentLayoutGrid.add( contextRootField );
+ Label archiveVHostLabel = new Label( Messages.getString( "virtualhost" ) );
+ archiveVHostLabel.setStyleName( "grid.cell" );
+ deploymentLayoutGrid.add( archiveVHostLabel );
+ virtualHostField = new TextField();
+ virtualHostField.setStyleName( "default" );
+ virtualHostField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ deploymentLayoutGrid.add( virtualHostField );
+
+ // update the window
+ update();
+ }
+
+ /**
+ * Update the pane.
+ */
+ public void update()
+ {
+ // update the archive name field
+ nameField.setText( archive.getName() );
+ // update the archive active field
+ if ( archive.isActive() )
+ {
+ activeField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ activeField.setSelectedIndex( 1 );
+ }
+ // update the archive blocker field
+ if ( archive.isBlocker() )
+ {
+ blockerField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ blockerField.setSelectedIndex( 1 );
+ }
+ // update the archive uri field
+ uriField.setText( archive.getUri() );
+ // update the archive path field
+ pathField.setText( archive.getPath() );
+ // update the archive classloader order field
+ if ( archive.getClassloaderorder() != null )
+ {
+ if ( archive.getClassloaderorder().equals( "PARENT_FIRST" ) )
+ {
+ classloaderOrderField.setSelectedIndex( 1 );
+ }
+ else
+ {
+ classloaderOrderField.setSelectedIndex( 0 );
+ }
+ }
+ // update the archive classloader policy field
+ if ( archive.getClassloaderpolicy() != null )
+ {
+ if ( archive.getClassloaderpolicy().equals( "SINGLE" ) )
+ {
+ classloaderPolicyField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ classloaderPolicyField.setSelectedIndex( 1 );
+ }
+ }
+ // update the archive context field
+ contextRootField.setText( archive.getContext() );
+ // update the archive vhost field
+ virtualHostField.setText( archive.getVhost() );
+ // update agent field
+ // load Kalumet configuration
+ Kalumet kalumet;
try
{
- parent.getParentPane().getApplication().addArchive( archive );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Add JEE application archive " + archive.getName() );
+ kalumet = ConfigurationManager.loadStore();
}
catch ( Exception e )
{
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "archive.exists" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage(),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
}
- }
- // update the window definition
- setTitle( Messages.getString( "archive" ) + " " + archive.getName() );
- setId( "archivewindow_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
- + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
- + archive.getName() );
- archiveName = archive.getName();
- // change the updated flag
- parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the parent window
- parent.update();
- // update the window
- update();
- }
- };
-
- // copy
- private ActionListener copy = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- try
- {
- KalumetConsoleApplication.getApplication().setCopyComponent( archive.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
-
- // paste
- private ActionListener paste = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
- // check if the copy is correct
- if ( copy == null || !( copy instanceof Archive ) )
- {
- return;
- }
- archive = (Archive) copy;
- archiveName = null;
- // update the parent pane
- parent.update();
- // update the window
- update();
- }
- };
-
- // status
- private ActionListener status = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if some change has not yet been saved
- if ( parent.getParentPane().getParentPane().getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // add a message into the log pane and the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application " + parent.getParentPane().getApplicationName() + " archive " + archiveName
- + " status check in progress...",
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getParentPane().getApplicationName() + " archive " + archiveName
- + " status check requested." );
- // launch the status thread
- final StatusThread statusThread = new StatusThread();
- statusThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask( KalumetConsoleApplication.getApplication().getTaskQueue(),
- new Runnable()
- {
- public void run()
- {
- if ( statusThread.ended )
- {
- if ( statusThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- statusThread.message,
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- statusThread.message,
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- }
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- statusThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(),
- this );
- }
- }
- } );
- }
- };
-
- // update
- private ActionListener update = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the lock
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if there is no pending change
- if ( parent.getParentPane().getParentPane().getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ // update agent list model
+ DefaultListModel agentListModel = (DefaultListModel) agentField.getModel();
+ agentListModel.removeAll();
+ agentListModel.add( "" );
+ for ( Iterator agentIterator = kalumet.getAgents().iterator(); agentIterator.hasNext(); )
{
- public void actionPerformed( ActionEvent event )
- {
- // add a message in the log pane and the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application " + parent.getParentPane().getApplicationName() + " archive " + archiveName
- + " update in progress...",
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getParentPane().getApplicationName() + " archive " + archiveName
- + " update requested." );
- // start the update thread
- final UpdateThread updateThread = new UpdateThread();
- updateThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
- {
- public void run()
- {
- if ( updateThread.ended )
- {
- if ( updateThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( updateThread.message,
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- updateThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "JEE application " + parent.getParentPane().getApplicationName() + " archive " + archiveName
- + " updated.",
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getParentPane().getApplicationName() + " archive " + archiveName
- + " updated." );
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
- } );
- }
- } ) );
+ Agent agent = (Agent) agentIterator.next();
+ agentListModel.add( agent.getId() );
+ }
+ // select the item
+ agentField.setSelectedItem( archive.getAgent() );
}
- };
-
- /**
- * Create a new <code>ApplicationArchiveWindow</code>.
- *
- * @param parent the <code>ApplicationArchivesPane</code>.
- * @param archiveName the original <code>Archive</code> name.
- */
- public ApplicationArchiveWindow( ApplicationArchivesPane parent, String archiveName )
- {
- super();
-
- // update the parent pane
- this.parent = parent;
-
- // update the archive name
- this.archiveName = archiveName;
-
- // update the archive object from the parent pane
- this.archive = parent.getParentPane().getApplication().getArchive( archiveName );
- if ( this.archive == null )
- {
- this.archive = new Archive();
- }
-
- if ( archiveName == null )
- {
- setTitle( Messages.getString( "archive" ) );
- }
- else
- {
- setTitle( Messages.getString( "archive" ) + " " + archiveName );
- }
- setId( "archivewindow_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
- + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
- + archiveName );
- setStyleName( "default" );
- setWidth( new Extent( 450, Extent.PX ) );
- setHeight( new Extent( 300, Extent.PX ) );
- setModal( false );
- setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
-
- // create a split pane for the control buttons
- SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
- add( splitPane );
-
- // add the control pane
- Row controlRow = new Row();
- controlRow.setStyleName( "control" );
- splitPane.add( controlRow );
- // add the refresh button
- Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
- refreshButton.setStyleName( "control" );
- refreshButton.addActionListener( refresh );
- controlRow.add( refreshButton );
- // add the copy button
- Button copyButton = new Button( Messages.getString( "copy" ), Styles.PAGE_COPY );
- copyButton.setStyleName( "control" );
- copyButton.addActionListener( copy );
- controlRow.add( copyButton );
- if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- // add the paste button
- Button pasteButton = new Button( Messages.getString( "paste" ), Styles.PAGE_PASTE );
- pasteButton.setStyleName( "control" );
- pasteButton.addActionListener( paste );
- controlRow.add( pasteButton );
- }
- // status
- Button statusButton = new Button( Messages.getString( "status" ), Styles.INFORMATION );
- statusButton.setStyleName( "control" );
- statusButton.addActionListener( status );
- controlRow.add( statusButton );
- if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
- {
- // update
- Button updateButton = new Button( Messages.getString( "update" ), Styles.COG );
- updateButton.setStyleName( "control" );
- updateButton.addActionListener( update );
- controlRow.add( updateButton );
- }
- if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- // add the apply button
- Button applyButton = new Button( Messages.getString( "apply" ), Styles.ACCEPT );
- applyButton.setStyleName( "control" );
- applyButton.addActionListener( apply );
- controlRow.add( applyButton );
- // add the delete button
- Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
- deleteButton.setStyleName( "control" );
- deleteButton.addActionListener( delete );
- controlRow.add( deleteButton );
- }
- // add the close button
- Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
- closeButton.setStyleName( "control" );
- closeButton.addActionListener( close );
- controlRow.add( closeButton );
-
- // add the main tab pane
- TabPane tabPane = new TabPane();
- tabPane.setStyleName( "default" );
- splitPane.add( tabPane );
-
- // add the general tab
- TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
-
- tabLayoutData.setTitle( Messages.getString( "general" ) );
- ContentPane generalTabPane = new ContentPane();
- generalTabPane.setStyleName( "tab.content" );
- generalTabPane.setLayoutData( tabLayoutData );
- tabPane.add( generalTabPane );
-
- Grid generalLayoutGrid = new Grid( 2 );
- generalLayoutGrid.setStyleName( "default" );
- generalLayoutGrid.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
- generalLayoutGrid.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
- generalTabPane.add( generalLayoutGrid );
- // name
- Label nameLabel = new Label( Messages.getString( "name" ) );
- nameLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( nameLabel );
- nameField = new TextField();
- nameField.setStyleName( "default" );
- nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
- generalLayoutGrid.add( nameField );
- // active
- Label activeLabel = new Label( Messages.getString( "active" ) );
- activeLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( activeLabel );
- activeField = new SelectField( MainScreen.LABELS );
- activeField.setStyleName( "default" );
- activeField.setWidth( new Extent( 10, Extent.EX ) );
- activeField.setSelectedIndex( 0 );
- generalLayoutGrid.add( activeField );
- // blocker
- Label blockerLabel = new Label( Messages.getString( "blocker" ) );
- blockerLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( blockerLabel );
- blockerField = new SelectField( MainScreen.LABELS );
- blockerField.setStyleName( "default" );
- blockerField.setWidth( new Extent( 10, Extent.EX ) );
- blockerField.setSelectedIndex( 1 );
- generalLayoutGrid.add( blockerField );
- // URI
- Label uriLabel = new Label( Messages.getString( "uri" ) );
- uriLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( uriLabel );
- uriField = new TextField();
- uriField.setStyleName( "default" );
- uriField.setWidth( new Extent( 100, Extent.PERCENT ) );
- generalLayoutGrid.add( uriField );
- // path
- Label pathLabel = new Label( Messages.getString( "path" ) );
- pathLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( pathLabel );
- pathField = new TextField();
- pathField.setStyleName( "default" );
- pathField.setWidth( new Extent( 100, Extent.PERCENT ) );
- generalLayoutGrid.add( pathField );
- // agent
- Label agentLabel = new Label( Messages.getString( "agent" ) );
- agentLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( agentLabel );
- agentField = new SelectField();
- agentField.setStyleName( "default" );
- agentField.setWidth( new Extent( 50, Extent.EX ) );
- generalLayoutGrid.add( agentField );
-
- // add the deployment tab
- tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "deployment" ) );
- ContentPane deploymentTabPane = new ContentPane();
- deploymentTabPane.setStyleName( "tab.content" );
- deploymentTabPane.setLayoutData( tabLayoutData );
- tabPane.add( deploymentTabPane );
- Grid deploymentLayoutGrid = new Grid( 2 );
- deploymentLayoutGrid.setStyleName( "default" );
- deploymentLayoutGrid.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
- deploymentLayoutGrid.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
- deploymentTabPane.add( deploymentLayoutGrid );
- // classloader mode
- Label archiveClassloaderOrderLabel = new Label( Messages.getString( "classloader.order" ) );
- archiveClassloaderOrderLabel.setStyleName( "grid.cell" );
- deploymentLayoutGrid.add( archiveClassloaderOrderLabel );
- classloaderOrderField = new SelectField( ApplicationArchiveWindow.CLASSLOADER_ORDER );
- classloaderOrderField.setStyleName( "default" );
- classloaderOrderField.setSelectedIndex( 0 );
- classloaderOrderField.setWidth( new Extent( 50, Extent.EX ) );
- deploymentLayoutGrid.add( classloaderOrderField );
- // classloader policy
- Label archiveClassLoaderPolicyLabel = new Label( Messages.getString( "classloader.policy" ) );
- archiveClassLoaderPolicyLabel.setStyleName( "grid.cell" );
- deploymentLayoutGrid.add( archiveClassLoaderPolicyLabel );
- classloaderPolicyField = new SelectField( ApplicationArchiveWindow.CLASSLOADER_POLICY );
- classloaderPolicyField.setStyleName( "default" );
- classloaderPolicyField.setSelectedIndex( 0 );
- classloaderPolicyField.setWidth( new Extent( 50, Extent.EX ) );
- deploymentLayoutGrid.add( classloaderPolicyField );
- // context root
- Label archiveContextLabel = new Label( Messages.getString( "contextroot" ) );
- archiveContextLabel.setStyleName( "grid.cell" );
- deploymentLayoutGrid.add( archiveContextLabel );
- contextRootField = new TextField();
- contextRootField.setStyleName( "default" );
- contextRootField.setWidth( new Extent( 100, Extent.PERCENT ) );
- deploymentLayoutGrid.add( contextRootField );
- Label archiveVHostLabel = new Label( Messages.getString( "virtualhost" ) );
- archiveVHostLabel.setStyleName( "grid.cell" );
- deploymentLayoutGrid.add( archiveVHostLabel );
- virtualHostField = new TextField();
- virtualHostField.setStyleName( "default" );
- virtualHostField.setWidth( new Extent( 100, Extent.PERCENT ) );
- deploymentLayoutGrid.add( virtualHostField );
-
- // update the window
- update();
- }
-
- /**
- * Update the pane.
- */
- public void update()
- {
- // update the archive name field
- nameField.setText( archive.getName() );
- // update the archive active field
- if ( archive.isActive() )
- {
- activeField.setSelectedIndex( 0 );
- }
- else
- {
- activeField.setSelectedIndex( 1 );
- }
- // update the archive blocker field
- if ( archive.isBlocker() )
- {
- blockerField.setSelectedIndex( 0 );
- }
- else
- {
- blockerField.setSelectedIndex( 1 );
- }
- // update the archive uri field
- uriField.setText( archive.getUri() );
- // update the archive path field
- pathField.setText( archive.getPath() );
- // update the archive classloader order field
- if ( archive.getClassloaderorder() != null )
- {
- if ( archive.getClassloaderorder().equals( "PARENT_FIRST" ) )
- {
- classloaderOrderField.setSelectedIndex( 1 );
- }
- else
- {
- classloaderOrderField.setSelectedIndex( 0 );
- }
- }
- // update the archive classloader policy field
- if ( archive.getClassloaderpolicy() != null )
- {
- if ( archive.getClassloaderpolicy().equals( "SINGLE" ) )
- {
- classloaderPolicyField.setSelectedIndex( 0 );
- }
- else
- {
- classloaderPolicyField.setSelectedIndex( 1 );
- }
- }
- // update the archive context field
- contextRootField.setText( archive.getContext() );
- // update the archive vhost field
- virtualHostField.setText( archive.getVhost() );
- // update agent field
- // load Kalumet configuration
- Kalumet kalumet;
- try
- {
- kalumet = ConfigurationManager.loadStore();
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage(),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // update agent list model
- DefaultListModel agentListModel = (DefaultListModel) agentField.getModel();
- agentListModel.removeAll();
- agentListModel.add( "" );
- for ( Iterator agentIterator = kalumet.getAgents().iterator(); agentIterator.hasNext(); )
- {
- Agent agent = (Agent) agentIterator.next();
- agentListModel.add( agent.getId() );
- }
- // select the item
- agentField.setSelectedItem( archive.getAgent() );
- }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationArchivesPane.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationArchivesPane.java
index d3e27f7..7766138 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationArchivesPane.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationArchivesPane.java
@@ -40,734 +40,754 @@
* JEE application archives pane.
*/
public class ApplicationArchivesPane
- extends ContentPane
+ extends ContentPane
{
- private ApplicationWindow parent;
+ private ApplicationWindow parent;
- private Grid grid;
+ private Grid grid;
- // status thread
- class StatusThread
- extends Thread
- {
-
- public String archiveName;
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // status thread
+ class StatusThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
- if ( agent == null )
+
+ public String archiveName;
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent =
+ kalumet.getAgent( parent.getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the web service
+ ArchiveClient client = new ArchiveClient( agent.getHostname(), agent.getPort() );
+ boolean uptodate = client.check( parent.getParentPane().getEnvironmentWindow().getEnvironmentName(),
+ parent.getServerName(), parent.getApplicationName(), archiveName );
+ if ( uptodate )
+ {
+ message = "JEE application " + parent.getApplicationName() + " archive " + archiveName
+ + " is up to date.";
+ }
+ else
+ {
+ failure = true;
+ message = "JEE application " + parent.getApplicationName() + " archive " + archiveName
+ + " is not up to date.";
+ }
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JEE application " + parent.getApplicationName() + " archive " + archiveName
+ + " status check failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- // call the web service
- ArchiveClient client = new ArchiveClient( agent.getHostname(), agent.getPort() );
- boolean uptodate =
- client.check( parent.getParentPane().getEnvironmentWindow().getEnvironmentName(), parent.getServerName(),
- parent.getApplicationName(), archiveName );
- if ( uptodate )
- {
- message = "JEE application " + parent.getApplicationName() + " archive " + archiveName + " is up to date.";
- }
- else
- {
- failure = true;
- message =
- "JEE application " + parent.getApplicationName() + " archive " + archiveName + " is not up to date.";
- }
- }
- catch ( Exception e )
- {
- failure = true;
- message =
- "JEE application " + parent.getApplicationName() + " archive " + archiveName + " status check failed: "
- + e.getMessage();
- }
- finally
- {
- ended = true;
- }
+
}
- }
-
- // update thread
- class UpdateThread
- extends Thread
- {
-
- public String archiveName;
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // update thread
+ class UpdateThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
- if ( agent == null )
+
+ public String archiveName;
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent =
+ kalumet.getAgent( parent.getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the web service
+ ArchiveClient client = new ArchiveClient( agent.getHostname(), agent.getPort() );
+ client.update( parent.getParentPane().getEnvironmentWindow().getEnvironmentName(),
+ parent.getServerName(), parent.getApplicationName(), archiveName, false );
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message =
+ "JEE application " + parent.getApplicationName() + " archive " + archiveName + " update failed: "
+ + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- // call the web service
- ArchiveClient client = new ArchiveClient( agent.getHostname(), agent.getPort() );
- client.update( parent.getParentPane().getEnvironmentWindow().getEnvironmentName(), parent.getServerName(),
- parent.getApplicationName(), archiveName, false );
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JEE application " + parent.getApplicationName() + " archive " + archiveName + " update failed: "
- + e.getMessage();
- }
- finally
- {
- ended = true;
- }
}
- }
- // toggle active
- private ActionListener toggleActive = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // toggle active
+ private ActionListener toggleActive = new ActionListener()
{
- // check if the user has the environment lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the archive object
- Archive archive = parent.getApplication().getArchive( event.getActionCommand() );
- if ( archive == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "archive.notfound" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // change the state and add change event
- if ( archive.isActive() )
- {
- archive.setActive( false );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Disable JEE application archive " + archive.getName() );
- }
- else
- {
- archive.setActive( true );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Enable JEE application archive " + archive.getName() );
- }
- // change the updated flag
- parent.getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the pane
- update();
- }
- };
-
- // toggle blocker
- private ActionListener toggleBlocker = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the archive object
- Archive archive = parent.getApplication().getArchive( event.getActionCommand() );
- if ( archive == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "archive.notfound" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // change the blocker state and add change event
- if ( archive.isBlocker() )
- {
- archive.setBlocker( false );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Set not blocker for JEE application archive " + archive.getName() );
- }
- else
- {
- archive.setBlocker( true );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Set blocker for JEE application archive " + archive.getName() );
- }
- // change the updated flag
- parent.getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the pane
- update();
- }
- };
-
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- final String archiveName = event.getActionCommand();
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
// looking for the archive object
- Archive archive = parent.getApplication().getArchive( archiveName );
+ Archive archive = parent.getApplication().getArchive( event.getActionCommand() );
if ( archive == null )
{
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "archive.notfound" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "archive.notfound" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
}
- // delete the archive object
- parent.getApplication().getArchives().remove( archive );
- // add a change event
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Delete JEE application archive " + archive.getName() );
+ // change the state and add change event
+ if ( archive.isActive() )
+ {
+ archive.setActive( false );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Disable JEE application archive " + archive.getName() );
+ }
+ else
+ {
+ archive.setActive( true );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Enable JEE application archive " + archive.getName() );
+ }
// change the updated flag
parent.getParentPane().getEnvironmentWindow().setUpdated( true );
// update the journal log tab pane
parent.getParentPane().getEnvironmentWindow().updateJournalPane();
// update the pane
update();
- }
- } ) );
- }
- };
+ }
+ };
- // status
- private ActionListener status = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // toggle blocker
+ private ActionListener toggleBlocker = new ActionListener()
{
- // check if some change has not yet been saved
- if ( parent.getParentPane().getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- String archiveName = event.getActionCommand();
- // add a message into the log pane and in the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application " + parent.getApplicationName() + " archive " + archiveName + " status check in progress...",
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getApplicationName() + " archive " + archiveName + " check requested." );
- // start the status thread
- final StatusThread statusThread = new StatusThread();
- statusThread.archiveName = archiveName;
- statusThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask( KalumetConsoleApplication.getApplication().getTaskQueue(),
- new Runnable()
- {
- public void run()
- {
- if ( statusThread.ended )
- {
- if ( statusThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- statusThread.message,
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- statusThread.message,
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- }
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- statusThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(),
- this );
- }
- }
- } );
- }
- };
-
- // update
- private ActionListener update = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if there is no pending change
- if ( parent.getParentPane().getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get the archive name
- final String archiveName = event.getActionCommand();
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- // add a message in the log pane and in the journal
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the archive object
+ Archive archive = parent.getApplication().getArchive( event.getActionCommand() );
+ if ( archive == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "archive.notfound" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // change the blocker state and add change event
+ if ( archive.isBlocker() )
+ {
+ archive.setBlocker( false );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Set not blocker for JEE application archive " + archive.getName() );
+ }
+ else
+ {
+ archive.setBlocker( true );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Set blocker for JEE application archive " + archive.getName() );
+ }
+ // change the updated flag
+ parent.getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the pane
+ update();
+ }
+ };
+
+ // delete
+ private ActionListener delete = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ final String archiveName = event.getActionCommand();
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // looking for the archive object
+ Archive archive = parent.getApplication().getArchive( archiveName );
+ if ( archive == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "archive.notfound" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // delete the archive object
+ parent.getApplication().getArchives().remove( archive );
+ // add a change event
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Delete JEE application archive " + archive.getName() );
+ // change the updated flag
+ parent.getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the pane
+ update();
+ }
+ } ) );
+ }
+ };
+
+ // status
+ private ActionListener status = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if some change has not yet been saved
+ if ( parent.getParentPane().getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ String archiveName = event.getActionCommand();
+ // add a message into the log pane and in the journal
KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application " + parent.getApplicationName() + " archive " + archiveName + " update in progress...",
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ "JEE application " + parent.getApplicationName() + " archive " + archiveName
+ + " status check in progress...",
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getApplicationName() + " archive " + archiveName + " update requested." );
- // start the update thread
- final UpdateThread updateThread = new UpdateThread();
- updateThread.archiveName = archiveName;
- updateThread.start();
+ "JEE application " + parent.getApplicationName() + " archive " + archiveName + " check requested." );
+ // start the status thread
+ final StatusThread statusThread = new StatusThread();
+ statusThread.archiveName = archiveName;
+ statusThread.start();
// sync with the client
KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
{
- public void run()
- {
- if ( updateThread.ended )
+ public void run()
{
- if ( updateThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( updateThread.message,
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add( updateThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "JEE application " + parent.getApplicationName() + " archive " + archiveName + " updated.",
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getApplicationName() + " archive " + archiveName + " updated" );
- }
+ if ( statusThread.ended )
+ {
+ if ( statusThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning( statusThread.message,
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo( statusThread.message,
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ }
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add( statusThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
}
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
} );
- }
- } ) );
- }
- };
+ }
+ };
- // edit
- private ActionListener edit = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // update
+ private ActionListener update = new ActionListener()
{
- if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
- "archivewindow_" + parent.getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
- + parent.getServerName() + "_" + parent.getApplicationName() + "_" + event.getActionCommand() ) == null )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ApplicationArchiveWindow( ApplicationArchivesPane.this, event.getActionCommand() ) );
- }
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if there is no pending change
+ if ( parent.getParentPane().getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get the archive name
+ final String archiveName = event.getActionCommand();
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // add a message in the log pane and in the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application " + parent.getApplicationName() + " archive " + archiveName
+ + " update in progress...",
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + parent.getApplicationName() + " archive " + archiveName
+ + " update requested." );
+ // start the update thread
+ final UpdateThread updateThread = new UpdateThread();
+ updateThread.archiveName = archiveName;
+ updateThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( updateThread.ended )
+ {
+ if ( updateThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ updateThread.message,
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ updateThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ "JEE application " + parent.getApplicationName() + " archive " + archiveName
+ + " updated.",
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + parent.getApplicationName() + " archive " + archiveName
+ + " updated" );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ } ) );
+ }
+ };
- // create
- private ActionListener create = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // edit
+ private ActionListener edit = new ActionListener()
{
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ApplicationArchiveWindow( ApplicationArchivesPane.this, null ) );
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
+ "archivewindow_" + parent.getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
+ + parent.getServerName() + "_" + parent.getApplicationName() + "_" + event.getActionCommand() )
+ == null )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ApplicationArchiveWindow( ApplicationArchivesPane.this, event.getActionCommand() ) );
+ }
+ }
+ };
- // copy
- private ActionListener copy = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // create
+ private ActionListener create = new ActionListener()
{
- // looking for the archive object
- Archive archive = parent.getApplication().getArchive( event.getActionCommand() );
- if ( archive == null )
- {
- return;
- }
- try
- {
- KalumetConsoleApplication.getApplication().setCopyComponent( archive.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ApplicationArchiveWindow( ApplicationArchivesPane.this, null ) );
+ }
+ };
- // up
- private ActionListener up = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // copy
+ private ActionListener copy = new ActionListener()
{
- // check if the user has the lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the archive object
- Archive archive = parent.getApplication().getArchive( event.getActionCommand() );
- if ( archive == null )
- {
- return;
- }
- // get the archive index
- int index = parent.getApplication().getArchives().indexOf( archive );
- // if the archive index is the first or if the archive object is not found
- // or if the archives list doesn't contain at least two elements, do nothing
- if ( index == 0 || index == -1 || parent.getApplication().getArchives().size() < 2 )
- {
- return;
- }
- // get the previous archive
- Archive previous = (Archive) parent.getApplication().getArchives().get( index - 1 );
- // switch the archives
- parent.getApplication().getArchives().set( index, previous );
- parent.getApplication().getArchives().set( index - 1, archive );
- // update the pane
- update();
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ // looking for the archive object
+ Archive archive = parent.getApplication().getArchive( event.getActionCommand() );
+ if ( archive == null )
+ {
+ return;
+ }
+ try
+ {
+ KalumetConsoleApplication.getApplication().setCopyComponent( archive.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
- // down
- private ActionListener down = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // up
+ private ActionListener up = new ActionListener()
{
- // check if the user has the lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get the archive object
- Archive archive = parent.getApplication().getArchive( event.getActionCommand() );
- if ( archive == null )
- {
- return;
- }
- // get the archive index
- int index = parent.getApplication().getArchives().indexOf( archive );
- // if the archive index is the last one, or the archive not found
- // or the archives list doesn't contain at least two elements,
- // do nothing
- if ( index == -1 || index == parent.getApplication().getArchives().size() - 1
- || parent.getApplication().getArchives().size() < 2 )
- {
- return;
- }
- // get the next archive
- Archive next = (Archive) parent.getApplication().getArchives().get( index + 1 );
- // switch the archives
- parent.getApplication().getArchives().set( index + 1, archive );
- parent.getApplication().getArchives().set( index, next );
- // update the pane
- update();
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the archive object
+ Archive archive = parent.getApplication().getArchive( event.getActionCommand() );
+ if ( archive == null )
+ {
+ return;
+ }
+ // get the archive index
+ int index = parent.getApplication().getArchives().indexOf( archive );
+ // if the archive index is the first or if the archive object is not found
+ // or if the archives list doesn't contain at least two elements, do nothing
+ if ( index == 0 || index == -1 || parent.getApplication().getArchives().size() < 2 )
+ {
+ return;
+ }
+ // get the previous archive
+ Archive previous = (Archive) parent.getApplication().getArchives().get( index - 1 );
+ // switch the archives
+ parent.getApplication().getArchives().set( index, previous );
+ parent.getApplication().getArchives().set( index - 1, archive );
+ // update the pane
+ update();
+ }
+ };
- /**
- * Create a new <code>ApplicationArchivesPane</code>.
- *
- * @param parent the parent <code>ApplicationWindow</code>.
- */
- public ApplicationArchivesPane( ApplicationWindow parent )
- {
- super();
- setStyleName( "tab.content" );
-
- // update parent
- this.parent = parent;
-
- // add the column content layout
- Column content = new Column();
- content.setInsets( new Insets( 2 ) );
- add( content );
-
- // add the create button
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
+ // down
+ private ActionListener down = new ActionListener()
{
- Button createButton = new Button( Messages.getString( "archive.add" ), Styles.ADD );
- createButton.addActionListener( create );
- content.add( createButton );
- }
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get the archive object
+ Archive archive = parent.getApplication().getArchive( event.getActionCommand() );
+ if ( archive == null )
+ {
+ return;
+ }
+ // get the archive index
+ int index = parent.getApplication().getArchives().indexOf( archive );
+ // if the archive index is the last one, or the archive not found
+ // or the archives list doesn't contain at least two elements,
+ // do nothing
+ if ( index == -1 || index == parent.getApplication().getArchives().size() - 1
+ || parent.getApplication().getArchives().size() < 2 )
+ {
+ return;
+ }
+ // get the next archive
+ Archive next = (Archive) parent.getApplication().getArchives().get( index + 1 );
+ // switch the archives
+ parent.getApplication().getArchives().set( index + 1, archive );
+ parent.getApplication().getArchives().set( index, next );
+ // update the pane
+ update();
+ }
+ };
- // add the archives grid
- grid = new Grid( 5 );
- grid.setStyleName( "border.grid" );
- grid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
- grid.setColumnWidth( 1, new Extent( 10, Extent.PERCENT ) );
- grid.setColumnWidth( 2, new Extent( 40, Extent.PERCENT ) );
- grid.setColumnWidth( 3, new Extent( 40, Extent.PERCENT ) );
- grid.setColumnWidth( 4, new Extent( 10, Extent.PERCENT ) );
- content.add( grid );
-
- // update the pane
- update();
- }
-
- /**
- * Update the pane.
- */
- public void update()
- {
- // remove all archives grid children
- grid.removeAll();
- // add archives grid header
- Label actionHeader = new Label( " " );
- actionHeader.setStyleName( "grid.header" );
- grid.add( actionHeader );
- Label nameHeader = new Label( Messages.getString( "name" ) );
- nameHeader.setStyleName( "grid.header" );
- grid.add( nameHeader );
- Label uriHeader = new Label( Messages.getString( "uri" ) );
- uriHeader.setStyleName( "grid.header" );
- grid.add( uriHeader );
- Label pathHeader = new Label( Messages.getString( "path" ) );
- pathHeader.setStyleName( "grid.header" );
- grid.add( pathHeader );
- Label agentHeader = new Label( Messages.getString( "agent" ) );
- agentHeader.setStyleName( "grid.header" );
- grid.add( agentHeader );
- // add archive
- for ( Iterator archiveIterator = parent.getApplication().getArchives().iterator(); archiveIterator.hasNext(); )
+ /**
+ * Create a new <code>ApplicationArchivesPane</code>.
+ *
+ * @param parent the parent <code>ApplicationWindow</code>.
+ */
+ public ApplicationArchivesPane( ApplicationWindow parent )
{
- Archive archive = (Archive) archiveIterator.next();
- // row
- Row row = new Row();
- row.setCellSpacing( new Extent( 2 ) );
- row.setInsets( new Insets( 2 ) );
- grid.add( row );
- // copy
- Button copyButton = new Button( Styles.PAGE_COPY );
- copyButton.setActionCommand( archive.getName() );
- copyButton.addActionListener( copy );
- copyButton.setToolTipText( Messages.getString( "copy" ) );
- row.add( copyButton );
- // active
- Button activeButton;
- if ( archive.isActive() )
- {
- activeButton = new Button( Styles.LIGHTBULB );
- activeButton.setToolTipText( Messages.getString( "switch.disable" ) );
- }
- else
- {
- activeButton = new Button( Styles.LIGHTBULB_OFF );
- activeButton.setToolTipText( Messages.getString( "switch.enable" ) );
- }
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- activeButton.setActionCommand( archive.getName() );
- activeButton.addActionListener( toggleActive );
- }
- row.add( activeButton );
- // blocker
- Button blockerButton;
- if ( archive.isBlocker() )
- {
- blockerButton = new Button( Styles.PLUGIN );
- blockerButton.setToolTipText( Messages.getString( "switch.notblocker" ) );
- }
- else
- {
- blockerButton = new Button( Styles.PLUGIN_DISABLED );
- blockerButton.setToolTipText( Messages.getString( "switch.blocker" ) );
- }
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- blockerButton.setActionCommand( archive.getName() );
- blockerButton.addActionListener( toggleBlocker );
- }
- row.add( blockerButton );
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- // up
- Button upButton = new Button( Styles.ARROW_UP );
- upButton.setToolTipText( Messages.getString( "up" ) );
- upButton.setActionCommand( archive.getName() );
- upButton.addActionListener( up );
- row.add( upButton );
- // down
- Button downButton = new Button( Styles.ARROW_DOWN );
- downButton.setToolTipText( Messages.getString( "down" ) );
- downButton.setActionCommand( archive.getName() );
- downButton.addActionListener( down );
- row.add( downButton );
- }
- // status
- Button statusButton = new Button( Styles.INFORMATION );
- statusButton.setActionCommand( archive.getName() );
- statusButton.addActionListener( status );
- statusButton.setToolTipText( Messages.getString( "status" ) );
- row.add( statusButton );
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
- {
- // update
- Button updateButton = new Button( Styles.COG );
- updateButton.setActionCommand( archive.getName() );
- updateButton.addActionListener( update );
- updateButton.setToolTipText( Messages.getString( "update" ) );
- row.add( updateButton );
- }
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- // delete
- Button deleteButton = new Button( Styles.DELETE );
- deleteButton.setActionCommand( archive.getName() );
- deleteButton.addActionListener( delete );
- deleteButton.setToolTipText( Messages.getString( "delete" ) );
- row.add( deleteButton );
- }
- // name
- Button name = new Button( archive.getName() );
- name.setStyleName( "default" );
- name.setActionCommand( archive.getName() );
- name.addActionListener( edit );
- grid.add( name );
- // uri
- Label uri = new Label( archive.getUri() );
- uri.setStyleName( "default" );
- grid.add( uri );
- // path
- Label path = new Label( archive.getPath() );
- path.setStyleName( "default" );
- grid.add( path );
- // agent
- Label agent = new Label( archive.getAgent() );
- agent.setStyleName( "default" );
- grid.add( agent );
- }
- }
+ super();
+ setStyleName( "tab.content" );
- /**
- * Return the parent <code>ApplicationWindow</code>.
- *
- * @return the parent <code>ApplicationWindow</code>.
- */
- public ApplicationWindow getParentPane()
- {
- return parent;
- }
+ // update parent
+ this.parent = parent;
+
+ // add the column content layout
+ Column content = new Column();
+ content.setInsets( new Insets( 2 ) );
+ add( content );
+
+ // add the create button
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ Button createButton = new Button( Messages.getString( "archive.add" ), Styles.ADD );
+ createButton.addActionListener( create );
+ content.add( createButton );
+ }
+
+ // add the archives grid
+ grid = new Grid( 5 );
+ grid.setStyleName( "border.grid" );
+ grid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
+ grid.setColumnWidth( 1, new Extent( 10, Extent.PERCENT ) );
+ grid.setColumnWidth( 2, new Extent( 40, Extent.PERCENT ) );
+ grid.setColumnWidth( 3, new Extent( 40, Extent.PERCENT ) );
+ grid.setColumnWidth( 4, new Extent( 10, Extent.PERCENT ) );
+ content.add( grid );
+
+ // update the pane
+ update();
+ }
+
+ /**
+ * Update the pane.
+ */
+ public void update()
+ {
+ // remove all archives grid children
+ grid.removeAll();
+ // add archives grid header
+ Label actionHeader = new Label( " " );
+ actionHeader.setStyleName( "grid.header" );
+ grid.add( actionHeader );
+ Label nameHeader = new Label( Messages.getString( "name" ) );
+ nameHeader.setStyleName( "grid.header" );
+ grid.add( nameHeader );
+ Label uriHeader = new Label( Messages.getString( "uri" ) );
+ uriHeader.setStyleName( "grid.header" );
+ grid.add( uriHeader );
+ Label pathHeader = new Label( Messages.getString( "path" ) );
+ pathHeader.setStyleName( "grid.header" );
+ grid.add( pathHeader );
+ Label agentHeader = new Label( Messages.getString( "agent" ) );
+ agentHeader.setStyleName( "grid.header" );
+ grid.add( agentHeader );
+ // add archive
+ for ( Iterator archiveIterator = parent.getApplication().getArchives().iterator(); archiveIterator.hasNext(); )
+ {
+ Archive archive = (Archive) archiveIterator.next();
+ // row
+ Row row = new Row();
+ row.setCellSpacing( new Extent( 2 ) );
+ row.setInsets( new Insets( 2 ) );
+ grid.add( row );
+ // copy
+ Button copyButton = new Button( Styles.PAGE_COPY );
+ copyButton.setActionCommand( archive.getName() );
+ copyButton.addActionListener( copy );
+ copyButton.setToolTipText( Messages.getString( "copy" ) );
+ row.add( copyButton );
+ // active
+ Button activeButton;
+ if ( archive.isActive() )
+ {
+ activeButton = new Button( Styles.LIGHTBULB );
+ activeButton.setToolTipText( Messages.getString( "switch.disable" ) );
+ }
+ else
+ {
+ activeButton = new Button( Styles.LIGHTBULB_OFF );
+ activeButton.setToolTipText( Messages.getString( "switch.enable" ) );
+ }
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ activeButton.setActionCommand( archive.getName() );
+ activeButton.addActionListener( toggleActive );
+ }
+ row.add( activeButton );
+ // blocker
+ Button blockerButton;
+ if ( archive.isBlocker() )
+ {
+ blockerButton = new Button( Styles.PLUGIN );
+ blockerButton.setToolTipText( Messages.getString( "switch.notblocker" ) );
+ }
+ else
+ {
+ blockerButton = new Button( Styles.PLUGIN_DISABLED );
+ blockerButton.setToolTipText( Messages.getString( "switch.blocker" ) );
+ }
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ blockerButton.setActionCommand( archive.getName() );
+ blockerButton.addActionListener( toggleBlocker );
+ }
+ row.add( blockerButton );
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // up
+ Button upButton = new Button( Styles.ARROW_UP );
+ upButton.setToolTipText( Messages.getString( "up" ) );
+ upButton.setActionCommand( archive.getName() );
+ upButton.addActionListener( up );
+ row.add( upButton );
+ // down
+ Button downButton = new Button( Styles.ARROW_DOWN );
+ downButton.setToolTipText( Messages.getString( "down" ) );
+ downButton.setActionCommand( archive.getName() );
+ downButton.addActionListener( down );
+ row.add( downButton );
+ }
+ // status
+ Button statusButton = new Button( Styles.INFORMATION );
+ statusButton.setActionCommand( archive.getName() );
+ statusButton.addActionListener( status );
+ statusButton.setToolTipText( Messages.getString( "status" ) );
+ row.add( statusButton );
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ // update
+ Button updateButton = new Button( Styles.COG );
+ updateButton.setActionCommand( archive.getName() );
+ updateButton.addActionListener( update );
+ updateButton.setToolTipText( Messages.getString( "update" ) );
+ row.add( updateButton );
+ }
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // delete
+ Button deleteButton = new Button( Styles.DELETE );
+ deleteButton.setActionCommand( archive.getName() );
+ deleteButton.addActionListener( delete );
+ deleteButton.setToolTipText( Messages.getString( "delete" ) );
+ row.add( deleteButton );
+ }
+ // name
+ Button name = new Button( archive.getName() );
+ name.setStyleName( "default" );
+ name.setActionCommand( archive.getName() );
+ name.addActionListener( edit );
+ grid.add( name );
+ // uri
+ Label uri = new Label( archive.getUri() );
+ uri.setStyleName( "default" );
+ grid.add( uri );
+ // path
+ Label path = new Label( archive.getPath() );
+ path.setStyleName( "default" );
+ grid.add( path );
+ // agent
+ Label agent = new Label( archive.getAgent() );
+ agent.setStyleName( "default" );
+ grid.add( agent );
+ }
+ }
+
+ /**
+ * Return the parent <code>ApplicationWindow</code>.
+ *
+ * @return the parent <code>ApplicationWindow</code>.
+ */
+ public ApplicationWindow getParentPane()
+ {
+ return parent;
+ }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationConfigurationFileWindow.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationConfigurationFileWindow.java
index 939bcdd..548064f 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationConfigurationFileWindow.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationConfigurationFileWindow.java
@@ -49,1029 +49,1041 @@
* JEE application configuration file window.
*/
public class ApplicationConfigurationFileWindow
- extends WindowPane
+ extends WindowPane
{
- private String configurationFileName;
+ private String configurationFileName;
- private ConfigurationFile configurationFile;
+ private ConfigurationFile configurationFile;
- private ApplicationConfigurationFilesPane parent;
+ private ApplicationConfigurationFilesPane parent;
- private TextField nameField;
+ private TextField nameField;
- private SelectField activeField;
+ private SelectField activeField;
- private SelectField blockerField;
+ private SelectField blockerField;
- private TextField uriField;
+ private TextField uriField;
- private TextField pathField;
+ private TextField pathField;
- private SelectField agentField;
+ private SelectField agentField;
- private Grid mappingsGrid;
+ private Grid mappingsGrid;
- private TextField newMappingKeyField;
+ private TextField newMappingKeyField;
- private TextField newMappingValueField;
+ private TextField newMappingValueField;
- // status thread
- class StatusThread
- extends Thread
- {
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // status thread
+ class StatusThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent =
- kalumet.getAgent( parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
- if ( agent == null )
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent(
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the webservice
+ ConfigurationFileClient client = new ConfigurationFileClient( agent.getHostname(), agent.getPort() );
+ boolean uptodate =
+ client.check( parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName(),
+ parent.getParentPane().getServerName(), parent.getParentPane().getApplicationName(),
+ configurationFileName );
+ if ( uptodate )
+ {
+ message = "JEE application " + parent.getParentPane().getApplicationName() + " configuration file "
+ + configurationFileName + " is up to date.";
+ }
+ else
+ {
+ failure = true;
+ message = "JEE application " + parent.getParentPane().getApplicationName() + " configuration file "
+ + configurationFileName + " is not up to date.";
+ }
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JEE application " + parent.getParentPane().getApplicationName() + " configuration file "
+ + configurationFileName + " status check failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- // call the webservice
- ConfigurationFileClient client = new ConfigurationFileClient( agent.getHostname(), agent.getPort() );
- boolean uptodate =
- client.check( parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName(),
- parent.getParentPane().getServerName(), parent.getParentPane().getApplicationName(),
- configurationFileName );
- if ( uptodate )
+ }
+
+ // update thread
+ class UpdateThread
+ extends Thread
+ {
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- message = "JEE application " + parent.getParentPane().getApplicationName() + " configuration file "
- + configurationFileName + " is up to date.";
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent(
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the webservice
+ ConfigurationFileClient client = new ConfigurationFileClient( agent.getHostname(), agent.getPort() );
+ client.update( parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName(),
+ parent.getParentPane().getServerName(), parent.getParentPane().getApplicationName(),
+ configurationFileName, false );
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JEE application " + parent.getParentPane().getApplicationName() + " configuration file "
+ + configurationFileName + " update failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- else
+ }
+
+ // refresh
+ private ActionListener refresh = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
{
- failure = true;
- message = "JEE application " + parent.getParentPane().getApplicationName() + " configuration file "
- + configurationFileName + " is not up to date.";
+ // looking for the configuration file object
+ ApplicationConfigurationFileWindow.this.configurationFile =
+ parent.getParentPane().getApplication().getConfigurationFile( configurationFileName );
+ if ( ApplicationConfigurationFileWindow.this.configurationFile == null )
+ {
+ ApplicationConfigurationFileWindow.this.configurationFile = new ConfigurationFile();
+ }
+ // update the window
+ update();
}
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JEE application " + parent.getParentPane().getApplicationName() + " configuration file "
- + configurationFileName + " status check failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
- }
- }
+ };
- // update thread
- class UpdateThread
- extends Thread
- {
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // close
+ private ActionListener close = new ActionListener()
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent =
- kalumet.getAgent( parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
- if ( agent == null )
+ public void actionPerformed( ActionEvent event )
{
- throw new IllegalArgumentException( "agent not found." );
+ ApplicationConfigurationFileWindow.this.userClose();
}
- // call the webservice
- ConfigurationFileClient client = new ConfigurationFileClient( agent.getHostname(), agent.getPort() );
- client.update( parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName(),
- parent.getParentPane().getServerName(), parent.getParentPane().getApplicationName(),
- configurationFileName, false );
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JEE application " + parent.getParentPane().getApplicationName() + " configuration file "
- + configurationFileName + " update failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
- }
- }
+ };
- // refresh
- private ActionListener refresh = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // delete
+ private ActionListener delete = new ActionListener()
{
- // looking for the configuration file object
- ApplicationConfigurationFileWindow.this.configurationFile =
- parent.getParentPane().getApplication().getConfigurationFile( configurationFileName );
- if ( ApplicationConfigurationFileWindow.this.configurationFile == null )
- {
- ApplicationConfigurationFileWindow.this.configurationFile = new ConfigurationFile();
- }
- // update the window
- update();
- }
- };
-
- // close
- private ActionListener close = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- ApplicationConfigurationFileWindow.this.userClose();
- }
- };
-
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- // delete the configuration file
- parent.getParentPane().getApplication().getConfigurationFiles().remove( configurationFile );
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // delete the configuration file
+ parent.getParentPane().getApplication().getConfigurationFiles().remove( configurationFile );
+ // add a change event
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Delete JEE application configuration file " + configurationFile.getName() );
+ // change the updated flag
+ parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the parent pane
+ parent.update();
+ // close the window
+ ApplicationConfigurationFileWindow.this.userClose();
+ }
+ } ) );
+ }
+ };
+
+ // apply
+ private ActionListener apply = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get the fields value
+ String nameFieldValue = nameField.getText();
+ int activeFieldIndex = activeField.getSelectedIndex();
+ int blockerFieldIndex = blockerField.getSelectedIndex();
+ String uriFieldValue = uriField.getText();
+ String pathFieldValue = pathField.getText();
+ String agentFieldValue = (String) agentField.getSelectedItem();
+ // check fields
+ if ( nameFieldValue == null || nameFieldValue.trim().length() < 1 || uriFieldValue == null
+ || uriFieldValue.trim().length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "configurationfile.warn.mandatory" ) );
+ return;
+ }
+ // if the user change the configuration file name, check if the new
+ // name doesn't already exist
+ if ( configurationFileName == null || ( configurationFileName != null && !configurationFileName.equals(
+ nameFieldValue ) ) )
+ {
+ if ( parent.getParentPane().getApplication().getConfigurationFile( nameFieldValue ) != null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "configurationfile.warn.exists" ) );
+ return;
+ }
+ }
// add a change event
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Delete JEE application configuration file " + configurationFile.getName() );
+ if ( configurationFileName != null )
+ {
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Change JEE application configuration file " + configurationFile.getName() );
+ }
+ // update the configuration file object
+ configurationFile.setName( nameFieldValue );
+ if ( activeFieldIndex == 0 )
+ {
+ configurationFile.setActive( true );
+ }
+ else
+ {
+ configurationFile.setActive( false );
+ }
+ if ( blockerFieldIndex == 0 )
+ {
+ configurationFile.setBlocker( true );
+ }
+ else
+ {
+ configurationFile.setBlocker( false );
+ }
+ configurationFile.setUri( uriFieldValue );
+ configurationFile.setPath( pathFieldValue );
+ configurationFile.setAgent( agentFieldValue );
+ // add the configuration file object if needed
+ if ( configurationFileName == null )
+ {
+ try
+ {
+ parent.getParentPane().getApplication().addConfigurationFile( configurationFile );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Add JEE application configuration file " + configurationFile.getName() );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "configurationfile.warn.exists" ) );
+ return;
+ }
+ }
+ // update the window definition
+ setTitle( Messages.getString( "configurationfile" ) + " " + configurationFile.getName() );
+ setId( "configurationfilewindow_"
+ + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
+ + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName()
+ + "_" + configurationFile.getName() );
+ configurationFileName = configurationFile.getName();
// change the updated flag
parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
// update the journal log tab pane
parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the parent window
+ parent.update();
+ // update the window
+ update();
+ }
+ };
+
+ // status
+ private ActionListener status = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if some change has not yet been saved
+ if ( parent.getParentPane().getParentPane().getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // add a message into the log pane and the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application " + parent.getParentPane().getApplicationName() + " configuration file "
+ + configurationFileName + " status check in progress...",
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + parent.getParentPane().getApplicationName() + " configuration file "
+ + configurationFileName + " status check requested." );
+ // start the status thread
+ final StatusThread statusThread = new StatusThread();
+ statusThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( statusThread.ended )
+ {
+ if ( statusThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning( statusThread.message,
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo( statusThread.message,
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ };
+
+ // update
+ private ActionListener update = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if no change has not been saved
+ if ( parent.getParentPane().getParentPane().getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // add a message into the log pane and the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application " + parent.getParentPane().getApplicationName() + " configuration file "
+ + configurationFileName + " update in progress...",
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + parent.getParentPane().getApplicationName() + " configuration file "
+ + configurationFileName + " update requested." );
+ // start the update thread
+ final UpdateThread updateThread = new UpdateThread();
+ updateThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( updateThread.ended )
+ {
+ if ( updateThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ updateThread.message,
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ updateThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ "JEE application " + parent.getParentPane().getApplicationName()
+ + " configuration file " + configurationFileName + " updated.",
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + parent.getParentPane().getApplicationName()
+ + " configuration file " + configurationFileName + " updated." );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ } ) );
+ }
+ };
+
+ // delete mapping
+ private ActionListener deleteMapping = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the mapping object
+ Mapping mapping = configurationFile.getMapping( event.getActionCommand() );
+ if ( mapping == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "configurationfile.warn.mapping.notfound" ) );
+ return;
+ }
+ // delete the mapping object
+ configurationFile.getMappings().remove( mapping );
+ // add a change event
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Delete JEE application configuration file " + configurationFile.getName() + " mapping "
+ + mapping.getKey() );
+ // change the updated flag
+ parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the window
+ update();
+ }
+ };
+
+ // edit mapping
+ private ActionListener editMapping = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get fields
+ TextField keyField = (TextField) ApplicationConfigurationFileWindow.this.getComponent(
+ "configurationfilemappingkey_"
+ + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
+ + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
+ + configurationFileName + "_" + event.getActionCommand() );
+ TextField valueField = (TextField) ApplicationConfigurationFileWindow.this.getComponent(
+ "configurationfilemappingvalue_"
+ + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
+ + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
+ + configurationFileName + "_" + event.getActionCommand() );
+ // get fields value
+ String keyFieldValue = keyField.getText();
+ String valueFieldValue = valueField.getText();
+ // check fields
+ if ( keyFieldValue == null || keyFieldValue.trim().length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "configurationfile.warn.mapping.mandatory" ) );
+ return;
+ }
+ // if the user change the mapping key, check if the key doesn't already
+ // exist
+ if ( !keyFieldValue.equals( event.getActionCommand() ) )
+ {
+ if ( configurationFile.getMapping( keyFieldValue ) != null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "configurationfile.warn.mapping.exists" ) );
+ return;
+ }
+ }
+ // looking for the mapping object
+ Mapping mapping = configurationFile.getMapping( event.getActionCommand() );
+ if ( mapping == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "configurationfile.warn.mapping.notfound" ) );
+ return;
+ }
+ // add a change event
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Change JEE application configuration file " + configurationFile.getName() + " mapping "
+ + mapping.getKey() );
+ // update the mapping
+ mapping.setKey( keyFieldValue );
+ mapping.setValue( valueFieldValue );
+ // change the updated flag
+ parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the window
+ update();
+ }
+ };
+
+ // create mapping
+ private ActionListener createMapping = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get fields value
+ String newMappingKeyFieldValue = newMappingKeyField.getText();
+ String newMappingValueFieldValue = newMappingValueField.getText();
+ // check fields
+ if ( newMappingKeyFieldValue == null || newMappingKeyFieldValue.trim().length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "configurationfile.warn.mapping.mandatory" ) );
+ return;
+ }
+ // create the mapping object
+ Mapping mapping = new Mapping();
+ mapping.setKey( newMappingKeyFieldValue );
+ mapping.setValue( newMappingValueFieldValue );
+ try
+ {
+ configurationFile.addMapping( mapping );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "configurationfile.warn.mapping.exists" ) );
+ return;
+ }
+ // add a change event
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Add JEE application configuration file " + configurationFile.getName() + " mapping "
+ + mapping.getKey() );
+ // change the updated flag
+ parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the window
+ update();
+ }
+ };
+
+ // copy button
+ private ActionListener copy = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ try
+ {
+ KalumetConsoleApplication.getApplication().setCopyComponent( configurationFile.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
+
+ // paste
+ private ActionListener paste = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+ // check if the copy is correct
+ if ( copy == null || !( copy instanceof ConfigurationFile ) )
+ {
+ return;
+ }
+ configurationFile = (ConfigurationFile) copy;
+ configurationFileName = null;
// update the parent pane
parent.update();
- // close the window
- ApplicationConfigurationFileWindow.this.userClose();
- }
- } ) );
- }
- };
-
- // apply
- private ActionListener apply = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get the fields value
- String nameFieldValue = nameField.getText();
- int activeFieldIndex = activeField.getSelectedIndex();
- int blockerFieldIndex = blockerField.getSelectedIndex();
- String uriFieldValue = uriField.getText();
- String pathFieldValue = pathField.getText();
- String agentFieldValue = (String) agentField.getSelectedItem();
- // check fields
- if ( nameFieldValue == null || nameFieldValue.trim().length() < 1 || uriFieldValue == null
- || uriFieldValue.trim().length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "configurationfile.warn.mandatory" ) );
- return;
- }
- // if the user change the configuration file name, check if the new
- // name doesn't already exist
- if ( configurationFileName == null || ( configurationFileName != null && !configurationFileName.equals(
- nameFieldValue ) ) )
- {
- if ( parent.getParentPane().getApplication().getConfigurationFile( nameFieldValue ) != null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "configurationfile.warn.exists" ) );
- return;
+ // update the window
+ update();
}
- }
- // add a change event
- if ( configurationFileName != null )
- {
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Change JEE application configuration file " + configurationFile.getName() );
- }
- // update the configuration file object
- configurationFile.setName( nameFieldValue );
- if ( activeFieldIndex == 0 )
- {
- configurationFile.setActive( true );
- }
- else
- {
- configurationFile.setActive( false );
- }
- if ( blockerFieldIndex == 0 )
- {
- configurationFile.setBlocker( true );
- }
- else
- {
- configurationFile.setBlocker( false );
- }
- configurationFile.setUri( uriFieldValue );
- configurationFile.setPath( pathFieldValue );
- configurationFile.setAgent( agentFieldValue );
- // add the configuration file object if needed
- if ( configurationFileName == null )
- {
+ };
+
+ // copy mapping
+ private ActionListener copyMapping = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // looking for the mapping object
+ Mapping mapping = configurationFile.getMapping( event.getActionCommand() );
+ if ( mapping == null )
+ {
+ return;
+ }
+ try
+ {
+ KalumetConsoleApplication.getApplication().setCopyComponent( mapping.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
+
+ // paste mapping
+ private ActionListener pasteMapping = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+ // check if the copy is correct
+ if ( copy == null || !( copy instanceof Mapping ) )
+ {
+ return;
+ }
+ // update new fields
+ newMappingKeyField.setText( ( (Mapping) copy ).getKey() );
+ newMappingValueField.setText( ( (Mapping) copy ).getValue() );
+ }
+ };
+
+ /**
+ * Create a new <code>ApplicationConfigurationFileWindow</code>.
+ *
+ * @param parent the <code>ApplicationConfigurationFilesPane</code>.
+ * @param configurationFileName the original <code>ConfigurationFile</code> name.
+ */
+ public ApplicationConfigurationFileWindow( ApplicationConfigurationFilesPane parent, String configurationFileName )
+ {
+ super();
+
+ // update the parent pane
+ this.parent = parent;
+
+ // update the configuration file name
+ this.configurationFileName = configurationFileName;
+
+ // update the configuration file object from the parent pane
+ this.configurationFile = parent.getParentPane().getApplication().getConfigurationFile( configurationFileName );
+ if ( this.configurationFile == null )
+ {
+ this.configurationFile = new ConfigurationFile();
+ }
+
+ if ( configurationFileName == null )
+ {
+ setTitle( Messages.getString( "configurationfile" ) );
+ }
+ else
+ {
+ setTitle( Messages.getString( "configurationfile" ) + " " + configurationFileName );
+ }
+ setId( "configurationfilewindow_"
+ + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
+ + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
+ + configurationFileName );
+ setStyleName( "default" );
+ setWidth( new Extent( 450, Extent.PX ) );
+ setHeight( new Extent( 300, Extent.PX ) );
+ setModal( false );
+ setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
+
+ // create a split pane for the control buttons
+ SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
+ add( splitPane );
+
+ // add the control pane
+ Row controlRow = new Row();
+ controlRow.setStyleName( "control" );
+ splitPane.add( controlRow );
+ // add the refresh button
+ Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
+ refreshButton.setStyleName( "control" );
+ refreshButton.addActionListener( refresh );
+ controlRow.add( refreshButton );
+ // add the copy button
+ Button copyButton = new Button( Messages.getString( "copy" ), Styles.PAGE_COPY );
+ copyButton.setStyleName( "control" );
+ copyButton.addActionListener( copy );
+ controlRow.add( copyButton );
+ if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // add the paste button
+ Button pasteButton = new Button( Messages.getString( "paste" ), Styles.PAGE_PASTE );
+ pasteButton.setStyleName( "control" );
+ pasteButton.addActionListener( paste );
+ controlRow.add( pasteButton );
+ }
+ // add the status button
+ Button statusButton = new Button( Messages.getString( "status" ), Styles.INFORMATION );
+ statusButton.setStyleName( "control" );
+ statusButton.addActionListener( status );
+ controlRow.add( statusButton );
+ if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ // add the update button
+ Button updateButton = new Button( Messages.getString( "update" ), Styles.COG );
+ updateButton.setStyleName( "control" );
+ updateButton.addActionListener( update );
+ controlRow.add( updateButton );
+ }
+ if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // add the apply button
+ Button applyButton = new Button( Messages.getString( "apply" ), Styles.ACCEPT );
+ applyButton.setStyleName( "control" );
+ applyButton.addActionListener( apply );
+ controlRow.add( applyButton );
+ // add the delete button
+ Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
+ deleteButton.setStyleName( "control" );
+ deleteButton.addActionListener( delete );
+ controlRow.add( deleteButton );
+ }
+ // add the close button
+ Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
+ closeButton.setStyleName( "control" );
+ closeButton.addActionListener( close );
+ controlRow.add( closeButton );
+
+ // add the main tab pane
+ TabPane tabPane = new TabPane();
+ tabPane.setStyleName( "default" );
+ splitPane.add( tabPane );
+
+ // add the general tab
+ TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "general" ) );
+ ContentPane generalTabPane = new ContentPane();
+ generalTabPane.setStyleName( "tab.content" );
+ generalTabPane.setLayoutData( tabLayoutData );
+ tabPane.add( generalTabPane );
+ Grid generalLayoutGrid = new Grid( 2 );
+ generalLayoutGrid.setStyleName( "default" );
+ generalLayoutGrid.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
+ generalLayoutGrid.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
+ generalTabPane.add( generalLayoutGrid );
+ // name
+ Label nameLabel = new Label( Messages.getString( "name" ) );
+ nameLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( nameLabel );
+ nameField = new TextField();
+ nameField.setStyleName( "default" );
+ nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ generalLayoutGrid.add( nameField );
+ // active
+ Label activeLabel = new Label( Messages.getString( "active" ) );
+ activeLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( activeLabel );
+ activeField = new SelectField( MainScreen.LABELS );
+ activeField.setStyleName( "default" );
+ activeField.setWidth( new Extent( 10, Extent.EX ) );
+ activeField.setSelectedIndex( 0 );
+ generalLayoutGrid.add( activeField );
+ // blocker
+ Label blockerLabel = new Label( Messages.getString( "blocker" ) );
+ blockerLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( blockerLabel );
+ blockerField = new SelectField( MainScreen.LABELS );
+ blockerField.setStyleName( "default" );
+ blockerField.setWidth( new Extent( 10, Extent.EX ) );
+ blockerField.setSelectedIndex( 1 );
+ generalLayoutGrid.add( blockerField );
+ // URI
+ Label uriLabel = new Label( Messages.getString( "uri" ) );
+ uriLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( uriLabel );
+ uriField = new TextField();
+ uriField.setStyleName( "default" );
+ uriField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ generalLayoutGrid.add( uriField );
+ // path
+ Label pathLabel = new Label( Messages.getString( "path" ) );
+ pathLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( pathLabel );
+ pathField = new TextField();
+ pathField.setStyleName( "default" );
+ pathField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ generalLayoutGrid.add( pathField );
+ // agent
+ Label agentLabel = new Label( Messages.getString( "agent" ) );
+ agentLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( agentLabel );
+ agentField = new SelectField();
+ agentField.setStyleName( "default" );
+ agentField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ generalLayoutGrid.add( agentField );
+
+ // add the mappings tab
+ tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "mappings" ) );
+ ContentPane mappingsTabPane = new ContentPane();
+ mappingsTabPane.setStyleName( "tab.content" );
+ mappingsTabPane.setLayoutData( tabLayoutData );
+ tabPane.add( mappingsTabPane );
+ mappingsGrid = new Grid( 3 );
+ mappingsGrid.setStyleName( "border.grid" );
+ mappingsGrid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
+ mappingsGrid.setColumnWidth( 1, new Extent( 50, Extent.PERCENT ) );
+ mappingsGrid.setColumnWidth( 2, new Extent( 50, Extent.PERCENT ) );
+ mappingsTabPane.add( mappingsGrid );
+
+ // update the window
+ update();
+ }
+
+ /**
+ * Update the window
+ */
+ public void update()
+ {
+ // update the configuration file name field
+ nameField.setText( configurationFile.getName() );
+ // update the configuration file active field
+ if ( configurationFile.isActive() )
+ {
+ activeField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ activeField.setSelectedIndex( 1 );
+ }
+ // update the configuration file blocker field
+ if ( configurationFile.isBlocker() )
+ {
+ blockerField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ blockerField.setSelectedIndex( 1 );
+ }
+ // update the configuration file uri field
+ uriField.setText( configurationFile.getUri() );
+ // update the configuration file path field
+ pathField.setText( configurationFile.getPath() );
+ // update the agent field
+ List agentList = new LinkedList();
try
{
- parent.getParentPane().getApplication().addConfigurationFile( configurationFile );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Add JEE application configuration file " + configurationFile.getName() );
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ agentList = kalumet.getAgents();
}
catch ( Exception e )
{
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "configurationfile.warn.exists" ) );
- return;
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage(),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
}
- }
- // update the window definition
- setTitle( Messages.getString( "configurationfile" ) + " " + configurationFile.getName() );
- setId(
- "configurationfilewindow_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
- + "_" + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
- + configurationFile.getName() );
- configurationFileName = configurationFile.getName();
- // change the updated flag
- parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the parent window
- parent.update();
- // update the window
- update();
- }
- };
-
- // status
- private ActionListener status = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if some change has not yet been saved
- if ( parent.getParentPane().getParentPane().getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // add a message into the log pane and the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application " + parent.getParentPane().getApplicationName() + " configuration file "
- + configurationFileName + " status check in progress...",
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getParentPane().getApplicationName() + " configuration file "
- + configurationFileName + " status check requested." );
- // start the status thread
- final StatusThread statusThread = new StatusThread();
- statusThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask( KalumetConsoleApplication.getApplication().getTaskQueue(),
- new Runnable()
- {
- public void run()
- {
- if ( statusThread.ended )
- {
- if ( statusThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- statusThread.message,
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- statusThread.message,
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(),
- this );
- }
- }
- } );
- }
- };
-
- // update
- private ActionListener update = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the lock
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if no change has not been saved
- if ( parent.getParentPane().getParentPane().getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ DefaultListModel agentListModel = (DefaultListModel) agentField.getModel();
+ agentListModel.removeAll();
+ agentListModel.add( "" );
+ for ( Iterator agentIterator = agentList.iterator(); agentIterator.hasNext(); )
{
- public void actionPerformed( ActionEvent event )
- {
- // add a message into the log pane and the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application " + parent.getParentPane().getApplicationName() + " configuration file "
- + configurationFileName + " update in progress...",
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getParentPane().getApplicationName() + " configuration file "
- + configurationFileName + " update requested." );
- // start the update thread
- final UpdateThread updateThread = new UpdateThread();
- updateThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ Agent agent = (Agent) agentIterator.next();
+ agentListModel.add( agent.getId() );
+ }
+ agentField.setSelectedItem( configurationFile.getAgent() );
+ // remove all mappings grid children
+ mappingsGrid.removeAll();
+ // add mappings grid header
+ Label mappingActionHeader = new Label( " " );
+ mappingActionHeader.setStyleName( "grid.header" );
+ mappingsGrid.add( mappingActionHeader );
+ Label mappingKeyLabel = new Label( Messages.getString( "key" ) );
+ mappingKeyLabel.setStyleName( "grid.header" );
+ mappingsGrid.add( mappingKeyLabel );
+ Label mappingValueLabel = new Label( Messages.getString( "value" ) );
+ mappingValueLabel.setStyleName( "grid.header" );
+ mappingsGrid.add( mappingValueLabel );
+ // add mappings
+ for ( Iterator mappingIterator = configurationFile.getMappings().iterator(); mappingIterator.hasNext(); )
+ {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ // row
+ Row row = new Row();
+ row.setCellSpacing( new Extent( 2 ) );
+ row.setInsets( new Insets( 2 ) );
+ mappingsGrid.add( row );
+ // copy
+ Button copyButton = new Button( Styles.PAGE_COPY );
+ copyButton.setToolTipText( Messages.getString( "copy" ) );
+ copyButton.setActionCommand( mapping.getKey() );
+ copyButton.addActionListener( copyMapping );
+ row.add( copyButton );
+ // delete / edit
+ if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
{
- public void run()
- {
- if ( updateThread.ended )
- {
- if ( updateThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( updateThread.message,
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- updateThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "JEE application " + parent.getParentPane().getApplicationName() + " configuration file "
- + configurationFileName + " updated.",
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getParentPane().getApplicationName() + " configuration file "
- + configurationFileName + " updated." );
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
- } );
- }
- } ) );
- }
- };
-
- // delete mapping
- private ActionListener deleteMapping = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the mapping object
- Mapping mapping = configurationFile.getMapping( event.getActionCommand() );
- if ( mapping == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "configurationfile.warn.mapping.notfound" ) );
- return;
- }
- // delete the mapping object
- configurationFile.getMappings().remove( mapping );
- // add a change event
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Delete JEE application configuration file " + configurationFile.getName() + " mapping " + mapping.getKey() );
- // change the updated flag
- parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the window
- update();
- }
- };
-
- // edit mapping
- private ActionListener editMapping = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get fields
- TextField keyField = (TextField) ApplicationConfigurationFileWindow.this.getComponent(
- "configurationfilemappingkey_"
- + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
- + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
- + configurationFileName + "_" + event.getActionCommand() );
- TextField valueField = (TextField) ApplicationConfigurationFileWindow.this.getComponent(
- "configurationfilemappingvalue_"
- + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
- + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
- + configurationFileName + "_" + event.getActionCommand() );
- // get fields value
- String keyFieldValue = keyField.getText();
- String valueFieldValue = valueField.getText();
- // check fields
- if ( keyFieldValue == null || keyFieldValue.trim().length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "configurationfile.warn.mapping.mandatory" ) );
- return;
- }
- // if the user change the mapping key, check if the key doesn't already
- // exist
- if ( !keyFieldValue.equals( event.getActionCommand() ) )
- {
- if ( configurationFile.getMapping( keyFieldValue ) != null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "configurationfile.warn.mapping.exists" ) );
- return;
+ // edit
+ Button editButton = new Button( Styles.ACCEPT );
+ editButton.setToolTipText( Messages.getString( "apply" ) );
+ editButton.setActionCommand( mapping.getKey() );
+ editButton.addActionListener( editMapping );
+ row.add( editButton );
+ // delete
+ Button deleteButton = new Button( Styles.DELETE );
+ deleteButton.setToolTipText( Messages.getString( "delete" ) );
+ deleteButton.setActionCommand( mapping.getKey() );
+ deleteButton.addActionListener( deleteMapping );
+ row.add( deleteButton );
+ }
+ // mapping key
+ TextField mappingKeyField = new TextField();
+ mappingKeyField.setStyleName( "default" );
+ mappingKeyField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ mappingKeyField.setId( "configurationfilemappingkey_"
+ + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
+ + "_" + parent.getParentPane().getServerName() + "_"
+ + parent.getParentPane().getApplicationName() + "_" + configurationFileName + "_"
+ + mapping.getKey() );
+ mappingKeyField.setText( mapping.getKey() );
+ mappingsGrid.add( mappingKeyField );
+ // mapping value
+ TextField mappingValueField = new TextField();
+ mappingValueField.setStyleName( "default" );
+ mappingValueField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ mappingValueField.setId( "configurationfilemappingvalue_"
+ + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
+ + "_" + parent.getParentPane().getServerName() + "_"
+ + parent.getParentPane().getApplicationName() + "_" + configurationFileName
+ + "_" + mapping.getKey() );
+ mappingValueField.setText( mapping.getValue() );
+ mappingsGrid.add( mappingValueField );
}
- }
- // looking for the mapping object
- Mapping mapping = configurationFile.getMapping( event.getActionCommand() );
- if ( mapping == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "configurationfile.warn.mapping.notfound" ) );
- return;
- }
- // add a change event
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Change JEE application configuration file " + configurationFile.getName() + " mapping " + mapping.getKey() );
- // update the mapping
- mapping.setKey( keyFieldValue );
- mapping.setValue( valueFieldValue );
- // change the updated flag
- parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the window
- update();
+ if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // row
+ Row row = new Row();
+ row.setCellSpacing( new Extent( 2 ) );
+ row.setInsets( new Insets( 2 ) );
+ mappingsGrid.add( row );
+ // paste
+ Button pasteButton = new Button( Styles.PAGE_PASTE );
+ pasteButton.setToolTipText( Messages.getString( "paste" ) );
+ pasteButton.addActionListener( pasteMapping );
+ row.add( pasteButton );
+ // add
+ Button addButton = new Button( Styles.ADD );
+ addButton.setToolTipText( Messages.getString( "add" ) );
+ addButton.addActionListener( createMapping );
+ row.add( addButton );
+ // key
+ newMappingKeyField = new TextField();
+ newMappingKeyField.setStyleName( "default" );
+ newMappingKeyField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ mappingsGrid.add( newMappingKeyField );
+ // value
+ newMappingValueField = new TextField();
+ newMappingValueField.setStyleName( "default" );
+ newMappingValueField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ mappingsGrid.add( newMappingValueField );
+ }
}
- };
-
- // create mapping
- private ActionListener createMapping = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get fields value
- String newMappingKeyFieldValue = newMappingKeyField.getText();
- String newMappingValueFieldValue = newMappingValueField.getText();
- // check fields
- if ( newMappingKeyFieldValue == null || newMappingKeyFieldValue.trim().length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "configurationfile.warn.mapping.mandatory" ) );
- return;
- }
- // create the mapping object
- Mapping mapping = new Mapping();
- mapping.setKey( newMappingKeyFieldValue );
- mapping.setValue( newMappingValueFieldValue );
- try
- {
- configurationFile.addMapping( mapping );
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "configurationfile.warn.mapping.exists" ) );
- return;
- }
- // add a change event
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Add JEE application configuration file " + configurationFile.getName() + " mapping " + mapping.getKey() );
- // change the updated flag
- parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the window
- update();
- }
- };
-
- // copy button
- private ActionListener copy = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- try
- {
- KalumetConsoleApplication.getApplication().setCopyComponent( configurationFile.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
-
- // paste
- private ActionListener paste = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
- // check if the copy is correct
- if ( copy == null || !( copy instanceof ConfigurationFile ) )
- {
- return;
- }
- configurationFile = (ConfigurationFile) copy;
- configurationFileName = null;
- // update the parent pane
- parent.update();
- // update the window
- update();
- }
- };
-
- // copy mapping
- private ActionListener copyMapping = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // looking for the mapping object
- Mapping mapping = configurationFile.getMapping( event.getActionCommand() );
- if ( mapping == null )
- {
- return;
- }
- try
- {
- KalumetConsoleApplication.getApplication().setCopyComponent( mapping.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
-
- // paste mapping
- private ActionListener pasteMapping = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
- // check if the copy is correct
- if ( copy == null || !( copy instanceof Mapping ) )
- {
- return;
- }
- // update new fields
- newMappingKeyField.setText( ( (Mapping) copy ).getKey() );
- newMappingValueField.setText( ( (Mapping) copy ).getValue() );
- }
- };
-
- /**
- * Create a new <code>ApplicationConfigurationFileWindow</code>.
- *
- * @param parent the <code>ApplicationConfigurationFilesPane</code>.
- * @param configurationFileName the original <code>ConfigurationFile</code> name.
- */
- public ApplicationConfigurationFileWindow( ApplicationConfigurationFilesPane parent, String configurationFileName )
- {
- super();
-
- // update the parent pane
- this.parent = parent;
-
- // update the configuration file name
- this.configurationFileName = configurationFileName;
-
- // update the configuration file object from the parent pane
- this.configurationFile = parent.getParentPane().getApplication().getConfigurationFile( configurationFileName );
- if ( this.configurationFile == null )
- {
- this.configurationFile = new ConfigurationFile();
- }
-
- if ( configurationFileName == null )
- {
- setTitle( Messages.getString( "configurationfile" ) );
- }
- else
- {
- setTitle( Messages.getString( "configurationfile" ) + " " + configurationFileName );
- }
- setId(
- "configurationfilewindow_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
- + "_" + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
- + configurationFileName );
- setStyleName( "default" );
- setWidth( new Extent( 450, Extent.PX ) );
- setHeight( new Extent( 300, Extent.PX ) );
- setModal( false );
- setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
-
- // create a split pane for the control buttons
- SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
- add( splitPane );
-
- // add the control pane
- Row controlRow = new Row();
- controlRow.setStyleName( "control" );
- splitPane.add( controlRow );
- // add the refresh button
- Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
- refreshButton.setStyleName( "control" );
- refreshButton.addActionListener( refresh );
- controlRow.add( refreshButton );
- // add the copy button
- Button copyButton = new Button( Messages.getString( "copy" ), Styles.PAGE_COPY );
- copyButton.setStyleName( "control" );
- copyButton.addActionListener( copy );
- controlRow.add( copyButton );
- if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- // add the paste button
- Button pasteButton = new Button( Messages.getString( "paste" ), Styles.PAGE_PASTE );
- pasteButton.setStyleName( "control" );
- pasteButton.addActionListener( paste );
- controlRow.add( pasteButton );
- }
- // add the status button
- Button statusButton = new Button( Messages.getString( "status" ), Styles.INFORMATION );
- statusButton.setStyleName( "control" );
- statusButton.addActionListener( status );
- controlRow.add( statusButton );
- if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
- {
- // add the update button
- Button updateButton = new Button( Messages.getString( "update" ), Styles.COG );
- updateButton.setStyleName( "control" );
- updateButton.addActionListener( update );
- controlRow.add( updateButton );
- }
- if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- // add the apply button
- Button applyButton = new Button( Messages.getString( "apply" ), Styles.ACCEPT );
- applyButton.setStyleName( "control" );
- applyButton.addActionListener( apply );
- controlRow.add( applyButton );
- // add the delete button
- Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
- deleteButton.setStyleName( "control" );
- deleteButton.addActionListener( delete );
- controlRow.add( deleteButton );
- }
- // add the close button
- Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
- closeButton.setStyleName( "control" );
- closeButton.addActionListener( close );
- controlRow.add( closeButton );
-
- // add the main tab pane
- TabPane tabPane = new TabPane();
- tabPane.setStyleName( "default" );
- splitPane.add( tabPane );
-
- // add the general tab
- TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "general" ) );
- ContentPane generalTabPane = new ContentPane();
- generalTabPane.setStyleName( "tab.content" );
- generalTabPane.setLayoutData( tabLayoutData );
- tabPane.add( generalTabPane );
- Grid generalLayoutGrid = new Grid( 2 );
- generalLayoutGrid.setStyleName( "default" );
- generalLayoutGrid.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
- generalLayoutGrid.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
- generalTabPane.add( generalLayoutGrid );
- // name
- Label nameLabel = new Label( Messages.getString( "name" ) );
- nameLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( nameLabel );
- nameField = new TextField();
- nameField.setStyleName( "default" );
- nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
- generalLayoutGrid.add( nameField );
- // active
- Label activeLabel = new Label( Messages.getString( "active" ) );
- activeLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( activeLabel );
- activeField = new SelectField( MainScreen.LABELS );
- activeField.setStyleName( "default" );
- activeField.setWidth( new Extent( 10, Extent.EX ) );
- activeField.setSelectedIndex( 0 );
- generalLayoutGrid.add( activeField );
- // blocker
- Label blockerLabel = new Label( Messages.getString( "blocker" ) );
- blockerLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( blockerLabel );
- blockerField = new SelectField( MainScreen.LABELS );
- blockerField.setStyleName( "default" );
- blockerField.setWidth( new Extent( 10, Extent.EX ) );
- blockerField.setSelectedIndex( 1 );
- generalLayoutGrid.add( blockerField );
- // URI
- Label uriLabel = new Label( Messages.getString( "uri" ) );
- uriLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( uriLabel );
- uriField = new TextField();
- uriField.setStyleName( "default" );
- uriField.setWidth( new Extent( 100, Extent.PERCENT ) );
- generalLayoutGrid.add( uriField );
- // path
- Label pathLabel = new Label( Messages.getString( "path" ) );
- pathLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( pathLabel );
- pathField = new TextField();
- pathField.setStyleName( "default" );
- pathField.setWidth( new Extent( 100, Extent.PERCENT ) );
- generalLayoutGrid.add( pathField );
- // agent
- Label agentLabel = new Label( Messages.getString( "agent" ) );
- agentLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( agentLabel );
- agentField = new SelectField();
- agentField.setStyleName( "default" );
- agentField.setWidth( new Extent( 100, Extent.PERCENT ) );
- generalLayoutGrid.add( agentField );
-
- // add the mappings tab
- tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "mappings" ) );
- ContentPane mappingsTabPane = new ContentPane();
- mappingsTabPane.setStyleName( "tab.content" );
- mappingsTabPane.setLayoutData( tabLayoutData );
- tabPane.add( mappingsTabPane );
- mappingsGrid = new Grid( 3 );
- mappingsGrid.setStyleName( "border.grid" );
- mappingsGrid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
- mappingsGrid.setColumnWidth( 1, new Extent( 50, Extent.PERCENT ) );
- mappingsGrid.setColumnWidth( 2, new Extent( 50, Extent.PERCENT ) );
- mappingsTabPane.add( mappingsGrid );
-
- // update the window
- update();
- }
-
- /**
- * Update the window
- */
- public void update()
- {
- // update the configuration file name field
- nameField.setText( configurationFile.getName() );
- // update the configuration file active field
- if ( configurationFile.isActive() )
- {
- activeField.setSelectedIndex( 0 );
- }
- else
- {
- activeField.setSelectedIndex( 1 );
- }
- // update the configuration file blocker field
- if ( configurationFile.isBlocker() )
- {
- blockerField.setSelectedIndex( 0 );
- }
- else
- {
- blockerField.setSelectedIndex( 1 );
- }
- // update the configuration file uri field
- uriField.setText( configurationFile.getUri() );
- // update the configuration file path field
- pathField.setText( configurationFile.getPath() );
- // update the agent field
- List agentList = new LinkedList();
- try
- {
- Kalumet kalumet = ConfigurationManager.loadStore();
- agentList = kalumet.getAgents();
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage(),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- }
- DefaultListModel agentListModel = (DefaultListModel) agentField.getModel();
- agentListModel.removeAll();
- agentListModel.add( "" );
- for ( Iterator agentIterator = agentList.iterator(); agentIterator.hasNext(); )
- {
- Agent agent = (Agent) agentIterator.next();
- agentListModel.add( agent.getId() );
- }
- agentField.setSelectedItem( configurationFile.getAgent() );
- // remove all mappings grid children
- mappingsGrid.removeAll();
- // add mappings grid header
- Label mappingActionHeader = new Label( " " );
- mappingActionHeader.setStyleName( "grid.header" );
- mappingsGrid.add( mappingActionHeader );
- Label mappingKeyLabel = new Label( Messages.getString( "key" ) );
- mappingKeyLabel.setStyleName( "grid.header" );
- mappingsGrid.add( mappingKeyLabel );
- Label mappingValueLabel = new Label( Messages.getString( "value" ) );
- mappingValueLabel.setStyleName( "grid.header" );
- mappingsGrid.add( mappingValueLabel );
- // add mappings
- for ( Iterator mappingIterator = configurationFile.getMappings().iterator(); mappingIterator.hasNext(); )
- {
- Mapping mapping = (Mapping) mappingIterator.next();
- // row
- Row row = new Row();
- row.setCellSpacing( new Extent( 2 ) );
- row.setInsets( new Insets( 2 ) );
- mappingsGrid.add( row );
- // copy
- Button copyButton = new Button( Styles.PAGE_COPY );
- copyButton.setToolTipText( Messages.getString( "copy" ) );
- copyButton.setActionCommand( mapping.getKey() );
- copyButton.addActionListener( copyMapping );
- row.add( copyButton );
- // delete / edit
- if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- // edit
- Button editButton = new Button( Styles.ACCEPT );
- editButton.setToolTipText( Messages.getString( "apply" ) );
- editButton.setActionCommand( mapping.getKey() );
- editButton.addActionListener( editMapping );
- row.add( editButton );
- // delete
- Button deleteButton = new Button( Styles.DELETE );
- deleteButton.setToolTipText( Messages.getString( "delete" ) );
- deleteButton.setActionCommand( mapping.getKey() );
- deleteButton.addActionListener( deleteMapping );
- row.add( deleteButton );
- }
- // mapping key
- TextField mappingKeyField = new TextField();
- mappingKeyField.setStyleName( "default" );
- mappingKeyField.setWidth( new Extent( 100, Extent.PERCENT ) );
- mappingKeyField.setId( "configurationfilemappingkey_"
- + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
- + "_" + parent.getParentPane().getServerName() + "_"
- + parent.getParentPane().getApplicationName() + "_" + configurationFileName + "_"
- + mapping.getKey() );
- mappingKeyField.setText( mapping.getKey() );
- mappingsGrid.add( mappingKeyField );
- // mapping value
- TextField mappingValueField = new TextField();
- mappingValueField.setStyleName( "default" );
- mappingValueField.setWidth( new Extent( 100, Extent.PERCENT ) );
- mappingValueField.setId( "configurationfilemappingvalue_"
- + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
- + "_" + parent.getParentPane().getServerName() + "_"
- + parent.getParentPane().getApplicationName() + "_" + configurationFileName + "_"
- + mapping.getKey() );
- mappingValueField.setText( mapping.getValue() );
- mappingsGrid.add( mappingValueField );
- }
- if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- // row
- Row row = new Row();
- row.setCellSpacing( new Extent( 2 ) );
- row.setInsets( new Insets( 2 ) );
- mappingsGrid.add( row );
- // paste
- Button pasteButton = new Button( Styles.PAGE_PASTE );
- pasteButton.setToolTipText( Messages.getString( "paste" ) );
- pasteButton.addActionListener( pasteMapping );
- row.add( pasteButton );
- // add
- Button addButton = new Button( Styles.ADD );
- addButton.setToolTipText( Messages.getString( "add" ) );
- addButton.addActionListener( createMapping );
- row.add( addButton );
- // key
- newMappingKeyField = new TextField();
- newMappingKeyField.setStyleName( "default" );
- newMappingKeyField.setWidth( new Extent( 100, Extent.PERCENT ) );
- mappingsGrid.add( newMappingKeyField );
- // value
- newMappingValueField = new TextField();
- newMappingValueField.setStyleName( "default" );
- newMappingValueField.setWidth( new Extent( 100, Extent.PERCENT ) );
- mappingsGrid.add( newMappingValueField );
- }
- }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationConfigurationFilesPane.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationConfigurationFilesPane.java
index 367f815..c7e7485 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationConfigurationFilesPane.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationConfigurationFilesPane.java
@@ -40,734 +40,762 @@
* JEE application configuration files pane.
*/
public class ApplicationConfigurationFilesPane
- extends ContentPane
+ extends ContentPane
{
- private ApplicationWindow parent;
+ private ApplicationWindow parent;
- private Grid grid;
+ private Grid grid;
- // status thread
- class StatusThread
- extends Thread
- {
-
- public String configurationFileName;
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // status thread
+ class StatusThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
- if ( agent == null )
+
+ public String configurationFileName;
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent =
+ kalumet.getAgent( parent.getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the web service
+ ConfigurationFileClient client = new ConfigurationFileClient( agent.getHostname(), agent.getPort() );
+ boolean uptodate = client.check( parent.getParentPane().getEnvironmentWindow().getEnvironmentName(),
+ parent.getServerName(), parent.getApplicationName(),
+ configurationFileName );
+ if ( uptodate )
+ {
+ message = "JEE application " + parent.getApplicationName() + " configuration file "
+ + configurationFileName + " is up to date.";
+ }
+ else
+ {
+ failure = true;
+ message = "JEE application " + parent.getApplicationName() + " configuration file "
+ + configurationFileName + " is not up to date.";
+ }
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message =
+ "JEE application " + parent.getApplicationName() + " configuration file " + configurationFileName
+ + " status check failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- // call the web service
- ConfigurationFileClient client = new ConfigurationFileClient( agent.getHostname(), agent.getPort() );
- boolean uptodate =
- client.check( parent.getParentPane().getEnvironmentWindow().getEnvironmentName(), parent.getServerName(),
- parent.getApplicationName(), configurationFileName );
- if ( uptodate )
+ }
+
+ // update thread
+ class UpdateThread
+ extends Thread
+ {
+
+ public String configurationFileName;
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- message = "JEE application " + parent.getApplicationName() + " configuration file " + configurationFileName
- + " is up to date.";
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent =
+ kalumet.getAgent( parent.getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the web service
+ ConfigurationFileClient client = new ConfigurationFileClient( agent.getHostname(), agent.getPort() );
+ client.update( parent.getParentPane().getEnvironmentWindow().getEnvironmentName(),
+ parent.getServerName(), parent.getApplicationName(), configurationFileName, false );
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message =
+ "JEE application " + parent.getApplicationName() + " configuration file " + configurationFileName
+ + " update failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- else
+ }
+
+ // toggle active
+ private ActionListener toggleActive = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
{
- failure = true;
- message = "JEE application " + parent.getApplicationName() + " configuration file " + configurationFileName
- + " is not up to date.";
- }
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JEE application " + parent.getApplicationName() + " configuration file " + configurationFileName
- + " status check failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
- }
- }
-
- // update thread
- class UpdateThread
- extends Thread
- {
-
- public String configurationFileName;
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
- {
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
- if ( agent == null )
- {
- throw new IllegalArgumentException( "agent not found." );
- }
- // call the web service
- ConfigurationFileClient client = new ConfigurationFileClient( agent.getHostname(), agent.getPort() );
- client.update( parent.getParentPane().getEnvironmentWindow().getEnvironmentName(), parent.getServerName(),
- parent.getApplicationName(), configurationFileName, false );
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JEE application " + parent.getApplicationName() + " configuration file " + configurationFileName
- + " update failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
- }
- }
-
- // toggle active
- private ActionListener toggleActive = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the configuration file object
- ConfigurationFile configurationFile = parent.getApplication().getConfigurationFile( event.getActionCommand() );
- if ( configurationFile == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "configurationfile.notfound" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // change the state and add a change event
- if ( configurationFile.isActive() )
- {
- configurationFile.setActive( false );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Disable JEE application configuration file " + configurationFile.getName() );
- }
- else
- {
- configurationFile.setActive( true );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Enable JEE application configuration file " + configurationFile.getName() );
- }
- // change the updated flag
- parent.getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the pane
- update();
- }
- };
-
- // toggle blocker
- private ActionListener toggleBlocker = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the configuration file object
- ConfigurationFile configurationFile = parent.getApplication().getConfigurationFile( event.getActionCommand() );
- if ( configurationFile == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "configurationfile.notfound" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // change the blocker state and add a change event
- if ( configurationFile.isBlocker() )
- {
- configurationFile.setBlocker( false );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Set not blocker for JEE application configuration file " + configurationFile.getName() );
- }
- else
- {
- configurationFile.setBlocker( true );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Set blocker for JEE application configuration file " + configurationFile.getName() );
- }
- // change the updated flag
- parent.getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the pane
- update();
- }
- };
-
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the configuration file object
- final ConfigurationFile configurationFile =
- parent.getApplication().getConfigurationFile( event.getActionCommand() );
- if ( configurationFile == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "configurationfile.notfound" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // delete the configuration file object
- parent.getApplication().getConfigurationFiles().remove( configurationFile );
- // add a change event
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Delete JEE application configuration file " + configurationFile.getName() );
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the configuration file object
+ ConfigurationFile configurationFile =
+ parent.getApplication().getConfigurationFile( event.getActionCommand() );
+ if ( configurationFile == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "configurationfile.notfound" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // change the state and add a change event
+ if ( configurationFile.isActive() )
+ {
+ configurationFile.setActive( false );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Disable JEE application configuration file " + configurationFile.getName() );
+ }
+ else
+ {
+ configurationFile.setActive( true );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Enable JEE application configuration file " + configurationFile.getName() );
+ }
// change the updated flag
parent.getParentPane().getEnvironmentWindow().setUpdated( true );
// update the journal log tab pane
parent.getParentPane().getEnvironmentWindow().updateJournalPane();
// update the pane
update();
- }
- } ) );
- }
- };
+ }
+ };
- // edit
- private ActionListener edit = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // toggle blocker
+ private ActionListener toggleBlocker = new ActionListener()
{
- if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
- "configurationfilewindow_" + parent.getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
- + parent.getServerName() + "_" + parent.getApplicationName() + "_" + event.getActionCommand() ) == null )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ApplicationConfigurationFileWindow( ApplicationConfigurationFilesPane.this, event.getActionCommand() ) );
- }
- }
- };
-
- // create
- private ActionListener create = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ApplicationConfigurationFileWindow( ApplicationConfigurationFilesPane.this, null ) );
- }
- };
-
- // copy
- private ActionListener copy = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // looking for the configuration file object
- ConfigurationFile configurationFile = parent.getApplication().getConfigurationFile( event.getActionCommand() );
- if ( configurationFile == null )
- {
- return;
- }
- try
- {
- KalumetConsoleApplication.getApplication().setCopyComponent( configurationFile.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
-
- // up
- private ActionListener up = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the configuration file object
- ConfigurationFile configurationFile = parent.getApplication().getConfigurationFile( event.getActionCommand() );
- if ( configurationFile == null )
- {
- return;
- }
- // get the configuration file index
- int index = parent.getApplication().getConfigurationFiles().indexOf( configurationFile );
- // if the index is the first one, or the configuration file is not found
- // or the configuration files list doesn't contain at least two elements
- // do nothing
- if ( index == 0 || index == -1 || parent.getApplication().getConfigurationFiles().size() < 2 )
- {
- return;
- }
- // get the previous configuration file
- ConfigurationFile previous = (ConfigurationFile) parent.getApplication().getConfigurationFiles().get( index - 1 );
- // switch the configuration files
- parent.getApplication().getConfigurationFiles().set( index - 1, configurationFile );
- parent.getApplication().getConfigurationFiles().set( index, previous );
- // update the pane
- update();
- }
- };
-
- // down
- private ActionListener down = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the configuration file object
- ConfigurationFile configurationFile = parent.getApplication().getConfigurationFile( event.getActionCommand() );
- if ( configurationFile == null )
- {
- return;
- }
- // get the configuration file index
- int index = parent.getApplication().getConfigurationFiles().indexOf( configurationFile );
- // if the index is the last one, or the configuration file is not found
- // or if the configuration files list doesn't contain at least two elements
- // do nothing
- if ( index == -1 || index == parent.getApplication().getConfigurationFiles().size() - 1
- || parent.getApplication().getConfigurationFiles().size() < 2 )
- {
- return;
- }
- // get the next configuration file
- ConfigurationFile next = (ConfigurationFile) parent.getApplication().getConfigurationFiles().get( index + 1 );
- // switch the configuration files
- parent.getApplication().getConfigurationFiles().set( index + 1, configurationFile );
- parent.getApplication().getConfigurationFiles().set( index, next );
- // update the pane
- update();
- }
- };
-
- // status
- private ActionListener status = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if some change has not yet been saved
- if ( parent.getParentPane().getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( Messages.getString( "environment.notsaved" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- String configurationFileName = event.getActionCommand();
- // add a message into the log pane and the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application " + parent.getApplicationName() + " configuration file " + configurationFileName
- + " status check in progress...", parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getApplicationName() + " configuration file " + configurationFileName
- + " status check requested." );
- // start the status thread
- final StatusThread statusThread = new StatusThread();
- statusThread.configurationFileName = configurationFileName;
- statusThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask( KalumetConsoleApplication.getApplication().getTaskQueue(),
- new Runnable()
- {
- public void run()
- {
- if ( statusThread.ended )
- {
- if ( statusThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- statusThread.message,
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- statusThread.message,
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(),
- this );
- }
- }
- } );
- }
- };
-
- // update
- private ActionListener update = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if a change has not been saved
- if ( parent.getParentPane().getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get the configuration file name
- final String configurationFileName = event.getActionCommand();
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- // add a message in the log pane and in the journal
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the configuration file object
+ ConfigurationFile configurationFile =
+ parent.getApplication().getConfigurationFile( event.getActionCommand() );
+ if ( configurationFile == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "configurationfile.notfound" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // change the blocker state and add a change event
+ if ( configurationFile.isBlocker() )
+ {
+ configurationFile.setBlocker( false );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Set not blocker for JEE application configuration file " + configurationFile.getName() );
+ }
+ else
+ {
+ configurationFile.setBlocker( true );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Set blocker for JEE application configuration file " + configurationFile.getName() );
+ }
+ // change the updated flag
+ parent.getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the pane
+ update();
+ }
+ };
+
+ // delete
+ private ActionListener delete = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the configuration file object
+ final ConfigurationFile configurationFile =
+ parent.getApplication().getConfigurationFile( event.getActionCommand() );
+ if ( configurationFile == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "configurationfile.notfound" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // delete the configuration file object
+ parent.getApplication().getConfigurationFiles().remove( configurationFile );
+ // add a change event
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Delete JEE application configuration file " + configurationFile.getName() );
+ // change the updated flag
+ parent.getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the pane
+ update();
+ }
+ } ) );
+ }
+ };
+
+ // edit
+ private ActionListener edit = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
+ "configurationfilewindow_" + parent.getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
+ + parent.getServerName() + "_" + parent.getApplicationName() + "_" + event.getActionCommand() )
+ == null )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ApplicationConfigurationFileWindow( ApplicationConfigurationFilesPane.this,
+ event.getActionCommand() ) );
+ }
+ }
+ };
+
+ // create
+ private ActionListener create = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ApplicationConfigurationFileWindow( ApplicationConfigurationFilesPane.this, null ) );
+ }
+ };
+
+ // copy
+ private ActionListener copy = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // looking for the configuration file object
+ ConfigurationFile configurationFile =
+ parent.getApplication().getConfigurationFile( event.getActionCommand() );
+ if ( configurationFile == null )
+ {
+ return;
+ }
+ try
+ {
+ KalumetConsoleApplication.getApplication().setCopyComponent( configurationFile.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
+
+ // up
+ private ActionListener up = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the configuration file object
+ ConfigurationFile configurationFile =
+ parent.getApplication().getConfigurationFile( event.getActionCommand() );
+ if ( configurationFile == null )
+ {
+ return;
+ }
+ // get the configuration file index
+ int index = parent.getApplication().getConfigurationFiles().indexOf( configurationFile );
+ // if the index is the first one, or the configuration file is not found
+ // or the configuration files list doesn't contain at least two elements
+ // do nothing
+ if ( index == 0 || index == -1 || parent.getApplication().getConfigurationFiles().size() < 2 )
+ {
+ return;
+ }
+ // get the previous configuration file
+ ConfigurationFile previous =
+ (ConfigurationFile) parent.getApplication().getConfigurationFiles().get( index - 1 );
+ // switch the configuration files
+ parent.getApplication().getConfigurationFiles().set( index - 1, configurationFile );
+ parent.getApplication().getConfigurationFiles().set( index, previous );
+ // update the pane
+ update();
+ }
+ };
+
+ // down
+ private ActionListener down = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the configuration file object
+ ConfigurationFile configurationFile =
+ parent.getApplication().getConfigurationFile( event.getActionCommand() );
+ if ( configurationFile == null )
+ {
+ return;
+ }
+ // get the configuration file index
+ int index = parent.getApplication().getConfigurationFiles().indexOf( configurationFile );
+ // if the index is the last one, or the configuration file is not found
+ // or if the configuration files list doesn't contain at least two elements
+ // do nothing
+ if ( index == -1 || index == parent.getApplication().getConfigurationFiles().size() - 1
+ || parent.getApplication().getConfigurationFiles().size() < 2 )
+ {
+ return;
+ }
+ // get the next configuration file
+ ConfigurationFile next =
+ (ConfigurationFile) parent.getApplication().getConfigurationFiles().get( index + 1 );
+ // switch the configuration files
+ parent.getApplication().getConfigurationFiles().set( index + 1, configurationFile );
+ parent.getApplication().getConfigurationFiles().set( index, next );
+ // update the pane
+ update();
+ }
+ };
+
+ // status
+ private ActionListener status = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if some change has not yet been saved
+ if ( parent.getParentPane().getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "environment.notsaved" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ String configurationFileName = event.getActionCommand();
+ // add a message into the log pane and the journal
KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application " + parent.getApplicationName() + " configuration file " + configurationFileName
- + " update in progress...", parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ "JEE application " + parent.getApplicationName() + " configuration file " + configurationFileName
+ + " status check in progress...",
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getApplicationName() + " configuration file " + configurationFileName
- + " update requested." );
- // start the update thread
- final UpdateThread updateThread = new UpdateThread();
- updateThread.configurationFileName = configurationFileName;
- updateThread.start();
+ "JEE application " + parent.getApplicationName() + " configuration file " + configurationFileName
+ + " status check requested." );
+ // start the status thread
+ final StatusThread statusThread = new StatusThread();
+ statusThread.configurationFileName = configurationFileName;
+ statusThread.start();
// sync with the client
KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
{
- public void run()
- {
- if ( updateThread.ended )
+ public void run()
{
- if ( updateThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( updateThread.message,
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add( updateThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "JEE application " + parent.getApplicationName() + " configuration file " + configurationFileName
- + " updated.", parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getApplicationName() + " configuration file " + configurationFileName
- + " updated." );
- }
+ if ( statusThread.ended )
+ {
+ if ( statusThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning( statusThread.message,
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo( statusThread.message,
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
}
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
} );
- }
- } ) );
- }
- };
+ }
+ };
- /**
- * Create a new <code>ApplicationConfigurationFilesPane</code>.
- *
- * @param parent the parent <code>ApplicationWindow</code>
- */
- public ApplicationConfigurationFilesPane( ApplicationWindow parent )
- {
- super();
- setStyleName( "tab.content" );
-
- // update parent
- this.parent = parent;
-
- // column layout content
- Column content = new Column();
- add( content );
-
- // add the create button
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
+ // update
+ private ActionListener update = new ActionListener()
{
- Button createButton = new Button( Messages.getString( "configurationfile.add" ), Styles.ADD );
- createButton.addActionListener( create );
- content.add( createButton );
- }
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if a change has not been saved
+ if ( parent.getParentPane().getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get the configuration file name
+ final String configurationFileName = event.getActionCommand();
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // add a message in the log pane and in the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application " + parent.getApplicationName() + " configuration file "
+ + configurationFileName + " update in progress...",
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + parent.getApplicationName() + " configuration file "
+ + configurationFileName + " update requested." );
+ // start the update thread
+ final UpdateThread updateThread = new UpdateThread();
+ updateThread.configurationFileName = configurationFileName;
+ updateThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( updateThread.ended )
+ {
+ if ( updateThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ updateThread.message,
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ updateThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ "JEE application " + parent.getApplicationName() + " configuration file "
+ + configurationFileName + " updated.",
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + parent.getApplicationName() + " configuration file "
+ + configurationFileName + " updated." );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ } ) );
+ }
+ };
- // add the configuration files grid
- grid = new Grid( 5 );
- grid.setStyleName( "border.grid" );
- content.add( grid );
-
- // update the pane
- update();
- }
-
- /**
- * Update the pane
- */
- public void update()
- {
- // remove all configuration files grid children
- grid.removeAll();
- // add configuration files grid header
- Label actionHeader = new Label( " " );
- actionHeader.setStyleName( "grid.header" );
- grid.add( actionHeader );
- Label nameHeader = new Label( Messages.getString( "name" ) );
- nameHeader.setStyleName( "grid.header" );
- grid.add( nameHeader );
- Label uriHeader = new Label( Messages.getString( "uri" ) );
- uriHeader.setStyleName( "grid.header" );
- grid.add( uriHeader );
- Label pathHeader = new Label( Messages.getString( "path" ) );
- pathHeader.setStyleName( "grid.header" );
- grid.add( pathHeader );
- Label agentHeader = new Label( Messages.getString( "agent" ) );
- agentHeader.setStyleName( "grid.header" );
- grid.add( agentHeader );
- // add configuration file
- for ( Iterator configurationFileIterator = parent.getApplication().getConfigurationFiles().iterator();
- configurationFileIterator.hasNext(); )
+ /**
+ * Create a new <code>ApplicationConfigurationFilesPane</code>.
+ *
+ * @param parent the parent <code>ApplicationWindow</code>
+ */
+ public ApplicationConfigurationFilesPane( ApplicationWindow parent )
{
- ConfigurationFile configurationFile = (ConfigurationFile) configurationFileIterator.next();
- // row
- Row row = new Row();
- row.setCellSpacing( new Extent( 2 ) );
- row.setInsets( new Insets( 2 ) );
- grid.add( row );
- // copy
- Button copyButton = new Button( Styles.PAGE_COPY );
- copyButton.setActionCommand( configurationFile.getName() );
- copyButton.setToolTipText( Messages.getString( "copy" ) );
- copyButton.addActionListener( copy );
- row.add( copyButton );
- // active
- Button activeButton;
- if ( configurationFile.isActive() )
- {
- activeButton = new Button( Styles.LIGHTBULB );
- activeButton.setToolTipText( Messages.getString( "switch.disable" ) );
- }
- else
- {
- activeButton = new Button( Styles.LIGHTBULB_OFF );
- activeButton.setToolTipText( Messages.getString( "switch.enable" ) );
- }
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- activeButton.setActionCommand( configurationFile.getName() );
- activeButton.addActionListener( toggleActive );
- }
- row.add( activeButton );
- // blocker
- Button blockerButton;
- if ( configurationFile.isBlocker() )
- {
- blockerButton = new Button( Styles.PLUGIN );
- blockerButton.setToolTipText( Messages.getString( "switch.notblocker" ) );
- }
- else
- {
- blockerButton = new Button( Styles.PLUGIN_DISABLED );
- blockerButton.setToolTipText( Messages.getString( "switch.blocker" ) );
- }
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- blockerButton.setActionCommand( configurationFile.getName() );
- blockerButton.addActionListener( toggleBlocker );
- }
- row.add( blockerButton );
- // up
- Button upButton = new Button( Styles.ARROW_UP );
- upButton.setToolTipText( Messages.getString( "up" ) );
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- upButton.setActionCommand( configurationFile.getName() );
- upButton.addActionListener( up );
- }
- row.add( upButton );
- // down
- Button downButton = new Button( Styles.ARROW_DOWN );
- downButton.setToolTipText( Messages.getString( "down" ) );
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- downButton.setActionCommand( configurationFile.getName() );
- downButton.addActionListener( down );
- }
- row.add( downButton );
- // status
- Button statusButton = new Button( Styles.INFORMATION );
- statusButton.setToolTipText( Messages.getString( "status" ) );
- statusButton.setActionCommand( configurationFile.getName() );
- statusButton.addActionListener( status );
- row.add( statusButton );
- // update
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
- {
- Button updateButton = new Button( Styles.COG );
- updateButton.setToolTipText( Messages.getString( "update" ) );
- updateButton.setActionCommand( configurationFile.getName() );
- updateButton.addActionListener( update );
- row.add( updateButton );
- }
- // delete
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- Button deleteButton = new Button( Styles.DELETE );
- deleteButton.setToolTipText( Messages.getString( "delete" ) );
- deleteButton.setActionCommand( configurationFile.getName() );
- deleteButton.addActionListener( delete );
- row.add( deleteButton );
- }
- // name
- Button name = new Button( configurationFile.getName() );
- name.setActionCommand( configurationFile.getName() );
- name.addActionListener( edit );
- grid.add( name );
- // uri
- Label uri = new Label( configurationFile.getUri() );
- uri.setStyleName( "default" );
- grid.add( uri );
- // path
- Label path = new Label( configurationFile.getPath() );
- path.setStyleName( "default" );
- grid.add( path );
- // agent
- Label agent = new Label( configurationFile.getAgent() );
- agent.setStyleName( "default" );
- grid.add( agent );
- }
- }
+ super();
+ setStyleName( "tab.content" );
- /**
- * Return the <code>ApplicationWindow</code> parent pane.
- *
- * @return the parent <code>ApplicationWindow</code>.
- */
- public ApplicationWindow getParentPane()
- {
- return parent;
- }
+ // update parent
+ this.parent = parent;
+
+ // column layout content
+ Column content = new Column();
+ add( content );
+
+ // add the create button
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ Button createButton = new Button( Messages.getString( "configurationfile.add" ), Styles.ADD );
+ createButton.addActionListener( create );
+ content.add( createButton );
+ }
+
+ // add the configuration files grid
+ grid = new Grid( 5 );
+ grid.setStyleName( "border.grid" );
+ content.add( grid );
+
+ // update the pane
+ update();
+ }
+
+ /**
+ * Update the pane
+ */
+ public void update()
+ {
+ // remove all configuration files grid children
+ grid.removeAll();
+ // add configuration files grid header
+ Label actionHeader = new Label( " " );
+ actionHeader.setStyleName( "grid.header" );
+ grid.add( actionHeader );
+ Label nameHeader = new Label( Messages.getString( "name" ) );
+ nameHeader.setStyleName( "grid.header" );
+ grid.add( nameHeader );
+ Label uriHeader = new Label( Messages.getString( "uri" ) );
+ uriHeader.setStyleName( "grid.header" );
+ grid.add( uriHeader );
+ Label pathHeader = new Label( Messages.getString( "path" ) );
+ pathHeader.setStyleName( "grid.header" );
+ grid.add( pathHeader );
+ Label agentHeader = new Label( Messages.getString( "agent" ) );
+ agentHeader.setStyleName( "grid.header" );
+ grid.add( agentHeader );
+ // add configuration file
+ for ( Iterator configurationFileIterator = parent.getApplication().getConfigurationFiles().iterator();
+ configurationFileIterator.hasNext(); )
+ {
+ ConfigurationFile configurationFile = (ConfigurationFile) configurationFileIterator.next();
+ // row
+ Row row = new Row();
+ row.setCellSpacing( new Extent( 2 ) );
+ row.setInsets( new Insets( 2 ) );
+ grid.add( row );
+ // copy
+ Button copyButton = new Button( Styles.PAGE_COPY );
+ copyButton.setActionCommand( configurationFile.getName() );
+ copyButton.setToolTipText( Messages.getString( "copy" ) );
+ copyButton.addActionListener( copy );
+ row.add( copyButton );
+ // active
+ Button activeButton;
+ if ( configurationFile.isActive() )
+ {
+ activeButton = new Button( Styles.LIGHTBULB );
+ activeButton.setToolTipText( Messages.getString( "switch.disable" ) );
+ }
+ else
+ {
+ activeButton = new Button( Styles.LIGHTBULB_OFF );
+ activeButton.setToolTipText( Messages.getString( "switch.enable" ) );
+ }
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ activeButton.setActionCommand( configurationFile.getName() );
+ activeButton.addActionListener( toggleActive );
+ }
+ row.add( activeButton );
+ // blocker
+ Button blockerButton;
+ if ( configurationFile.isBlocker() )
+ {
+ blockerButton = new Button( Styles.PLUGIN );
+ blockerButton.setToolTipText( Messages.getString( "switch.notblocker" ) );
+ }
+ else
+ {
+ blockerButton = new Button( Styles.PLUGIN_DISABLED );
+ blockerButton.setToolTipText( Messages.getString( "switch.blocker" ) );
+ }
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ blockerButton.setActionCommand( configurationFile.getName() );
+ blockerButton.addActionListener( toggleBlocker );
+ }
+ row.add( blockerButton );
+ // up
+ Button upButton = new Button( Styles.ARROW_UP );
+ upButton.setToolTipText( Messages.getString( "up" ) );
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ upButton.setActionCommand( configurationFile.getName() );
+ upButton.addActionListener( up );
+ }
+ row.add( upButton );
+ // down
+ Button downButton = new Button( Styles.ARROW_DOWN );
+ downButton.setToolTipText( Messages.getString( "down" ) );
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ downButton.setActionCommand( configurationFile.getName() );
+ downButton.addActionListener( down );
+ }
+ row.add( downButton );
+ // status
+ Button statusButton = new Button( Styles.INFORMATION );
+ statusButton.setToolTipText( Messages.getString( "status" ) );
+ statusButton.setActionCommand( configurationFile.getName() );
+ statusButton.addActionListener( status );
+ row.add( statusButton );
+ // update
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ Button updateButton = new Button( Styles.COG );
+ updateButton.setToolTipText( Messages.getString( "update" ) );
+ updateButton.setActionCommand( configurationFile.getName() );
+ updateButton.addActionListener( update );
+ row.add( updateButton );
+ }
+ // delete
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ Button deleteButton = new Button( Styles.DELETE );
+ deleteButton.setToolTipText( Messages.getString( "delete" ) );
+ deleteButton.setActionCommand( configurationFile.getName() );
+ deleteButton.addActionListener( delete );
+ row.add( deleteButton );
+ }
+ // name
+ Button name = new Button( configurationFile.getName() );
+ name.setActionCommand( configurationFile.getName() );
+ name.addActionListener( edit );
+ grid.add( name );
+ // uri
+ Label uri = new Label( configurationFile.getUri() );
+ uri.setStyleName( "default" );
+ grid.add( uri );
+ // path
+ Label path = new Label( configurationFile.getPath() );
+ path.setStyleName( "default" );
+ grid.add( path );
+ // agent
+ Label agent = new Label( configurationFile.getAgent() );
+ agent.setStyleName( "default" );
+ grid.add( agent );
+ }
+ }
+
+ /**
+ * Return the <code>ApplicationWindow</code> parent pane.
+ *
+ * @return the parent <code>ApplicationWindow</code>.
+ */
+ public ApplicationWindow getParentPane()
+ {
+ return parent;
+ }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationContentManagerWindow.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationContentManagerWindow.java
index f7f0ff6..0a9ab23 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationContentManagerWindow.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationContentManagerWindow.java
@@ -47,915 +47,931 @@
* JEE application content manager window.
*/
public class ApplicationContentManagerWindow
- extends WindowPane
+ extends WindowPane
{
- private String contentManagerName;
+ private String contentManagerName;
- private ContentManager contentManager;
+ private ContentManager contentManager;
- private ApplicationContentManagersPane parent;
+ private ApplicationContentManagersPane parent;
- private TextField nameField;
+ private TextField nameField;
- private SelectField activeField;
+ private SelectField activeField;
- private SelectField blockerField;
+ private SelectField blockerField;
- private TextField classnameField;
+ private TextField classnameField;
- private SelectField agentField;
+ private SelectField agentField;
- private Grid propertiesGrid;
+ private Grid propertiesGrid;
- private TextField newPropertyNameField;
+ private TextField newPropertyNameField;
- private TextField newPropertyValueField;
+ private TextField newPropertyValueField;
- class UpdateThread
- extends Thread
- {
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ class UpdateThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent =
- kalumet.getAgent( parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
- if ( agent == null )
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent(
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the webservice
+ ContentManagerClient client = new ContentManagerClient( agent.getHostname(), agent.getPort() );
+ client.update( parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName(),
+ parent.getParentPane().getServerName(), parent.getParentPane().getApplicationName(),
+ contentManagerName, false );
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JEE application " + parent.getParentPane().getApplicationName() + " content manager "
+ + contentManagerName + " update failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- // call the webservice
- ContentManagerClient client = new ContentManagerClient( agent.getHostname(), agent.getPort() );
- client.update( parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName(),
- parent.getParentPane().getServerName(), parent.getParentPane().getApplicationName(),
- contentManagerName, false );
- }
- catch ( Exception e )
- {
- failure = true;
- message =
- "JEE application " + parent.getParentPane().getApplicationName() + " content manager " + contentManagerName
- + " update failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
}
- }
- // refresh
- private ActionListener refresh = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // refresh
+ private ActionListener refresh = new ActionListener()
{
- // looking for the content manager object
- ApplicationContentManagerWindow.this.contentManager =
- parent.getParentPane().getApplication().getContentManager( contentManagerName );
- if ( ApplicationContentManagerWindow.this.contentManager == null )
- {
- ApplicationContentManagerWindow.this.contentManager = new ContentManager();
- }
- // update the window
- update();
- }
- };
-
- // close
- private ActionListener close = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- ApplicationContentManagerWindow.this.userClose();
- }
- };
-
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- // delete the content manager
- parent.getParentPane().getApplication().getContentManagers().remove( contentManager );
+ // looking for the content manager object
+ ApplicationContentManagerWindow.this.contentManager =
+ parent.getParentPane().getApplication().getContentManager( contentManagerName );
+ if ( ApplicationContentManagerWindow.this.contentManager == null )
+ {
+ ApplicationContentManagerWindow.this.contentManager = new ContentManager();
+ }
+ // update the window
+ update();
+ }
+ };
+
+ // close
+ private ActionListener close = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ ApplicationContentManagerWindow.this.userClose();
+ }
+ };
+
+ // delete
+ private ActionListener delete = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // delete the content manager
+ parent.getParentPane().getApplication().getContentManagers().remove( contentManager );
+ // add a change event
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Delete JEE application " + parent.getParentPane().getApplicationName()
+ + " content manager " + contentManager.getName() );
+ // change the updated flag
+ parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the parent pane
+ parent.update();
+ // close the window
+ ApplicationContentManagerWindow.this.userClose();
+ }
+ } ) );
+ }
+ };
+
+ // apply
+ private ActionListener apply = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get the fields value
+ String nameFieldValue = nameField.getText();
+ int activeFieldIndex = activeField.getSelectedIndex();
+ int blockerFieldIndex = blockerField.getSelectedIndex();
+ String classnameFieldValue = classnameField.getText();
+ String agentFieldValue = (String) agentField.getSelectedItem();
+ // check fields
+ if ( nameFieldValue == null || nameFieldValue.trim().length() < 1 || classnameFieldValue == null
+ || classnameFieldValue.trim().length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "contentmanager.mandatory" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // if the user change the content manager name, check if the new
+ // content manager name doesn't already exist
+ if ( contentManagerName == null || ( contentManagerName != null && !contentManagerName.equals(
+ nameFieldValue ) ) )
+ {
+ if ( parent.getParentPane().getApplication().getContentManager( nameFieldValue ) != null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "contentmanager.exists" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ }
// add a change event
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Delete JEE application " + parent.getParentPane().getApplicationName() + " content manager "
- + contentManager.getName() );
+ if ( contentManagerName != null )
+ {
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Change JEE application " + parent.getParentPane().getApplicationName() + " content manager "
+ + contentManager.getName() );
+ }
+ // update the content manager object
+ contentManager.setName( nameFieldValue );
+ if ( activeFieldIndex == 0 )
+ {
+ contentManager.setActive( true );
+ }
+ else
+ {
+ contentManager.setActive( false );
+ }
+ if ( blockerFieldIndex == 0 )
+ {
+ contentManager.setBlocker( true );
+ }
+ else
+ {
+ contentManager.setBlocker( false );
+ }
+ contentManager.setClassname( classnameFieldValue );
+ contentManager.setAgent( agentFieldValue );
+ // add the content manager object if needed
+ if ( contentManagerName == null )
+ {
+ try
+ {
+ parent.getParentPane().getApplication().addContentManager( contentManager );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Add JEE application " + parent.getParentPane().getApplicationName() + " content manager "
+ + contentManager.getName() );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "contentmanager.exists" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ }
+ // update the window definition
+ setTitle( Messages.getString( "contentmanager" ) + " " + contentManager.getName() );
+ setId( "contentmanagerwindow_"
+ + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
+ + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName()
+ + "_" + contentManager.getName() );
+ contentManagerName = contentManager.getName();
// change the updated flag
parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
// update the journal log tab pane
parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the parent window
+ parent.update();
+ // update the window
+ update();
+ }
+ };
+
+ // delete property
+ private ActionListener deleteProperty = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the property object
+ Property property = contentManager.getProperty( event.getActionCommand() );
+ if ( property == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "property.notfound" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // delete the property object
+ contentManager.getProperties().remove( property );
+ // add a change event
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Delete JEE application " + parent.getParentPane().getApplicationName() + " content manager "
+ + contentManager.getName() + " property " + property.getName() );
+ // change the updated flag
+ parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the window
+ update();
+ }
+ };
+
+ // edit property
+ private ActionListener editProperty = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get fields
+ TextField propertyNameField = (TextField) ApplicationContentManagerWindow.this.getComponent(
+ "propertyname_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
+ + "_" + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName()
+ + "_" + contentManagerName + "_" + event.getActionCommand() );
+ TextField propertyValueField = (TextField) ApplicationContentManagerWindow.this.getComponent(
+ "propertyvalue_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
+ + "_" + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName()
+ + "_" + contentManagerName + "_" + event.getActionCommand() );
+ // get fields value
+ String propertyNameFieldValue = propertyNameField.getText();
+ String propertyValueFieldValue = propertyValueField.getText();
+ // check fields
+ if ( propertyNameFieldValue == null || propertyNameFieldValue.trim().length() < 1
+ || propertyValueFieldValue == null || propertyValueFieldValue.trim().length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "contentmanager.mandatory" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // if the user change the property name, check if the name doens't
+ // already exist
+ if ( !propertyNameFieldValue.equals( event.getActionCommand() ) )
+ {
+ if ( contentManager.getProperty( propertyNameFieldValue ) != null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "contentmanager.exists" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ }
+ // looking for the property object
+ Property property = contentManager.getProperty( event.getActionCommand() );
+ if ( property == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "property.notfound" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // add a change event
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Change JEE application " + parent.getParentPane().getApplicationName() + " content manager "
+ + contentManagerName + " property " + property.getName() );
+ // update the property
+ property.setName( propertyNameFieldValue );
+ property.setValue( propertyValueFieldValue );
+ // change the updated flag
+ parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the window
+ update();
+ }
+ };
+
+ // create property
+ private ActionListener createProperty = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get fields value
+ String newPropertyNameFieldValue = newPropertyNameField.getText();
+ String newPropertyValueFieldValue = newPropertyValueField.getText();
+ // check fields
+ if ( newPropertyNameFieldValue == null || newPropertyNameFieldValue.trim().length() < 1
+ || newPropertyValueFieldValue == null || newPropertyValueFieldValue.trim().length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "property.mandatory" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // create the property object
+ Property property = new Property();
+ property.setName( newPropertyNameFieldValue );
+ property.setValue( newPropertyValueFieldValue );
+ try
+ {
+ contentManager.addProperty( property );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "property.exists" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // add a change event
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Add JEE application " + parent.getParentPane().getApplicationName() + " content manager "
+ + contentManagerName + " property " + property.getName() );
+ // change the updated flag
+ parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the window
+ update();
+ }
+ };
+
+ // copy
+ private ActionListener copy = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ try
+ {
+ KalumetConsoleApplication.getApplication().setCopyComponent( contentManager.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
+
+ // paste
+ private ActionListener paste = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+ // check if the copy is correct
+ if ( copy == null || !( copy instanceof ContentManager ) )
+ {
+ return;
+ }
+ contentManager = (ContentManager) copy;
+ contentManagerName = null;
// update the parent pane
parent.update();
- // close the window
- ApplicationContentManagerWindow.this.userClose();
- }
- } ) );
- }
- };
-
- // apply
- private ActionListener apply = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get the fields value
- String nameFieldValue = nameField.getText();
- int activeFieldIndex = activeField.getSelectedIndex();
- int blockerFieldIndex = blockerField.getSelectedIndex();
- String classnameFieldValue = classnameField.getText();
- String agentFieldValue = (String) agentField.getSelectedItem();
- // check fields
- if ( nameFieldValue == null || nameFieldValue.trim().length() < 1 || classnameFieldValue == null
- || classnameFieldValue.trim().length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "contentmanager.mandatory" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // if the user change the content manager name, check if the new
- // content manager name doesn't already exist
- if ( contentManagerName == null || ( contentManagerName != null && !contentManagerName.equals(
- nameFieldValue ) ) )
- {
- if ( parent.getParentPane().getApplication().getContentManager( nameFieldValue ) != null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "contentmanager.exists" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
+ // upate the window
+ update();
}
- }
- // add a change event
- if ( contentManagerName != null )
- {
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Change JEE application " + parent.getParentPane().getApplicationName() + " content manager "
- + contentManager.getName() );
- }
- // update the content manager object
- contentManager.setName( nameFieldValue );
- if ( activeFieldIndex == 0 )
- {
- contentManager.setActive( true );
- }
- else
- {
- contentManager.setActive( false );
- }
- if ( blockerFieldIndex == 0 )
- {
- contentManager.setBlocker( true );
- }
- else
- {
- contentManager.setBlocker( false );
- }
- contentManager.setClassname( classnameFieldValue );
- contentManager.setAgent( agentFieldValue );
- // add the content manager object if needed
- if ( contentManagerName == null )
- {
+ };
+
+ // update
+ private ActionListener update = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if a change has not been saved
+ if ( parent.getParentPane().getParentPane().getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // add a message into the log pane and the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application " + parent.getParentPane().getApplicationName() + " content manager "
+ + contentManagerName + " update in progress...",
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + parent.getParentPane().getApplicationName() + " content manager "
+ + contentManagerName + " update requested." );
+ // start the update thread
+ final UpdateThread updateThread = new UpdateThread();
+ updateThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( updateThread.ended )
+ {
+ if ( updateThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ updateThread.message,
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ updateThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ "JEE application " + parent.getParentPane().getApplicationName()
+ + " content manager " + contentManagerName + " updated.",
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + parent.getParentPane().getApplicationName()
+ + " content manager " + contentManagerName + " updated." );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ } ) );
+ }
+ };
+
+ // copy property
+ private ActionListener copyProperty = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // looking for the property object
+ Property property = contentManager.getProperty( event.getActionCommand() );
+ if ( property == null )
+ {
+ return;
+ }
+ try
+ {
+ KalumetConsoleApplication.getApplication().setCopyComponent( property );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
+
+ // paste property
+ private ActionListener pasteProperty = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+ // check if the copy is correct
+ if ( copy == null || !( copy instanceof Property ) )
+ {
+ return;
+ }
+ // update the new fields
+ newPropertyNameField.setText( ( (Property) copy ).getName() );
+ newPropertyValueField.setText( ( (Property) copy ).getValue() );
+ }
+ };
+
+ /**
+ * Create a new <code>ApplicationContentManagerWindow</code>.
+ *
+ * @param parent the <code>ApplicationContentManagersPane</code>.
+ * @param contentManagerName the original <code>ContentManager</code> name.
+ */
+ public ApplicationContentManagerWindow( ApplicationContentManagersPane parent, String contentManagerName )
+ {
+ super();
+
+ // update the parent pane
+ this.parent = parent;
+
+ // update the content manager name
+ this.contentManagerName = contentManagerName;
+
+ // update the content manager object from the parent pane
+ this.contentManager = parent.getParentPane().getApplication().getContentManager( contentManagerName );
+ if ( this.contentManager == null )
+ {
+ this.contentManager = new ContentManager();
+ }
+
+ if ( contentManagerName == null )
+ {
+ setTitle( Messages.getString( "contentmanager" ) );
+ }
+ else
+ {
+ setTitle( Messages.getString( "contentmanager" ) + " " + contentManagerName );
+ }
+ setId(
+ "contentmanagerwindow_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
+ + "_" + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
+ + contentManagerName );
+ setStyleName( "default" );
+ setWidth( new Extent( 450, Extent.PX ) );
+ setHeight( new Extent( 300, Extent.PX ) );
+ setModal( false );
+ setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
+
+ // create a split pane for the control buttons
+ SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
+ add( splitPane );
+
+ // add the control pane
+ Row controlRow = new Row();
+ controlRow.setStyleName( "control" );
+ splitPane.add( controlRow );
+ // add the refresh button
+ Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
+ refreshButton.setStyleName( "control" );
+ refreshButton.addActionListener( refresh );
+ controlRow.add( refreshButton );
+ // add the copy button
+ Button copyButton = new Button( Messages.getString( "copy" ), Styles.PAGE_COPY );
+ copyButton.setStyleName( "control" );
+ copyButton.addActionListener( copy );
+ controlRow.add( copyButton );
+ if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // add the paste button
+ Button pasteButton = new Button( Messages.getString( "paste" ), Styles.PAGE_PASTE );
+ pasteButton.setStyleName( "control" );
+ pasteButton.addActionListener( paste );
+ controlRow.add( pasteButton );
+ }
+ // add the update button
+ if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ Button updateButton = new Button( Messages.getString( "update" ), Styles.COG );
+ updateButton.setStyleName( "control" );
+ updateButton.addActionListener( update );
+ controlRow.add( updateButton );
+ }
+ if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // add the apply button
+ Button applyButton = new Button( Messages.getString( "apply" ), Styles.ACCEPT );
+ applyButton.setStyleName( "control" );
+ applyButton.addActionListener( apply );
+ controlRow.add( applyButton );
+ // add the delete button
+ Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
+ deleteButton.setStyleName( "control" );
+ deleteButton.addActionListener( delete );
+ controlRow.add( deleteButton );
+ }
+ // add the close button
+ Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
+ closeButton.setStyleName( "control" );
+ closeButton.addActionListener( close );
+ controlRow.add( closeButton );
+
+ // add the main tab pane
+ TabPane tabPane = new TabPane();
+ tabPane.setStyleName( "default" );
+ splitPane.add( tabPane );
+
+ // add the general tab
+ TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "general" ) );
+ ContentPane generalTabPane = new ContentPane();
+ generalTabPane.setStyleName( "tab.content" );
+ generalTabPane.setLayoutData( tabLayoutData );
+ tabPane.add( generalTabPane );
+ Grid generalLayoutGrid = new Grid( 2 );
+ generalLayoutGrid.setStyleName( "default" );
+ generalLayoutGrid.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
+ generalLayoutGrid.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
+ generalTabPane.add( generalLayoutGrid );
+ // name
+ Label nameLabel = new Label( Messages.getString( "name" ) );
+ nameLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( nameLabel );
+ nameField = new TextField();
+ nameField.setStyleName( "default" );
+ nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ generalLayoutGrid.add( nameField );
+ // active
+ Label activeLabel = new Label( Messages.getString( "active" ) );
+ activeLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( activeLabel );
+ activeField = new SelectField( MainScreen.LABELS );
+ activeField.setStyleName( "default" );
+ activeField.setSelectedIndex( 0 );
+ activeField.setWidth( new Extent( 10, Extent.EX ) );
+ generalLayoutGrid.add( activeField );
+ // blocker
+ Label blockerLabel = new Label( Messages.getString( "blocker" ) );
+ blockerLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( blockerLabel );
+ blockerField = new SelectField( MainScreen.LABELS );
+ blockerField.setStyleName( "default" );
+ blockerField.setSelectedIndex( 1 );
+ blockerField.setWidth( new Extent( 10, Extent.EX ) );
+ generalLayoutGrid.add( blockerField );
+ // classname
+ Label classnameLabel = new Label( Messages.getString( "classname" ) );
+ classnameLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( classnameLabel );
+ classnameField = new TextField();
+ classnameField.setStyleName( "default" );
+ classnameField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ generalLayoutGrid.add( classnameField );
+ // agent
+ Label agentLabel = new Label( Messages.getString( "agent" ) );
+ agentLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( agentLabel );
+ agentField = new SelectField();
+ agentField.setStyleName( "default" );
+ agentField.setWidth( new Extent( 50, Extent.EX ) );
+ generalLayoutGrid.add( agentField );
+
+ // add the properties tab
+ tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "properties" ) );
+ ContentPane propertiesTabPane = new ContentPane();
+ propertiesTabPane.setStyleName( "tab.content" );
+ propertiesTabPane.setLayoutData( tabLayoutData );
+ tabPane.add( propertiesTabPane );
+ propertiesGrid = new Grid( 3 );
+ propertiesGrid.setStyleName( "grid.border" );
+ propertiesGrid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
+ propertiesGrid.setColumnWidth( 1, new Extent( 50, Extent.PERCENT ) );
+ propertiesGrid.setColumnWidth( 2, new Extent( 50, Extent.PERCENT ) );
+ propertiesTabPane.add( propertiesGrid );
+
+ // update the window
+ update();
+ }
+
+ /**
+ * Update the window
+ */
+ public void update()
+ {
+ // update the content manager name field
+ nameField.setText( contentManager.getName() );
+ // update the content manager active field
+ if ( contentManager.isActive() )
+ {
+ activeField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ activeField.setSelectedIndex( 1 );
+ }
+ // update the content manager blocker field
+ if ( contentManager.isBlocker() )
+ {
+ blockerField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ blockerField.setSelectedIndex( 1 );
+ }
+ // update the classname field
+ classnameField.setText( contentManager.getClassname() );
+ // update the agent field
+ DefaultListModel agentListModel = (DefaultListModel) agentField.getModel();
+ agentListModel.removeAll();
+ agentListModel.add( "" );
try
{
- parent.getParentPane().getApplication().addContentManager( contentManager );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Add JEE application " + parent.getParentPane().getApplicationName() + " content manager "
- + contentManager.getName() );
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ for ( Iterator agentIterator = kalumet.getAgents().iterator(); agentIterator.hasNext(); )
+ {
+ Agent agent = (Agent) agentIterator.next();
+ agentListModel.add( agent.getId() );
+ }
+ agentField.setSelectedItem( contentManager.getAgent() );
}
catch ( Exception e )
{
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "contentmanager.exists" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage(),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
}
- }
- // update the window definition
- setTitle( Messages.getString( "contentmanager" ) + " " + contentManager.getName() );
- setId(
- "contentmanagerwindow_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
- + "_" + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
- + contentManager.getName() );
- contentManagerName = contentManager.getName();
- // change the updated flag
- parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the parent window
- parent.update();
- // update the window
- update();
- }
- };
-
- // delete property
- private ActionListener deleteProperty = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the property object
- Property property = contentManager.getProperty( event.getActionCommand() );
- if ( property == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "property.notfound" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // delete the property object
- contentManager.getProperties().remove( property );
- // add a change event
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Delete JEE application " + parent.getParentPane().getApplicationName() + " content manager "
- + contentManager.getName() + " property " + property.getName() );
- // change the updated flag
- parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the window
- update();
- }
- };
-
- // edit property
- private ActionListener editProperty = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get fields
- TextField propertyNameField = (TextField) ApplicationContentManagerWindow.this.getComponent(
- "propertyname_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
- + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
- + contentManagerName + "_" + event.getActionCommand() );
- TextField propertyValueField = (TextField) ApplicationContentManagerWindow.this.getComponent(
- "propertyvalue_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
- + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
- + contentManagerName + "_" + event.getActionCommand() );
- // get fields value
- String propertyNameFieldValue = propertyNameField.getText();
- String propertyValueFieldValue = propertyValueField.getText();
- // check fields
- if ( propertyNameFieldValue == null || propertyNameFieldValue.trim().length() < 1
- || propertyValueFieldValue == null || propertyValueFieldValue.trim().length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "contentmanager.mandatory" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // if the user change the property name, check if the name doens't
- // already exist
- if ( !propertyNameFieldValue.equals( event.getActionCommand() ) )
- {
- if ( contentManager.getProperty( propertyNameFieldValue ) != null )
+ // remove all properties grid children
+ propertiesGrid.removeAll();
+ // add properties grid header
+ Label propertyActionHeader = new Label( " " );
+ propertyActionHeader.setStyleName( "grid.header" );
+ propertiesGrid.add( propertyActionHeader );
+ Label propertyNameHeader = new Label( Messages.getString( "name" ) );
+ propertyNameHeader.setStyleName( "grid.header" );
+ propertiesGrid.add( propertyNameHeader );
+ Label propertyValueHeader = new Label( Messages.getString( "value" ) );
+ propertyValueHeader.setStyleName( "grid.header" );
+ propertiesGrid.add( propertyValueHeader );
+ // add properties
+ for ( Iterator propertyIterator = contentManager.getProperties().iterator(); propertyIterator.hasNext(); )
{
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "contentmanager.exists" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- }
- // looking for the property object
- Property property = contentManager.getProperty( event.getActionCommand() );
- if ( property == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "property.notfound" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // add a change event
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Change JEE application " + parent.getParentPane().getApplicationName() + " content manager "
- + contentManagerName + " property " + property.getName() );
- // update the property
- property.setName( propertyNameFieldValue );
- property.setValue( propertyValueFieldValue );
- // change the updated flag
- parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the window
- update();
- }
- };
-
- // create property
- private ActionListener createProperty = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get fields value
- String newPropertyNameFieldValue = newPropertyNameField.getText();
- String newPropertyValueFieldValue = newPropertyValueField.getText();
- // check fields
- if ( newPropertyNameFieldValue == null || newPropertyNameFieldValue.trim().length() < 1
- || newPropertyValueFieldValue == null || newPropertyValueFieldValue.trim().length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "property.mandatory" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // create the property object
- Property property = new Property();
- property.setName( newPropertyNameFieldValue );
- property.setValue( newPropertyValueFieldValue );
- try
- {
- contentManager.addProperty( property );
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "property.exists" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // add a change event
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Add JEE application " + parent.getParentPane().getApplicationName() + " content manager " + contentManagerName
- + " property " + property.getName() );
- // change the updated flag
- parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the window
- update();
- }
- };
-
- // copy
- private ActionListener copy = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- try
- {
- KalumetConsoleApplication.getApplication().setCopyComponent( contentManager.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
-
- // paste
- private ActionListener paste = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
- // check if the copy is correct
- if ( copy == null || !( copy instanceof ContentManager ) )
- {
- return;
- }
- contentManager = (ContentManager) copy;
- contentManagerName = null;
- // update the parent pane
- parent.update();
- // upate the window
- update();
- }
- };
-
- // update
- private ActionListener update = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the lock
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if a change has not been saved
- if ( parent.getParentPane().getParentPane().getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // add a message into the log pane and the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application " + parent.getParentPane().getApplicationName() + " content manager "
- + contentManagerName + " update in progress...",
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getParentPane().getApplicationName() + " content manager "
- + contentManagerName + " update requested." );
- // start the update thread
- final UpdateThread updateThread = new UpdateThread();
- updateThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ Property property = (Property) propertyIterator.next();
+ // row
+ Row row = new Row();
+ row.setCellSpacing( new Extent( 2 ) );
+ row.setInsets( new Insets( 2 ) );
+ propertiesGrid.add( row );
+ // property copy
+ Button copyButton = new Button( Styles.PAGE_COPY );
+ copyButton.setToolTipText( Messages.getString( "copy" ) );
+ copyButton.setActionCommand( property.getName() );
+ copyButton.addActionListener( copyProperty );
+ row.add( copyButton );
+ // property delete / edit
+ if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
{
- public void run()
- {
- if ( updateThread.ended )
- {
- if ( updateThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( updateThread.message,
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- updateThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "JEE application " + parent.getParentPane().getApplicationName() + " content manager "
- + contentManagerName + " updated.",
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getParentPane().getApplicationName() + " content manager "
- + contentManagerName + " updated." );
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
- } );
- }
- } ) );
+ // property edit
+ Button editButton = new Button( Styles.ACCEPT );
+ editButton.setToolTipText( Messages.getString( "apply" ) );
+ editButton.setActionCommand( property.getName() );
+ editButton.addActionListener( editProperty );
+ row.add( editButton );
+ // property delete
+ Button deleteButton = new Button( Styles.DELETE );
+ deleteButton.setToolTipText( Messages.getString( "delete" ) );
+ deleteButton.setActionCommand( property.getName() );
+ deleteButton.addActionListener( deleteProperty );
+ row.add( deleteButton );
+ }
+ // property name
+ TextField propertyNameField = new TextField();
+ propertyNameField.setStyleName( "default" );
+ propertyNameField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ propertyNameField.setId(
+ "propertyname_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
+ + "_" + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName()
+ + "_" + contentManagerName + "_" + property.getName() );
+ propertyNameField.setText( property.getName() );
+ propertiesGrid.add( propertyNameField );
+ // property value
+ TextField propertyValueField = new TextField();
+ propertyValueField.setStyleName( "default" );
+ propertyValueField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ propertyValueField.setId(
+ "propertyvalue_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
+ + "_" + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName()
+ + "_" + contentManagerName + "_" + property.getName() );
+ propertyValueField.setText( property.getValue() );
+ propertiesGrid.add( propertyValueField );
+ }
+ // add the adding property row
+ if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // row
+ Row row = new Row();
+ row.setCellSpacing( new Extent( 2 ) );
+ row.setInsets( new Insets( 2 ) );
+ propertiesGrid.add( row );
+ // paste
+ Button pasteButton = new Button( Styles.PAGE_PASTE );
+ pasteButton.setToolTipText( Messages.getString( "paste" ) );
+ pasteButton.addActionListener( pasteProperty );
+ row.add( pasteButton );
+ // add
+ Button addButton = new Button( Styles.ADD );
+ addButton.setToolTipText( Messages.getString( "add" ) );
+ addButton.addActionListener( createProperty );
+ row.add( addButton );
+ // new property name
+ newPropertyNameField = new TextField();
+ newPropertyNameField.setStyleName( "default" );
+ newPropertyNameField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ propertiesGrid.add( newPropertyNameField );
+ // new property value
+ newPropertyValueField = new TextField();
+ newPropertyValueField.setStyleName( "default" );
+ newPropertyValueField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ propertiesGrid.add( newPropertyValueField );
+ }
}
- };
-
- // copy property
- private ActionListener copyProperty = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // looking for the property object
- Property property = contentManager.getProperty( event.getActionCommand() );
- if ( property == null )
- {
- return;
- }
- try
- {
- KalumetConsoleApplication.getApplication().setCopyComponent( property );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
-
- // paste property
- private ActionListener pasteProperty = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
- // check if the copy is correct
- if ( copy == null || !( copy instanceof Property ) )
- {
- return;
- }
- // update the new fields
- newPropertyNameField.setText( ( (Property) copy ).getName() );
- newPropertyValueField.setText( ( (Property) copy ).getValue() );
- }
- };
-
- /**
- * Create a new <code>ApplicationContentManagerWindow</code>.
- *
- * @param parent the <code>ApplicationContentManagersPane</code>.
- * @param contentManagerName the original <code>ContentManager</code> name.
- */
- public ApplicationContentManagerWindow( ApplicationContentManagersPane parent, String contentManagerName )
- {
- super();
-
- // update the parent pane
- this.parent = parent;
-
- // update the content manager name
- this.contentManagerName = contentManagerName;
-
- // update the content manager object from the parent pane
- this.contentManager = parent.getParentPane().getApplication().getContentManager( contentManagerName );
- if ( this.contentManager == null )
- {
- this.contentManager = new ContentManager();
- }
-
- if ( contentManagerName == null )
- {
- setTitle( Messages.getString( "contentmanager" ) );
- }
- else
- {
- setTitle( Messages.getString( "contentmanager" ) + " " + contentManagerName );
- }
- setId(
- "contentmanagerwindow_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
- + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
- + contentManagerName );
- setStyleName( "default" );
- setWidth( new Extent( 450, Extent.PX ) );
- setHeight( new Extent( 300, Extent.PX ) );
- setModal( false );
- setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
-
- // create a split pane for the control buttons
- SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
- add( splitPane );
-
- // add the control pane
- Row controlRow = new Row();
- controlRow.setStyleName( "control" );
- splitPane.add( controlRow );
- // add the refresh button
- Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
- refreshButton.setStyleName( "control" );
- refreshButton.addActionListener( refresh );
- controlRow.add( refreshButton );
- // add the copy button
- Button copyButton = new Button( Messages.getString( "copy" ), Styles.PAGE_COPY );
- copyButton.setStyleName( "control" );
- copyButton.addActionListener( copy );
- controlRow.add( copyButton );
- if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- // add the paste button
- Button pasteButton = new Button( Messages.getString( "paste" ), Styles.PAGE_PASTE );
- pasteButton.setStyleName( "control" );
- pasteButton.addActionListener( paste );
- controlRow.add( pasteButton );
- }
- // add the update button
- if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
- {
- Button updateButton = new Button( Messages.getString( "update" ), Styles.COG );
- updateButton.setStyleName( "control" );
- updateButton.addActionListener( update );
- controlRow.add( updateButton );
- }
- if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- // add the apply button
- Button applyButton = new Button( Messages.getString( "apply" ), Styles.ACCEPT );
- applyButton.setStyleName( "control" );
- applyButton.addActionListener( apply );
- controlRow.add( applyButton );
- // add the delete button
- Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
- deleteButton.setStyleName( "control" );
- deleteButton.addActionListener( delete );
- controlRow.add( deleteButton );
- }
- // add the close button
- Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
- closeButton.setStyleName( "control" );
- closeButton.addActionListener( close );
- controlRow.add( closeButton );
-
- // add the main tab pane
- TabPane tabPane = new TabPane();
- tabPane.setStyleName( "default" );
- splitPane.add( tabPane );
-
- // add the general tab
- TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "general" ) );
- ContentPane generalTabPane = new ContentPane();
- generalTabPane.setStyleName( "tab.content" );
- generalTabPane.setLayoutData( tabLayoutData );
- tabPane.add( generalTabPane );
- Grid generalLayoutGrid = new Grid( 2 );
- generalLayoutGrid.setStyleName( "default" );
- generalLayoutGrid.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
- generalLayoutGrid.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
- generalTabPane.add( generalLayoutGrid );
- // name
- Label nameLabel = new Label( Messages.getString( "name" ) );
- nameLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( nameLabel );
- nameField = new TextField();
- nameField.setStyleName( "default" );
- nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
- generalLayoutGrid.add( nameField );
- // active
- Label activeLabel = new Label( Messages.getString( "active" ) );
- activeLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( activeLabel );
- activeField = new SelectField( MainScreen.LABELS );
- activeField.setStyleName( "default" );
- activeField.setSelectedIndex( 0 );
- activeField.setWidth( new Extent( 10, Extent.EX ) );
- generalLayoutGrid.add( activeField );
- // blocker
- Label blockerLabel = new Label( Messages.getString( "blocker" ) );
- blockerLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( blockerLabel );
- blockerField = new SelectField( MainScreen.LABELS );
- blockerField.setStyleName( "default" );
- blockerField.setSelectedIndex( 1 );
- blockerField.setWidth( new Extent( 10, Extent.EX ) );
- generalLayoutGrid.add( blockerField );
- // classname
- Label classnameLabel = new Label( Messages.getString( "classname" ) );
- classnameLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( classnameLabel );
- classnameField = new TextField();
- classnameField.setStyleName( "default" );
- classnameField.setWidth( new Extent( 100, Extent.PERCENT ) );
- generalLayoutGrid.add( classnameField );
- // agent
- Label agentLabel = new Label( Messages.getString( "agent" ) );
- agentLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( agentLabel );
- agentField = new SelectField();
- agentField.setStyleName( "default" );
- agentField.setWidth( new Extent( 50, Extent.EX ) );
- generalLayoutGrid.add( agentField );
-
- // add the properties tab
- tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "properties" ) );
- ContentPane propertiesTabPane = new ContentPane();
- propertiesTabPane.setStyleName( "tab.content" );
- propertiesTabPane.setLayoutData( tabLayoutData );
- tabPane.add( propertiesTabPane );
- propertiesGrid = new Grid( 3 );
- propertiesGrid.setStyleName( "grid.border" );
- propertiesGrid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
- propertiesGrid.setColumnWidth( 1, new Extent( 50, Extent.PERCENT ) );
- propertiesGrid.setColumnWidth( 2, new Extent( 50, Extent.PERCENT ) );
- propertiesTabPane.add( propertiesGrid );
-
- // update the window
- update();
- }
-
- /**
- * Update the window
- */
- public void update()
- {
- // update the content manager name field
- nameField.setText( contentManager.getName() );
- // update the content manager active field
- if ( contentManager.isActive() )
- {
- activeField.setSelectedIndex( 0 );
- }
- else
- {
- activeField.setSelectedIndex( 1 );
- }
- // update the content manager blocker field
- if ( contentManager.isBlocker() )
- {
- blockerField.setSelectedIndex( 0 );
- }
- else
- {
- blockerField.setSelectedIndex( 1 );
- }
- // update the classname field
- classnameField.setText( contentManager.getClassname() );
- // update the agent field
- DefaultListModel agentListModel = (DefaultListModel) agentField.getModel();
- agentListModel.removeAll();
- agentListModel.add( "" );
- try
- {
- Kalumet kalumet = ConfigurationManager.loadStore();
- for ( Iterator agentIterator = kalumet.getAgents().iterator(); agentIterator.hasNext(); )
- {
- Agent agent = (Agent) agentIterator.next();
- agentListModel.add( agent.getId() );
- }
- agentField.setSelectedItem( contentManager.getAgent() );
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage(),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- }
- // remove all properties grid children
- propertiesGrid.removeAll();
- // add properties grid header
- Label propertyActionHeader = new Label( " " );
- propertyActionHeader.setStyleName( "grid.header" );
- propertiesGrid.add( propertyActionHeader );
- Label propertyNameHeader = new Label( Messages.getString( "name" ) );
- propertyNameHeader.setStyleName( "grid.header" );
- propertiesGrid.add( propertyNameHeader );
- Label propertyValueHeader = new Label( Messages.getString( "value" ) );
- propertyValueHeader.setStyleName( "grid.header" );
- propertiesGrid.add( propertyValueHeader );
- // add properties
- for ( Iterator propertyIterator = contentManager.getProperties().iterator(); propertyIterator.hasNext(); )
- {
- Property property = (Property) propertyIterator.next();
- // row
- Row row = new Row();
- row.setCellSpacing( new Extent( 2 ) );
- row.setInsets( new Insets( 2 ) );
- propertiesGrid.add( row );
- // property copy
- Button copyButton = new Button( Styles.PAGE_COPY );
- copyButton.setToolTipText( Messages.getString( "copy" ) );
- copyButton.setActionCommand( property.getName() );
- copyButton.addActionListener( copyProperty );
- row.add( copyButton );
- // property delete / edit
- if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- // property edit
- Button editButton = new Button( Styles.ACCEPT );
- editButton.setToolTipText( Messages.getString( "apply" ) );
- editButton.setActionCommand( property.getName() );
- editButton.addActionListener( editProperty );
- row.add( editButton );
- // property delete
- Button deleteButton = new Button( Styles.DELETE );
- deleteButton.setToolTipText( Messages.getString( "delete" ) );
- deleteButton.setActionCommand( property.getName() );
- deleteButton.addActionListener( deleteProperty );
- row.add( deleteButton );
- }
- // property name
- TextField propertyNameField = new TextField();
- propertyNameField.setStyleName( "default" );
- propertyNameField.setWidth( new Extent( 100, Extent.PERCENT ) );
- propertyNameField.setId(
- "propertyname_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
- + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
- + contentManagerName + "_" + property.getName() );
- propertyNameField.setText( property.getName() );
- propertiesGrid.add( propertyNameField );
- // property value
- TextField propertyValueField = new TextField();
- propertyValueField.setStyleName( "default" );
- propertyValueField.setWidth( new Extent( 100, Extent.PERCENT ) );
- propertyValueField.setId(
- "propertyvalue_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
- + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
- + contentManagerName + "_" + property.getName() );
- propertyValueField.setText( property.getValue() );
- propertiesGrid.add( propertyValueField );
- }
- // add the adding property row
- if ( parent.getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- // row
- Row row = new Row();
- row.setCellSpacing( new Extent( 2 ) );
- row.setInsets( new Insets( 2 ) );
- propertiesGrid.add( row );
- // paste
- Button pasteButton = new Button( Styles.PAGE_PASTE );
- pasteButton.setToolTipText( Messages.getString( "paste" ) );
- pasteButton.addActionListener( pasteProperty );
- row.add( pasteButton );
- // add
- Button addButton = new Button( Styles.ADD );
- addButton.setToolTipText( Messages.getString( "add" ) );
- addButton.addActionListener( createProperty );
- row.add( addButton );
- // new property name
- newPropertyNameField = new TextField();
- newPropertyNameField.setStyleName( "default" );
- newPropertyNameField.setWidth( new Extent( 100, Extent.PERCENT ) );
- propertiesGrid.add( newPropertyNameField );
- // new property value
- newPropertyValueField = new TextField();
- newPropertyValueField.setStyleName( "default" );
- newPropertyValueField.setWidth( new Extent( 100, Extent.PERCENT ) );
- propertiesGrid.add( newPropertyValueField );
- }
- }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationContentManagersPane.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationContentManagersPane.java
index ac33590..36a8fe5 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationContentManagersPane.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationContentManagersPane.java
@@ -40,508 +40,525 @@
* JEE application content managers pane.
*/
public class ApplicationContentManagersPane
- extends ContentPane
+ extends ContentPane
{
- private ApplicationWindow parent;
+ private ApplicationWindow parent;
- private Grid grid;
+ private Grid grid;
- class UpdateThread
- extends Thread
- {
-
- public String contentManagerName;
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ class UpdateThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
- if ( agent == null )
+
+ public String contentManagerName;
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent =
+ kalumet.getAgent( parent.getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the webservice
+ ContentManagerClient client = new ContentManagerClient( agent.getHostname(), agent.getPort() );
+ client.update( parent.getParentPane().getEnvironmentWindow().getEnvironmentName(),
+ parent.getServerName(), parent.getApplicationName(), contentManagerName, false );
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JEE application " + parent.getApplicationName() + " content manager " + contentManagerName
+ + " update failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- // call the webservice
- ContentManagerClient client = new ContentManagerClient( agent.getHostname(), agent.getPort() );
- client.update( parent.getParentPane().getEnvironmentWindow().getEnvironmentName(), parent.getServerName(),
- parent.getApplicationName(), contentManagerName, false );
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JEE application " + parent.getApplicationName() + " content manager " + contentManagerName
- + " update failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
}
- }
- // toggle active
- private ActionListener toggleActive = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // toggle active
+ private ActionListener toggleActive = new ActionListener()
{
- // check if the user has the environment lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the content manager object
- ContentManager contentManager = parent.getApplication().getContentManager( event.getActionCommand() );
- if ( contentManager == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "contentmanager.notfound" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // change the state and add a change event
- if ( contentManager.isActive() )
- {
- contentManager.setActive( false );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Disable JEE application " + parent.getApplicationName() + " content manager " + contentManager.getName() );
- }
- else
- {
- contentManager.setActive( true );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Enable JEE application " + parent.getApplicationName() + " content manager " + contentManager.getName() );
- }
- // change the updated flag
- parent.getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the pane
- update();
- }
- };
-
- // toggle blocker
- private ActionListener toggleBlocker = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the content manager object
- ContentManager contentManager = parent.getApplication().getContentManager( event.getActionCommand() );
- if ( contentManager == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "contentmanager.notfound" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // change the blocker state and add a change event
- if ( contentManager.isBlocker() )
- {
- contentManager.setBlocker( false );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Set not blocker for JEE application " + parent.getApplicationName() + " content manager "
- + contentManager.getName() );
- }
- else
- {
- contentManager.setBlocker( true );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Set blocker for JEE application " + parent.getApplicationName() + " content manager "
- + contentManager.getName() );
- }
- // change the updated flag
- parent.getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the pane
- update();
- }
- };
-
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the content manager object
- final ContentManager contentManager = parent.getApplication().getContentManager( event.getActionCommand() );
- if ( contentManager == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "contentmanager.notfound" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- // delete the content manager object
- parent.getApplication().getContentManagers().remove( contentManager );
- // add a change event
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Delete JEE application " + parent.getApplicationName() + " content manager "
- + contentManager.getName() );
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the content manager object
+ ContentManager contentManager = parent.getApplication().getContentManager( event.getActionCommand() );
+ if ( contentManager == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "contentmanager.notfound" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // change the state and add a change event
+ if ( contentManager.isActive() )
+ {
+ contentManager.setActive( false );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Disable JEE application " + parent.getApplicationName() + " content manager "
+ + contentManager.getName() );
+ }
+ else
+ {
+ contentManager.setActive( true );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Enable JEE application " + parent.getApplicationName() + " content manager "
+ + contentManager.getName() );
+ }
// change the updated flag
parent.getParentPane().getEnvironmentWindow().setUpdated( true );
// update the journal log tab pane
parent.getParentPane().getEnvironmentWindow().updateJournalPane();
// update the pane
update();
- }
- } ) );
- }
- };
+ }
+ };
- // update
- private ActionListener update = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // toggle blocker
+ private ActionListener toggleBlocker = new ActionListener()
{
- // check if the user has the lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if a change has not been saved
- if ( parent.getParentPane().getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get the content manager name
- final String contentManagerName = event.getActionCommand();
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- // add a message into the log pane and the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application " + parent.getApplicationName() + " content manager " + contentManagerName
- + " update in progress...", parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getApplicationName() + " content manager " + contentManagerName
- + " update requested." );
- // start the update thread
- final UpdateThread updateThread = new UpdateThread();
- updateThread.contentManagerName = contentManagerName;
- updateThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
{
- public void run()
- {
- if ( updateThread.ended )
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the content manager object
+ ContentManager contentManager = parent.getApplication().getContentManager( event.getActionCommand() );
+ if ( contentManager == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "contentmanager.notfound" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // change the blocker state and add a change event
+ if ( contentManager.isBlocker() )
+ {
+ contentManager.setBlocker( false );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Set not blocker for JEE application " + parent.getApplicationName() + " content manager "
+ + contentManager.getName() );
+ }
+ else
+ {
+ contentManager.setBlocker( true );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Set blocker for JEE application " + parent.getApplicationName() + " content manager "
+ + contentManager.getName() );
+ }
+ // change the updated flag
+ parent.getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the pane
+ update();
+ }
+ };
+
+ // delete
+ private ActionListener delete = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the content manager object
+ final ContentManager contentManager = parent.getApplication().getContentManager( event.getActionCommand() );
+ if ( contentManager == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "contentmanager.notfound" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
{
- if ( updateThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( updateThread.message,
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add( updateThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "JEE application " + parent.getApplicationName() + " content manager " + contentManagerName
- + " updated.", parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getApplicationName() + " content manager " + contentManagerName
- + " updated." );
- }
- }
- else
+ public void actionPerformed( ActionEvent event )
+ {
+ // delete the content manager object
+ parent.getApplication().getContentManagers().remove( contentManager );
+ // add a change event
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Delete JEE application " + parent.getApplicationName() + " content manager "
+ + contentManager.getName() );
+ // change the updated flag
+ parent.getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the pane
+ update();
+ }
+ } ) );
+ }
+ };
+
+ // update
+ private ActionListener update = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if a change has not been saved
+ if ( parent.getParentPane().getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get the content manager name
+ final String contentManagerName = event.getActionCommand();
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
{
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
- } );
- }
- } ) );
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ // add a message into the log pane and the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application " + parent.getApplicationName() + " content manager " + contentManagerName
+ + " update in progress...",
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + parent.getApplicationName() + " content manager " + contentManagerName
+ + " update requested." );
+ // start the update thread
+ final UpdateThread updateThread = new UpdateThread();
+ updateThread.contentManagerName = contentManagerName;
+ updateThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( updateThread.ended )
+ {
+ if ( updateThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ updateThread.message,
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ updateThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ "JEE application " + parent.getApplicationName() + " content manager "
+ + contentManagerName + " updated.",
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + parent.getApplicationName() + " content manager "
+ + contentManagerName + " updated." );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ } ) );
+ }
+ };
- // edit
- private ActionListener edit = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // edit
+ private ActionListener edit = new ActionListener()
{
- if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
- "contentmanagerwindow_" + parent.getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
- + parent.getServerName() + "_" + parent.getApplicationName() + "_" + event.getActionCommand() ) == null )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ApplicationContentManagerWindow( ApplicationContentManagersPane.this, event.getActionCommand() ) );
- }
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
+ "contentmanagerwindow_" + parent.getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
+ + parent.getServerName() + "_" + parent.getApplicationName() + "_" + event.getActionCommand() )
+ == null )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ApplicationContentManagerWindow( ApplicationContentManagersPane.this,
+ event.getActionCommand() ) );
+ }
+ }
+ };
- // create
- private ActionListener create = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // create
+ private ActionListener create = new ActionListener()
{
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ApplicationContentManagerWindow( ApplicationContentManagersPane.this, null ) );
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ApplicationContentManagerWindow( ApplicationContentManagersPane.this, null ) );
+ }
+ };
- // copy
- private ActionListener copy = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // copy
+ private ActionListener copy = new ActionListener()
{
- // looking for the content manager object
- ContentManager contentManager = parent.getApplication().getContentManager( event.getActionCommand() );
- if ( contentManager == null )
- {
- return;
- }
- try
- {
- KalumetConsoleApplication.getApplication().setCopyComponent( contentManager.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ // looking for the content manager object
+ ContentManager contentManager = parent.getApplication().getContentManager( event.getActionCommand() );
+ if ( contentManager == null )
+ {
+ return;
+ }
+ try
+ {
+ KalumetConsoleApplication.getApplication().setCopyComponent( contentManager.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
- /**
- * Create a new <code>ApplicationContentManagersPane</code>.
- *
- * @param parent the parent <code>ApplicationWindow</code>.
- */
- public ApplicationContentManagersPane( ApplicationWindow parent )
- {
- super();
- setStyleName( "tab.content" );
-
- // update parent
- this.parent = parent;
-
- // column layout content
- Column content = new Column();
- add( content );
-
- // add the create button
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
+ /**
+ * Create a new <code>ApplicationContentManagersPane</code>.
+ *
+ * @param parent the parent <code>ApplicationWindow</code>.
+ */
+ public ApplicationContentManagersPane( ApplicationWindow parent )
{
- Button createButton = new Button( Messages.getString( "contentmanager.add" ), Styles.ADD );
- createButton.addActionListener( create );
- content.add( createButton );
+ super();
+ setStyleName( "tab.content" );
+
+ // update parent
+ this.parent = parent;
+
+ // column layout content
+ Column content = new Column();
+ add( content );
+
+ // add the create button
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ Button createButton = new Button( Messages.getString( "contentmanager.add" ), Styles.ADD );
+ createButton.addActionListener( create );
+ content.add( createButton );
+ }
+
+ // add the content managers grid
+ grid = new Grid( 4 );
+ grid.setStyleName( "border.grid" );
+ grid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
+ content.add( grid );
+
+ // update the pane
+ update();
}
- // add the content managers grid
- grid = new Grid( 4 );
- grid.setStyleName( "border.grid" );
- grid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
- content.add( grid );
-
- // update the pane
- update();
- }
-
- /**
- * Update the pane
- */
- public void update()
- {
- // remove all content mangers grid children
- grid.removeAll();
- // add content managers grid header
- // action header
- Label actionHeader = new Label( " " );
- actionHeader.setStyleName( "grid.header" );
- grid.add( actionHeader );
- // name header
- Label nameHeader = new Label( Messages.getString( "name" ) );
- nameHeader.setStyleName( "grid.header" );
- grid.add( nameHeader );
- // classname header
- Label classnameHeader = new Label( Messages.getString( "classname" ) );
- classnameHeader.setStyleName( "grid.header" );
- grid.add( classnameHeader );
- // agent header
- Label agentHeader = new Label( Messages.getString( "agent" ) );
- agentHeader.setStyleName( "grid.header" );
- grid.add( agentHeader );
- // add content manager
- for ( Iterator contentManagerIterator = parent.getApplication().getContentManagers().iterator();
- contentManagerIterator.hasNext(); )
+ /**
+ * Update the pane
+ */
+ public void update()
{
- ContentManager contentManager = (ContentManager) contentManagerIterator.next();
- // row
- Row row = new Row();
- row.setCellSpacing( new Extent( 2 ) );
- row.setInsets( new Insets( 2 ) );
- grid.add( row );
- // copy
- Button copyButton = new Button( Styles.PAGE_COPY );
- copyButton.setToolTipText( Messages.getString( "copy" ) );
- copyButton.setActionCommand( contentManager.getName() );
- copyButton.addActionListener( copy );
- row.add( copyButton );
- // active
- Button activeButton;
- if ( contentManager.isActive() )
- {
- activeButton = new Button( Styles.LIGHTBULB );
- activeButton.setToolTipText( Messages.getString( "switch.disable" ) );
- }
- else
- {
- activeButton = new Button( Styles.LIGHTBULB_OFF );
- activeButton.setToolTipText( Messages.getString( "switch.enable" ) );
- }
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- activeButton.setActionCommand( contentManager.getName() );
- activeButton.addActionListener( toggleActive );
- }
- row.add( activeButton );
- // blocker
- Button blockerButton;
- if ( contentManager.isBlocker() )
- {
- blockerButton = new Button( Styles.PLUGIN );
- blockerButton.setToolTipText( Messages.getString( "switch.notblocker" ) );
- }
- else
- {
- blockerButton = new Button( Styles.PLUGIN_DISABLED );
- blockerButton.setToolTipText( Messages.getString( "switch.blocker" ) );
- }
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- blockerButton.setActionCommand( contentManager.getName() );
- blockerButton.addActionListener( toggleBlocker );
- }
- row.add( blockerButton );
- // up
- // TODO
- // down
- // TODO
- // update
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
- {
- Button updateButton = new Button( Styles.COG );
- updateButton.setToolTipText( Messages.getString( "update" ) );
- updateButton.setActionCommand( contentManager.getName() );
- updateButton.addActionListener( update );
- row.add( updateButton );
- }
- // delete
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- Button deleteButton = new Button( Styles.DELETE );
- deleteButton.setToolTipText( Messages.getString( "delete" ) );
- deleteButton.setActionCommand( contentManager.getName() );
- deleteButton.addActionListener( delete );
- row.add( deleteButton );
- }
- // name
- Button name = new Button( contentManager.getName() );
- name.setStyleName( "default" );
- name.setActionCommand( contentManager.getName() );
- name.addActionListener( edit );
- grid.add( name );
- // classname
- Label classname = new Label( contentManager.getClassname() );
- classname.setStyleName( "default" );
- grid.add( classname );
- // agent
- Label agent = new Label( contentManager.getAgent() );
- agent.setStyleName( "default" );
- grid.add( agent );
+ // remove all content mangers grid children
+ grid.removeAll();
+ // add content managers grid header
+ // action header
+ Label actionHeader = new Label( " " );
+ actionHeader.setStyleName( "grid.header" );
+ grid.add( actionHeader );
+ // name header
+ Label nameHeader = new Label( Messages.getString( "name" ) );
+ nameHeader.setStyleName( "grid.header" );
+ grid.add( nameHeader );
+ // classname header
+ Label classnameHeader = new Label( Messages.getString( "classname" ) );
+ classnameHeader.setStyleName( "grid.header" );
+ grid.add( classnameHeader );
+ // agent header
+ Label agentHeader = new Label( Messages.getString( "agent" ) );
+ agentHeader.setStyleName( "grid.header" );
+ grid.add( agentHeader );
+ // add content manager
+ for ( Iterator contentManagerIterator = parent.getApplication().getContentManagers().iterator();
+ contentManagerIterator.hasNext(); )
+ {
+ ContentManager contentManager = (ContentManager) contentManagerIterator.next();
+ // row
+ Row row = new Row();
+ row.setCellSpacing( new Extent( 2 ) );
+ row.setInsets( new Insets( 2 ) );
+ grid.add( row );
+ // copy
+ Button copyButton = new Button( Styles.PAGE_COPY );
+ copyButton.setToolTipText( Messages.getString( "copy" ) );
+ copyButton.setActionCommand( contentManager.getName() );
+ copyButton.addActionListener( copy );
+ row.add( copyButton );
+ // active
+ Button activeButton;
+ if ( contentManager.isActive() )
+ {
+ activeButton = new Button( Styles.LIGHTBULB );
+ activeButton.setToolTipText( Messages.getString( "switch.disable" ) );
+ }
+ else
+ {
+ activeButton = new Button( Styles.LIGHTBULB_OFF );
+ activeButton.setToolTipText( Messages.getString( "switch.enable" ) );
+ }
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ activeButton.setActionCommand( contentManager.getName() );
+ activeButton.addActionListener( toggleActive );
+ }
+ row.add( activeButton );
+ // blocker
+ Button blockerButton;
+ if ( contentManager.isBlocker() )
+ {
+ blockerButton = new Button( Styles.PLUGIN );
+ blockerButton.setToolTipText( Messages.getString( "switch.notblocker" ) );
+ }
+ else
+ {
+ blockerButton = new Button( Styles.PLUGIN_DISABLED );
+ blockerButton.setToolTipText( Messages.getString( "switch.blocker" ) );
+ }
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ blockerButton.setActionCommand( contentManager.getName() );
+ blockerButton.addActionListener( toggleBlocker );
+ }
+ row.add( blockerButton );
+ // up
+ // TODO
+ // down
+ // TODO
+ // update
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ Button updateButton = new Button( Styles.COG );
+ updateButton.setToolTipText( Messages.getString( "update" ) );
+ updateButton.setActionCommand( contentManager.getName() );
+ updateButton.addActionListener( update );
+ row.add( updateButton );
+ }
+ // delete
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ Button deleteButton = new Button( Styles.DELETE );
+ deleteButton.setToolTipText( Messages.getString( "delete" ) );
+ deleteButton.setActionCommand( contentManager.getName() );
+ deleteButton.addActionListener( delete );
+ row.add( deleteButton );
+ }
+ // name
+ Button name = new Button( contentManager.getName() );
+ name.setStyleName( "default" );
+ name.setActionCommand( contentManager.getName() );
+ name.addActionListener( edit );
+ grid.add( name );
+ // classname
+ Label classname = new Label( contentManager.getClassname() );
+ classname.setStyleName( "default" );
+ grid.add( classname );
+ // agent
+ Label agent = new Label( contentManager.getAgent() );
+ agent.setStyleName( "default" );
+ grid.add( agent );
+ }
}
- }
- /**
- * Get the parent <code>ApplicationWindow</code>.
- *
- * @return the parent <code>ApplicationWindow</code>.
- */
- public ApplicationWindow getParentPane()
- {
- return parent;
- }
+ /**
+ * Get the parent <code>ApplicationWindow</code>.
+ *
+ * @return the parent <code>ApplicationWindow</code>.
+ */
+ public ApplicationWindow getParentPane()
+ {
+ return parent;
+ }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationDatabaseSqlScriptWindow.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationDatabaseSqlScriptWindow.java
index 0db5970..04d5304 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationDatabaseSqlScriptWindow.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationDatabaseSqlScriptWindow.java
@@ -42,773 +42,788 @@
* JEE application database sql script window.
*/
public class ApplicationDatabaseSqlScriptWindow
- extends WindowPane
+ extends WindowPane
{
- private String sqlScriptName;
+ private String sqlScriptName;
- private SqlScript sqlScript;
+ private SqlScript sqlScript;
- private ApplicationDatabaseWindow parent;
+ private ApplicationDatabaseWindow parent;
- private TextField nameField;
+ private TextField nameField;
- private SelectField activeField;
+ private SelectField activeField;
- private SelectField blockerField;
+ private SelectField blockerField;
- private SelectField forceField;
+ private SelectField forceField;
- private TextField uriField;
+ private TextField uriField;
- private Grid mappingsGrid;
+ private Grid mappingsGrid;
- private TextField newMappingKeyField;
+ private TextField newMappingKeyField;
- private TextField newMappingValueField;
+ private TextField newMappingValueField;
- // refresh
- private ActionListener refresh = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // refresh
+ private ActionListener refresh = new ActionListener()
{
- // looking for the sql script object
- ApplicationDatabaseSqlScriptWindow.this.sqlScript = parent.getDatabase().getSqlScript( sqlScriptName );
- if ( ApplicationDatabaseSqlScriptWindow.this.sqlScript == null )
- {
- ApplicationDatabaseSqlScriptWindow.this.sqlScript = new SqlScript();
- }
- // update the window
- update();
- }
- };
-
- // close
- private ActionListener close = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- ApplicationDatabaseSqlScriptWindow.this.userClose();
- }
- };
-
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- // delete the sql script
- parent.getDatabase().getSqlScripts().remove( sqlScript );
+ // looking for the sql script object
+ ApplicationDatabaseSqlScriptWindow.this.sqlScript = parent.getDatabase().getSqlScript( sqlScriptName );
+ if ( ApplicationDatabaseSqlScriptWindow.this.sqlScript == null )
+ {
+ ApplicationDatabaseSqlScriptWindow.this.sqlScript = new SqlScript();
+ }
+ // update the window
+ update();
+ }
+ };
+
+ // close
+ private ActionListener close = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ ApplicationDatabaseSqlScriptWindow.this.userClose();
+ }
+ };
+
+ // delete
+ private ActionListener delete = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // delete the sql script
+ parent.getDatabase().getSqlScripts().remove( sqlScript );
+ // add a change event
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Delete SQL script " + sqlScript.getName() );
+ // change the updated flag
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().setUpdated(
+ true );
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the parent pane
+ parent.update();
+ // close the window
+ ApplicationDatabaseSqlScriptWindow.this.userClose();
+ }
+ } ) );
+ }
+ };
+
+ // apply
+ private ActionListener apply = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get the fields value
+ String nameFieldValue = nameField.getText();
+ int activeFieldIndex = activeField.getSelectedIndex();
+ int blockerFieldIndex = blockerField.getSelectedIndex();
+ int forceFieldIndex = forceField.getSelectedIndex();
+ String uriFieldValue = uriField.getText();
+ // check fields
+ if ( nameFieldValue == null || nameFieldValue.trim().length() < 1 || uriFieldValue == null
+ || uriFieldValue.trim().length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "sql.script.mandatory" ),
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // if the user change the sql script name, check if the new name
+ // doesn't already exist
+ if ( sqlScriptName == null || ( sqlScriptName != null && !sqlScriptName.equals( nameFieldValue ) ) )
+ {
+ if ( parent.getDatabase().getSqlScript( nameFieldValue ) != null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "sql.script.exists" ),
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ }
// add a change event
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Delete SQL script " + sqlScript.getName() );
+ if ( sqlScriptName != null )
+ {
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Change SQL script " + sqlScript.getName() );
+ }
+ // update the sql script object
+ sqlScript.setName( nameFieldValue );
+ if ( activeFieldIndex == 0 )
+ {
+ sqlScript.setActive( true );
+ }
+ else
+ {
+ sqlScript.setActive( false );
+ }
+ if ( blockerFieldIndex == 0 )
+ {
+ sqlScript.setBlocker( true );
+ }
+ else
+ {
+ sqlScript.setBlocker( false );
+ }
+ if ( forceFieldIndex == 0 )
+ {
+ sqlScript.setForce( true );
+ }
+ else
+ {
+ sqlScript.setForce( false );
+ }
+ sqlScript.setUri( uriFieldValue );
+ // add the sql script object if needed
+ if ( sqlScriptName == null )
+ {
+ try
+ {
+ parent.getDatabase().addSqlScript( sqlScript );
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Add SQL script " + sqlScript.getName() );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "sql.script.exists" ),
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ }
+ // update the window definition
+ setTitle( Messages.getString( "sql.script" ) + " " + sqlScript.getName() );
+ setId( "sqlscriptwindow_"
+ + parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
+ + "_" + parent.getParentPane().getParentPane().getServerName() + "_"
+ + parent.getParentPane().getParentPane().getApplicationName() + "_" + parent.getDatabaseName()
+ + "_" + sqlScript.getName() );
+ sqlScriptName = sqlScript.getName();
// change the updated flag
parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
// update the journal log tab pane
parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the parent window
+ parent.update();
+ // update the window
+ update();
+ }
+ };
+
+ // delete mapping
+ public ActionListener deleteMapping = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the mapping object
+ Mapping mapping = sqlScript.getMapping( event.getActionCommand() );
+ if ( mapping == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "mapping.notfound" ),
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // delete the mapping object
+ sqlScript.getMappings().remove( mapping );
+ // add a change event
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Delete SQL script " + sqlScript.getName() + " mapping " + mapping.getKey() );
+ // change the updated flag
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the window
+ update();
+ }
+ };
+
+ // edit mapping
+ private ActionListener editMapping = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get fields
+ TextField mappingKeyField = (TextField) ApplicationDatabaseSqlScriptWindow.this.getComponent( "mappingkey_"
+ + parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
+ + "_"
+ + parent.getParentPane().getParentPane().getServerName()
+ + "_"
+ + parent.getParentPane().getParentPane().getApplicationName()
+ + "_"
+ + parent.getDatabaseName()
+ + "_"
+ + sqlScriptName
+ + "_"
+ + event.getActionCommand() );
+ TextField mappingValueField = (TextField) ApplicationDatabaseSqlScriptWindow.this.getComponent(
+ "mappingvalue_"
+ + parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
+ + "_" + parent.getParentPane().getParentPane().getServerName() + "_"
+ + parent.getParentPane().getParentPane().getApplicationName() + "_" + parent.getDatabaseName() + "_"
+ + sqlScriptName + "_" + event.getActionCommand() );
+ // get fields value
+ String mappingKeyFieldValue = mappingKeyField.getText();
+ String mappingValueFieldValue = mappingValueField.getText();
+ // check fields
+ if ( mappingKeyFieldValue == null || mappingKeyFieldValue.trim().length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "mapping.mandatory" ),
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // if the user change the mapping key, check if the key doesn't already
+ // exists
+ if ( !mappingKeyFieldValue.equals( event.getActionCommand() ) )
+ {
+ if ( sqlScript.getMapping( mappingKeyFieldValue ) != null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "mapping.exists" ),
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ }
+ // looking for the mapping object
+ Mapping mapping = sqlScript.getMapping( event.getActionCommand() );
+ if ( mapping == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "mapping.notfound" ),
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // add change event
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Change SQL script " + sqlScript.getName() + " mapping " + mapping.getKey() );
+ // update the mapping
+ mapping.setKey( mappingKeyFieldValue );
+ mapping.setValue( mappingValueFieldValue );
+ // change the updated flag
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the window
+ update();
+ }
+ };
+
+ // create mapping
+ private ActionListener createMapping = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get fields value
+ String newMappingKeyFieldValue = newMappingKeyField.getText();
+ String newMappingValueFieldValue = newMappingValueField.getText();
+ // check fields
+ if ( newMappingKeyFieldValue == null || newMappingKeyFieldValue.trim().length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "mapping.mandatory" ),
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // create the mapping object
+ Mapping mapping = new Mapping();
+ mapping.setKey( newMappingKeyFieldValue );
+ mapping.setValue( newMappingValueFieldValue );
+ try
+ {
+ sqlScript.addMapping( mapping );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "mapping.exists" ),
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // add a change event
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Add SQL script " + sqlScript.getName() + " mapping " + mapping.getKey() );
+ // change the updated flag
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the window
+ update();
+ }
+ };
+
+ // copy
+ private ActionListener copy = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ try
+ {
+ KalumetConsoleApplication.getApplication().setCopyComponent( sqlScript.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
+
+ // paste
+ private ActionListener paste = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+ // check if the copy is correct
+ if ( copy == null || !( copy instanceof SqlScript ) )
+ {
+ return;
+ }
+ sqlScript = (SqlScript) copy;
+ sqlScriptName = null;
// update the parent pane
parent.update();
- // close the window
- ApplicationDatabaseSqlScriptWindow.this.userClose();
- }
- } ) );
- }
- };
-
- // apply
- private ActionListener apply = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get the fields value
- String nameFieldValue = nameField.getText();
- int activeFieldIndex = activeField.getSelectedIndex();
- int blockerFieldIndex = blockerField.getSelectedIndex();
- int forceFieldIndex = forceField.getSelectedIndex();
- String uriFieldValue = uriField.getText();
- // check fields
- if ( nameFieldValue == null || nameFieldValue.trim().length() < 1 || uriFieldValue == null
- || uriFieldValue.trim().length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "sql.script.mandatory" ),
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // if the user change the sql script name, check if the new name
- // doesn't already exist
- if ( sqlScriptName == null || ( sqlScriptName != null && !sqlScriptName.equals( nameFieldValue ) ) )
- {
- if ( parent.getDatabase().getSqlScript( nameFieldValue ) != null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "sql.script.exists" ),
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
+ // update the window
+ update();
}
- }
- // add a change event
- if ( sqlScriptName != null )
- {
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Change SQL script " + sqlScript.getName() );
- }
- // update the sql script object
- sqlScript.setName( nameFieldValue );
- if ( activeFieldIndex == 0 )
- {
- sqlScript.setActive( true );
- }
- else
- {
- sqlScript.setActive( false );
- }
- if ( blockerFieldIndex == 0 )
- {
- sqlScript.setBlocker( true );
- }
- else
- {
- sqlScript.setBlocker( false );
- }
- if ( forceFieldIndex == 0 )
- {
- sqlScript.setForce( true );
- }
- else
- {
- sqlScript.setForce( false );
- }
- sqlScript.setUri( uriFieldValue );
- // add the sql script object if needed
- if ( sqlScriptName == null )
- {
- try
+ };
+
+ // copy mapping
+ private ActionListener copyMapping = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
{
- parent.getDatabase().addSqlScript( sqlScript );
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Add SQL script " + sqlScript.getName() );
+ // looking for the mapping object
+ Mapping mapping = sqlScript.getMapping( event.getActionCommand() );
+ if ( mapping == null )
+ {
+ return;
+ }
+ try
+ {
+ KalumetConsoleApplication.getApplication().setCopyComponent( mapping.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
}
- catch ( Exception e )
+ };
+
+ // paste mapping
+ private ActionListener pasteMapping = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
{
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "sql.script.exists" ),
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
+ Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+ // check if the copy is correct
+ if ( copy == null || !( copy instanceof Mapping ) )
+ {
+ return;
+ }
+ // update new field
+ newMappingKeyField.setText( ( (Mapping) copy ).getKey() );
+ newMappingValueField.setText( ( (Mapping) copy ).getValue() );
}
- }
- // update the window definition
- setTitle( Messages.getString( "sql.script" ) + " " + sqlScript.getName() );
- setId( "sqlscriptwindow_"
- + parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
- + "_" + parent.getParentPane().getParentPane().getServerName() + "_"
- + parent.getParentPane().getParentPane().getApplicationName() + "_" + parent.getDatabaseName() + "_"
- + sqlScript.getName() );
- sqlScriptName = sqlScript.getName();
- // change the updated flag
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the parent window
- parent.update();
- // update the window
- update();
- }
- };
+ };
- // delete mapping
- public ActionListener deleteMapping = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ /**
+ * Create a new <code>ApplicationDatabaseSqlScriptWindow</code>.
+ *
+ * @param parent the parent <code>ApplicationDatabaseWindow</code>.
+ * @param sqlScriptName the original <code>SqlScript</code> name.
+ */
+ public ApplicationDatabaseSqlScriptWindow( ApplicationDatabaseWindow parent, String sqlScriptName )
{
- // check if the user has the environment lock
- if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the mapping object
- Mapping mapping = sqlScript.getMapping( event.getActionCommand() );
- if ( mapping == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "mapping.notfound" ),
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // delete the mapping object
- sqlScript.getMappings().remove( mapping );
- // add a change event
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Delete SQL script " + sqlScript.getName() + " mapping " + mapping.getKey() );
- // change the updated flag
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the window
- update();
- }
- };
+ super();
- // edit mapping
- private ActionListener editMapping = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get fields
- TextField mappingKeyField = (TextField) ApplicationDatabaseSqlScriptWindow.this.getComponent( "mappingkey_"
- + parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
- + "_"
- + parent.getParentPane().getParentPane().getServerName()
- + "_"
- + parent.getParentPane().getParentPane().getApplicationName()
- + "_"
- + parent.getDatabaseName()
- + "_"
- + sqlScriptName
- + "_"
- + event.getActionCommand() );
- TextField mappingValueField = (TextField) ApplicationDatabaseSqlScriptWindow.this.getComponent( "mappingvalue_"
- + parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
- + "_"
- + parent.getParentPane().getParentPane().getServerName()
- + "_"
- + parent.getParentPane().getParentPane().getApplicationName()
- + "_"
- + parent.getDatabaseName()
- + "_"
- + sqlScriptName
- + "_"
- + event.getActionCommand() );
- // get fields value
- String mappingKeyFieldValue = mappingKeyField.getText();
- String mappingValueFieldValue = mappingValueField.getText();
- // check fields
- if ( mappingKeyFieldValue == null || mappingKeyFieldValue.trim().length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "mapping.mandatory" ),
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // if the user change the mapping key, check if the key doesn't already
- // exists
- if ( !mappingKeyFieldValue.equals( event.getActionCommand() ) )
- {
- if ( sqlScript.getMapping( mappingKeyFieldValue ) != null )
+ // update the parent pane
+ this.parent = parent;
+
+ // update the sql script name
+ this.sqlScriptName = sqlScriptName;
+
+ // update the sql script object from the parent pane
+ this.sqlScript = parent.getDatabase().getSqlScript( sqlScriptName );
+ if ( this.sqlScript == null )
{
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "mapping.exists" ),
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
+ this.sqlScript = new SqlScript();
}
- }
- // looking for the mapping object
- Mapping mapping = sqlScript.getMapping( event.getActionCommand() );
- if ( mapping == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "mapping.notfound" ),
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // add change event
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Change SQL script " + sqlScript.getName() + " mapping " + mapping.getKey() );
- // update the mapping
- mapping.setKey( mappingKeyFieldValue );
- mapping.setValue( mappingValueFieldValue );
- // change the updated flag
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the window
- update();
- }
- };
- // create mapping
- private ActionListener createMapping = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ if ( sqlScriptName == null )
+ {
+ setTitle( Messages.getString( "sql.script" ) );
+ }
+ else
+ {
+ setTitle( Messages.getString( "sql.script" ) + " " + sqlScriptName );
+ }
+ setId( "sqlscriptwindow_"
+ + parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
+ + "_" + parent.getParentPane().getParentPane().getServerName() + "_"
+ + parent.getParentPane().getParentPane().getApplicationName() + "_" + parent.getDatabaseName() + "_"
+ + sqlScriptName );
+ setStyleName( "default" );
+ setModal( false );
+ setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
+
+ // create a split pane for the control buttons
+ SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
+ add( splitPane );
+
+ // add the control pane
+ Row controlRow = new Row();
+ controlRow.setStyleName( "control" );
+ splitPane.add( controlRow );
+ // add the refresh button
+ Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
+ refreshButton.setStyleName( "control" );
+ refreshButton.addActionListener( refresh );
+ controlRow.add( refreshButton );
+ // add the copy button
+ Button copyButton = new Button( Messages.getString( "copy" ), Styles.PAGE_COPY );
+ copyButton.setStyleName( "control" );
+ copyButton.addActionListener( copy );
+ controlRow.add( copyButton );
+ if ( parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // add the paste button
+ Button pasteButton = new Button( Messages.getString( "paste" ), Styles.PAGE_PASTE );
+ pasteButton.setStyleName( "control" );
+ pasteButton.addActionListener( paste );
+ controlRow.add( pasteButton );
+ // add the apply button
+ Button applyButton = new Button( Messages.getString( "apply" ), Styles.ACCEPT );
+ applyButton.setStyleName( "control" );
+ applyButton.addActionListener( apply );
+ controlRow.add( applyButton );
+ // add the delete button
+ Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
+ deleteButton.setStyleName( "control" );
+ deleteButton.addActionListener( delete );
+ controlRow.add( deleteButton );
+ }
+ // add the close button
+ Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
+ closeButton.setStyleName( "control" );
+ closeButton.addActionListener( close );
+ controlRow.add( closeButton );
+
+ // add the main tab pane
+ TabPane tabPane = new TabPane();
+ tabPane.setStyleName( "default" );
+ splitPane.add( tabPane );
+
+ // add the general tab
+ TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "general" ) );
+ ContentPane generalTabPane = new ContentPane();
+ generalTabPane.setStyleName( "tab.content" );
+ generalTabPane.setLayoutData( tabLayoutData );
+ tabPane.add( generalTabPane );
+
+ Grid generalLayoutGrid = new Grid( 2 );
+ generalLayoutGrid.setStyleName( "default" );
+ generalLayoutGrid.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
+ generalLayoutGrid.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
+ generalTabPane.add( generalLayoutGrid );
+ // name
+ Label nameLabel = new Label( Messages.getString( "name" ) );
+ nameLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( nameLabel );
+ nameField = new TextField();
+ nameField.setStyleName( "default" );
+ nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ generalLayoutGrid.add( nameField );
+ // active
+ Label activeLabel = new Label( Messages.getString( "active" ) );
+ activeLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( activeLabel );
+ activeField = new SelectField( MainScreen.LABELS );
+ activeField.setSelectedIndex( 0 );
+ activeField.setStyleName( "default" );
+ activeField.setWidth( new Extent( 10, Extent.EX ) );
+ generalLayoutGrid.add( activeField );
+ Label blockerLabel = new Label( Messages.getString( "blocker" ) );
+ blockerLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( blockerLabel );
+ blockerField = new SelectField( MainScreen.LABELS );
+ blockerField.setSelectedIndex( 0 );
+ blockerField.setStyleName( "default" );
+ blockerField.setWidth( new Extent( 10, Extent.EX ) );
+ generalLayoutGrid.add( blockerField );
+ Label forceLabel = new Label( Messages.getString( "force" ) );
+ forceLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( forceLabel );
+ forceField = new SelectField( MainScreen.LABELS );
+ forceField.setSelectedIndex( 0 );
+ forceField.setStyleName( "default" );
+ forceField.setWidth( new Extent( 10, Extent.EX ) );
+ generalLayoutGrid.add( forceField );
+ Label uriLabel = new Label( Messages.getString( "uri" ) );
+ uriLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( uriLabel );
+ uriField = new TextField();
+ uriField.setStyleName( "default" );
+ uriField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ generalLayoutGrid.add( uriField );
+
+ // add the mappings tab
+ tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "mappings" ) );
+ ContentPane mappingsTabPane = new ContentPane();
+ mappingsTabPane.setStyleName( "tab.content" );
+ mappingsTabPane.setLayoutData( tabLayoutData );
+ tabPane.add( mappingsTabPane );
+ mappingsGrid = new Grid( 3 );
+ mappingsGrid.setStyleName( "grid.border" );
+ mappingsGrid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
+ mappingsGrid.setColumnWidth( 1, new Extent( 50, Extent.PERCENT ) );
+ mappingsGrid.setColumnWidth( 2, new Extent( 50, Extent.PERCENT ) );
+ mappingsTabPane.add( mappingsGrid );
+
+ // update the window
+ update();
+ }
+
+ /**
+ * Update the window.
+ */
+ public void update()
{
- // check if the user has the environment lock
- if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get fields value
- String newMappingKeyFieldValue = newMappingKeyField.getText();
- String newMappingValueFieldValue = newMappingValueField.getText();
- // check fields
- if ( newMappingKeyFieldValue == null || newMappingKeyFieldValue.trim().length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "mapping.mandatory" ),
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // create the mapping object
- Mapping mapping = new Mapping();
- mapping.setKey( newMappingKeyFieldValue );
- mapping.setValue( newMappingValueFieldValue );
- try
- {
- sqlScript.addMapping( mapping );
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "mapping.exists" ),
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // add a change event
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Add SQL script " + sqlScript.getName() + " mapping " + mapping.getKey() );
- // change the updated flag
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the window
- update();
+ // update the sql script name field
+ nameField.setText( sqlScript.getName() );
+ // update the sql script active field
+ if ( sqlScript.isActive() )
+ {
+ activeField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ activeField.setSelectedIndex( 1 );
+ }
+ // update the sql script blocker field
+ if ( sqlScript.isBlocker() )
+ {
+ blockerField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ blockerField.setSelectedIndex( 1 );
+ }
+ // update the sql script force field
+ if ( sqlScript.isForce() )
+ {
+ forceField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ forceField.setSelectedIndex( 1 );
+ }
+ // update the sql script uri field
+ uriField.setText( sqlScript.getUri() );
+
+ // remove all mappings grid children
+ mappingsGrid.removeAll();
+ // add mappings grid header
+ Label mappingActionHeader = new Label( " " );
+ mappingActionHeader.setStyleName( "grid.header" );
+ mappingsGrid.add( mappingActionHeader );
+ Label mappingKeyHeader = new Label( Messages.getString( "key" ) );
+ mappingKeyHeader.setStyleName( "grid.header" );
+ mappingsGrid.add( mappingKeyHeader );
+ Label mappingValueHeader = new Label( Messages.getString( "value" ) );
+ mappingValueHeader.setStyleName( "grid.header" );
+ mappingsGrid.add( mappingValueHeader );
+ // add mapping
+ for ( Iterator mappingIterator = sqlScript.getMappings().iterator(); mappingIterator.hasNext(); )
+ {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ // row
+ Row row = new Row();
+ row.setCellSpacing( new Extent( 2 ) );
+ row.setInsets( new Insets( 2 ) );
+ mappingsGrid.add( row );
+ // mapping copy
+ Button copyButton = new Button( Styles.PAGE_COPY );
+ copyButton.setToolTipText( Messages.getString( "copy" ) );
+ copyButton.setActionCommand( mapping.getKey() );
+ copyButton.addActionListener( copyMapping );
+ row.add( copyButton );
+ // mapping delete / edit
+ if ( parent.getEnvironmentWindow().adminPermission
+ || parent.getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // mapping delete
+ Button deleteButton = new Button( Styles.DELETE );
+ deleteButton.setToolTipText( Messages.getString( "delete" ) );
+ deleteButton.setActionCommand( mapping.getKey() );
+ deleteButton.addActionListener( deleteMapping );
+ row.add( deleteButton );
+ // mapping apply
+ Button applyButton = new Button( Styles.ACCEPT );
+ applyButton.setToolTipText( Messages.getString( "apply" ) );
+ applyButton.setActionCommand( mapping.getKey() );
+ applyButton.addActionListener( editMapping );
+ row.add( applyButton );
+ }
+ // mapping key
+ TextField mappingKeyField = new TextField();
+ mappingKeyField.setStyleName( "default" );
+ mappingKeyField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ mappingKeyField.setId( "mappingkey_"
+ + parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
+ + "_" + parent.getParentPane().getParentPane().getServerName() + "_"
+ + parent.getParentPane().getParentPane().getApplicationName() + "_"
+ + parent.getDatabaseName() + "_" + sqlScriptName + "_" + mapping.getKey() );
+ mappingKeyField.setText( mapping.getKey() );
+ mappingsGrid.add( mappingKeyField );
+ // mapping value
+ TextField mappingValueField = new TextField();
+ mappingValueField.setStyleName( "default" );
+ mappingValueField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ mappingValueField.setId( "mappingvalue_"
+ + parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
+ + "_" + parent.getParentPane().getParentPane().getServerName() + "_"
+ + parent.getParentPane().getParentPane().getApplicationName() + "_"
+ + parent.getDatabaseName() + "_" + sqlScriptName + "_" + mapping.getKey() );
+ mappingValueField.setText( mapping.getValue() );
+ mappingsGrid.add( mappingValueField );
+ }
+ // add a new mapping
+ if ( parent.getEnvironmentWindow().adminPermission
+ || parent.getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // row
+ Row row = new Row();
+ row.setCellSpacing( new Extent( 2 ) );
+ row.setInsets( new Insets( 2 ) );
+ mappingsGrid.add( row );
+ // paste
+ Button pasteButton = new Button( Styles.PAGE_PASTE );
+ pasteButton.setToolTipText( Messages.getString( "paste" ) );
+ pasteButton.addActionListener( pasteMapping );
+ row.add( pasteButton );
+ // add
+ Button addButton = new Button( Styles.ADD );
+ addButton.setToolTipText( Messages.getString( "add" ) );
+ addButton.addActionListener( createMapping );
+ row.add( addButton );
+ // new mapping key
+ newMappingKeyField = new TextField();
+ newMappingKeyField.setStyleName( "default" );
+ newMappingKeyField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ mappingsGrid.add( newMappingKeyField );
+ // new mapping value
+ newMappingValueField = new TextField();
+ newMappingValueField.setStyleName( "default" );
+ newMappingValueField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ mappingsGrid.add( newMappingValueField );
+ }
}
- };
-
- // copy
- private ActionListener copy = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- try
- {
- KalumetConsoleApplication.getApplication().setCopyComponent( sqlScript.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
-
- // paste
- private ActionListener paste = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
- // check if the copy is correct
- if ( copy == null || !( copy instanceof SqlScript ) )
- {
- return;
- }
- sqlScript = (SqlScript) copy;
- sqlScriptName = null;
- // update the parent pane
- parent.update();
- // update the window
- update();
- }
- };
-
- // copy mapping
- private ActionListener copyMapping = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // looking for the mapping object
- Mapping mapping = sqlScript.getMapping( event.getActionCommand() );
- if ( mapping == null )
- {
- return;
- }
- try
- {
- KalumetConsoleApplication.getApplication().setCopyComponent( mapping.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
-
- // paste mapping
- private ActionListener pasteMapping = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
- // check if the copy is correct
- if ( copy == null || !( copy instanceof Mapping ) )
- {
- return;
- }
- // update new field
- newMappingKeyField.setText( ( (Mapping) copy ).getKey() );
- newMappingValueField.setText( ( (Mapping) copy ).getValue() );
- }
- };
-
- /**
- * Create a new <code>ApplicationDatabaseSqlScriptWindow</code>.
- *
- * @param parent the parent <code>ApplicationDatabaseWindow</code>.
- * @param sqlScriptName the original <code>SqlScript</code> name.
- */
- public ApplicationDatabaseSqlScriptWindow( ApplicationDatabaseWindow parent, String sqlScriptName )
- {
- super();
-
- // update the parent pane
- this.parent = parent;
-
- // update the sql script name
- this.sqlScriptName = sqlScriptName;
-
- // update the sql script object from the parent pane
- this.sqlScript = parent.getDatabase().getSqlScript( sqlScriptName );
- if ( this.sqlScript == null )
- {
- this.sqlScript = new SqlScript();
- }
-
- if ( sqlScriptName == null )
- {
- setTitle( Messages.getString( "sql.script" ) );
- }
- else
- {
- setTitle( Messages.getString( "sql.script" ) + " " + sqlScriptName );
- }
- setId( "sqlscriptwindow_"
- + parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
- + parent.getParentPane().getParentPane().getServerName() + "_"
- + parent.getParentPane().getParentPane().getApplicationName() + "_" + parent.getDatabaseName() + "_"
- + sqlScriptName );
- setStyleName( "default" );
- setModal( false );
- setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
-
- // create a split pane for the control buttons
- SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
- add( splitPane );
-
- // add the control pane
- Row controlRow = new Row();
- controlRow.setStyleName( "control" );
- splitPane.add( controlRow );
- // add the refresh button
- Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
- refreshButton.setStyleName( "control" );
- refreshButton.addActionListener( refresh );
- controlRow.add( refreshButton );
- // add the copy button
- Button copyButton = new Button( Messages.getString( "copy" ), Styles.PAGE_COPY );
- copyButton.setStyleName( "control" );
- copyButton.addActionListener( copy );
- controlRow.add( copyButton );
- if ( parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- // add the paste button
- Button pasteButton = new Button( Messages.getString( "paste" ), Styles.PAGE_PASTE );
- pasteButton.setStyleName( "control" );
- pasteButton.addActionListener( paste );
- controlRow.add( pasteButton );
- // add the apply button
- Button applyButton = new Button( Messages.getString( "apply" ), Styles.ACCEPT );
- applyButton.setStyleName( "control" );
- applyButton.addActionListener( apply );
- controlRow.add( applyButton );
- // add the delete button
- Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
- deleteButton.setStyleName( "control" );
- deleteButton.addActionListener( delete );
- controlRow.add( deleteButton );
- }
- // add the close button
- Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
- closeButton.setStyleName( "control" );
- closeButton.addActionListener( close );
- controlRow.add( closeButton );
-
- // add the main tab pane
- TabPane tabPane = new TabPane();
- tabPane.setStyleName( "default" );
- splitPane.add( tabPane );
-
- // add the general tab
- TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "general" ) );
- ContentPane generalTabPane = new ContentPane();
- generalTabPane.setStyleName( "tab.content" );
- generalTabPane.setLayoutData( tabLayoutData );
- tabPane.add( generalTabPane );
-
- Grid generalLayoutGrid = new Grid( 2 );
- generalLayoutGrid.setStyleName( "default" );
- generalLayoutGrid.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
- generalLayoutGrid.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
- generalTabPane.add( generalLayoutGrid );
- // name
- Label nameLabel = new Label( Messages.getString( "name" ) );
- nameLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( nameLabel );
- nameField = new TextField();
- nameField.setStyleName( "default" );
- nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
- generalLayoutGrid.add( nameField );
- // active
- Label activeLabel = new Label( Messages.getString( "active" ) );
- activeLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( activeLabel );
- activeField = new SelectField( MainScreen.LABELS );
- activeField.setSelectedIndex( 0 );
- activeField.setStyleName( "default" );
- activeField.setWidth( new Extent( 10, Extent.EX ) );
- generalLayoutGrid.add( activeField );
- Label blockerLabel = new Label( Messages.getString( "blocker" ) );
- blockerLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( blockerLabel );
- blockerField = new SelectField( MainScreen.LABELS );
- blockerField.setSelectedIndex( 0 );
- blockerField.setStyleName( "default" );
- blockerField.setWidth( new Extent( 10, Extent.EX ) );
- generalLayoutGrid.add( blockerField );
- Label forceLabel = new Label( Messages.getString( "force" ) );
- forceLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( forceLabel );
- forceField = new SelectField( MainScreen.LABELS );
- forceField.setSelectedIndex( 0 );
- forceField.setStyleName( "default" );
- forceField.setWidth( new Extent( 10, Extent.EX ) );
- generalLayoutGrid.add( forceField );
- Label uriLabel = new Label( Messages.getString( "uri" ) );
- uriLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( uriLabel );
- uriField = new TextField();
- uriField.setStyleName( "default" );
- uriField.setWidth( new Extent( 100, Extent.PERCENT ) );
- generalLayoutGrid.add( uriField );
-
- // add the mappings tab
- tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "mappings" ) );
- ContentPane mappingsTabPane = new ContentPane();
- mappingsTabPane.setStyleName( "tab.content" );
- mappingsTabPane.setLayoutData( tabLayoutData );
- tabPane.add( mappingsTabPane );
- mappingsGrid = new Grid( 3 );
- mappingsGrid.setStyleName( "grid.border" );
- mappingsGrid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
- mappingsGrid.setColumnWidth( 1, new Extent( 50, Extent.PERCENT ) );
- mappingsGrid.setColumnWidth( 2, new Extent( 50, Extent.PERCENT ) );
- mappingsTabPane.add( mappingsGrid );
-
- // update the window
- update();
- }
-
- /**
- * Update the window.
- */
- public void update()
- {
- // update the sql script name field
- nameField.setText( sqlScript.getName() );
- // update the sql script active field
- if ( sqlScript.isActive() )
- {
- activeField.setSelectedIndex( 0 );
- }
- else
- {
- activeField.setSelectedIndex( 1 );
- }
- // update the sql script blocker field
- if ( sqlScript.isBlocker() )
- {
- blockerField.setSelectedIndex( 0 );
- }
- else
- {
- blockerField.setSelectedIndex( 1 );
- }
- // update the sql script force field
- if ( sqlScript.isForce() )
- {
- forceField.setSelectedIndex( 0 );
- }
- else
- {
- forceField.setSelectedIndex( 1 );
- }
- // update the sql script uri field
- uriField.setText( sqlScript.getUri() );
-
- // remove all mappings grid children
- mappingsGrid.removeAll();
- // add mappings grid header
- Label mappingActionHeader = new Label( " " );
- mappingActionHeader.setStyleName( "grid.header" );
- mappingsGrid.add( mappingActionHeader );
- Label mappingKeyHeader = new Label( Messages.getString( "key" ) );
- mappingKeyHeader.setStyleName( "grid.header" );
- mappingsGrid.add( mappingKeyHeader );
- Label mappingValueHeader = new Label( Messages.getString( "value" ) );
- mappingValueHeader.setStyleName( "grid.header" );
- mappingsGrid.add( mappingValueHeader );
- // add mapping
- for ( Iterator mappingIterator = sqlScript.getMappings().iterator(); mappingIterator.hasNext(); )
- {
- Mapping mapping = (Mapping) mappingIterator.next();
- // row
- Row row = new Row();
- row.setCellSpacing( new Extent( 2 ) );
- row.setInsets( new Insets( 2 ) );
- mappingsGrid.add( row );
- // mapping copy
- Button copyButton = new Button( Styles.PAGE_COPY );
- copyButton.setToolTipText( Messages.getString( "copy" ) );
- copyButton.setActionCommand( mapping.getKey() );
- copyButton.addActionListener( copyMapping );
- row.add( copyButton );
- // mapping delete / edit
- if ( parent.getEnvironmentWindow().adminPermission || parent.getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- // mapping delete
- Button deleteButton = new Button( Styles.DELETE );
- deleteButton.setToolTipText( Messages.getString( "delete" ) );
- deleteButton.setActionCommand( mapping.getKey() );
- deleteButton.addActionListener( deleteMapping );
- row.add( deleteButton );
- // mapping apply
- Button applyButton = new Button( Styles.ACCEPT );
- applyButton.setToolTipText( Messages.getString( "apply" ) );
- applyButton.setActionCommand( mapping.getKey() );
- applyButton.addActionListener( editMapping );
- row.add( applyButton );
- }
- // mapping key
- TextField mappingKeyField = new TextField();
- mappingKeyField.setStyleName( "default" );
- mappingKeyField.setWidth( new Extent( 100, Extent.PERCENT ) );
- mappingKeyField.setId( "mappingkey_"
- + parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
- + "_" + parent.getParentPane().getParentPane().getServerName() + "_"
- + parent.getParentPane().getParentPane().getApplicationName() + "_"
- + parent.getDatabaseName() + "_" + sqlScriptName + "_" + mapping.getKey() );
- mappingKeyField.setText( mapping.getKey() );
- mappingsGrid.add( mappingKeyField );
- // mapping value
- TextField mappingValueField = new TextField();
- mappingValueField.setStyleName( "default" );
- mappingValueField.setWidth( new Extent( 100, Extent.PERCENT ) );
- mappingValueField.setId( "mappingvalue_"
- + parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
- + "_" + parent.getParentPane().getParentPane().getServerName() + "_"
- + parent.getParentPane().getParentPane().getApplicationName() + "_"
- + parent.getDatabaseName() + "_" + sqlScriptName + "_" + mapping.getKey() );
- mappingValueField.setText( mapping.getValue() );
- mappingsGrid.add( mappingValueField );
- }
- // add a new mapping
- if ( parent.getEnvironmentWindow().adminPermission || parent.getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- // row
- Row row = new Row();
- row.setCellSpacing( new Extent( 2 ) );
- row.setInsets( new Insets( 2 ) );
- mappingsGrid.add( row );
- // paste
- Button pasteButton = new Button( Styles.PAGE_PASTE );
- pasteButton.setToolTipText( Messages.getString( "paste" ) );
- pasteButton.addActionListener( pasteMapping );
- row.add( pasteButton );
- // add
- Button addButton = new Button( Styles.ADD );
- addButton.setToolTipText( Messages.getString( "add" ) );
- addButton.addActionListener( createMapping );
- row.add( addButton );
- // new mapping key
- newMappingKeyField = new TextField();
- newMappingKeyField.setStyleName( "default" );
- newMappingKeyField.setWidth( new Extent( 100, Extent.PERCENT ) );
- mappingsGrid.add( newMappingKeyField );
- // new mapping value
- newMappingValueField = new TextField();
- newMappingValueField.setStyleName( "default" );
- newMappingValueField.setWidth( new Extent( 100, Extent.PERCENT ) );
- mappingsGrid.add( newMappingValueField );
- }
- }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationDatabaseWindow.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationDatabaseWindow.java
index e13594e..3cd111e 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationDatabaseWindow.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationDatabaseWindow.java
@@ -54,1190 +54,1195 @@
* JEE application database window.
*/
public class ApplicationDatabaseWindow
- extends WindowPane
+ extends WindowPane
{
- private static String[] DRIVERS =
- new String[]{ Messages.getString( "jdbc.driver.oracle.thin" ), Messages.getString( "jdbc.driver.ibm.db2" ),
- Messages.getString( "jdbc.driver.mysql" ), Messages.getString( "jdbc.driver.postgresql" ) };
+ private static String[] DRIVERS =
+ new String[]{ Messages.getString( "jdbc.driver.oracle.thin" ), Messages.getString( "jdbc.driver.ibm.db2" ),
+ Messages.getString( "jdbc.driver.mysql" ), Messages.getString( "jdbc.driver.postgresql" ) };
- private String databaseName;
+ private String databaseName;
- private Database database;
+ private Database database;
- private ApplicationDatabasesPane parent;
+ private ApplicationDatabasesPane parent;
- private TextField nameField;
+ private TextField nameField;
- private SelectField activeField;
+ private SelectField activeField;
- private SelectField blockerField;
+ private SelectField blockerField;
- private TextArea sqlCommandArea;
+ private TextArea sqlCommandArea;
- private SelectField driverField;
+ private SelectField driverField;
- private TextField userField;
+ private TextField userField;
- private PasswordField passwordField;
+ private PasswordField passwordField;
- private PasswordField confirmPasswordField;
+ private PasswordField confirmPasswordField;
- private TextField urlField;
+ private TextField urlField;
- private SelectField connectionPoolField;
+ private SelectField connectionPoolField;
- private SelectField agentField;
+ private SelectField agentField;
- private Grid sqlScriptsGrid;
+ private Grid sqlScriptsGrid;
- // update thread
- class UpdateThread
- extends Thread
- {
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // update thread
+ class UpdateThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent =
- kalumet.getAgent( parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
- if ( agent == null )
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent(
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the webservice
+ DatabaseClient client = new DatabaseClient( agent.getHostname(), agent.getPort() );
+ client.update( parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName(),
+ parent.getParentPane().getServerName(), parent.getParentPane().getApplicationName(),
+ databaseName, false );
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JEE application " + parent.getParentPane().getApplicationName() + " database " + databaseName
+ + " update failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- // call the webservice
- DatabaseClient client = new DatabaseClient( agent.getHostname(), agent.getPort() );
- client.update( parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName(),
- parent.getParentPane().getServerName(), parent.getParentPane().getApplicationName(),
- databaseName, false );
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JEE application " + parent.getParentPane().getApplicationName() + " database " + databaseName
- + " update failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
}
- }
- // refresh
- private ActionListener refresh = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // refresh
+ private ActionListener refresh = new ActionListener()
{
- // looking for the database object
- ApplicationDatabaseWindow.this.database = parent.getParentPane().getApplication().getDatabase( databaseName );
- if ( ApplicationDatabaseWindow.this.database == null )
- {
- ApplicationDatabaseWindow.this.database = new Database();
- }
- // update the window
- update();
- }
- };
-
- // close
- private ActionListener close = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- ApplicationDatabaseWindow.this.userClose();
- }
- };
-
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- // delete the database
- parent.getParentPane().getApplication().getDatabases().remove( database );
+ // looking for the database object
+ ApplicationDatabaseWindow.this.database =
+ parent.getParentPane().getApplication().getDatabase( databaseName );
+ if ( ApplicationDatabaseWindow.this.database == null )
+ {
+ ApplicationDatabaseWindow.this.database = new Database();
+ }
+ // update the window
+ update();
+ }
+ };
+
+ // close
+ private ActionListener close = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ ApplicationDatabaseWindow.this.userClose();
+ }
+ };
+
+ // delete
+ private ActionListener delete = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // delete the database
+ parent.getParentPane().getApplication().getDatabases().remove( database );
+ // add a change event
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Delete database " + database.getName() );
+ // change the updated flag
+ parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the parent pane
+ parent.update();
+ // close the window
+ ApplicationDatabaseWindow.this.userClose();
+ }
+ } ) );
+ }
+ };
+
+ // apply
+ private ActionListener apply = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get the fields value
+ String nameFieldValue = nameField.getText();
+ int activeFieldIndex = activeField.getSelectedIndex();
+ int blockerFieldIndex = blockerField.getSelectedIndex();
+ String sqlCommandAreaValue = sqlCommandArea.getText();
+ int driverFieldIndex = driverField.getSelectedIndex();
+ String userFieldValue = userField.getText();
+ String passwordFieldValue = passwordField.getText();
+ String confirmPasswordFieldValue = confirmPasswordField.getText();
+ String urlFieldValue = urlField.getText();
+ String connectionPoolFieldValue = (String) connectionPoolField.getSelectedItem();
+ String agentFieldValue = (String) agentField.getSelectedItem();
+ // check fields
+ if ( nameFieldValue == null || nameFieldValue.trim().length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "database.mandatory" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ if ( !passwordFieldValue.equals( confirmPasswordFieldValue ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "database.password" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // if the user change the database name, check if the new database name
+ // doesn't already exist
+ if ( databaseName == null || ( databaseName != null && !databaseName.equals( nameFieldValue ) ) )
+ {
+ if ( parent.getParentPane().getApplication().getDatabase( nameFieldValue ) != null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "database.exists" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ }
// add a change event
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Delete database " + database.getName() );
+ if ( databaseName != null )
+ {
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Change database " + database.getName() );
+ }
+ // update the database object
+ database.setName( nameFieldValue );
+ if ( activeFieldIndex == 0 )
+ {
+ database.setActive( true );
+ }
+ else
+ {
+ database.setActive( false );
+ }
+ if ( blockerFieldIndex == 0 )
+ {
+ database.setBlocker( true );
+ }
+ else
+ {
+ database.setBlocker( false );
+ }
+ if ( driverFieldIndex == 0 )
+ {
+ database.setDriver( "oracle.jdbc.driver.OracleDriver" );
+ }
+ if ( driverFieldIndex == 1 )
+ {
+ database.setDriver( "com.ibm.db2.jcc.DB2Driver" );
+ }
+ if ( driverFieldIndex == 2 )
+ {
+ database.setDriver( "com.mysql.jdbc.Driver" );
+ }
+ if ( driverFieldIndex == 3 )
+ {
+ database.setDriver( "org.postgresql.Driver" );
+ }
+ database.setSqlCommand( sqlCommandAreaValue );
+ database.setUser( userFieldValue );
+ database.setPassword( passwordFieldValue );
+ database.setJdbcurl( urlFieldValue );
+ database.setConnectionPool( connectionPoolFieldValue );
+ database.setAgent( agentFieldValue );
+ // add the database object if needed
+ if ( databaseName == null )
+ {
+ try
+ {
+ parent.getParentPane().getApplication().addDatabase( database );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Add database " + database.getName() );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "database.exists" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ }
+ // update the window definition
+ setTitle( Messages.getString( "database" ) + " " + database.getName() );
+ setId(
+ "databasewindow_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
+ + "_" + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName()
+ + "_" + database.getName() );
+ databaseName = database.getName();
// change the updated flag
parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
// update the journal log tab pane
parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the parent window
+ parent.update();
+ // update the window
+ update();
+ }
+ };
+
+ // toggle active sql script
+ public ActionListener toggleActiveSqlScript = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the sql script object
+ SqlScript sqlScript = database.getSqlScript( event.getActionCommand() );
+ if ( sqlScript == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "sqlscript.notfound" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // change the sql script object state
+ if ( sqlScript.isActive() )
+ {
+ sqlScript.setActive( false );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Disable SQL script " + sqlScript.getName() );
+ }
+ else
+ {
+ sqlScript.setActive( true );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Enable SQL script " + sqlScript.getName() );
+ }
+ // change the updated flag
+ parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the window
+ update();
+ }
+ };
+
+ // toggle blocker sql script
+ public ActionListener toggleBlockerSqlScript = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the sql script object
+ SqlScript sqlScript = database.getSqlScript( event.getActionCommand() );
+ if ( sqlScript == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "sqlscript.notfound" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // change the sql script blocker state
+ if ( sqlScript.isBlocker() )
+ {
+ sqlScript.setBlocker( false );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Set not blocker for SQL script " + sqlScript.getName() );
+ }
+ else
+ {
+ sqlScript.setBlocker( true );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Set blocker for SQL script " + sqlScript.getName() );
+ }
+ // change the updated flag
+ parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the window
+ update();
+ }
+ };
+
+ // toggle force sql script
+ public ActionListener toggleForceSqlScript = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the sql script object
+ SqlScript sqlScript = database.getSqlScript( event.getActionCommand() );
+ if ( sqlScript == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "sqlscript.notfound" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // change the sql script force state
+ if ( sqlScript.isForce() )
+ {
+ sqlScript.setForce( false );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Set not force for SQL script " + sqlScript.getName() );
+ }
+ else
+ {
+ sqlScript.setForce( true );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Set force for SQL script " + sqlScript.getName() );
+ }
+ // change the updated flag
+ parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the window
+ update();
+ }
+ };
+
+ // delete sql script
+ private ActionListener deleteSqlScript = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the sql script object
+ SqlScript sqlScript = database.getSqlScript( event.getActionCommand() );
+ if ( sqlScript == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "sqlscript.notfound" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // delete the sql script object
+ database.getSqlScripts().remove( sqlScript );
+ // add a change event
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Delete SQL script " + sqlScript.getName() );
+ // change the updated flag
+ parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the window
+ update();
+ }
+ };
+
+ // edit sql script
+ private ActionListener editSqlScript = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
+ "sqlscriptwindow_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName()
+ + "_" + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName()
+ + "_" + databaseName + "_" + event.getActionCommand() ) == null )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ApplicationDatabaseSqlScriptWindow( ApplicationDatabaseWindow.this,
+ event.getActionCommand() ) );
+ }
+ }
+ };
+
+ // create sql script
+ private ActionListener createSqlScript = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ApplicationDatabaseSqlScriptWindow( ApplicationDatabaseWindow.this, null ) );
+ }
+ };
+
+ // copy
+ private ActionListener copy = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ try
+ {
+ KalumetConsoleApplication.getApplication().setCopyComponent( database.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
+
+ // paste
+ private ActionListener paste = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+ // check if the copy is correct
+ if ( copy == null || !( copy instanceof Database ) )
+ {
+ return;
+ }
+ database = (Database) copy;
+ databaseName = null;
// update the parent pane
parent.update();
- // close the window
- ApplicationDatabaseWindow.this.userClose();
- }
- } ) );
- }
- };
-
- // apply
- private ActionListener apply = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get the fields value
- String nameFieldValue = nameField.getText();
- int activeFieldIndex = activeField.getSelectedIndex();
- int blockerFieldIndex = blockerField.getSelectedIndex();
- String sqlCommandAreaValue = sqlCommandArea.getText();
- int driverFieldIndex = driverField.getSelectedIndex();
- String userFieldValue = userField.getText();
- String passwordFieldValue = passwordField.getText();
- String confirmPasswordFieldValue = confirmPasswordField.getText();
- String urlFieldValue = urlField.getText();
- String connectionPoolFieldValue = (String) connectionPoolField.getSelectedItem();
- String agentFieldValue = (String) agentField.getSelectedItem();
- // check fields
- if ( nameFieldValue == null || nameFieldValue.trim().length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "database.mandatory" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- if ( !passwordFieldValue.equals( confirmPasswordFieldValue ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "database.password" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // if the user change the database name, check if the new database name
- // doesn't already exist
- if ( databaseName == null || ( databaseName != null && !databaseName.equals( nameFieldValue ) ) )
- {
- if ( parent.getParentPane().getApplication().getDatabase( nameFieldValue ) != null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "database.exists" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
+ // update the window
+ update();
}
- }
- // add a change event
- if ( databaseName != null )
- {
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Change database " + database.getName() );
- }
- // update the database object
- database.setName( nameFieldValue );
- if ( activeFieldIndex == 0 )
- {
- database.setActive( true );
- }
- else
- {
- database.setActive( false );
- }
- if ( blockerFieldIndex == 0 )
- {
- database.setBlocker( true );
- }
- else
- {
- database.setBlocker( false );
- }
- if ( driverFieldIndex == 0 )
- {
- database.setDriver( "oracle.jdbc.driver.OracleDriver" );
- }
- if ( driverFieldIndex == 1 )
- {
- database.setDriver( "com.ibm.db2.jcc.DB2Driver" );
- }
- if ( driverFieldIndex == 2 )
- {
- database.setDriver( "com.mysql.jdbc.Driver" );
- }
- if ( driverFieldIndex == 3 )
- {
- database.setDriver( "org.postgresql.Driver" );
- }
- database.setSqlCommand( sqlCommandAreaValue );
- database.setUser( userFieldValue );
- database.setPassword( passwordFieldValue );
- database.setJdbcurl( urlFieldValue );
- database.setConnectionPool( connectionPoolFieldValue );
- database.setAgent( agentFieldValue );
- // add the database object if needed
- if ( databaseName == null )
- {
+ };
+
+ // update
+ private ActionListener update = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if some change has not been saved
+ if ( getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // add a message into the log pane and the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application " + parent.getParentPane().getApplicationName() + " database "
+ + databaseName + " update in progress...",
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + parent.getParentPane().getApplicationName() + " database "
+ + databaseName + " update in progress ..." );
+ // start the update thread
+ final UpdateThread updateThread = new UpdateThread();
+ updateThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( updateThread.ended )
+ {
+ if ( updateThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ updateThread.message,
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ updateThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ "JEE application " + parent.getParentPane().getApplicationName()
+ + " database " + databaseName + " updated.",
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + parent.getParentPane().getApplicationName()
+ + " database " + databaseName + " updated." );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ } ) );
+ }
+ };
+
+ // copy sql script
+ private ActionListener copySqlScript = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // looking for the sql script object
+ SqlScript sqlScript = database.getSqlScript( event.getActionCommand() );
+ if ( sqlScript == null )
+ {
+ return;
+ }
+ try
+ {
+ KalumetConsoleApplication.getApplication().setCopyComponent( sqlScript.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
+
+ // up
+ private ActionListener up = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the SQL script object
+ SqlScript sqlScript = database.getSqlScript( event.getActionCommand() );
+ if ( sqlScript == null )
+ {
+ return;
+ }
+ // get the SQL script index
+ int index = database.getSqlScripts().indexOf( sqlScript );
+ // if the SQL script index is the first one or the object is not found,
+ // do nothing, the size of the list must contains at leat 2 SQL scripts
+ if ( index == 0 || index == -1 || database.getSqlScripts().size() < 2 )
+ {
+ return;
+ }
+ // get the previous sql script
+ SqlScript previous = (SqlScript) database.getSqlScripts().get( index - 1 );
+ // switch the SQL scripts
+ database.getSqlScripts().set( index, previous );
+ database.getSqlScripts().set( index - 1, sqlScript );
+ // update the pane
+ update();
+ }
+ };
+
+ // down
+ private ActionListener down = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the SQL script object
+ SqlScript sqlScript = database.getSqlScript( event.getActionCommand() );
+ if ( sqlScript == null )
+ {
+ return;
+ }
+ // get the SQL script index
+ int index = database.getSqlScripts().indexOf( sqlScript );
+ // if the SQL script index is the last one or the object is not found,
+ // the size of the list must contains at least 2 SQL scripts
+ if ( index == -1 || index == database.getSqlScripts().size() - 1 || database.getSqlScripts().size() < 2 )
+ {
+ return;
+ }
+ // get the next SQL script
+ SqlScript next = (SqlScript) database.getSqlScripts().get( index + 1 );
+ // switch the application
+ database.getSqlScripts().set( index + 1, sqlScript );
+ database.getSqlScripts().set( index, next );
+ // update the pane
+ update();
+ }
+ };
+
+ /**
+ * Create a new <code>ApplicationDatabaseWindow</code>.
+ *
+ * @param parent the parent <code>ApplicationDatabasesPane</code>.
+ * @param databaseName the original <code>Database</code> name.
+ */
+ public ApplicationDatabaseWindow( ApplicationDatabasesPane parent, String databaseName )
+ {
+ super();
+
+ // update the parent pane
+ this.parent = parent;
+
+ // update the database name
+ this.databaseName = databaseName;
+
+ // update the database object from the parent pane
+ this.database = parent.getParentPane().getApplication().getDatabase( databaseName );
+ if ( this.database == null )
+ {
+ this.database = new Database();
+ }
+
+ if ( databaseName == null )
+ {
+ setTitle( Messages.getString( "database" ) );
+ }
+ else
+ {
+ setTitle( Messages.getString( "database" ) + " " + databaseName );
+ }
+ setId(
+ "databasewindow_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
+ + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
+ + databaseName );
+ setStyleName( "default" );
+ setWidth( new Extent( 450, Extent.PX ) );
+ setHeight( new Extent( 300, Extent.PX ) );
+ setModal( false );
+ setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
+
+ // create a split pane for the control buttons
+ SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
+ add( splitPane );
+
+ // add the control pane
+ Row controlRow = new Row();
+ controlRow.setStyleName( "control" );
+ splitPane.add( controlRow );
+ // add the refresh button
+ Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
+ refreshButton.setStyleName( "control" );
+ refreshButton.addActionListener( refresh );
+ controlRow.add( refreshButton );
+ // add the copy button
+ Button copyButton = new Button( Messages.getString( "copy" ), Styles.PAGE_COPY );
+ copyButton.setStyleName( "control" );
+ copyButton.addActionListener( copy );
+ controlRow.add( copyButton );
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // add the paste button
+ Button pasteButton = new Button( Messages.getString( "paste" ), Styles.PAGE_PASTE );
+ pasteButton.setStyleName( "control" );
+ pasteButton.addActionListener( paste );
+ controlRow.add( pasteButton );
+ }
+ // add the update button
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ Button updateButton = new Button( Messages.getString( "update" ), Styles.COG );
+ updateButton.setStyleName( "control" );
+ updateButton.addActionListener( update );
+ controlRow.add( updateButton );
+ }
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // add the apply button
+ Button applyButton = new Button( Messages.getString( "apply" ), Styles.ACCEPT );
+ applyButton.setStyleName( "control" );
+ applyButton.addActionListener( apply );
+ controlRow.add( applyButton );
+ // add the delete button
+ Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
+ deleteButton.setStyleName( "control" );
+ deleteButton.addActionListener( delete );
+ controlRow.add( deleteButton );
+ }
+ // add the close button
+ Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
+ closeButton.setStyleName( "control" );
+ closeButton.addActionListener( close );
+ controlRow.add( closeButton );
+
+ // add the main tab pane
+ TabPane tabPane = new TabPane();
+ tabPane.setStyleName( "default" );
+ splitPane.add( tabPane );
+
+ // add the general tab
+ TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "general" ) );
+ ContentPane generalTabPane = new ContentPane();
+ generalTabPane.setStyleName( "tab.content" );
+ generalTabPane.setLayoutData( tabLayoutData );
+ tabPane.add( generalTabPane );
+ Grid generalLayoutGrid = new Grid( 2 );
+ generalLayoutGrid.setStyleName( "default" );
+ generalLayoutGrid.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
+ generalLayoutGrid.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
+ generalTabPane.add( generalLayoutGrid );
+ // name
+ Label nameLabel = new Label( Messages.getString( "name" ) );
+ nameLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( nameLabel );
+ nameField = new TextField();
+ nameField.setStyleName( "default" );
+ nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ generalLayoutGrid.add( nameField );
+ // active
+ Label activeLabel = new Label( Messages.getString( "active" ) );
+ activeLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( activeLabel );
+ activeField = new SelectField( MainScreen.LABELS );
+ activeField.setSelectedIndex( 0 );
+ activeField.setStyleName( "default" );
+ activeField.setWidth( new Extent( 10, Extent.EX ) );
+ generalLayoutGrid.add( activeField );
+ // blocker
+ Label blockerLabel = new Label( Messages.getString( "blocker" ) );
+ blockerLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( blockerLabel );
+ blockerField = new SelectField( MainScreen.LABELS );
+ blockerField.setStyleName( "default" );
+ blockerField.setSelectedIndex( 1 );
+ blockerField.setWidth( new Extent( 10, Extent.EX ) );
+ generalLayoutGrid.add( blockerField );
+ // SQL command
+ Label sqlCommandLabel = new Label( Messages.getString( "sql.command" ) );
+ sqlCommandLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( sqlCommandLabel );
+ sqlCommandArea = new TextArea();
+ sqlCommandArea.setStyleName( "default" );
+ sqlCommandArea.setWidth( new Extent( 100, Extent.PERCENT ) );
+ sqlCommandArea.setHeight( new Extent( 5, Extent.EX ) );
+ generalLayoutGrid.add( sqlCommandArea );
+ // driver
+ Label driverLabel = new Label( Messages.getString( "driver" ) );
+ driverLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( driverLabel );
+ driverField = new SelectField( ApplicationDatabaseWindow.DRIVERS );
+ driverField.setSelectedIndex( 0 );
+ driverField.setStyleName( "default" );
+ driverField.setWidth( new Extent( 50, Extent.EX ) );
+ generalLayoutGrid.add( driverField );
+ // user
+ Label userLabel = new Label( Messages.getString( "user" ) );
+ userLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( userLabel );
+ userField = new TextField();
+ userField.setStyleName( "default" );
+ userField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ generalLayoutGrid.add( userField );
+ // password
+ Label passwordLabel = new Label( Messages.getString( "password" ) );
+ passwordLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( passwordLabel );
+ passwordField = new PasswordField();
+ passwordField.setStyleName( "default" );
+ passwordField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ generalLayoutGrid.add( passwordField );
+ // confirm password
+ Label confirmPasswordLabel = new Label( Messages.getString( "password.confirm" ) );
+ confirmPasswordLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( confirmPasswordLabel );
+ confirmPasswordField = new PasswordField();
+ confirmPasswordField.setStyleName( "default" );
+ confirmPasswordField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ generalLayoutGrid.add( confirmPasswordField );
+ // URL
+ Label urlLabel = new Label( Messages.getString( "url" ) );
+ urlLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( urlLabel );
+ urlField = new TextField();
+ urlField.setStyleName( "default" );
+ urlField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ generalLayoutGrid.add( urlField );
+ // connection pool
+ Label connectionPoolLabel = new Label( Messages.getString( "connectionpool" ) );
+ connectionPoolLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( connectionPoolLabel );
+ connectionPoolField = new SelectField();
+ connectionPoolField.setStyleName( "default" );
+ connectionPoolField.setWidth( new Extent( 50, Extent.EX ) );
+ generalLayoutGrid.add( connectionPoolField );
+ // agent
+ Label agentLabel = new Label( Messages.getString( "agent" ) );
+ agentLabel.setStyleName( "grid.cell" );
+ generalLayoutGrid.add( agentLabel );
+ agentField = new SelectField();
+ agentField.setStyleName( "default" );
+ agentField.setWidth( new Extent( 50, Extent.EX ) );
+ generalLayoutGrid.add( agentField );
+
+ // add the sql scripts tab
+ tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "sql.scripts" ) );
+ ContentPane sqlScriptsTabPane = new ContentPane();
+ sqlScriptsTabPane.setStyleName( "tab.content" );
+ sqlScriptsTabPane.setLayoutData( tabLayoutData );
+ tabPane.add( sqlScriptsTabPane );
+ Column column = new Column();
+ sqlScriptsTabPane.add( column );
+ Button createButton = new Button( Messages.getString( "sql.script.add" ), Styles.ADD );
+ createButton.addActionListener( createSqlScript );
+ column.add( createButton );
+ sqlScriptsGrid = new Grid( 3 );
+ sqlScriptsGrid.setStyleName( "border.grid" );
+ sqlScriptsGrid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
+ column.add( sqlScriptsGrid );
+
+ // update the window
+ update();
+ }
+
+ /**
+ * Update the pane.
+ */
+ public void update()
+ {
+ // update the database name field
+ nameField.setText( database.getName() );
+ // update the database active field
+ if ( database.isActive() )
+ {
+ activeField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ activeField.setSelectedIndex( 1 );
+ }
+ // update the database blocker field
+ if ( database.isBlocker() )
+ {
+ blockerField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ blockerField.setSelectedIndex( 1 );
+ }
+ // update the database system launcher
+ sqlCommandArea.setText( database.getSqlCommand() );
+ // update the database driver field
+ if ( StringUtils.containsIgnoreCase( database.getDriver(), "oracle" ) )
+ {
+ driverField.setSelectedIndex( 0 );
+ }
+ if ( StringUtils.containsIgnoreCase( database.getDriver(), "db2" ) )
+ {
+ driverField.setSelectedIndex( 1 );
+ }
+ if ( StringUtils.containsIgnoreCase( database.getDriver(), "mysql" ) )
+ {
+ driverField.setSelectedIndex( 2 );
+ }
+ if ( StringUtils.containsIgnoreCase( database.getDriver(), "postgre" ) )
+ {
+ driverField.setSelectedIndex( 3 );
+ }
+ // update the database user field
+ userField.setText( database.getUser() );
+ // update the database password field
+ passwordField.setText( database.getPassword() );
+ confirmPasswordField.setText( database.getPassword() );
+ // update the database url field
+ urlField.setText( database.getJdbcurl() );
+ // update agent field
+ List agents = new LinkedList();
+ // load Kalumet
try
{
- parent.getParentPane().getApplication().addDatabase( database );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Add database " + database.getName() );
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ agents = kalumet.getAgents();
}
catch ( Exception e )
{
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "database.exists" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage(), getEnvironmentWindow().getEnvironmentName() );
}
- }
- // update the window definition
- setTitle( Messages.getString( "database" ) + " " + database.getName() );
- setId(
- "databasewindow_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
- + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
- + database.getName() );
- databaseName = database.getName();
- // change the updated flag
- parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the parent window
- parent.update();
- // update the window
- update();
- }
- };
-
- // toggle active sql script
- public ActionListener toggleActiveSqlScript = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the sql script object
- SqlScript sqlScript = database.getSqlScript( event.getActionCommand() );
- if ( sqlScript == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "sqlscript.notfound" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // change the sql script object state
- if ( sqlScript.isActive() )
- {
- sqlScript.setActive( false );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Disable SQL script " + sqlScript.getName() );
- }
- else
- {
- sqlScript.setActive( true );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Enable SQL script " + sqlScript.getName() );
- }
- // change the updated flag
- parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the window
- update();
- }
- };
-
- // toggle blocker sql script
- public ActionListener toggleBlockerSqlScript = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the sql script object
- SqlScript sqlScript = database.getSqlScript( event.getActionCommand() );
- if ( sqlScript == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "sqlscript.notfound" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // change the sql script blocker state
- if ( sqlScript.isBlocker() )
- {
- sqlScript.setBlocker( false );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Set not blocker for SQL script " + sqlScript.getName() );
- }
- else
- {
- sqlScript.setBlocker( true );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Set blocker for SQL script " + sqlScript.getName() );
- }
- // change the updated flag
- parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the window
- update();
- }
- };
-
- // toggle force sql script
- public ActionListener toggleForceSqlScript = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the sql script object
- SqlScript sqlScript = database.getSqlScript( event.getActionCommand() );
- if ( sqlScript == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "sqlscript.notfound" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // change the sql script force state
- if ( sqlScript.isForce() )
- {
- sqlScript.setForce( false );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Set not force for SQL script " + sqlScript.getName() );
- }
- else
- {
- sqlScript.setForce( true );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Set force for SQL script " + sqlScript.getName() );
- }
- // change the updated flag
- parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the window
- update();
- }
- };
-
- // delete sql script
- private ActionListener deleteSqlScript = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the sql script object
- SqlScript sqlScript = database.getSqlScript( event.getActionCommand() );
- if ( sqlScript == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "sqlscript.notfound" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // delete the sql script object
- database.getSqlScripts().remove( sqlScript );
- // add a change event
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Delete SQL script " + sqlScript.getName() );
- // change the updated flag
- parent.getParentPane().getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the window
- update();
- }
- };
-
- // edit sql script
- private ActionListener editSqlScript = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
- "sqlscriptwindow_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
- + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
- + databaseName + "_" + event.getActionCommand() ) == null )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ApplicationDatabaseSqlScriptWindow( ApplicationDatabaseWindow.this, event.getActionCommand() ) );
- }
- }
- };
-
- // create sql script
- private ActionListener createSqlScript = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ApplicationDatabaseSqlScriptWindow( ApplicationDatabaseWindow.this, null ) );
- }
- };
-
- // copy
- private ActionListener copy = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- try
- {
- KalumetConsoleApplication.getApplication().setCopyComponent( database.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
-
- // paste
- private ActionListener paste = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
- // check if the copy is correct
- if ( copy == null || !( copy instanceof Database ) )
- {
- return;
- }
- database = (Database) copy;
- databaseName = null;
- // update the parent pane
- parent.update();
- // update the window
- update();
- }
- };
-
- // update
- private ActionListener update = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsUpdatePermission )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if some change has not been saved
- if ( getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ DefaultListModel agentListModel = (DefaultListModel) agentField.getModel();
+ agentListModel.removeAll();
+ agentListModel.add( " " );
+ for ( Iterator agentIterator = agents.iterator(); agentIterator.hasNext(); )
{
- public void actionPerformed( ActionEvent event )
- {
- // add a message into the log pane and the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application " + parent.getParentPane().getApplicationName() + " database " + databaseName
- + " update in progress...",
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getParentPane().getApplicationName() + " database " + databaseName
- + " update in progress ..." );
- // start the update thread
- final UpdateThread updateThread = new UpdateThread();
- updateThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ Agent agent = (Agent) agentIterator.next();
+ agentListModel.add( agent.getId() );
+ }
+ agentField.setSelectedItem( database.getAgent() );
+ // update connection pool field
+ DefaultListModel connectionPoolListModel = (DefaultListModel) connectionPoolField.getModel();
+ connectionPoolListModel.removeAll();
+ connectionPoolListModel.add( "" );
+ for ( Iterator connectionPoolIterator =
+ getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ parent.getParentPane().getServerName() ).getJDBCConnectionPools().iterator();
+ connectionPoolIterator.hasNext(); )
+ {
+ JDBCConnectionPool connectionPool = (JDBCConnectionPool) connectionPoolIterator.next();
+ connectionPoolListModel.add( connectionPool.getName() );
+ }
+ connectionPoolField.setSelectedItem( database.getConnectionPool() );
+
+ // remove all sql scripts grid children
+ sqlScriptsGrid.removeAll();
+ // add sql scripts grid header
+ Label sqlScriptActionHeader = new Label( " " );
+ sqlScriptActionHeader.setStyleName( "grid.header" );
+ sqlScriptsGrid.add( sqlScriptActionHeader );
+ Label sqlScriptNameHeader = new Label( Messages.getString( "name" ) );
+ sqlScriptNameHeader.setStyleName( "grid.header" );
+ sqlScriptsGrid.add( sqlScriptNameHeader );
+ Label sqlScriptUriHeader = new Label( Messages.getString( "uri" ) );
+ sqlScriptUriHeader.setStyleName( "grid.header" );
+ sqlScriptsGrid.add( sqlScriptUriHeader );
+ // add sql script
+ for ( Iterator sqlScriptIterator = database.getSqlScripts().iterator(); sqlScriptIterator.hasNext(); )
+ {
+ SqlScript sqlScript = (SqlScript) sqlScriptIterator.next();
+ // row
+ Row row = new Row();
+ row.setCellSpacing( new Extent( 2 ) );
+ row.setInsets( new Insets( 2 ) );
+ sqlScriptsGrid.add( row );
+ // copy
+ Button copyButton = new Button( Styles.PAGE_COPY );
+ copyButton.setToolTipText( Messages.getString( "copy" ) );
+ copyButton.setActionCommand( sqlScript.getName() );
+ copyButton.addActionListener( copySqlScript );
+ row.add( copyButton );
+ // sqlscript active
+ Button activeButton;
+ if ( sqlScript.isActive() )
{
- public void run()
- {
- if ( updateThread.ended )
- {
- if ( updateThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( updateThread.message,
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- updateThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "JEE application " + parent.getParentPane().getApplicationName() + " database " + databaseName
- + " updated.",
- parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getParentPane().getApplicationName() + " database " + databaseName
- + " updated." );
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
- } );
- }
- } ) );
- }
- };
-
- // copy sql script
- private ActionListener copySqlScript = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // looking for the sql script object
- SqlScript sqlScript = database.getSqlScript( event.getActionCommand() );
- if ( sqlScript == null )
- {
- return;
- }
- try
- {
- KalumetConsoleApplication.getApplication().setCopyComponent( sqlScript.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
-
- // up
- private ActionListener up = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the SQL script object
- SqlScript sqlScript = database.getSqlScript( event.getActionCommand() );
- if ( sqlScript == null )
- {
- return;
- }
- // get the SQL script index
- int index = database.getSqlScripts().indexOf( sqlScript );
- // if the SQL script index is the first one or the object is not found,
- // do nothing, the size of the list must contains at leat 2 SQL scripts
- if ( index == 0 || index == -1 || database.getSqlScripts().size() < 2 )
- {
- return;
- }
- // get the previous sql script
- SqlScript previous = (SqlScript) database.getSqlScripts().get( index - 1 );
- // switch the SQL scripts
- database.getSqlScripts().set( index, previous );
- database.getSqlScripts().set( index - 1, sqlScript );
- // update the pane
- update();
- }
- };
-
- // down
- private ActionListener down = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the SQL script object
- SqlScript sqlScript = database.getSqlScript( event.getActionCommand() );
- if ( sqlScript == null )
- {
- return;
- }
- // get the SQL script index
- int index = database.getSqlScripts().indexOf( sqlScript );
- // if the SQL script index is the last one or the object is not found,
- // the size of the list must contains at least 2 SQL scripts
- if ( index == -1 || index == database.getSqlScripts().size() - 1 || database.getSqlScripts().size() < 2 )
- {
- return;
- }
- // get the next SQL script
- SqlScript next = (SqlScript) database.getSqlScripts().get( index + 1 );
- // switch the application
- database.getSqlScripts().set( index + 1, sqlScript );
- database.getSqlScripts().set( index, next );
- // update the pane
- update();
- }
- };
-
- /**
- * Create a new <code>ApplicationDatabaseWindow</code>.
- *
- * @param parent the parent <code>ApplicationDatabasesPane</code>.
- * @param databaseName the original <code>Database</code> name.
- */
- public ApplicationDatabaseWindow( ApplicationDatabasesPane parent, String databaseName )
- {
- super();
-
- // update the parent pane
- this.parent = parent;
-
- // update the database name
- this.databaseName = databaseName;
-
- // update the database object from the parent pane
- this.database = parent.getParentPane().getApplication().getDatabase( databaseName );
- if ( this.database == null )
- {
- this.database = new Database();
+ activeButton = new Button( Styles.LIGHTBULB );
+ activeButton.setToolTipText( Messages.getString( "switch.disable" ) );
+ }
+ else
+ {
+ activeButton = new Button( Styles.LIGHTBULB_OFF );
+ activeButton.setToolTipText( Messages.getString( "switch.enable" ) );
+ }
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ activeButton.setActionCommand( sqlScript.getName() );
+ activeButton.addActionListener( toggleActiveSqlScript );
+ }
+ row.add( activeButton );
+ // sqlscript blocker
+ Button blockerButton;
+ if ( sqlScript.isBlocker() )
+ {
+ blockerButton = new Button( Styles.PLUGIN );
+ blockerButton.setToolTipText( Messages.getString( "switch.notblocker" ) );
+ }
+ else
+ {
+ blockerButton = new Button( Styles.PLUGIN_DISABLED );
+ blockerButton.setToolTipText( Messages.getString( "switch.blocker" ) );
+ }
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ blockerButton.setActionCommand( sqlScript.getName() );
+ blockerButton.addActionListener( toggleBlockerSqlScript );
+ }
+ row.add( blockerButton );
+ // sqlscript force
+ Button forceButton;
+ if ( sqlScript.isForce() )
+ {
+ forceButton = new Button( Styles.DATABASE_GEAR );
+ forceButton.setToolTipText( Messages.getString( "switch.notforce" ) );
+ }
+ else
+ {
+ forceButton = new Button( Styles.DATABASE );
+ forceButton.setToolTipText( Messages.getString( "switch.force" ) );
+ }
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ forceButton.setActionCommand( sqlScript.getName() );
+ forceButton.addActionListener( toggleForceSqlScript );
+ }
+ row.add( forceButton );
+ // up / down / delete
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // up button
+ Button upButton = new Button( Styles.ARROW_UP );
+ upButton.setToolTipText( Messages.getString( "up" ) );
+ upButton.setActionCommand( sqlScript.getName() );
+ upButton.addActionListener( up );
+ row.add( upButton );
+ // down button
+ Button downButton = new Button( Styles.ARROW_DOWN );
+ downButton.setToolTipText( Messages.getString( "down" ) );
+ downButton.setActionCommand( sqlScript.getName() );
+ downButton.addActionListener( down );
+ row.add( downButton );
+ // delete button
+ Button deleteButton = new Button( Styles.DELETE );
+ deleteButton.setToolTipText( Messages.getString( "delete" ) );
+ deleteButton.setActionCommand( sqlScript.getName() );
+ deleteButton.addActionListener( deleteSqlScript );
+ row.add( deleteButton );
+ }
+ // sqlscript name
+ Button sqlScriptName = new Button( sqlScript.getName() );
+ sqlScriptName.setStyleName( "default" );
+ sqlScriptName.setActionCommand( sqlScript.getName() );
+ sqlScriptName.addActionListener( editSqlScript );
+ sqlScriptsGrid.add( sqlScriptName );
+ // sqlscript uri
+ Label sqlScriptUri = new Label( sqlScript.getUri() );
+ sqlScriptUri.setStyleName( "default" );
+ sqlScriptsGrid.add( sqlScriptUri );
+ }
}
- if ( databaseName == null )
+ /**
+ * Get the <code>Database</code>.
+ *
+ * @return the <code>Database</code>.
+ */
+ public Database getDatabase()
{
- setTitle( Messages.getString( "database" ) );
+ return this.database;
}
- else
- {
- setTitle( Messages.getString( "database" ) + " " + databaseName );
- }
- setId( "databasewindow_" + parent.getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
- + parent.getParentPane().getServerName() + "_" + parent.getParentPane().getApplicationName() + "_"
- + databaseName );
- setStyleName( "default" );
- setWidth( new Extent( 450, Extent.PX ) );
- setHeight( new Extent( 300, Extent.PX ) );
- setModal( false );
- setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
- // create a split pane for the control buttons
- SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
- add( splitPane );
+ /**
+ * Get the <code>Database</code> name.
+ *
+ * @return the <code>Database</code> name.
+ */
+ public String getDatabaseName()
+ {
+ return this.databaseName;
+ }
- // add the control pane
- Row controlRow = new Row();
- controlRow.setStyleName( "control" );
- splitPane.add( controlRow );
- // add the refresh button
- Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
- refreshButton.setStyleName( "control" );
- refreshButton.addActionListener( refresh );
- controlRow.add( refreshButton );
- // add the copy button
- Button copyButton = new Button( Messages.getString( "copy" ), Styles.PAGE_COPY );
- copyButton.setStyleName( "control" );
- copyButton.addActionListener( copy );
- controlRow.add( copyButton );
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission)
+ /**
+ * Get the parent <code>ApplicationDatabasesPane</code>.
+ *
+ * @return the parent <code>ApplicationDatabasesPane</code>.
+ */
+ public ApplicationDatabasesPane getParentPane()
{
- // add the paste button
- Button pasteButton = new Button( Messages.getString( "paste" ), Styles.PAGE_PASTE );
- pasteButton.setStyleName( "control" );
- pasteButton.addActionListener( paste );
- controlRow.add( pasteButton );
+ return parent;
}
- // add the update button
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsUpdatePermission )
- {
- Button updateButton = new Button( Messages.getString( "update" ), Styles.COG );
- updateButton.setStyleName( "control" );
- updateButton.addActionListener( update );
- controlRow.add( updateButton );
- }
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- // add the apply button
- Button applyButton = new Button( Messages.getString( "apply" ), Styles.ACCEPT );
- applyButton.setStyleName( "control" );
- applyButton.addActionListener( apply );
- controlRow.add( applyButton );
- // add the delete button
- Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
- deleteButton.setStyleName( "control" );
- deleteButton.addActionListener( delete );
- controlRow.add( deleteButton );
- }
- // add the close button
- Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
- closeButton.setStyleName( "control" );
- closeButton.addActionListener( close );
- controlRow.add( closeButton );
- // add the main tab pane
- TabPane tabPane = new TabPane();
- tabPane.setStyleName( "default" );
- splitPane.add( tabPane );
-
- // add the general tab
- TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "general" ) );
- ContentPane generalTabPane = new ContentPane();
- generalTabPane.setStyleName( "tab.content" );
- generalTabPane.setLayoutData( tabLayoutData );
- tabPane.add( generalTabPane );
- Grid generalLayoutGrid = new Grid( 2 );
- generalLayoutGrid.setStyleName( "default" );
- generalLayoutGrid.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
- generalLayoutGrid.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
- generalTabPane.add( generalLayoutGrid );
- // name
- Label nameLabel = new Label( Messages.getString( "name" ) );
- nameLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( nameLabel );
- nameField = new TextField();
- nameField.setStyleName( "default" );
- nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
- generalLayoutGrid.add( nameField );
- // active
- Label activeLabel = new Label( Messages.getString( "active" ) );
- activeLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( activeLabel );
- activeField = new SelectField( MainScreen.LABELS );
- activeField.setSelectedIndex( 0 );
- activeField.setStyleName( "default" );
- activeField.setWidth( new Extent( 10, Extent.EX ) );
- generalLayoutGrid.add( activeField );
- // blocker
- Label blockerLabel = new Label( Messages.getString( "blocker" ) );
- blockerLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( blockerLabel );
- blockerField = new SelectField( MainScreen.LABELS );
- blockerField.setStyleName( "default" );
- blockerField.setSelectedIndex( 1 );
- blockerField.setWidth( new Extent( 10, Extent.EX ) );
- generalLayoutGrid.add( blockerField );
- // SQL command
- Label sqlCommandLabel = new Label( Messages.getString( "sql.command" ) );
- sqlCommandLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( sqlCommandLabel );
- sqlCommandArea = new TextArea();
- sqlCommandArea.setStyleName( "default" );
- sqlCommandArea.setWidth( new Extent( 100, Extent.PERCENT ) );
- sqlCommandArea.setHeight( new Extent( 5, Extent.EX ) );
- generalLayoutGrid.add( sqlCommandArea );
- // driver
- Label driverLabel = new Label( Messages.getString( "driver" ) );
- driverLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( driverLabel );
- driverField = new SelectField( ApplicationDatabaseWindow.DRIVERS );
- driverField.setSelectedIndex( 0 );
- driverField.setStyleName( "default" );
- driverField.setWidth( new Extent( 50, Extent.EX ) );
- generalLayoutGrid.add( driverField );
- // user
- Label userLabel = new Label( Messages.getString( "user" ) );
- userLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( userLabel );
- userField = new TextField();
- userField.setStyleName( "default" );
- userField.setWidth( new Extent( 100, Extent.PERCENT ) );
- generalLayoutGrid.add( userField );
- // password
- Label passwordLabel = new Label( Messages.getString( "password" ) );
- passwordLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( passwordLabel );
- passwordField = new PasswordField();
- passwordField.setStyleName( "default" );
- passwordField.setWidth( new Extent( 100, Extent.PERCENT ) );
- generalLayoutGrid.add( passwordField );
- // confirm password
- Label confirmPasswordLabel = new Label( Messages.getString( "password.confirm" ) );
- confirmPasswordLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( confirmPasswordLabel );
- confirmPasswordField = new PasswordField();
- confirmPasswordField.setStyleName( "default" );
- confirmPasswordField.setWidth( new Extent( 100, Extent.PERCENT ) );
- generalLayoutGrid.add( confirmPasswordField );
- // URL
- Label urlLabel = new Label( Messages.getString( "url" ) );
- urlLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( urlLabel );
- urlField = new TextField();
- urlField.setStyleName( "default" );
- urlField.setWidth( new Extent( 100, Extent.PERCENT ) );
- generalLayoutGrid.add( urlField );
- // connection pool
- Label connectionPoolLabel = new Label( Messages.getString( "connectionpool" ) );
- connectionPoolLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( connectionPoolLabel );
- connectionPoolField = new SelectField();
- connectionPoolField.setStyleName( "default" );
- connectionPoolField.setWidth( new Extent( 50, Extent.EX ) );
- generalLayoutGrid.add( connectionPoolField );
- // agent
- Label agentLabel = new Label( Messages.getString( "agent" ) );
- agentLabel.setStyleName( "grid.cell" );
- generalLayoutGrid.add( agentLabel );
- agentField = new SelectField();
- agentField.setStyleName( "default" );
- agentField.setWidth( new Extent( 50, Extent.EX ) );
- generalLayoutGrid.add( agentField );
-
- // add the sql scripts tab
- tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "sql.scripts" ) );
- ContentPane sqlScriptsTabPane = new ContentPane();
- sqlScriptsTabPane.setStyleName( "tab.content" );
- sqlScriptsTabPane.setLayoutData( tabLayoutData );
- tabPane.add( sqlScriptsTabPane );
- Column column = new Column();
- sqlScriptsTabPane.add( column );
- Button createButton = new Button( Messages.getString( "sql.script.add" ), Styles.ADD );
- createButton.addActionListener( createSqlScript );
- column.add( createButton );
- sqlScriptsGrid = new Grid( 3 );
- sqlScriptsGrid.setStyleName( "border.grid" );
- sqlScriptsGrid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
- column.add( sqlScriptsGrid );
-
- // update the window
- update();
- }
-
- /**
- * Update the pane.
- */
- public void update()
- {
- // update the database name field
- nameField.setText( database.getName() );
- // update the database active field
- if ( database.isActive() )
+ public EnvironmentWindow getEnvironmentWindow()
{
- activeField.setSelectedIndex( 0 );
+ return parent.getParentPane().getParentPane().getEnvironmentWindow();
}
- else
- {
- activeField.setSelectedIndex( 1 );
- }
- // update the database blocker field
- if ( database.isBlocker() )
- {
- blockerField.setSelectedIndex( 0 );
- }
- else
- {
- blockerField.setSelectedIndex( 1 );
- }
- // update the database system launcher
- sqlCommandArea.setText( database.getSqlCommand() );
- // update the database driver field
- if ( StringUtils.containsIgnoreCase( database.getDriver(), "oracle" ) )
- {
- driverField.setSelectedIndex( 0 );
- }
- if ( StringUtils.containsIgnoreCase( database.getDriver(), "db2" ) )
- {
- driverField.setSelectedIndex( 1 );
- }
- if ( StringUtils.containsIgnoreCase( database.getDriver(), "mysql" ) )
- {
- driverField.setSelectedIndex( 2 );
- }
- if ( StringUtils.containsIgnoreCase( database.getDriver(), "postgre" ) )
- {
- driverField.setSelectedIndex( 3 );
- }
- // update the database user field
- userField.setText( database.getUser() );
- // update the database password field
- passwordField.setText( database.getPassword() );
- confirmPasswordField.setText( database.getPassword() );
- // update the database url field
- urlField.setText( database.getJdbcurl() );
- // update agent field
- List agents = new LinkedList();
- // load Kalumet
- try
- {
- Kalumet kalumet = ConfigurationManager.loadStore();
- agents = kalumet.getAgents();
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage(), getEnvironmentWindow().getEnvironmentName() );
- }
- DefaultListModel agentListModel = (DefaultListModel) agentField.getModel();
- agentListModel.removeAll();
- agentListModel.add( " " );
- for ( Iterator agentIterator = agents.iterator(); agentIterator.hasNext(); )
- {
- Agent agent = (Agent) agentIterator.next();
- agentListModel.add( agent.getId() );
- }
- agentField.setSelectedItem( database.getAgent() );
- // update connection pool field
- DefaultListModel connectionPoolListModel = (DefaultListModel) connectionPoolField.getModel();
- connectionPoolListModel.removeAll();
- connectionPoolListModel.add( "" );
- for ( Iterator connectionPoolIterator =
- getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- parent.getParentPane().getServerName() ).getJDBCConnectionPools().iterator();
- connectionPoolIterator.hasNext(); )
- {
- JDBCConnectionPool connectionPool = (JDBCConnectionPool) connectionPoolIterator.next();
- connectionPoolListModel.add( connectionPool.getName() );
- }
- connectionPoolField.setSelectedItem( database.getConnectionPool() );
-
- // remove all sql scripts grid children
- sqlScriptsGrid.removeAll();
- // add sql scripts grid header
- Label sqlScriptActionHeader = new Label( " " );
- sqlScriptActionHeader.setStyleName( "grid.header" );
- sqlScriptsGrid.add( sqlScriptActionHeader );
- Label sqlScriptNameHeader = new Label( Messages.getString( "name" ) );
- sqlScriptNameHeader.setStyleName( "grid.header" );
- sqlScriptsGrid.add( sqlScriptNameHeader );
- Label sqlScriptUriHeader = new Label( Messages.getString( "uri" ) );
- sqlScriptUriHeader.setStyleName( "grid.header" );
- sqlScriptsGrid.add( sqlScriptUriHeader );
- // add sql script
- for ( Iterator sqlScriptIterator = database.getSqlScripts().iterator(); sqlScriptIterator.hasNext(); )
- {
- SqlScript sqlScript = (SqlScript) sqlScriptIterator.next();
- // row
- Row row = new Row();
- row.setCellSpacing( new Extent( 2 ) );
- row.setInsets( new Insets( 2 ) );
- sqlScriptsGrid.add( row );
- // copy
- Button copyButton = new Button( Styles.PAGE_COPY );
- copyButton.setToolTipText( Messages.getString( "copy" ) );
- copyButton.setActionCommand( sqlScript.getName() );
- copyButton.addActionListener( copySqlScript );
- row.add( copyButton );
- // sqlscript active
- Button activeButton;
- if ( sqlScript.isActive() )
- {
- activeButton = new Button( Styles.LIGHTBULB );
- activeButton.setToolTipText( Messages.getString( "switch.disable" ) );
- }
- else
- {
- activeButton = new Button( Styles.LIGHTBULB_OFF );
- activeButton.setToolTipText( Messages.getString( "switch.enable" ) );
- }
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- activeButton.setActionCommand( sqlScript.getName() );
- activeButton.addActionListener( toggleActiveSqlScript );
- }
- row.add( activeButton );
- // sqlscript blocker
- Button blockerButton;
- if ( sqlScript.isBlocker() )
- {
- blockerButton = new Button( Styles.PLUGIN );
- blockerButton.setToolTipText( Messages.getString( "switch.notblocker" ) );
- }
- else
- {
- blockerButton = new Button( Styles.PLUGIN_DISABLED );
- blockerButton.setToolTipText( Messages.getString( "switch.blocker" ) );
- }
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- blockerButton.setActionCommand( sqlScript.getName() );
- blockerButton.addActionListener( toggleBlockerSqlScript );
- }
- row.add( blockerButton );
- // sqlscript force
- Button forceButton;
- if ( sqlScript.isForce() )
- {
- forceButton = new Button( Styles.DATABASE_GEAR );
- forceButton.setToolTipText( Messages.getString( "switch.notforce" ) );
- }
- else
- {
- forceButton = new Button( Styles.DATABASE );
- forceButton.setToolTipText( Messages.getString( "switch.force" ) );
- }
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- forceButton.setActionCommand( sqlScript.getName() );
- forceButton.addActionListener( toggleForceSqlScript );
- }
- row.add( forceButton );
- // up / down / delete
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- // up button
- Button upButton = new Button( Styles.ARROW_UP );
- upButton.setToolTipText( Messages.getString( "up" ) );
- upButton.setActionCommand( sqlScript.getName() );
- upButton.addActionListener( up );
- row.add( upButton );
- // down button
- Button downButton = new Button( Styles.ARROW_DOWN );
- downButton.setToolTipText( Messages.getString( "down" ) );
- downButton.setActionCommand( sqlScript.getName() );
- downButton.addActionListener( down );
- row.add( downButton );
- // delete button
- Button deleteButton = new Button( Styles.DELETE );
- deleteButton.setToolTipText( Messages.getString( "delete" ) );
- deleteButton.setActionCommand( sqlScript.getName() );
- deleteButton.addActionListener( deleteSqlScript );
- row.add( deleteButton );
- }
- // sqlscript name
- Button sqlScriptName = new Button( sqlScript.getName() );
- sqlScriptName.setStyleName( "default" );
- sqlScriptName.setActionCommand( sqlScript.getName() );
- sqlScriptName.addActionListener( editSqlScript );
- sqlScriptsGrid.add( sqlScriptName );
- // sqlscript uri
- Label sqlScriptUri = new Label( sqlScript.getUri() );
- sqlScriptUri.setStyleName( "default" );
- sqlScriptsGrid.add( sqlScriptUri );
- }
- }
-
- /**
- * Get the <code>Database</code>.
- *
- * @return the <code>Database</code>.
- */
- public Database getDatabase()
- {
- return this.database;
- }
-
- /**
- * Get the <code>Database</code> name.
- *
- * @return the <code>Database</code> name.
- */
- public String getDatabaseName()
- {
- return this.databaseName;
- }
-
- /**
- * Get the parent <code>ApplicationDatabasesPane</code>.
- *
- * @return the parent <code>ApplicationDatabasesPane</code>.
- */
- public ApplicationDatabasesPane getParentPane()
- {
- return parent;
- }
-
- public EnvironmentWindow getEnvironmentWindow()
- {
- return parent.getParentPane().getParentPane().getEnvironmentWindow();
- }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationDatabasesPane.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationDatabasesPane.java
index f140ffb..0fd12f1 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationDatabasesPane.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationDatabasesPane.java
@@ -40,523 +40,546 @@
* JEE application databases pane.
*/
public class ApplicationDatabasesPane
- extends ContentPane
+ extends ContentPane
{
- private ApplicationWindow parent;
+ private ApplicationWindow parent;
- private Grid grid;
+ private Grid grid;
- class UpdateThread
- extends Thread
- {
-
- public String databaseName;
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ class UpdateThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
- if ( agent == null )
+
+ public String databaseName;
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent =
+ kalumet.getAgent( parent.getParentPane().getEnvironmentWindow().getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the webservice
+ DatabaseClient client = new DatabaseClient( agent.getHostname(), agent.getPort() );
+ client.update( parent.getParentPane().getEnvironmentWindow().getEnvironmentName(),
+ parent.getServerName(), parent.getApplicationName(), databaseName, false );
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message =
+ "JEE application " + parent.getApplicationName() + " database " + databaseName + " update failed: "
+ + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- // call the webservice
- DatabaseClient client = new DatabaseClient( agent.getHostname(), agent.getPort() );
- client.update( parent.getParentPane().getEnvironmentWindow().getEnvironmentName(), parent.getServerName(),
- parent.getApplicationName(), databaseName, false );
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JEE application " + parent.getApplicationName() + " database " + databaseName + " update failed: "
- + e.getMessage();
- }
- finally
- {
- ended = true;
- }
}
- }
- // toggle active
- private ActionListener toggleActive = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // toggle active
+ private ActionListener toggleActive = new ActionListener()
{
- // check if the user has the environment lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the database object
- Database database = parent.getApplication().getDatabase( event.getActionCommand() );
- if ( database == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "database.notfound" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // change the state and add a change event
- if ( database.isActive() )
- {
- database.setActive( false );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add( "Disable database " + database.getName() );
- }
- else
- {
- database.setActive( true );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add( "Enable database " + database.getName() );
- }
- // change the updated flag
- parent.getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the pane
- update();
- }
- };
-
- // toggle blocker
- private ActionListener toggleBlocker = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the database object
- Database database = parent.getApplication().getDatabase( event.getActionCommand() );
- if ( database == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "database.notfound" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // change the blocker state and add a change event
- if ( database.isBlocker() )
- {
- database.setBlocker( false );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Set not blocker for database " + database.getName() );
- }
- else
- {
- database.setBlocker( true );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Set blocker for database " + database.getName() );
- }
- // change the updated flag
- parent.getParentPane().getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getParentPane().getEnvironmentWindow().updateJournalPane();
- // update the pane
- update();
- }
- };
-
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the database file object
- final Database database = parent.getApplication().getDatabase( event.getActionCommand() );
- if ( database == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "database.notfound" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- // delete the database object
- parent.getApplication().getDatabases().remove( database );
- // add a change event
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "Delete database " + database.getName() );
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the database object
+ Database database = parent.getApplication().getDatabase( event.getActionCommand() );
+ if ( database == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "database.notfound" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // change the state and add a change event
+ if ( database.isActive() )
+ {
+ database.setActive( false );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Disable database " + database.getName() );
+ }
+ else
+ {
+ database.setActive( true );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Enable database " + database.getName() );
+ }
// change the updated flag
parent.getParentPane().getEnvironmentWindow().setUpdated( true );
// update the journal log tab pane
parent.getParentPane().getEnvironmentWindow().updateJournalPane();
// update the pane
update();
- }
- } ) );
- }
- };
+ }
+ };
- // edit
- private ActionListener edit = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // toggle blocker
+ private ActionListener toggleBlocker = new ActionListener()
{
- if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
- "databasewindow_" + parent.getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
- + parent.getServerName() + "_" + parent.getApplicationName() + "_" + event.getActionCommand() ) == null )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ApplicationDatabaseWindow( ApplicationDatabasesPane.this, event.getActionCommand() ) );
- }
- }
- };
-
- // create
- private ActionListener create = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ApplicationDatabaseWindow( ApplicationDatabasesPane.this, null ) );
- }
- };
-
- // copy
- private ActionListener copy = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // looking for the database file object
- Database database = parent.getApplication().getDatabase( event.getActionCommand() );
- if ( database == null )
- {
- return;
- }
- try
- {
- KalumetConsoleApplication.getApplication().setCopyComponent( database.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
-
- // update
- private ActionListener update = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the lock
- if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
- && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if some change has not been saved
- if ( parent.getParentPane().getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- final String databaseName = event.getActionCommand();
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- // add a message in the log pane and the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application " + parent.getApplicationName() + " database " + databaseName
- + " update in progress...", parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getApplicationName() + " database " + databaseName + " update requested." );
- // start the update thread
- final UpdateThread updateThread = new UpdateThread();
- updateThread.databaseName = databaseName;
- updateThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
{
- public void run()
- {
- if ( updateThread.ended )
- {
- if ( updateThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( updateThread.message,
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add( updateThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "JEE application " + parent.getApplicationName() + " database " + databaseName + " updated.",
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + parent.getApplicationName() + " database " + databaseName + " updated." );
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
- } );
- }
- } ) );
- }
- };
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the database object
+ Database database = parent.getApplication().getDatabase( event.getActionCommand() );
+ if ( database == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "database.notfound" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // change the blocker state and add a change event
+ if ( database.isBlocker() )
+ {
+ database.setBlocker( false );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Set not blocker for database " + database.getName() );
+ }
+ else
+ {
+ database.setBlocker( true );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Set blocker for database " + database.getName() );
+ }
+ // change the updated flag
+ parent.getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the pane
+ update();
+ }
+ };
- /**
- * Create a new <code>ApplicationDatabasesPane</code>.
- *
- * @param parent the parent <code>ApplicationWindow</code>.
- */
- public ApplicationDatabasesPane( ApplicationWindow parent )
- {
- super();
- setStyleName( "tab.content" );
-
- // update parent
- this.parent = parent;
-
- // column layout content
- Column content = new Column();
- add( content );
-
- // add the create button
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
+ // delete
+ private ActionListener delete = new ActionListener()
{
- Button createButton = new Button( Messages.getString( "database.add" ), Styles.ADD );
- createButton.addActionListener( create );
- content.add( createButton );
- }
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the database file object
+ final Database database = parent.getApplication().getDatabase( event.getActionCommand() );
+ if ( database == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "database.notfound" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // delete the database object
+ parent.getApplication().getDatabases().remove( database );
+ // add a change event
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "Delete database " + database.getName() );
+ // change the updated flag
+ parent.getParentPane().getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the pane
+ update();
+ }
+ } ) );
+ }
+ };
- // add the databases grid
- grid = new Grid( 8 );
- grid.setStyleName( "border.grid" );
- content.add( grid );
-
- // update the pane
- update();
- }
-
- /**
- * Update the pane.
- */
- public void update()
- {
- // remove all databases grid children
- grid.removeAll();
- // add databases grid header
- // action header
- Label actionHeader = new Label( " " );
- actionHeader.setStyleName( "grid.header" );
- grid.add( actionHeader );
- // name header
- Label nameHeader = new Label( Messages.getString( "name" ) );
- nameHeader.setStyleName( "grid.header" );
- grid.add( nameHeader );
- // driver header
- Label driverHeader = new Label( Messages.getString( "driver" ) );
- driverHeader.setStyleName( "grid.header" );
- grid.add( driverHeader );
- // user header
- Label userHeader = new Label( Messages.getString( "user" ) );
- userHeader.setStyleName( "grid.header" );
- grid.add( userHeader );
- // URL header
- Label urlHeader = new Label( Messages.getString( "url" ) );
- urlHeader.setStyleName( "grid.header" );
- grid.add( urlHeader );
- // connection pool header
- Label connectionPoolHeader = new Label( Messages.getString( "connectionpool" ) );
- connectionPoolHeader.setStyleName( "grid.header" );
- grid.add( connectionPoolHeader );
- // SQL command header
- Label sqlCommandHeader = new Label( Messages.getString( "sql.command" ) );
- sqlCommandHeader.setStyleName( "grid.header" );
- grid.add( sqlCommandHeader );
- // agent header
- Label agentHeader = new Label( Messages.getString( "agent" ) );
- agentHeader.setStyleName( "grid.header" );
- grid.add( agentHeader );
- // add database
- for ( Iterator databaseIterator = parent.getApplication().getDatabases().iterator(); databaseIterator.hasNext(); )
+ // edit
+ private ActionListener edit = new ActionListener()
{
- Database database = (Database) databaseIterator.next();
- // row
- Row row = new Row();
- row.setCellSpacing( new Extent( 2 ) );
- row.setInsets( new Insets( 2 ) );
- grid.add( row );
- // copy
- Button copyButton = new Button( Styles.PAGE_COPY );
- copyButton.setToolTipText( Messages.getString( "copy" ) );
- copyButton.setActionCommand( database.getName() );
- copyButton.addActionListener( copy );
- row.add( copyButton );
- // active
- Button activeButton;
- if ( database.isActive() )
- {
- activeButton = new Button( Styles.LIGHTBULB );
- activeButton.setToolTipText( Messages.getString( "switch.disable" ) );
- }
- else
- {
- activeButton = new Button( Styles.LIGHTBULB_OFF );
- activeButton.setToolTipText( Messages.getString( "switch.enable" ) );
- }
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- activeButton.setActionCommand( database.getName() );
- activeButton.addActionListener( toggleActive );
- }
- row.add( activeButton );
- // blocker
- Button blockerButton;
- if ( database.isBlocker() )
- {
- blockerButton = new Button( Styles.PLUGIN );
- blockerButton.setToolTipText( Messages.getString( "switch.notblocker" ) );
- }
- else
- {
- blockerButton = new Button( Styles.PLUGIN_DISABLED );
- blockerButton.setToolTipText( Messages.getString( "switch.blocker" ) );
- }
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- blockerButton.setActionCommand( database.getName() );
- blockerButton.addActionListener( toggleBlocker );
- }
- row.add( blockerButton );
- // update
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
- {
- Button updateButton = new Button( Styles.COG );
- updateButton.setToolTipText( Messages.getString( "update" ) );
- updateButton.setActionCommand( database.getName() );
- updateButton.addActionListener( update );
- row.add( updateButton );
- }
- // delete
- if ( parent.getParentPane().getEnvironmentWindow().adminPermission
- || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- Button deleteButton = new Button( Styles.DELETE );
- deleteButton.setToolTipText( Messages.getString( "delete" ) );
- deleteButton.setActionCommand( database.getName() );
- deleteButton.addActionListener( delete );
- row.add( deleteButton );
- }
- // name
- Button databaseName = new Button( database.getName() );
- databaseName.setStyleName( "default" );
- databaseName.setActionCommand( database.getName() );
- databaseName.addActionListener( edit );
- grid.add( databaseName );
- // driver
- Label databaseDriver = new Label( database.getDriver() );
- databaseDriver.setStyleName( "default" );
- grid.add( databaseDriver );
- // user
- Label databaseUser = new Label( database.getUser() );
- databaseUser.setStyleName( "default" );
- grid.add( databaseUser );
- // URL
- Label databaseUrl = new Label( database.getJdbcurl() );
- databaseUrl.setStyleName( "default" );
- grid.add( databaseUrl );
- // connection pool
- Label connectionPool = new Label( database.getConnectionPool() );
- connectionPool.setStyleName( "default" );
- grid.add( connectionPool );
- // SQL command
- Label sqlCommand = new Label( database.getSqlCommand() );
- sqlCommand.setStyleName( "default" );
- grid.add( sqlCommand );
- // agent
- Label agent = new Label( database.getAgent() );
- agent.setStyleName( "default" );
- grid.add( agent );
- }
- }
+ public void actionPerformed( ActionEvent event )
+ {
+ if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
+ "databasewindow_" + parent.getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
+ + parent.getServerName() + "_" + parent.getApplicationName() + "_" + event.getActionCommand() )
+ == null )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ApplicationDatabaseWindow( ApplicationDatabasesPane.this, event.getActionCommand() ) );
+ }
+ }
+ };
- /**
- * Return the parent <code>ApplicationWindow</code>.
- *
- * @return the parent <code>ApplicationWindow</code>.
- */
- public ApplicationWindow getParentPane()
- {
- return parent;
- }
+ // create
+ private ActionListener create = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ApplicationDatabaseWindow( ApplicationDatabasesPane.this, null ) );
+ }
+ };
+
+ // copy
+ private ActionListener copy = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // looking for the database file object
+ Database database = parent.getApplication().getDatabase( event.getActionCommand() );
+ if ( database == null )
+ {
+ return;
+ }
+ try
+ {
+ KalumetConsoleApplication.getApplication().setCopyComponent( database.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
+
+ // update
+ private ActionListener update = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if some change has not been saved
+ if ( parent.getParentPane().getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ final String databaseName = event.getActionCommand();
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // add a message in the log pane and the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application " + parent.getApplicationName() + " database " + databaseName
+ + " update in progress...",
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + parent.getApplicationName() + " database " + databaseName
+ + " update requested." );
+ // start the update thread
+ final UpdateThread updateThread = new UpdateThread();
+ updateThread.databaseName = databaseName;
+ updateThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( updateThread.ended )
+ {
+ if ( updateThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ updateThread.message,
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ updateThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ "JEE application " + parent.getApplicationName() + " database "
+ + databaseName + " updated.",
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + parent.getApplicationName() + " database "
+ + databaseName + " updated." );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ } ) );
+ }
+ };
+
+ /**
+ * Create a new <code>ApplicationDatabasesPane</code>.
+ *
+ * @param parent the parent <code>ApplicationWindow</code>.
+ */
+ public ApplicationDatabasesPane( ApplicationWindow parent )
+ {
+ super();
+ setStyleName( "tab.content" );
+
+ // update parent
+ this.parent = parent;
+
+ // column layout content
+ Column content = new Column();
+ add( content );
+
+ // add the create button
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ Button createButton = new Button( Messages.getString( "database.add" ), Styles.ADD );
+ createButton.addActionListener( create );
+ content.add( createButton );
+ }
+
+ // add the databases grid
+ grid = new Grid( 8 );
+ grid.setStyleName( "border.grid" );
+ content.add( grid );
+
+ // update the pane
+ update();
+ }
+
+ /**
+ * Update the pane.
+ */
+ public void update()
+ {
+ // remove all databases grid children
+ grid.removeAll();
+ // add databases grid header
+ // action header
+ Label actionHeader = new Label( " " );
+ actionHeader.setStyleName( "grid.header" );
+ grid.add( actionHeader );
+ // name header
+ Label nameHeader = new Label( Messages.getString( "name" ) );
+ nameHeader.setStyleName( "grid.header" );
+ grid.add( nameHeader );
+ // driver header
+ Label driverHeader = new Label( Messages.getString( "driver" ) );
+ driverHeader.setStyleName( "grid.header" );
+ grid.add( driverHeader );
+ // user header
+ Label userHeader = new Label( Messages.getString( "user" ) );
+ userHeader.setStyleName( "grid.header" );
+ grid.add( userHeader );
+ // URL header
+ Label urlHeader = new Label( Messages.getString( "url" ) );
+ urlHeader.setStyleName( "grid.header" );
+ grid.add( urlHeader );
+ // connection pool header
+ Label connectionPoolHeader = new Label( Messages.getString( "connectionpool" ) );
+ connectionPoolHeader.setStyleName( "grid.header" );
+ grid.add( connectionPoolHeader );
+ // SQL command header
+ Label sqlCommandHeader = new Label( Messages.getString( "sql.command" ) );
+ sqlCommandHeader.setStyleName( "grid.header" );
+ grid.add( sqlCommandHeader );
+ // agent header
+ Label agentHeader = new Label( Messages.getString( "agent" ) );
+ agentHeader.setStyleName( "grid.header" );
+ grid.add( agentHeader );
+ // add database
+ for ( Iterator databaseIterator = parent.getApplication().getDatabases().iterator();
+ databaseIterator.hasNext(); )
+ {
+ Database database = (Database) databaseIterator.next();
+ // row
+ Row row = new Row();
+ row.setCellSpacing( new Extent( 2 ) );
+ row.setInsets( new Insets( 2 ) );
+ grid.add( row );
+ // copy
+ Button copyButton = new Button( Styles.PAGE_COPY );
+ copyButton.setToolTipText( Messages.getString( "copy" ) );
+ copyButton.setActionCommand( database.getName() );
+ copyButton.addActionListener( copy );
+ row.add( copyButton );
+ // active
+ Button activeButton;
+ if ( database.isActive() )
+ {
+ activeButton = new Button( Styles.LIGHTBULB );
+ activeButton.setToolTipText( Messages.getString( "switch.disable" ) );
+ }
+ else
+ {
+ activeButton = new Button( Styles.LIGHTBULB_OFF );
+ activeButton.setToolTipText( Messages.getString( "switch.enable" ) );
+ }
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ activeButton.setActionCommand( database.getName() );
+ activeButton.addActionListener( toggleActive );
+ }
+ row.add( activeButton );
+ // blocker
+ Button blockerButton;
+ if ( database.isBlocker() )
+ {
+ blockerButton = new Button( Styles.PLUGIN );
+ blockerButton.setToolTipText( Messages.getString( "switch.notblocker" ) );
+ }
+ else
+ {
+ blockerButton = new Button( Styles.PLUGIN_DISABLED );
+ blockerButton.setToolTipText( Messages.getString( "switch.blocker" ) );
+ }
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ blockerButton.setActionCommand( database.getName() );
+ blockerButton.addActionListener( toggleBlocker );
+ }
+ row.add( blockerButton );
+ // update
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ Button updateButton = new Button( Styles.COG );
+ updateButton.setToolTipText( Messages.getString( "update" ) );
+ updateButton.setActionCommand( database.getName() );
+ updateButton.addActionListener( update );
+ row.add( updateButton );
+ }
+ // delete
+ if ( parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ Button deleteButton = new Button( Styles.DELETE );
+ deleteButton.setToolTipText( Messages.getString( "delete" ) );
+ deleteButton.setActionCommand( database.getName() );
+ deleteButton.addActionListener( delete );
+ row.add( deleteButton );
+ }
+ // name
+ Button databaseName = new Button( database.getName() );
+ databaseName.setStyleName( "default" );
+ databaseName.setActionCommand( database.getName() );
+ databaseName.addActionListener( edit );
+ grid.add( databaseName );
+ // driver
+ Label databaseDriver = new Label( database.getDriver() );
+ databaseDriver.setStyleName( "default" );
+ grid.add( databaseDriver );
+ // user
+ Label databaseUser = new Label( database.getUser() );
+ databaseUser.setStyleName( "default" );
+ grid.add( databaseUser );
+ // URL
+ Label databaseUrl = new Label( database.getJdbcurl() );
+ databaseUrl.setStyleName( "default" );
+ grid.add( databaseUrl );
+ // connection pool
+ Label connectionPool = new Label( database.getConnectionPool() );
+ connectionPool.setStyleName( "default" );
+ grid.add( connectionPool );
+ // SQL command
+ Label sqlCommand = new Label( database.getSqlCommand() );
+ sqlCommand.setStyleName( "default" );
+ grid.add( sqlCommand );
+ // agent
+ Label agent = new Label( database.getAgent() );
+ agent.setStyleName( "default" );
+ grid.add( agent );
+ }
+ }
+
+ /**
+ * Return the parent <code>ApplicationWindow</code>.
+ *
+ * @return the parent <code>ApplicationWindow</code>.
+ */
+ public ApplicationWindow getParentPane()
+ {
+ return parent;
+ }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationGeneralPane.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationGeneralPane.java
index 0d9b91d..641e3e6 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationGeneralPane.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationGeneralPane.java
@@ -40,210 +40,211 @@
* JEE application general pane.
*/
public class ApplicationGeneralPane
- extends ContentPane
+ extends ContentPane
{
- private ApplicationWindow parent;
+ private ApplicationWindow parent;
- private TextField nameField;
+ private TextField nameField;
- private SelectField activeField;
+ private SelectField activeField;
- private SelectField blockerField;
+ private SelectField blockerField;
- private TextField uriField;
+ private TextField uriField;
- private SelectField agentField;
+ private SelectField agentField;
- // test URI
- private ActionListener testUri = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // test URI
+ private ActionListener testUri = new ActionListener()
{
- String uri = FileManipulator.format( getUriField().getText() );
- boolean exists = false;
- FileManipulator fileManipulator = null;
- try
- {
- fileManipulator = new FileManipulator();
- exists = fileManipulator.exists( uri );
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- "Can't check the URI " + uri + ": " + e.getMessage(), parent.getEnvironmentWindow().getEnvironmentName() );
- }
- finally
- {
- if ( fileManipulator != null )
+ public void actionPerformed( ActionEvent event )
{
- fileManipulator.close();
+ String uri = FileManipulator.format( getUriField().getText() );
+ boolean exists = false;
+ FileManipulator fileManipulator = null;
+ try
+ {
+ fileManipulator = new FileManipulator();
+ exists = fileManipulator.exists( uri );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ "Can't check the URI " + uri + ": " + e.getMessage(),
+ parent.getEnvironmentWindow().getEnvironmentName() );
+ }
+ finally
+ {
+ if ( fileManipulator != null )
+ {
+ fileManipulator.close();
+ }
+ }
+ if ( exists )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm( "URI " + uri + " exists.",
+ parent.getEnvironmentWindow().getEnvironmentName() );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning( "URI " + uri + " doesn't exists.",
+ parent.getEnvironmentWindow().getEnvironmentName() );
+ }
}
- }
- if ( exists )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm( "URI " + uri + " exists.",
- parent.getEnvironmentWindow().getEnvironmentName() );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( "URI " + uri + " doesn't exists.",
- parent.getEnvironmentWindow().getEnvironmentName() );
- }
- }
- };
+ };
- /**
- * Create a new <code>ApplicationGeneralPane</code>.
- *
- * @param parent the parent <code>ApplicationWindow</code>.
- */
- public ApplicationGeneralPane( ApplicationWindow parent )
- {
- super();
- setStyleName( "tab.content" );
-
- // update parent
- this.parent = parent;
-
- // grid layout
- Grid layout = new Grid( 2 );
- layout.setStyleName( "default" );
- layout.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
- layout.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
- add( layout );
-
- // add application name field
- Label nameLabel = new Label( Messages.getString( "name" ) );
- nameLabel.setStyleName( "grid.cell" );
- layout.add( nameLabel );
- nameField = new TextField();
- nameField.setStyleName( "default" );
- nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
- layout.add( nameField );
-
- // add the application active field
- Label activeLabel = new Label( Messages.getString( "active" ) );
- activeLabel.setStyleName( "grid.cell" );
- layout.add( activeLabel );
- activeField = new SelectField( MainScreen.LABELS );
- activeField.setStyleName( "default" );
- activeField.setWidth( new Extent( 10, Extent.EX ) );
- layout.add( activeField );
-
- // add the application blocker field
- Label blockerLabel = new Label( Messages.getString( "blocker" ) );
- blockerLabel.setStyleName( "grid.cell" );
- layout.add( blockerLabel );
- blockerField = new SelectField( MainScreen.LABELS );
- blockerField.setStyleName( "default" );
- blockerField.setWidth( new Extent( 10, Extent.EX ) );
- layout.add( blockerField );
-
- // add the application uri field)
- Label uriLabel = new Label( Messages.getString( "uri" ) );
- uriLabel.setStyleName( "grid.cell" );
- layout.add( uriLabel );
- Row uriRow = new Row();
- layout.add( uriRow );
- uriField = new TextField();
- uriField.setWidth( new Extent( 500, Extent.PX ) );
- uriField.setStyleName( "default" );
- uriRow.add( uriField );
- Button testUriButton = new Button( Styles.WORLD );
- testUriButton.setToolTipText( Messages.getString( "uri.test" ) );
- testUriButton.addActionListener( testUri );
- uriRow.add( testUriButton );
-
- // add the application agent field
- Label agentLabel = new Label( Messages.getString( "agent" ) );
- agentLabel.setStyleName( "grid.cell" );
- layout.add( agentLabel );
- agentField = new SelectField();
- agentField.setStyleName( "default" );
- agentField.setWidth( new Extent( 50, Extent.EX ) );
- layout.add( agentField );
-
- // update the pane
- update();
- }
-
- /**
- * Update the pane.
- */
- public void update()
- {
- // update the application name field
- nameField.setText( parent.getApplication().getName() );
- // update the application active field
- if ( parent.getApplication().isActive() )
+ /**
+ * Create a new <code>ApplicationGeneralPane</code>.
+ *
+ * @param parent the parent <code>ApplicationWindow</code>.
+ */
+ public ApplicationGeneralPane( ApplicationWindow parent )
{
- activeField.setSelectedIndex( 0 );
- }
- else
- {
- activeField.setSelectedIndex( 1 );
- }
- // update the application blocker field
- if ( parent.getApplication().isBlocker() )
- {
- blockerField.setSelectedIndex( 0 );
- }
- else
- {
- blockerField.setSelectedIndex( 1 );
- }
- // update the application uri field
- uriField.setText( parent.getApplication().getUri() );
- // update the application agent field
- // load Kalumet configuration
- Kalumet kalumet;
- try
- {
- kalumet = ConfigurationManager.loadStore();
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage(),
- parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // update the agent field model
- DefaultListModel agentListModel = (DefaultListModel) agentField.getModel();
- agentListModel.removeAll();
- agentListModel.add( "" );
- for ( Iterator agentIterator = kalumet.getAgents().iterator(); agentIterator.hasNext(); )
- {
- Agent agent = (Agent) agentIterator.next();
- agentListModel.add( agent.getId() );
- }
- agentField.setSelectedItem( parent.getApplication().getAgent() );
- }
+ super();
+ setStyleName( "tab.content" );
- public TextField getNameField()
- {
- return this.nameField;
- }
+ // update parent
+ this.parent = parent;
- public SelectField getActiveField()
- {
- return this.activeField;
- }
+ // grid layout
+ Grid layout = new Grid( 2 );
+ layout.setStyleName( "default" );
+ layout.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
+ layout.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
+ add( layout );
- public SelectField getBlockerField()
- {
- return this.blockerField;
- }
+ // add application name field
+ Label nameLabel = new Label( Messages.getString( "name" ) );
+ nameLabel.setStyleName( "grid.cell" );
+ layout.add( nameLabel );
+ nameField = new TextField();
+ nameField.setStyleName( "default" );
+ nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ layout.add( nameField );
- public TextField getUriField()
- {
- return this.uriField;
- }
+ // add the application active field
+ Label activeLabel = new Label( Messages.getString( "active" ) );
+ activeLabel.setStyleName( "grid.cell" );
+ layout.add( activeLabel );
+ activeField = new SelectField( MainScreen.LABELS );
+ activeField.setStyleName( "default" );
+ activeField.setWidth( new Extent( 10, Extent.EX ) );
+ layout.add( activeField );
- public SelectField getAgentField()
- {
- return this.agentField;
- }
+ // add the application blocker field
+ Label blockerLabel = new Label( Messages.getString( "blocker" ) );
+ blockerLabel.setStyleName( "grid.cell" );
+ layout.add( blockerLabel );
+ blockerField = new SelectField( MainScreen.LABELS );
+ blockerField.setStyleName( "default" );
+ blockerField.setWidth( new Extent( 10, Extent.EX ) );
+ layout.add( blockerField );
+
+ // add the application uri field)
+ Label uriLabel = new Label( Messages.getString( "uri" ) );
+ uriLabel.setStyleName( "grid.cell" );
+ layout.add( uriLabel );
+ Row uriRow = new Row();
+ layout.add( uriRow );
+ uriField = new TextField();
+ uriField.setWidth( new Extent( 500, Extent.PX ) );
+ uriField.setStyleName( "default" );
+ uriRow.add( uriField );
+ Button testUriButton = new Button( Styles.WORLD );
+ testUriButton.setToolTipText( Messages.getString( "uri.test" ) );
+ testUriButton.addActionListener( testUri );
+ uriRow.add( testUriButton );
+
+ // add the application agent field
+ Label agentLabel = new Label( Messages.getString( "agent" ) );
+ agentLabel.setStyleName( "grid.cell" );
+ layout.add( agentLabel );
+ agentField = new SelectField();
+ agentField.setStyleName( "default" );
+ agentField.setWidth( new Extent( 50, Extent.EX ) );
+ layout.add( agentField );
+
+ // update the pane
+ update();
+ }
+
+ /**
+ * Update the pane.
+ */
+ public void update()
+ {
+ // update the application name field
+ nameField.setText( parent.getApplication().getName() );
+ // update the application active field
+ if ( parent.getApplication().isActive() )
+ {
+ activeField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ activeField.setSelectedIndex( 1 );
+ }
+ // update the application blocker field
+ if ( parent.getApplication().isBlocker() )
+ {
+ blockerField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ blockerField.setSelectedIndex( 1 );
+ }
+ // update the application uri field
+ uriField.setText( parent.getApplication().getUri() );
+ // update the application agent field
+ // load Kalumet configuration
+ Kalumet kalumet;
+ try
+ {
+ kalumet = ConfigurationManager.loadStore();
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage(),
+ parent.getParentPane().getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // update the agent field model
+ DefaultListModel agentListModel = (DefaultListModel) agentField.getModel();
+ agentListModel.removeAll();
+ agentListModel.add( "" );
+ for ( Iterator agentIterator = kalumet.getAgents().iterator(); agentIterator.hasNext(); )
+ {
+ Agent agent = (Agent) agentIterator.next();
+ agentListModel.add( agent.getId() );
+ }
+ agentField.setSelectedItem( parent.getApplication().getAgent() );
+ }
+
+ public TextField getNameField()
+ {
+ return this.nameField;
+ }
+
+ public SelectField getActiveField()
+ {
+ return this.activeField;
+ }
+
+ public SelectField getBlockerField()
+ {
+ return this.blockerField;
+ }
+
+ public TextField getUriField()
+ {
+ return this.uriField;
+ }
+
+ public SelectField getAgentField()
+ {
+ return this.agentField;
+ }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerCachesPane.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerCachesPane.java
index 55616b7..ccf504b 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerCachesPane.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerCachesPane.java
@@ -36,329 +36,332 @@
* JEE application server caches pane.
*/
public class ApplicationServerCachesPane
- extends ContentPane
+ extends ContentPane
{
- private ApplicationServerWindow parent;
+ private ApplicationServerWindow parent;
- private Grid grid;
+ private Grid grid;
- private TextField newPathField;
+ private TextField newPathField;
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // delete
+ private ActionListener delete = new ActionListener()
{
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationServersChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restrictied" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get the cache path
- final String cachePath = event.getActionCommand();
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission
+ && !getEnvironmentWindow().jeeApplicationServersChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restrictied" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get the cache path
+ final String cachePath = event.getActionCommand();
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // looking for the cache object
+ Cache cache = parent.getApplicationServer().getCache( cachePath );
+ if ( cache == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "cache.notfound" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // remove the cache
+ parent.getApplicationServer().getCaches().remove( cache );
+ // add a change event
+ parent.getEnvironmentWindow().getChangeEvents().add( "Delete cache " + cache.getPath() );
+ // change the updated flag
+ parent.getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getEnvironmentWindow().updateJournalPane();
+ // update the pane
+ update();
+ }
+ } ) );
+ }
+ };
+
+ // edit
+ private ActionListener edit = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission
+ && !getEnvironmentWindow().jeeApplicationServersChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get the cache path
+ String cachePath = event.getActionCommand();
+ // get the cache path field
+ TextField cachePathField = (TextField) ApplicationServerCachesPane.this.getComponent(
+ "pathfield_" + parent.getEnvironmentWindow().getEnvironmentName() + "_"
+ + parent.getApplicationServerName() + "_" + cachePath );
+ // get the cache path field value
+ String cachePathFieldValue = cachePathField.getText();
+ // check mandatory field
+ if ( cachePathFieldValue == null || cachePathFieldValue.trim().length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "cache.mandatory" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // if the user change the cache path, check if the cache path doesn't
+ // already exist
+ if ( !cachePath.equals( cachePathFieldValue ) )
+ {
+ if ( parent.getApplicationServer().getCache( cachePathFieldValue ) != null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "cache.exists" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ }
// looking for the cache object
Cache cache = parent.getApplicationServer().getCache( cachePath );
if ( cache == null )
{
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "cache.notfound" ), getEnvironmentWindow().getEnvironmentName() );
- return;
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "cache.notfound" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
}
- // remove the cache
- parent.getApplicationServer().getCaches().remove( cache );
// add a change event
- parent.getEnvironmentWindow().getChangeEvents().add( "Delete cache " + cache.getPath() );
+ parent.getEnvironmentWindow().getChangeEvents().add( "Change cache " + cache.getPath() );
+ // update the cache object
+ cache.setPath( cachePathFieldValue );
// change the updated flag
parent.getEnvironmentWindow().setUpdated( true );
// update the journal log tab pane
parent.getEnvironmentWindow().updateJournalPane();
// update the pane
update();
- }
- } ) );
- }
- };
-
- // edit
- private ActionListener edit = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationServersChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get the cache path
- String cachePath = event.getActionCommand();
- // get the cache path field
- TextField cachePathField = (TextField) ApplicationServerCachesPane.this.getComponent(
- "pathfield_" + parent.getEnvironmentWindow().getEnvironmentName() + "_" + parent.getApplicationServerName()
- + "_" + cachePath );
- // get the cache path field value
- String cachePathFieldValue = cachePathField.getText();
- // check mandatory field
- if ( cachePathFieldValue == null || cachePathFieldValue.trim().length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "cache.mandatory" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // if the user change the cache path, check if the cache path doesn't
- // already exist
- if ( !cachePath.equals( cachePathFieldValue ) )
- {
- if ( parent.getApplicationServer().getCache( cachePathFieldValue ) != null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "cache.exists" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
}
- }
- // looking for the cache object
- Cache cache = parent.getApplicationServer().getCache( cachePath );
- if ( cache == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "cache.notfound" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // add a change event
- parent.getEnvironmentWindow().getChangeEvents().add( "Change cache " + cache.getPath() );
- // update the cache object
- cache.setPath( cachePathFieldValue );
- // change the updated flag
- parent.getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getEnvironmentWindow().updateJournalPane();
- // update the pane
- update();
- }
- };
+ };
- // create
- private ActionListener create = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // create
+ private ActionListener create = new ActionListener()
{
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationServersChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get cache path value
- String newPathFieldValue = newPathField.getText();
- // check mandatory field
- if ( newPathFieldValue == null || newPathFieldValue.trim().length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "cache.mandatory" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // create a new cache object
- Cache cache = new Cache();
- cache.setPath( newPathFieldValue );
- try
- {
- parent.getApplicationServer().addCache( cache );
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "cache.exists" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // add a change event
- parent.getEnvironmentWindow().getChangeEvents().add( "Add cache " + cache.getPath() );
- // change the updated flag
- parent.getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getEnvironmentWindow().updateJournalPane();
- // update the pane
- update();
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission
+ && !getEnvironmentWindow().jeeApplicationServersChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get cache path value
+ String newPathFieldValue = newPathField.getText();
+ // check mandatory field
+ if ( newPathFieldValue == null || newPathFieldValue.trim().length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "cache.mandatory" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // create a new cache object
+ Cache cache = new Cache();
+ cache.setPath( newPathFieldValue );
+ try
+ {
+ parent.getApplicationServer().addCache( cache );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "cache.exists" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // add a change event
+ parent.getEnvironmentWindow().getChangeEvents().add( "Add cache " + cache.getPath() );
+ // change the updated flag
+ parent.getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getEnvironmentWindow().updateJournalPane();
+ // update the pane
+ update();
+ }
+ };
- // copy
- private ActionListener copy = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // copy
+ private ActionListener copy = new ActionListener()
{
- // looking for the cache object
- Cache cache = parent.getApplicationServer().getCache( event.getActionCommand() );
- if ( cache == null )
- {
- return;
- }
- try
- {
- // put the cache clone in the copy component
- KalumetConsoleApplication.getApplication().setCopyComponent( cache.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ // looking for the cache object
+ Cache cache = parent.getApplicationServer().getCache( event.getActionCommand() );
+ if ( cache == null )
+ {
+ return;
+ }
+ try
+ {
+ // put the cache clone in the copy component
+ KalumetConsoleApplication.getApplication().setCopyComponent( cache.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
- // paste
- private ActionListener paste = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // paste
+ private ActionListener paste = new ActionListener()
{
- // check if the copy is correct
- Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
- if ( copy == null || !( copy instanceof Cache ) )
- {
- return;
- }
- // update the new fields
- newPathField.setText( ( (Cache) copy ).getPath() );
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the copy is correct
+ Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+ if ( copy == null || !( copy instanceof Cache ) )
+ {
+ return;
+ }
+ // update the new fields
+ newPathField.setText( ( (Cache) copy ).getPath() );
+ }
+ };
- /**
- * Create a new <code>ApplicationServerCachesPane</code>.
- *
- * @param parent the parent <code>ApplicationServerWindow</code>.
- */
- public ApplicationServerCachesPane( ApplicationServerWindow parent )
- {
- super();
- setStyleName( "tab.content" );
-
- // update parent
- this.parent = parent;
-
- // add the caches grid
- grid = new Grid( 2 );
- grid.setStyleName( "border.grid" );
- grid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
- add( grid );
-
- // update the pane
- update();
- }
-
- /**
- * Update the pane.
- */
- public void update()
- {
- // remove all caches grid children
- grid.removeAll();
- // action header
- Label actionHeader = new Label( " " );
- actionHeader.setStyleName( "grid.header" );
- grid.add( actionHeader );
- Label pathHeader = new Label( Messages.getString( "path" ) );
- pathHeader.setStyleName( "grid.header" );
- grid.add( pathHeader );
- // add cache
- for ( Iterator cacheIterator = parent.getApplicationServer().getCaches().iterator(); cacheIterator.hasNext(); )
+ /**
+ * Create a new <code>ApplicationServerCachesPane</code>.
+ *
+ * @param parent the parent <code>ApplicationServerWindow</code>.
+ */
+ public ApplicationServerCachesPane( ApplicationServerWindow parent )
{
- Cache cache = (Cache) cacheIterator.next();
- // row
- Row row = new Row();
- row.setCellSpacing( new Extent( 2 ) );
- row.setInsets( new Insets( 2 ) );
- grid.add( row );
- // copy
- Button copyButton = new Button( Styles.PAGE_COPY );
- copyButton.setToolTipText( Messages.getString( "copy" ) );
- copyButton.setActionCommand( cache.getPath() );
- copyButton.addActionListener( copy );
- row.add( copyButton );
- // delete / edit
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationServersChangePermission)
- {
- // edit
- Button editButton = new Button( Styles.ACCEPT );
- editButton.setActionCommand( cache.getPath() );
- editButton.addActionListener( edit );
- row.add( editButton );
- // delete
- Button deleteButton = new Button( Styles.DELETE );
- deleteButton.setToolTipText( Messages.getString( "delete" ) );
- deleteButton.setActionCommand( cache.getPath() );
- deleteButton.addActionListener( delete );
- row.add( deleteButton );
- }
- // path
- TextField cachePathField = new TextField();
- cachePathField.setId(
- "pathfield_" + parent.getEnvironmentWindow().getEnvironmentName() + "_" + parent.getApplicationServerName()
- + "_" + cache.getPath() );
- cachePathField.setStyleName( "default" );
- cachePathField.setWidth( new Extent( 100, Extent.PERCENT ) );
- cachePathField.setText( cache.getPath() );
- grid.add( cachePathField );
- }
- // add cache adding row
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationServersChangePermission)
- {
- // row
- Row row = new Row();
- row.setCellSpacing( new Extent( 2 ) );
- row.setInsets( new Insets( 2 ) );
- grid.add( row );
- // paste
- Button pasteButton = new Button( Styles.PAGE_PASTE );
- pasteButton.addActionListener( paste );
- row.add( pasteButton );
- // add
- Button addButton = new Button( Styles.ADD );
- addButton.addActionListener( create );
- row.add( addButton );
- // path
- newPathField = new TextField();
- newPathField.setStyleName( "default" );
- newPathField.setWidth( new Extent( 100, Extent.PERCENT ) );
- grid.add( newPathField );
- }
- }
+ super();
+ setStyleName( "tab.content" );
- public EnvironmentWindow getEnvironmentWindow()
- {
- return parent.getEnvironmentWindow();
- }
+ // update parent
+ this.parent = parent;
+
+ // add the caches grid
+ grid = new Grid( 2 );
+ grid.setStyleName( "border.grid" );
+ grid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
+ add( grid );
+
+ // update the pane
+ update();
+ }
+
+ /**
+ * Update the pane.
+ */
+ public void update()
+ {
+ // remove all caches grid children
+ grid.removeAll();
+ // action header
+ Label actionHeader = new Label( " " );
+ actionHeader.setStyleName( "grid.header" );
+ grid.add( actionHeader );
+ Label pathHeader = new Label( Messages.getString( "path" ) );
+ pathHeader.setStyleName( "grid.header" );
+ grid.add( pathHeader );
+ // add cache
+ for ( Iterator cacheIterator = parent.getApplicationServer().getCaches().iterator(); cacheIterator.hasNext(); )
+ {
+ Cache cache = (Cache) cacheIterator.next();
+ // row
+ Row row = new Row();
+ row.setCellSpacing( new Extent( 2 ) );
+ row.setInsets( new Insets( 2 ) );
+ grid.add( row );
+ // copy
+ Button copyButton = new Button( Styles.PAGE_COPY );
+ copyButton.setToolTipText( Messages.getString( "copy" ) );
+ copyButton.setActionCommand( cache.getPath() );
+ copyButton.addActionListener( copy );
+ row.add( copyButton );
+ // delete / edit
+ if ( getEnvironmentWindow().adminPermission
+ || getEnvironmentWindow().jeeApplicationServersChangePermission )
+ {
+ // edit
+ Button editButton = new Button( Styles.ACCEPT );
+ editButton.setActionCommand( cache.getPath() );
+ editButton.addActionListener( edit );
+ row.add( editButton );
+ // delete
+ Button deleteButton = new Button( Styles.DELETE );
+ deleteButton.setToolTipText( Messages.getString( "delete" ) );
+ deleteButton.setActionCommand( cache.getPath() );
+ deleteButton.addActionListener( delete );
+ row.add( deleteButton );
+ }
+ // path
+ TextField cachePathField = new TextField();
+ cachePathField.setId( "pathfield_" + parent.getEnvironmentWindow().getEnvironmentName() + "_"
+ + parent.getApplicationServerName() + "_" + cache.getPath() );
+ cachePathField.setStyleName( "default" );
+ cachePathField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ cachePathField.setText( cache.getPath() );
+ grid.add( cachePathField );
+ }
+ // add cache adding row
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationServersChangePermission )
+ {
+ // row
+ Row row = new Row();
+ row.setCellSpacing( new Extent( 2 ) );
+ row.setInsets( new Insets( 2 ) );
+ grid.add( row );
+ // paste
+ Button pasteButton = new Button( Styles.PAGE_PASTE );
+ pasteButton.addActionListener( paste );
+ row.add( pasteButton );
+ // add
+ Button addButton = new Button( Styles.ADD );
+ addButton.addActionListener( create );
+ row.add( addButton );
+ // path
+ newPathField = new TextField();
+ newPathField.setStyleName( "default" );
+ newPathField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ grid.add( newPathField );
+ }
+ }
+
+ public EnvironmentWindow getEnvironmentWindow()
+ {
+ return parent.getEnvironmentWindow();
+ }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerGeneralPane.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerGeneralPane.java
index c4df519..d91cc6e 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerGeneralPane.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerGeneralPane.java
@@ -38,366 +38,368 @@
* JEE application server general pane.
*/
public class ApplicationServerGeneralPane
- extends ContentPane
+ extends ContentPane
{
- private static String[] APPLICATIONSERVER_TYPES =
- new String[]{ Messages.getString( "jboss4" ), Messages.getString( "jboss6" ), Messages.getString( "weblogic8" ),
- Messages.getString( "websphere5" ) };
+ private static String[] APPLICATIONSERVER_TYPES =
+ new String[]{ Messages.getString( "jboss4" ), Messages.getString( "jboss6" ), Messages.getString( "weblogic8" ),
+ Messages.getString( "websphere5" ) };
- private ApplicationServerWindow parent;
+ private ApplicationServerWindow parent;
- private TextField nameField;
+ private TextField nameField;
- private SelectField activeField;
+ private SelectField activeField;
- private SelectField blockerField;
+ private SelectField blockerField;
- private SelectField typeField;
+ private SelectField typeField;
- private TextField jmxField;
+ private TextField jmxField;
- private TextField adminUserField;
+ private TextField adminUserField;
- private PasswordField adminPasswordField;
+ private PasswordField adminPasswordField;
- private PasswordField adminConfirmPasswordField;
+ private PasswordField adminConfirmPasswordField;
- private SelectField agentField;
+ private SelectField agentField;
- private SelectField updateRequireRestartField;
+ private SelectField updateRequireRestartField;
- private SelectField updateRequireCachesClean;
+ private SelectField updateRequireCachesClean;
- private SelectField stopUsingJmx;
+ private SelectField stopUsingJmx;
- private TextArea startupCommandArea;
+ private TextArea startupCommandArea;
- private TextArea shutdownCommandArea;
+ private TextArea shutdownCommandArea;
- /**
- * Create a new <code>ApplicationServerGeneralPane</code>.
- *
- * @param parent the parent <code>ApplicationServerWindow</code>.
- */
- public ApplicationServerGeneralPane( ApplicationServerWindow parent )
- {
- super();
- setStyleName( "tab.content" );
-
- // update parent
- this.parent = parent;
-
- // add the general layout grid
- Grid layout = new Grid( 2 );
- layout.setStyleName( "default" );
- layout.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
- layout.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
- layout.setInsets( new Insets( 2 ) );
- add( layout );
-
- // add the name field
- Label nameLabel = new Label( Messages.getString( "name" ) );
- nameLabel.setStyleName( "grid.cell" );
- layout.add( nameLabel );
- nameField = new TextField();
- nameField.setStyleName( "default" );
- nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
- layout.add( nameField );
- // add the active select field
- Label activeLabel = new Label( Messages.getString( "active" ) );
- activeLabel.setStyleName( "grid.cell" );
- layout.add( activeLabel );
- activeField = new SelectField( MainScreen.LABELS );
- activeField.setStyleName( "default" );
- activeField.setWidth( new Extent( 10, Extent.EX ) );
- activeField.setSelectedIndex( 0 );
- layout.add( activeField );
- // add the blocker select field
- Label blockerLabel = new Label( Messages.getString( "blocker" ) );
- blockerLabel.setStyleName( "grid.cell" );
- layout.add( blockerLabel );
- blockerField = new SelectField( MainScreen.LABELS );
- blockerField.setStyleName( "default" );
- blockerField.setWidth( new Extent( 10, Extent.EX ) );
- blockerField.setSelectedIndex( 0 );
- layout.add( blockerField );
- // add the type select field
- Label typeLabel = new Label( Messages.getString( "type" ) );
- typeLabel.setStyleName( "grid.cell" );
- layout.add( typeLabel );
- typeField = new SelectField( ApplicationServerGeneralPane.APPLICATIONSERVER_TYPES );
- typeField.setStyleName( "default" );
- typeField.setSelectedIndex( 0 );
- typeField.setWidth( new Extent( 50, Extent.EX ) );
- layout.add( typeField );
- // add the jmx url field
- Label jmxLabel = new Label( Messages.getString( "jmx" ) );
- jmxLabel.setStyleName( "grid.cell" );
- layout.add( jmxLabel );
- jmxField = new TextField();
- jmxField.setStyleName( "default" );
- jmxField.setWidth( new Extent( 100, Extent.PERCENT ) );
- layout.add( jmxField );
- // add the admin user field
- Label adminUserLabel = new Label( Messages.getString( "user" ) );
- adminUserLabel.setStyleName( "grid.cell" );
- layout.add( adminUserLabel );
- adminUserField = new TextField();
- adminUserField.setStyleName( "default" );
- adminUserField.setWidth( new Extent( 100, Extent.PERCENT ) );
- layout.add( adminUserField );
- // add the admin user password field
- Label adminPasswordLabel = new Label( Messages.getString( "password" ) );
- adminPasswordLabel.setStyleName( "grid.cell" );
- layout.add( adminPasswordLabel );
- adminPasswordField = new PasswordField();
- adminPasswordField.setStyleName( "default" );
- adminPasswordField.setWidth( new Extent( 100, Extent.PERCENT ) );
- layout.add( adminPasswordField );
- Label adminConfirmPasswordLabel = new Label( Messages.getString( "password.confirm" ) );
- adminConfirmPasswordLabel.setStyleName( "grid.cell" );
- layout.add( adminConfirmPasswordLabel );
- adminConfirmPasswordField = new PasswordField();
- adminConfirmPasswordField.setStyleName( "default" );
- adminConfirmPasswordField.setWidth( new Extent( 100, Extent.PERCENT ) );
- layout.add( adminConfirmPasswordField );
- // add the agent field
- Label agentLabel = new Label( Messages.getString( "agent" ) );
- agentLabel.setStyleName( "grid.cell" );
- layout.add( agentLabel );
- agentField = new SelectField();
- agentField.setStyleName( "default" );
- agentField.setWidth( new Extent( 50, Extent.EX ) );
- layout.add( agentField );
- // add the update require restart field
- Label updateRequireRestartLabel = new Label( Messages.getString( "update.require.restart" ) );
- updateRequireRestartLabel.setStyleName( "grid.cell" );
- layout.add( updateRequireRestartLabel );
- updateRequireRestartField = new SelectField( MainScreen.LABELS );
- updateRequireRestartField.setStyleName( "default" );
- updateRequireRestartField.setSelectedIndex( 0 );
- updateRequireRestartField.setWidth( new Extent( 10, Extent.EX ) );
- layout.add( updateRequireRestartField );
- // add the update require cache cleaning field
- Label updateRequireCachesCleaningLabel = new Label( Messages.getString( "update.require.caches.clean" ) );
- updateRequireCachesCleaningLabel.setStyleName( "grid.cell" );
- layout.add( updateRequireCachesCleaningLabel );
- updateRequireCachesClean = new SelectField( MainScreen.LABELS );
- updateRequireCachesClean.setStyleName( "default" );
- updateRequireCachesClean.setSelectedIndex( 0 );
- updateRequireCachesClean.setWidth( new Extent( 10, Extent.EX ) );
- layout.add( updateRequireCachesClean );
- // add the use jmx stop field
- Label stopUsingJmxLabel = new Label( Messages.getString( "stop.using.jmx" ) );
- stopUsingJmxLabel.setStyleName( "grid.cell" );
- layout.add( stopUsingJmxLabel );
- stopUsingJmx = new SelectField( MainScreen.LABELS );
- stopUsingJmx.setStyleName( "default" );
- stopUsingJmx.setSelectedIndex( 0 );
- stopUsingJmx.setWidth( new Extent( 10, Extent.EX ) );
- layout.add( stopUsingJmx );
- // add the startup command area
- Label startupCommandLabel = new Label( Messages.getString( "applicationserver.startup" ) );
- startupCommandLabel.setStyleName( "grid.cell" );
- layout.add( startupCommandLabel );
- startupCommandArea = new TextArea();
- startupCommandArea.setStyleName( "default" );
- startupCommandArea.setWidth( new Extent( 100, Extent.PERCENT ) );
- startupCommandArea.setHeight( new Extent( 20, Extent.EX ) );
- layout.add( startupCommandArea );
- // add the shutdown command area
- Label serverShutdownCommandLabel = new Label( Messages.getString( "applicationserver.shutdown" ) );
- serverShutdownCommandLabel.setStyleName( "grid.cell" );
- layout.add( serverShutdownCommandLabel );
- shutdownCommandArea = new TextArea();
- shutdownCommandArea.setStyleName( "default" );
- shutdownCommandArea.setWidth( new Extent( 100, Extent.PERCENT ) );
- shutdownCommandArea.setHeight( new Extent( 20, Extent.EX ) );
- layout.add( shutdownCommandArea );
-
- // update the pane
- update();
- }
-
- /**
- * Update the pane.
- */
- public void update()
- {
- // updae the JEE server name field
- nameField.setText( parent.getApplicationServer().getName() );
- // update the JEE server active field
- if ( parent.getApplicationServer().isActive() )
+ /**
+ * Create a new <code>ApplicationServerGeneralPane</code>.
+ *
+ * @param parent the parent <code>ApplicationServerWindow</code>.
+ */
+ public ApplicationServerGeneralPane( ApplicationServerWindow parent )
{
- activeField.setSelectedIndex( 0 );
- }
- else
- {
- activeField.setSelectedIndex( 1 );
- }
- // update the JEE server blocker field
- if ( parent.getApplicationServer().isBlocker() )
- {
- blockerField.setSelectedIndex( 0 );
- }
- else
- {
- blockerField.setSelectedIndex( 1 );
- }
- // update the JEE application server type field
- if ( parent.getApplicationServer().getClassname() != null )
- {
- if ( parent.getApplicationServer().getClassname().equals( ApplicationServerWindow.JBOSS4_CONTROLLER_CLASSNAME ) )
- {
+ super();
+ setStyleName( "tab.content" );
+
+ // update parent
+ this.parent = parent;
+
+ // add the general layout grid
+ Grid layout = new Grid( 2 );
+ layout.setStyleName( "default" );
+ layout.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
+ layout.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
+ layout.setInsets( new Insets( 2 ) );
+ add( layout );
+
+ // add the name field
+ Label nameLabel = new Label( Messages.getString( "name" ) );
+ nameLabel.setStyleName( "grid.cell" );
+ layout.add( nameLabel );
+ nameField = new TextField();
+ nameField.setStyleName( "default" );
+ nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ layout.add( nameField );
+ // add the active select field
+ Label activeLabel = new Label( Messages.getString( "active" ) );
+ activeLabel.setStyleName( "grid.cell" );
+ layout.add( activeLabel );
+ activeField = new SelectField( MainScreen.LABELS );
+ activeField.setStyleName( "default" );
+ activeField.setWidth( new Extent( 10, Extent.EX ) );
+ activeField.setSelectedIndex( 0 );
+ layout.add( activeField );
+ // add the blocker select field
+ Label blockerLabel = new Label( Messages.getString( "blocker" ) );
+ blockerLabel.setStyleName( "grid.cell" );
+ layout.add( blockerLabel );
+ blockerField = new SelectField( MainScreen.LABELS );
+ blockerField.setStyleName( "default" );
+ blockerField.setWidth( new Extent( 10, Extent.EX ) );
+ blockerField.setSelectedIndex( 0 );
+ layout.add( blockerField );
+ // add the type select field
+ Label typeLabel = new Label( Messages.getString( "type" ) );
+ typeLabel.setStyleName( "grid.cell" );
+ layout.add( typeLabel );
+ typeField = new SelectField( ApplicationServerGeneralPane.APPLICATIONSERVER_TYPES );
+ typeField.setStyleName( "default" );
typeField.setSelectedIndex( 0 );
- }
- if ( parent.getApplicationServer().getClassname().equals( ApplicationServerWindow.JBOSS6_CONTROLLER_CLASSNAME ) )
- {
- typeField.setSelectedIndex( 1 );
- }
- if ( parent.getApplicationServer().getClassname().equals(
- ApplicationServerWindow.WEBLOGIC_CONTROLLER_CLASSNAME ) )
- {
- typeField.setSelectedIndex( 2 );
- }
- if ( parent.getApplicationServer().getClassname().equals(
- ApplicationServerWindow.WEBSPHERE_CONTROLLER_CLASSNAME ) )
- {
- typeField.setSelectedIndex( 3 );
- }
+ typeField.setWidth( new Extent( 50, Extent.EX ) );
+ layout.add( typeField );
+ // add the jmx url field
+ Label jmxLabel = new Label( Messages.getString( "jmx" ) );
+ jmxLabel.setStyleName( "grid.cell" );
+ layout.add( jmxLabel );
+ jmxField = new TextField();
+ jmxField.setStyleName( "default" );
+ jmxField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ layout.add( jmxField );
+ // add the admin user field
+ Label adminUserLabel = new Label( Messages.getString( "user" ) );
+ adminUserLabel.setStyleName( "grid.cell" );
+ layout.add( adminUserLabel );
+ adminUserField = new TextField();
+ adminUserField.setStyleName( "default" );
+ adminUserField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ layout.add( adminUserField );
+ // add the admin user password field
+ Label adminPasswordLabel = new Label( Messages.getString( "password" ) );
+ adminPasswordLabel.setStyleName( "grid.cell" );
+ layout.add( adminPasswordLabel );
+ adminPasswordField = new PasswordField();
+ adminPasswordField.setStyleName( "default" );
+ adminPasswordField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ layout.add( adminPasswordField );
+ Label adminConfirmPasswordLabel = new Label( Messages.getString( "password.confirm" ) );
+ adminConfirmPasswordLabel.setStyleName( "grid.cell" );
+ layout.add( adminConfirmPasswordLabel );
+ adminConfirmPasswordField = new PasswordField();
+ adminConfirmPasswordField.setStyleName( "default" );
+ adminConfirmPasswordField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ layout.add( adminConfirmPasswordField );
+ // add the agent field
+ Label agentLabel = new Label( Messages.getString( "agent" ) );
+ agentLabel.setStyleName( "grid.cell" );
+ layout.add( agentLabel );
+ agentField = new SelectField();
+ agentField.setStyleName( "default" );
+ agentField.setWidth( new Extent( 50, Extent.EX ) );
+ layout.add( agentField );
+ // add the update require restart field
+ Label updateRequireRestartLabel = new Label( Messages.getString( "update.require.restart" ) );
+ updateRequireRestartLabel.setStyleName( "grid.cell" );
+ layout.add( updateRequireRestartLabel );
+ updateRequireRestartField = new SelectField( MainScreen.LABELS );
+ updateRequireRestartField.setStyleName( "default" );
+ updateRequireRestartField.setSelectedIndex( 0 );
+ updateRequireRestartField.setWidth( new Extent( 10, Extent.EX ) );
+ layout.add( updateRequireRestartField );
+ // add the update require cache cleaning field
+ Label updateRequireCachesCleaningLabel = new Label( Messages.getString( "update.require.caches.clean" ) );
+ updateRequireCachesCleaningLabel.setStyleName( "grid.cell" );
+ layout.add( updateRequireCachesCleaningLabel );
+ updateRequireCachesClean = new SelectField( MainScreen.LABELS );
+ updateRequireCachesClean.setStyleName( "default" );
+ updateRequireCachesClean.setSelectedIndex( 0 );
+ updateRequireCachesClean.setWidth( new Extent( 10, Extent.EX ) );
+ layout.add( updateRequireCachesClean );
+ // add the use jmx stop field
+ Label stopUsingJmxLabel = new Label( Messages.getString( "stop.using.jmx" ) );
+ stopUsingJmxLabel.setStyleName( "grid.cell" );
+ layout.add( stopUsingJmxLabel );
+ stopUsingJmx = new SelectField( MainScreen.LABELS );
+ stopUsingJmx.setStyleName( "default" );
+ stopUsingJmx.setSelectedIndex( 0 );
+ stopUsingJmx.setWidth( new Extent( 10, Extent.EX ) );
+ layout.add( stopUsingJmx );
+ // add the startup command area
+ Label startupCommandLabel = new Label( Messages.getString( "applicationserver.startup" ) );
+ startupCommandLabel.setStyleName( "grid.cell" );
+ layout.add( startupCommandLabel );
+ startupCommandArea = new TextArea();
+ startupCommandArea.setStyleName( "default" );
+ startupCommandArea.setWidth( new Extent( 100, Extent.PERCENT ) );
+ startupCommandArea.setHeight( new Extent( 20, Extent.EX ) );
+ layout.add( startupCommandArea );
+ // add the shutdown command area
+ Label serverShutdownCommandLabel = new Label( Messages.getString( "applicationserver.shutdown" ) );
+ serverShutdownCommandLabel.setStyleName( "grid.cell" );
+ layout.add( serverShutdownCommandLabel );
+ shutdownCommandArea = new TextArea();
+ shutdownCommandArea.setStyleName( "default" );
+ shutdownCommandArea.setWidth( new Extent( 100, Extent.PERCENT ) );
+ shutdownCommandArea.setHeight( new Extent( 20, Extent.EX ) );
+ layout.add( shutdownCommandArea );
+
+ // update the pane
+ update();
}
- // update the jee application server jmx field
- jmxField.setText( parent.getApplicationServer().getJmxurl() );
- // update the jee application server admin user field
- adminUserField.setText( parent.getApplicationServer().getAdminuser() );
- // update the jee application server admin password/confirm password
- // fields
- adminPasswordField.setText( parent.getApplicationServer().getAdminpassword() );
- adminConfirmPasswordField.setText( parent.getApplicationServer().getAdminpassword() );
- // load Kalumet configuration
- Kalumet kalumet = null;
- try
+
+ /**
+ * Update the pane.
+ */
+ public void update()
{
- kalumet = ConfigurationManager.loadStore();
+ // updae the JEE server name field
+ nameField.setText( parent.getApplicationServer().getName() );
+ // update the JEE server active field
+ if ( parent.getApplicationServer().isActive() )
+ {
+ activeField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ activeField.setSelectedIndex( 1 );
+ }
+ // update the JEE server blocker field
+ if ( parent.getApplicationServer().isBlocker() )
+ {
+ blockerField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ blockerField.setSelectedIndex( 1 );
+ }
+ // update the JEE application server type field
+ if ( parent.getApplicationServer().getClassname() != null )
+ {
+ if ( parent.getApplicationServer().getClassname().equals(
+ ApplicationServerWindow.JBOSS4_CONTROLLER_CLASSNAME ) )
+ {
+ typeField.setSelectedIndex( 0 );
+ }
+ if ( parent.getApplicationServer().getClassname().equals(
+ ApplicationServerWindow.JBOSS6_CONTROLLER_CLASSNAME ) )
+ {
+ typeField.setSelectedIndex( 1 );
+ }
+ if ( parent.getApplicationServer().getClassname().equals(
+ ApplicationServerWindow.WEBLOGIC_CONTROLLER_CLASSNAME ) )
+ {
+ typeField.setSelectedIndex( 2 );
+ }
+ if ( parent.getApplicationServer().getClassname().equals(
+ ApplicationServerWindow.WEBSPHERE_CONTROLLER_CLASSNAME ) )
+ {
+ typeField.setSelectedIndex( 3 );
+ }
+ }
+ // update the jee application server jmx field
+ jmxField.setText( parent.getApplicationServer().getJmxurl() );
+ // update the jee application server admin user field
+ adminUserField.setText( parent.getApplicationServer().getAdminuser() );
+ // update the jee application server admin password/confirm password
+ // fields
+ adminPasswordField.setText( parent.getApplicationServer().getAdminpassword() );
+ adminConfirmPasswordField.setText( parent.getApplicationServer().getAdminpassword() );
+ // load Kalumet configuration
+ Kalumet kalumet = null;
+ try
+ {
+ kalumet = ConfigurationManager.loadStore();
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage() );
+ return;
+ }
+ // update the jee application server agent
+ DefaultListModel agentListModel = (DefaultListModel) agentField.getModel();
+ agentListModel.removeAll();
+ agentListModel.add( "" );
+ for ( Iterator agentIterator = kalumet.getAgents().iterator(); agentIterator.hasNext(); )
+ {
+ Agent agent = (Agent) agentIterator.next();
+ agentListModel.add( agent.getId() );
+ }
+ agentField.setSelectedItem( parent.getApplicationServer().getAgent() );
+ // update the jee application server update require restart field
+ if ( parent.getApplicationServer().isUpdateRequireRestart() )
+ {
+ updateRequireRestartField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ updateRequireRestartField.setSelectedIndex( 1 );
+ }
+ // update the jee application server update require caches cleaning field
+ if ( parent.getApplicationServer().isUpdateRequireCacheCleaning() )
+ {
+ updateRequireCachesClean.setSelectedIndex( 0 );
+ }
+ else
+ {
+ updateRequireCachesClean.setSelectedIndex( 1 );
+ }
+ // update the use jmx stop field
+ if ( parent.getApplicationServer().isUsejmxstop() )
+ {
+ stopUsingJmx.setSelectedIndex( 0 );
+ }
+ else
+ {
+ stopUsingJmx.setSelectedIndex( 1 );
+ }
+ // update the startup command area
+ startupCommandArea.setText( parent.getApplicationServer().getStartupcommand() );
+ // update the shutdown command area
+ shutdownCommandArea.setText( parent.getApplicationServer().getShutdowncommand() );
}
- catch ( Exception e )
+
+ public TextField getNameField()
{
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage() );
- return;
+ return this.nameField;
}
- // update the jee application server agent
- DefaultListModel agentListModel = (DefaultListModel) agentField.getModel();
- agentListModel.removeAll();
- agentListModel.add( "" );
- for ( Iterator agentIterator = kalumet.getAgents().iterator(); agentIterator.hasNext(); )
+
+ public SelectField getActiveField()
{
- Agent agent = (Agent) agentIterator.next();
- agentListModel.add( agent.getId() );
+ return this.activeField;
}
- agentField.setSelectedItem( parent.getApplicationServer().getAgent() );
- // update the jee application server update require restart field
- if ( parent.getApplicationServer().isUpdateRequireRestart() )
+
+ public SelectField getBlockerField()
{
- updateRequireRestartField.setSelectedIndex( 0 );
+ return this.blockerField;
}
- else
+
+ public SelectField getTypeField()
{
- updateRequireRestartField.setSelectedIndex( 1 );
+ return this.typeField;
}
- // update the jee application server update require caches cleaning field
- if ( parent.getApplicationServer().isUpdateRequireCacheCleaning() )
+
+ public TextField getJmxField()
{
- updateRequireCachesClean.setSelectedIndex( 0 );
+ return this.jmxField;
}
- else
+
+ public TextField getAdminUserField()
{
- updateRequireCachesClean.setSelectedIndex( 1 );
+ return this.adminUserField;
}
- // update the use jmx stop field
- if ( parent.getApplicationServer().isUsejmxstop() )
+
+ public PasswordField getAdminPasswordField()
{
- stopUsingJmx.setSelectedIndex( 0 );
+ return this.adminPasswordField;
}
- else
+
+ public PasswordField getAdminConfirmPasswordField()
{
- stopUsingJmx.setSelectedIndex( 1 );
+ return this.adminConfirmPasswordField;
}
- // update the startup command area
- startupCommandArea.setText( parent.getApplicationServer().getStartupcommand() );
- // update the shutdown command area
- shutdownCommandArea.setText( parent.getApplicationServer().getShutdowncommand() );
- }
- public TextField getNameField()
- {
- return this.nameField;
- }
+ public SelectField getUpdateRequireRestartField()
+ {
+ return this.updateRequireRestartField;
+ }
- public SelectField getActiveField()
- {
- return this.activeField;
- }
+ public SelectField getUpdateRequireCachesCleanField()
+ {
+ return this.updateRequireCachesClean;
+ }
- public SelectField getBlockerField()
- {
- return this.blockerField;
- }
+ public SelectField getStopUsingJmxField()
+ {
+ return this.stopUsingJmx;
+ }
- public SelectField getTypeField()
- {
- return this.typeField;
- }
+ public TextArea getStartupCommandArea()
+ {
+ return this.startupCommandArea;
+ }
- public TextField getJmxField()
- {
- return this.jmxField;
- }
+ public TextArea getShutdownCommandArea()
+ {
+ return this.shutdownCommandArea;
+ }
- public TextField getAdminUserField()
- {
- return this.adminUserField;
- }
-
- public PasswordField getAdminPasswordField()
- {
- return this.adminPasswordField;
- }
-
- public PasswordField getAdminConfirmPasswordField()
- {
- return this.adminConfirmPasswordField;
- }
-
- public SelectField getUpdateRequireRestartField()
- {
- return this.updateRequireRestartField;
- }
-
- public SelectField getUpdateRequireCachesCleanField()
- {
- return this.updateRequireCachesClean;
- }
-
- public SelectField getStopUsingJmxField()
- {
- return this.stopUsingJmx;
- }
-
- public TextArea getStartupCommandArea()
- {
- return this.startupCommandArea;
- }
-
- public TextArea getShutdownCommandArea()
- {
- return this.shutdownCommandArea;
- }
-
- public SelectField getAgentField()
- {
- return this.agentField;
- }
+ public SelectField getAgentField()
+ {
+ return this.agentField;
+ }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerWindow.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerWindow.java
index 2385453..8d58642 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerWindow.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerWindow.java
@@ -37,897 +37,907 @@
* JEE application server window.
*/
public class ApplicationServerWindow
- extends WindowPane
+ extends WindowPane
{
- private String serverName;
+ private String serverName;
- private JEEApplicationServer server = null;
+ private JEEApplicationServer server = null;
- private ApplicationServersPane parent;
+ private ApplicationServersPane parent;
- private ApplicationServerGeneralPane generalPane;
+ private ApplicationServerGeneralPane generalPane;
- private ApplicationServerCachesPane cachesPane;
+ private ApplicationServerCachesPane cachesPane;
- public final static String JBOSS4_CONTROLLER_CLASSNAME = "org.apache.kalumet.controller.jboss.JBoss4Controller";
+ public final static String JBOSS4_CONTROLLER_CLASSNAME = "org.apache.kalumet.controller.jboss.JBoss4Controller";
- public final static String JBOSS6_CONTROLLER_CLASSNAME = "org.apache.kalumet.controller.jboss.JBoss6Controller";
+ public final static String JBOSS6_CONTROLLER_CLASSNAME = "org.apache.kalumet.controller.jboss.JBoss6Controller";
- public final static String WEBLOGIC_CONTROLLER_CLASSNAME =
- "org.apache.kalumet.controller.weblogic.WeblogicController";
+ public final static String WEBLOGIC_CONTROLLER_CLASSNAME =
+ "org.apache.kalumet.controller.weblogic.WeblogicController";
- public final static String WEBSPHERE_CONTROLLER_CLASSNAME =
- "org.apache.kalumet.controller.websphere.WebsphereController";
+ public final static String WEBSPHERE_CONTROLLER_CLASSNAME =
+ "org.apache.kalumet.controller.websphere.WebsphereController";
- // status thread
- class StatusThread
- extends Thread
- {
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // status thread
+ class StatusThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getEnvironmentWindow().getEnvironment().getAgent() );
- if ( agent == null )
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent( parent.getEnvironmentWindow().getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the webservice
+ JEEApplicationServerClient client =
+ new JEEApplicationServerClient( agent.getHostname(), agent.getPort() );
+ message = client.status( parent.getEnvironmentWindow().getEnvironmentName(), serverName );
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JEE application server " + serverName + " status check failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- // call the webservice
- JEEApplicationServerClient client = new JEEApplicationServerClient( agent.getHostname(), agent.getPort() );
- message = client.status( parent.getEnvironmentWindow().getEnvironmentName(), serverName );
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JEE application server " + serverName + " status check failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
}
- }
- // update thread
- class UpdateThread
- extends Thread
- {
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // update thread
+ class UpdateThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getEnvironmentWindow().getEnvironment().getAgent() );
- if ( agent == null )
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent( parent.getEnvironmentWindow().getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the webservice
+ JEEApplicationServerClient client =
+ new JEEApplicationServerClient( agent.getHostname(), agent.getPort() );
+ client.update( parent.getEnvironmentWindow().getEnvironmentName(), serverName, false );
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JEE application server " + serverName + " update failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- // call the webservice
- JEEApplicationServerClient client = new JEEApplicationServerClient( agent.getHostname(), agent.getPort() );
- client.update( parent.getEnvironmentWindow().getEnvironmentName(), serverName, false );
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JEE application server " + serverName + " update failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
}
- }
- // stop thread
- class StopThread
- extends Thread
- {
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // stop thread
+ class StopThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getEnvironmentWindow().getEnvironment().getAgent() );
- if ( agent == null )
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent( parent.getEnvironmentWindow().getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the webservice
+ JEEApplicationServerClient client =
+ new JEEApplicationServerClient( agent.getHostname(), agent.getPort() );
+ client.stop( parent.getEnvironmentWindow().getEnvironmentName(), serverName );
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JEE application server " + serverName + " stop failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- // call the webservice
- JEEApplicationServerClient client = new JEEApplicationServerClient( agent.getHostname(), agent.getPort() );
- client.stop( parent.getEnvironmentWindow().getEnvironmentName(), serverName );
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JEE application server " + serverName + " stop failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
}
- }
- // start thread
- class StartThread
- extends Thread
- {
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // start thread
+ class StartThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getEnvironmentWindow().getEnvironment().getAgent() );
- if ( agent == null )
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent( parent.getEnvironmentWindow().getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the webservice
+ JEEApplicationServerClient client =
+ new JEEApplicationServerClient( agent.getHostname(), agent.getPort() );
+ client.start( parent.getEnvironmentWindow().getEnvironmentName(), serverName );
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JEE application server " + serverName + " start failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- // call the webservice
- JEEApplicationServerClient client = new JEEApplicationServerClient( agent.getHostname(), agent.getPort() );
- client.start( parent.getEnvironmentWindow().getEnvironmentName(), serverName );
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JEE application server " + serverName + " start failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
}
- }
- // close
- private ActionListener close = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // close
+ private ActionListener close = new ActionListener()
{
- ApplicationServerWindow.this.userClose();
- }
- };
-
- // refresh
- private ActionListener refresh = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // looking for original application server object
- server = parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- serverName );
- if ( server == null )
- {
- server = new JEEApplicationServer();
- }
- // update the window
- update();
- }
- };
-
- // apply
- private ActionListener apply = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationServersChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get fields value
- String nameFieldValue = generalPane.getNameField().getText();
- int activeFieldIndex = generalPane.getActiveField().getSelectedIndex();
- int blockerFieldIndex = generalPane.getBlockerField().getSelectedIndex();
- int typeFieldIndex = generalPane.getTypeField().getSelectedIndex();
- String jmxFieldValue = generalPane.getJmxField().getText();
- String adminUserFieldValue = generalPane.getAdminUserField().getText();
- String adminPasswordFieldValue = generalPane.getAdminPasswordField().getText();
- String adminConfirmPasswordFieldValue = generalPane.getAdminConfirmPasswordField().getText();
- int updateRequireRestartFieldIndex = generalPane.getUpdateRequireRestartField().getSelectedIndex();
- int updateRequireCachesCleanFieldIndex = generalPane.getUpdateRequireCachesCleanField().getSelectedIndex();
- int stopUsingJmxFieldIndex = generalPane.getStopUsingJmxField().getSelectedIndex();
- String startupCommandAreaValue = generalPane.getStartupCommandArea().getText();
- String shutdownCommandAreaValue = generalPane.getShutdownCommandArea().getText();
- String agentFieldValue = (String) generalPane.getAgentField().getSelectedItem();
- // check fields
- // name and JMX are mandatory
- if ( nameFieldValue == null || nameFieldValue.trim().length() < 1 || jmxFieldValue == null
- || jmxFieldValue.trim().length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "applicationserver.mandatory" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check password matching
- if ( !adminPasswordFieldValue.equals( adminConfirmPasswordFieldValue ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "applicationserver.password.notmatch" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // if the user change the JEE application server name, check if the
- // JEE application server name doesn't already exist
- if ( serverName == null || ( serverName != null && !serverName.equals( nameFieldValue ) ) )
- {
- if ( parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- nameFieldValue ) != null )
+ public void actionPerformed( ActionEvent event )
{
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "applicationserver.exists" ), getEnvironmentWindow().getEnvironmentName() );
- return;
+ ApplicationServerWindow.this.userClose();
}
- }
- // add a change event
- if ( serverName != null )
- {
- parent.getEnvironmentWindow().getChangeEvents().add( "Change JEE application server " + server.getName() );
- }
- // update the application server object
- server.setName( nameFieldValue );
- if ( activeFieldIndex == 0 )
- {
- server.setActive( true );
- }
- else
- {
- server.setActive( false );
- }
- if ( blockerFieldIndex == 0 )
- {
- server.setBlocker( true );
- }
- else
- {
- server.setBlocker( false );
- }
- if ( typeFieldIndex == 0 )
- {
- server.setClassname( ApplicationServerWindow.JBOSS4_CONTROLLER_CLASSNAME );
- }
- if ( typeFieldIndex == 1 )
- {
- server.setClassname( ApplicationServerWindow.JBOSS6_CONTROLLER_CLASSNAME );
- }
- if ( typeFieldIndex == 2 )
- {
- server.setClassname( ApplicationServerWindow.WEBLOGIC_CONTROLLER_CLASSNAME );
- }
- if ( typeFieldIndex == 3 )
- {
- server.setClassname( ApplicationServerWindow.WEBSPHERE_CONTROLLER_CLASSNAME );
- }
- server.setJmxurl( jmxFieldValue );
- server.setAdminuser( adminUserFieldValue );
- server.setAdminpassword( adminPasswordFieldValue );
- if ( updateRequireRestartFieldIndex == 0 )
- {
- server.setUpdateRequireRestart( true );
- }
- else
- {
- server.setUpdateRequireRestart( false );
- }
- if ( updateRequireCachesCleanFieldIndex == 0 )
- {
- server.setUpdateRequireCacheCleaning( true );
- }
- else
- {
- server.setUpdateRequireCacheCleaning( false );
- }
- if ( stopUsingJmxFieldIndex == 0 )
- {
- server.setUsejmxstop( true );
- }
- else
- {
- server.setUsejmxstop( false );
- }
- server.setStartupcommand( startupCommandAreaValue );
- server.setShutdowncommand( shutdownCommandAreaValue );
- server.setAgent( agentFieldValue );
- // add the application server object if needed
- if ( serverName == null )
- {
- try
- {
- parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().addJEEApplicationServer( server );
- parent.getEnvironmentWindow().getChangeEvents().add( "Add JEE application server " + server.getName() );
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "applicationserver.exists" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- }
- // update the window definition
- setTitle( Messages.getString( "applicationserver" ) + " " + server.getName() );
- setId( "applicationserverwindow_" + parent.getEnvironmentWindow().getEnvironmentName() + "_" + server.getName() );
- serverName = server.getName();
- // change the updated flag
- parent.getEnvironmentWindow().setUpdated( true );
- // update the whole environment window
- parent.getEnvironmentWindow().update();
- // update the window
- update();
- }
- };
+ };
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // refresh
+ private ActionListener refresh = new ActionListener()
{
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission || !getEnvironmentWindow().jeeApplicationServersChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- // delete the application server object
- parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServers().remove(
- server );
- // add a change event
- parent.getEnvironmentWindow().getChangeEvents().add( "Delete JEE application server " + server.getName() );
+ // looking for original application server object
+ server = parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ serverName );
+ if ( server == null )
+ {
+ server = new JEEApplicationServer();
+ }
// update the window
update();
- // update the whole parent window
+ }
+ };
+
+ // apply
+ private ActionListener apply = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission
+ && !getEnvironmentWindow().jeeApplicationServersChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get fields value
+ String nameFieldValue = generalPane.getNameField().getText();
+ int activeFieldIndex = generalPane.getActiveField().getSelectedIndex();
+ int blockerFieldIndex = generalPane.getBlockerField().getSelectedIndex();
+ int typeFieldIndex = generalPane.getTypeField().getSelectedIndex();
+ String jmxFieldValue = generalPane.getJmxField().getText();
+ String adminUserFieldValue = generalPane.getAdminUserField().getText();
+ String adminPasswordFieldValue = generalPane.getAdminPasswordField().getText();
+ String adminConfirmPasswordFieldValue = generalPane.getAdminConfirmPasswordField().getText();
+ int updateRequireRestartFieldIndex = generalPane.getUpdateRequireRestartField().getSelectedIndex();
+ int updateRequireCachesCleanFieldIndex = generalPane.getUpdateRequireCachesCleanField().getSelectedIndex();
+ int stopUsingJmxFieldIndex = generalPane.getStopUsingJmxField().getSelectedIndex();
+ String startupCommandAreaValue = generalPane.getStartupCommandArea().getText();
+ String shutdownCommandAreaValue = generalPane.getShutdownCommandArea().getText();
+ String agentFieldValue = (String) generalPane.getAgentField().getSelectedItem();
+ // check fields
+ // name and JMX are mandatory
+ if ( nameFieldValue == null || nameFieldValue.trim().length() < 1 || jmxFieldValue == null
+ || jmxFieldValue.trim().length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "applicationserver.mandatory" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check password matching
+ if ( !adminPasswordFieldValue.equals( adminConfirmPasswordFieldValue ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "applicationserver.password.notmatch" ),
+ getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // if the user change the JEE application server name, check if the
+ // JEE application server name doesn't already exist
+ if ( serverName == null || ( serverName != null && !serverName.equals( nameFieldValue ) ) )
+ {
+ if ( parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ nameFieldValue ) != null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "applicationserver.exists" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ }
+ // add a change event
+ if ( serverName != null )
+ {
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "Change JEE application server " + server.getName() );
+ }
+ // update the application server object
+ server.setName( nameFieldValue );
+ if ( activeFieldIndex == 0 )
+ {
+ server.setActive( true );
+ }
+ else
+ {
+ server.setActive( false );
+ }
+ if ( blockerFieldIndex == 0 )
+ {
+ server.setBlocker( true );
+ }
+ else
+ {
+ server.setBlocker( false );
+ }
+ if ( typeFieldIndex == 0 )
+ {
+ server.setClassname( ApplicationServerWindow.JBOSS4_CONTROLLER_CLASSNAME );
+ }
+ if ( typeFieldIndex == 1 )
+ {
+ server.setClassname( ApplicationServerWindow.JBOSS6_CONTROLLER_CLASSNAME );
+ }
+ if ( typeFieldIndex == 2 )
+ {
+ server.setClassname( ApplicationServerWindow.WEBLOGIC_CONTROLLER_CLASSNAME );
+ }
+ if ( typeFieldIndex == 3 )
+ {
+ server.setClassname( ApplicationServerWindow.WEBSPHERE_CONTROLLER_CLASSNAME );
+ }
+ server.setJmxurl( jmxFieldValue );
+ server.setAdminuser( adminUserFieldValue );
+ server.setAdminpassword( adminPasswordFieldValue );
+ if ( updateRequireRestartFieldIndex == 0 )
+ {
+ server.setUpdateRequireRestart( true );
+ }
+ else
+ {
+ server.setUpdateRequireRestart( false );
+ }
+ if ( updateRequireCachesCleanFieldIndex == 0 )
+ {
+ server.setUpdateRequireCacheCleaning( true );
+ }
+ else
+ {
+ server.setUpdateRequireCacheCleaning( false );
+ }
+ if ( stopUsingJmxFieldIndex == 0 )
+ {
+ server.setUsejmxstop( true );
+ }
+ else
+ {
+ server.setUsejmxstop( false );
+ }
+ server.setStartupcommand( startupCommandAreaValue );
+ server.setShutdowncommand( shutdownCommandAreaValue );
+ server.setAgent( agentFieldValue );
+ // add the application server object if needed
+ if ( serverName == null )
+ {
+ try
+ {
+ parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().addJEEApplicationServer(
+ server );
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "Add JEE application server " + server.getName() );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "applicationserver.exists" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ }
+ // update the window definition
+ setTitle( Messages.getString( "applicationserver" ) + " " + server.getName() );
+ setId( "applicationserverwindow_" + parent.getEnvironmentWindow().getEnvironmentName() + "_"
+ + server.getName() );
+ serverName = server.getName();
+ // change the updated flag
+ parent.getEnvironmentWindow().setUpdated( true );
+ // update the whole environment window
parent.getEnvironmentWindow().update();
- // close the window
- ApplicationServerWindow.this.userClose();
- }
- } ) );
- }
- };
+ // update the window
+ update();
+ }
+ };
- // copy
- private ActionListener copy = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // delete
+ private ActionListener delete = new ActionListener()
{
- try
- {
- // put the application server clone in the copy component
- KalumetConsoleApplication.getApplication().setCopyComponent( server.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
-
- // paste
- private ActionListener paste = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the copy component is correct
- Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
- if ( copy == null || !( copy instanceof JEEApplicationServer) )
- {
- return;
- }
- // update the application server object
- server = (JEEApplicationServer) copy;
- serverName = null;
- // update the whole window
- parent.getEnvironmentWindow().update();
- // update the window
- update();
- }
- };
-
- // status
- private ActionListener status = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if some change has not yet been saved
- if ( parent.getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ), parent.getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // add a message into the log pane and the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application server " + serverName + " status check in progress...",
- parent.getEnvironmentWindow().getEnvironmentName() );
- parent.getEnvironmentWindow().getChangeEvents().add(
- "JEE application server " + serverName + " status check requested." );
- // start status thread
- final StatusThread statusThread = new StatusThread();
- statusThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask( KalumetConsoleApplication.getApplication().getTaskQueue(),
- new Runnable()
- {
- public void run()
- {
- if ( statusThread.ended )
- {
- if ( statusThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- statusThread.message,
- parent.getEnvironmentWindow().getEnvironmentName() );
- parent.getEnvironmentWindow().getChangeEvents().add(
- statusThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application server " + serverName
- + " status: " + statusThread.message,
- parent.getEnvironmentWindow().getEnvironmentName() );
- parent.getEnvironmentWindow().getChangeEvents().add(
- "JEE application server " + serverName
- + " status: " + statusThread.message );
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(),
- this );
- }
- }
- } );
- }
- };
-
- // update
- private ActionListener update = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationServersUpdatePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if some change has not been saved
- if ( getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission
+ || !getEnvironmentWindow().jeeApplicationServersChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // delete the application server object
+ parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServers().remove(
+ server );
+ // add a change event
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "Delete JEE application server " + server.getName() );
+ // update the window
+ update();
+ // update the whole parent window
+ parent.getEnvironmentWindow().update();
+ // close the window
+ ApplicationServerWindow.this.userClose();
+ }
+ } ) );
+ }
+ };
+
+ // copy
+ private ActionListener copy = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ try
+ {
+ // put the application server clone in the copy component
+ KalumetConsoleApplication.getApplication().setCopyComponent( server.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
+
+ // paste
+ private ActionListener paste = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the copy component is correct
+ Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+ if ( copy == null || !( copy instanceof JEEApplicationServer ) )
+ {
+ return;
+ }
+ // update the application server object
+ server = (JEEApplicationServer) copy;
+ serverName = null;
+ // update the whole window
+ parent.getEnvironmentWindow().update();
+ // update the window
+ update();
+ }
+ };
+
+ // status
+ private ActionListener status = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if some change has not yet been saved
+ if ( parent.getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ), parent.getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
// add a message into the log pane and the journal
KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application server " + serverName + " update in progress...",
- parent.getEnvironmentWindow().getEnvironmentName() );
+ "JEE application server " + serverName + " status check in progress...",
+ parent.getEnvironmentWindow().getEnvironmentName() );
parent.getEnvironmentWindow().getChangeEvents().add(
- "JEE application server " + serverName + " update requested." );
- // start the update thread
- final UpdateThread updateThread = new UpdateThread();
- updateThread.start();
+ "JEE application server " + serverName + " status check requested." );
+ // start status thread
+ final StatusThread statusThread = new StatusThread();
+ statusThread.start();
// sync with the client
KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
{
- public void run()
- {
- if ( updateThread.ended )
+ public void run()
{
- if ( updateThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( updateThread.message,
- parent.getEnvironmentWindow().getEnvironmentName() );
- parent.getEnvironmentWindow().getChangeEvents().add( updateThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "JEE application server " + serverName + " updated.",
- parent.getEnvironmentWindow().getEnvironmentName() );
- parent.getEnvironmentWindow().getChangeEvents().add(
- "JEE application server " + serverName + " updated." );
- }
+ if ( statusThread.ended )
+ {
+ if ( statusThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning( statusThread.message,
+ parent.getEnvironmentWindow().getEnvironmentName() );
+ parent.getEnvironmentWindow().getChangeEvents().add( statusThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application server " + serverName + " status: " + statusThread.message,
+ parent.getEnvironmentWindow().getEnvironmentName() );
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "JEE application server " + serverName + " status: " + statusThread.message );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
}
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
} );
- }
- } ) );
- }
- };
+ }
+ };
- // stop
- private ActionListener stop = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // update
+ private ActionListener update = new ActionListener()
{
- // check if the user has the lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationServersControlPermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if some change has been saved
- if ( getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- // add a message into the log pane and the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application server " + serverName + " stop in progress...",
- parent.getEnvironmentWindow().getEnvironmentName() );
- parent.getEnvironmentWindow().getChangeEvents().add(
- "JEE application server " + serverName + " stop requested." );
- // start the stop thread
- final StopThread stopThread = new StopThread();
- stopThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ // check if the user has the lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
{
- public void run()
- {
- if ( stopThread.ended )
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission
+ && !getEnvironmentWindow().jeeApplicationServersUpdatePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if some change has not been saved
+ if ( getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
{
- if ( stopThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( stopThread.message,
- parent.getEnvironmentWindow().getEnvironmentName() );
- parent.getEnvironmentWindow().getChangeEvents().add( stopThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "JEE application server " + serverName + " stopped.",
- parent.getEnvironmentWindow().getEnvironmentName() );
- parent.getEnvironmentWindow().getChangeEvents().add(
- "JEE application server " + serverName + " stopped." );
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
- } );
- }
- } ) );
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ // add a message into the log pane and the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application server " + serverName + " update in progress...",
+ parent.getEnvironmentWindow().getEnvironmentName() );
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "JEE application server " + serverName + " update requested." );
+ // start the update thread
+ final UpdateThread updateThread = new UpdateThread();
+ updateThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( updateThread.ended )
+ {
+ if ( updateThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ updateThread.message, parent.getEnvironmentWindow().getEnvironmentName() );
+ parent.getEnvironmentWindow().getChangeEvents().add( updateThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ "JEE application server " + serverName + " updated.",
+ parent.getEnvironmentWindow().getEnvironmentName() );
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "JEE application server " + serverName + " updated." );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ } ) );
+ }
+ };
- // start
- private ActionListener start = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // stop
+ private ActionListener stop = new ActionListener()
{
- // check if the user has the lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationServersControlPermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if some change has not been saved
- if ( getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- // add a message into the log pane and the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application server " + serverName + " start in progress...",
- parent.getEnvironmentWindow().getEnvironmentName() );
- parent.getEnvironmentWindow().getChangeEvents().add(
- "JEE application server " + serverName + " start requested." );
- // start the start thread
- final StartThread startThread = new StartThread();
- startThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ // check if the user has the lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
{
- public void run()
- {
- if ( startThread.ended )
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission
+ && !getEnvironmentWindow().jeeApplicationServersControlPermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if some change has been saved
+ if ( getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
{
- if ( startThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( startThread.message,
- parent.getEnvironmentWindow().getEnvironmentName() );
- parent.getEnvironmentWindow().getChangeEvents().add( startThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "JEE application server " + serverName + " started.",
- parent.getEnvironmentWindow().getEnvironmentName() );
- parent.getEnvironmentWindow().getChangeEvents().add(
- "JEE application server " + serverName + " started." );
- }
- }
- else
+ public void actionPerformed( ActionEvent event )
+ {
+ // add a message into the log pane and the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application server " + serverName + " stop in progress...",
+ parent.getEnvironmentWindow().getEnvironmentName() );
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "JEE application server " + serverName + " stop requested." );
+ // start the stop thread
+ final StopThread stopThread = new StopThread();
+ stopThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( stopThread.ended )
+ {
+ if ( stopThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ stopThread.message, parent.getEnvironmentWindow().getEnvironmentName() );
+ parent.getEnvironmentWindow().getChangeEvents().add( stopThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ "JEE application server " + serverName + " stopped.",
+ parent.getEnvironmentWindow().getEnvironmentName() );
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "JEE application server " + serverName + " stopped." );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ } ) );
+ }
+ };
+
+ // start
+ private ActionListener start = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission
+ && !getEnvironmentWindow().jeeApplicationServersControlPermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if some change has not been saved
+ if ( getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
{
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
- } );
- }
- } ) );
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ // add a message into the log pane and the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application server " + serverName + " start in progress...",
+ parent.getEnvironmentWindow().getEnvironmentName() );
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "JEE application server " + serverName + " start requested." );
+ // start the start thread
+ final StartThread startThread = new StartThread();
+ startThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( startThread.ended )
+ {
+ if ( startThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ startThread.message, parent.getEnvironmentWindow().getEnvironmentName() );
+ parent.getEnvironmentWindow().getChangeEvents().add( startThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ "JEE application server " + serverName + " started.",
+ parent.getEnvironmentWindow().getEnvironmentName() );
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "JEE application server " + serverName + " started." );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ } ) );
+ }
+ };
- /**
- * Create a new <code>ApplicationServerWindow</code>.
- *
- * @param parent the <code>ApplicationServersPane</code>.
- * @param ApplicationServerName the original JEE application server name.
- */
- public ApplicationServerWindow( ApplicationServersPane parent, String ApplicationServerName )
- {
- super();
-
- // update the parent tab pane
- this.parent = parent;
-
- // update the application server name
- this.serverName = ApplicationServerName;
-
- // update the application server object from the parent environment
- this.server =
- parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer( serverName );
- if ( this.server == null )
+ /**
+ * Create a new <code>ApplicationServerWindow</code>.
+ *
+ * @param parent the <code>ApplicationServersPane</code>.
+ * @param ApplicationServerName the original JEE application server name.
+ */
+ public ApplicationServerWindow( ApplicationServersPane parent, String ApplicationServerName )
{
- this.server = new JEEApplicationServer();
+ super();
+
+ // update the parent tab pane
+ this.parent = parent;
+
+ // update the application server name
+ this.serverName = ApplicationServerName;
+
+ // update the application server object from the parent environment
+ this.server = parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ serverName );
+ if ( this.server == null )
+ {
+ this.server = new JEEApplicationServer();
+ }
+
+ if ( serverName == null )
+ {
+ setTitle( Messages.getString( "applicationserver" ) );
+ }
+ else
+ {
+ setTitle( Messages.getString( "applicationserver" ) + " " + serverName );
+ }
+ setId( "applicationserverwindow_" + parent.getEnvironmentWindow().getEnvironmentName() + "_" + serverName );
+ setStyleName( "default" );
+ setWidth( new Extent( 800, Extent.PX ) );
+ setHeight( new Extent( 600, Extent.PX ) );
+ setIcon( Styles.APPLICATION );
+ setModal( false );
+ setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
+
+ // create a split pane for the control buttons
+ SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
+ add( splitPane );
+
+ // add the control pane
+ Row controlRow = new Row();
+ controlRow.setStyleName( "control" );
+ splitPane.add( controlRow );
+ // add the refresh button
+ Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
+ refreshButton.setStyleName( "control" );
+ refreshButton.addActionListener( refresh );
+ controlRow.add( refreshButton );
+ // add the copy button
+ Button copyButton = new Button( Messages.getString( "copy" ), Styles.PAGE_COPY );
+ copyButton.setStyleName( "control" );
+ copyButton.addActionListener( copy );
+ controlRow.add( copyButton );
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationServersChangePermission )
+ {
+ // add the paste button
+ Button pasteButton = new Button( Messages.getString( "paste" ), Styles.PAGE_PASTE );
+ pasteButton.setStyleName( "control" );
+ pasteButton.addActionListener( paste );
+ controlRow.add( pasteButton );
+ // add the apply button
+ Button applyButton = new Button( Messages.getString( "apply" ), Styles.ACCEPT );
+ applyButton.setStyleName( "control" );
+ applyButton.addActionListener( apply );
+ controlRow.add( applyButton );
+ }
+ // add the status button
+ Button statusButton = new Button( Messages.getString( "status" ), Styles.INFORMATION );
+ statusButton.setStyleName( "control" );
+ statusButton.addActionListener( status );
+ controlRow.add( statusButton );
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationServersControlPermission )
+ {
+ // add the stop button
+ Button stopButton = new Button( Messages.getString( "stop" ), Styles.FLAG_RED );
+ stopButton.setStyleName( "control" );
+ stopButton.addActionListener( stop );
+ controlRow.add( stopButton );
+ // add the start button
+ Button startButton = new Button( Messages.getString( "start" ), Styles.FLAG_GREEN );
+ startButton.setStyleName( "control" );
+ startButton.addActionListener( start );
+ controlRow.add( startButton );
+ }
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationServersUpdatePermission )
+ {
+ // add the update button
+ Button updateButton = new Button( Messages.getString( "update" ), Styles.COG );
+ updateButton.setStyleName( "control" );
+ updateButton.addActionListener( update );
+ controlRow.add( updateButton );
+ }
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationServersChangePermission )
+ {
+ // add the delete button
+ Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
+ deleteButton.setStyleName( "control" );
+ deleteButton.addActionListener( delete );
+ controlRow.add( deleteButton );
+ }
+ // add the close button
+ Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
+ closeButton.setStyleName( "control" );
+ closeButton.addActionListener( close );
+ controlRow.add( closeButton );
+
+ // add tab pane
+ TabPane tabPane = new TabPane();
+ tabPane.setStyleName( "default" );
+ splitPane.add( tabPane );
+
+ // add the jee application server general tab
+ TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "general" ) );
+ generalPane = new ApplicationServerGeneralPane( this );
+ generalPane.setLayoutData( tabLayoutData );
+ tabPane.add( generalPane );
+
+ // add the jee application server caches tab
+ tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "caches" ) );
+ cachesPane = new ApplicationServerCachesPane( this );
+ cachesPane.setLayoutData( tabLayoutData );
+ tabPane.add( cachesPane );
+
+ // update the pane
+ update();
}
- if ( serverName == null )
+ /**
+ * Update the pane.
+ */
+ public void update()
{
- setTitle( Messages.getString( "applicationserver" ) );
+ generalPane.update();
+ cachesPane.update();
}
- else
+
+ public JEEApplicationServer getApplicationServer()
{
- setTitle( Messages.getString( "applicationserver" ) + " " + serverName );
+ return this.server;
}
- setId( "applicationserverwindow_" + parent.getEnvironmentWindow().getEnvironmentName() + "_" + serverName );
- setStyleName( "default" );
- setWidth( new Extent( 800, Extent.PX ) );
- setHeight( new Extent( 600, Extent.PX ) );
- setIcon( Styles.APPLICATION );
- setModal( false );
- setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
- // create a split pane for the control buttons
- SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
- add( splitPane );
-
- // add the control pane
- Row controlRow = new Row();
- controlRow.setStyleName( "control" );
- splitPane.add( controlRow );
- // add the refresh button
- Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
- refreshButton.setStyleName( "control" );
- refreshButton.addActionListener( refresh );
- controlRow.add( refreshButton );
- // add the copy button
- Button copyButton = new Button( Messages.getString( "copy" ), Styles.PAGE_COPY );
- copyButton.setStyleName( "control" );
- copyButton.addActionListener( copy );
- controlRow.add( copyButton );
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationServersChangePermission)
+ public String getApplicationServerName()
{
- // add the paste button
- Button pasteButton = new Button( Messages.getString( "paste" ), Styles.PAGE_PASTE );
- pasteButton.setStyleName( "control" );
- pasteButton.addActionListener( paste );
- controlRow.add( pasteButton );
- // add the apply button
- Button applyButton = new Button( Messages.getString( "apply" ), Styles.ACCEPT );
- applyButton.setStyleName( "control" );
- applyButton.addActionListener( apply );
- controlRow.add( applyButton );
+ return this.serverName;
}
- // add the status button
- Button statusButton = new Button( Messages.getString( "status" ), Styles.INFORMATION );
- statusButton.setStyleName( "control" );
- statusButton.addActionListener( status );
- controlRow.add( statusButton );
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationServersControlPermission)
+
+ public EnvironmentWindow getEnvironmentWindow()
{
- // add the stop button
- Button stopButton = new Button( Messages.getString( "stop" ), Styles.FLAG_RED );
- stopButton.setStyleName( "control" );
- stopButton.addActionListener( stop );
- controlRow.add( stopButton );
- // add the start button
- Button startButton = new Button( Messages.getString( "start" ), Styles.FLAG_GREEN );
- startButton.setStyleName( "control" );
- startButton.addActionListener( start );
- controlRow.add( startButton );
+ return parent.getEnvironmentWindow();
}
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationServersUpdatePermission)
- {
- // add the update button
- Button updateButton = new Button( Messages.getString( "update" ), Styles.COG );
- updateButton.setStyleName( "control" );
- updateButton.addActionListener( update );
- controlRow.add( updateButton );
- }
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationServersChangePermission)
- {
- // add the delete button
- Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
- deleteButton.setStyleName( "control" );
- deleteButton.addActionListener( delete );
- controlRow.add( deleteButton );
- }
- // add the close button
- Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
- closeButton.setStyleName( "control" );
- closeButton.addActionListener( close );
- controlRow.add( closeButton );
-
- // add tab pane
- TabPane tabPane = new TabPane();
- tabPane.setStyleName( "default" );
- splitPane.add( tabPane );
-
- // add the jee application server general tab
- TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "general" ) );
- generalPane = new ApplicationServerGeneralPane( this );
- generalPane.setLayoutData( tabLayoutData );
- tabPane.add( generalPane );
-
- // add the jee application server caches tab
- tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "caches" ) );
- cachesPane = new ApplicationServerCachesPane( this );
- cachesPane.setLayoutData( tabLayoutData );
- tabPane.add( cachesPane );
-
- // update the pane
- update();
- }
-
- /**
- * Update the pane.
- */
- public void update()
- {
- generalPane.update();
- cachesPane.update();
- }
-
- public JEEApplicationServer getApplicationServer()
- {
- return this.server;
- }
-
- public String getApplicationServerName()
- {
- return this.serverName;
- }
-
- public EnvironmentWindow getEnvironmentWindow()
- {
- return parent.getEnvironmentWindow();
- }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationServersPane.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationServersPane.java
index d7145bf..8311640 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationServersPane.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationServersPane.java
@@ -41,886 +41,895 @@
* Environment application servers pane.
*/
public class ApplicationServersPane
- extends ContentPane
+ extends ContentPane
{
- private EnvironmentWindow parent;
+ private EnvironmentWindow parent;
- private SelectField topologyField;
+ private SelectField topologyField;
- private Grid serversGrid;
+ private Grid serversGrid;
- // update thread
- class UpdateThread
- extends Thread
- {
-
- public String serverName;
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // update thread
+ class UpdateThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
- if ( agent == null )
+
+ public String serverName;
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
- }
- // call the WebService
- JEEApplicationServerClient client = new JEEApplicationServerClient( agent.getHostname(), agent.getPort() );
- client.update( parent.getEnvironmentName(), serverName, false );
- }
- catch ( Exception e )
- {
- message = "JEE application server " + serverName + " update failed: " + e.getMessage();
- failure = true;
- }
- finally
- {
- ended = true;
- }
- }
-
- }
-
- // stop thread
- class StopThread
- extends Thread
- {
-
- public String serverName;
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
- {
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
- if ( agent == null )
- {
- throw new IllegalArgumentException( "agent not found." );
- }
- // call the WebService
- JEEApplicationServerClient client = new JEEApplicationServerClient( agent.getHostname(), agent.getPort() );
- client.stop( parent.getEnvironmentName(), serverName );
- }
- catch ( Exception e )
- {
- message = "JEE application server " + serverName + " stop failed: " + e.getMessage();
- failure = true;
- }
- finally
- {
- ended = true;
- }
- }
-
- }
-
- // start thread
- class StartThread
- extends Thread
- {
-
- public String serverName;
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
- {
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agnet
- Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
- if ( agent == null )
- {
- throw new IllegalArgumentException( "agent not found." );
- }
- // call the WebService
- JEEApplicationServerClient client = new JEEApplicationServerClient( agent.getHostname(), agent.getPort() );
- client.start( parent.getEnvironmentName(), serverName );
- }
- catch ( Exception e )
- {
- message = "JEE application server " + serverName + " start failed: " + e.getMessage();
- failure = true;
- }
- finally
- {
- ended = true;
- }
- }
-
- }
-
- // status thread
- class StatusThread
- extends Thread
- {
-
- public String serverName;
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
- {
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
- if ( agent == null )
- {
- throw new IllegalArgumentException( "agent not found." );
- }
- // call the WebService
- JEEApplicationServerClient client = new JEEApplicationServerClient( agent.getHostname(), agent.getPort() );
- message = client.status( parent.getEnvironmentName(), serverName );
- }
- catch ( Exception e )
- {
- message = "JEE application server " + serverName + " status failed: " + e.getMessage();
- failure = true;
- }
- finally
- {
- ended = true;
- }
- }
- }
-
- // update
- private ActionListener update = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // get JEE application server name
- final String serverName = event.getActionCommand();
- // check if the user has the environment lock
- if ( !parent.getEnvironment().getLock().equals( KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.adminPermission && !parent.jeeApplicationServersUpdatePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getEnvironmentName() );
- return;
- }
- // check if no modification has been performed
- if ( parent.isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ), parent.getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // put message in the log pane and in the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application server " + serverName + " update in progress...", parent.getEnvironmentName() );
- parent.getChangeEvents().add( "JEE application server " + serverName + " update requested." );
- // launch async task
- final UpdateThread updateThread = new UpdateThread();
- updateThread.serverName = serverName;
- updateThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ try
{
- public void run()
- {
- if ( updateThread.ended )
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
+ if ( agent == null )
{
- if ( updateThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( updateThread.message,
- parent.getEnvironmentName() );
- parent.getChangeEvents().add( updateThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "JEE application server " + serverName + " updated.", parent.getEnvironmentName() );
- parent.getChangeEvents().add( "JEE application server " + serverName + " updated." );
- }
+ throw new IllegalArgumentException( "agent not found." );
}
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
- } );
- }
- } ) );
- }
- };
-
- // start
- private ActionListener start = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // get JEE application server name
- final String serverName = event.getActionCommand();
- // check if the user has the environment lock
- if ( !parent.getEnvironment().getLock().equals( KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.adminPermission && !parent.jeeApplicationServersControlPermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getEnvironmentName() );
- return;
- }
- // check if no modification has been performed
- if ( parent.isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ), parent.getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // put message in the log pane and the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application server " + serverName + " start in progress...", parent.getEnvironmentName() );
- parent.getChangeEvents().add( "JEE application server " + serverName + " start requested." );
- // launch async task
- final StartThread startThread = new StartThread();
- startThread.serverName = serverName;
- startThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ // call the WebService
+ JEEApplicationServerClient client =
+ new JEEApplicationServerClient( agent.getHostname(), agent.getPort() );
+ client.update( parent.getEnvironmentName(), serverName, false );
+ }
+ catch ( Exception e )
{
- public void run()
- {
- if ( startThread.ended )
- {
- if ( startThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( startThread.message,
- parent.getEnvironmentName() );
- parent.getChangeEvents().add( startThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "JEE application server " + serverName + " started.", parent.getEnvironmentName() );
- parent.getChangeEvents().add( "JEE application server " + serverName + " started." );
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
- } );
- }
- } ) );
- }
- };
-
- // stop
- private ActionListener stop = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // get JEE application server name
- final String serverName = event.getActionCommand();
- // check if the user has the environment lock
- if ( !parent.getEnvironment().getLock().equals( KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.adminPermission && !parent.jeeApplicationServersControlPermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getEnvironmentName() );
- return;
- }
- // check if no modification has been performed
- if ( parent.isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ), parent.getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // put a message in the log pane and in the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application server " + serverName + " stop in progress...", parent.getEnvironmentName() );
- parent.getChangeEvents().add( "JEE application server " + serverName + " stop requested." );
- // launch async task
- final StopThread stopThread = new StopThread();
- stopThread.serverName = serverName;
- stopThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ message = "JEE application server " + serverName + " update failed: " + e.getMessage();
+ failure = true;
+ }
+ finally
{
- public void run()
- {
- if ( stopThread.ended )
- {
- if ( stopThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( stopThread.message,
- parent.getEnvironmentName() );
- parent.getChangeEvents().add( stopThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "JEE application server " + serverName + " stopped.", parent.getEnvironmentName() );
- parent.getChangeEvents().add( "JEE application server " + serverName + " stopped." );
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
- } );
- }
- } ) );
- }
- };
+ ended = true;
+ }
+ }
- // status
- private ActionListener status = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if some change has not yet been saved
- if ( parent.isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ), parent.getEnvironmentName() );
- return;
- }
- // get JEE application server name
- final String serverName = event.getActionCommand();
- // put a message in the log pane and in the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application server " + serverName + " status check in progress...", parent.getEnvironmentName() );
- parent.getChangeEvents().add( "JEE application server " + serverName + " status check." );
- // launch async task
- final StatusThread statusThread = new StatusThread();
- statusThread.serverName = serverName;
- statusThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask( KalumetConsoleApplication.getApplication().getTaskQueue(),
- new Runnable()
- {
- public void run()
- {
- if ( statusThread.ended )
- {
- if ( statusThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- statusThread.message,
- parent.getEnvironmentName() );
- parent.getChangeEvents().add(
- statusThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE server " + serverName + " status: "
- + statusThread.message,
- parent.getEnvironmentName() );
- parent.getChangeEvents().add(
- "JEE server " + serverName + " status: "
- + statusThread.message );
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(),
- this );
- }
- }
- } );
}
- };
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // stop thread
+ class StopThread
+ extends Thread
{
- // check if the user has the environment lock
- if ( !parent.getEnvironment().getLock().equals( KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.adminPermission && !parent.jeeApplicationServersChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getEnvironmentName() );
- return;
- }
- // looking for the application server object
- final JEEApplicationServer applicationServer =
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer( event.getActionCommand() );
- if ( applicationServer == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "applicationserver.notfound" ), parent.getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+
+ public String serverName;
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- public void actionPerformed( ActionEvent event )
- {
- // delete the application server
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServers().remove( applicationServer );
- // add change event
- parent.getChangeEvents().add( "Delete JEE application server " + applicationServer.getName() );
- // change the updated flag
- parent.setUpdated( true );
- // update the whole window
- parent.update();
- }
- } ) );
- }
- };
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the WebService
+ JEEApplicationServerClient client =
+ new JEEApplicationServerClient( agent.getHostname(), agent.getPort() );
+ client.stop( parent.getEnvironmentName(), serverName );
+ }
+ catch ( Exception e )
+ {
+ message = "JEE application server " + serverName + " stop failed: " + e.getMessage();
+ failure = true;
+ }
+ finally
+ {
+ ended = true;
+ }
+ }
- // edit
- private ActionListener edit = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ }
+
+ // start thread
+ class StartThread
+ extends Thread
{
- if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
- "applicationserverwindow_" + parent.getEnvironmentName() + "_" + event.getActionCommand() ) == null )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ApplicationServerWindow( ApplicationServersPane.this, event.getActionCommand() ) );
- }
- }
- };
- // create
- private ActionListener create = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ public String serverName;
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
+ {
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agnet
+ Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the WebService
+ JEEApplicationServerClient client =
+ new JEEApplicationServerClient( agent.getHostname(), agent.getPort() );
+ client.start( parent.getEnvironmentName(), serverName );
+ }
+ catch ( Exception e )
+ {
+ message = "JEE application server " + serverName + " start failed: " + e.getMessage();
+ failure = true;
+ }
+ finally
+ {
+ ended = true;
+ }
+ }
+
+ }
+
+ // status thread
+ class StatusThread
+ extends Thread
{
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ApplicationServerWindow( ApplicationServersPane.this, null ) );
+
+ public String serverName;
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
+ {
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the WebService
+ JEEApplicationServerClient client =
+ new JEEApplicationServerClient( agent.getHostname(), agent.getPort() );
+ message = client.status( parent.getEnvironmentName(), serverName );
+ }
+ catch ( Exception e )
+ {
+ message = "JEE application server " + serverName + " status failed: " + e.getMessage();
+ failure = true;
+ }
+ finally
+ {
+ ended = true;
+ }
+ }
}
- };
-
- // copy
- private ActionListener copy = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // looking for the application server object
- JEEApplicationServer applicationServer =
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer( event.getActionCommand() );
- if ( applicationServer == null )
- {
- return;
- }
- try
- {
- // put the application server clone in the copy component
- KalumetConsoleApplication.getApplication().setCopyComponent( applicationServer.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
-
- // toggle active
- private ActionListener toggleActive = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getEnvironment().getLock().equals( KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.adminPermission && !parent.jeeApplicationServersChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getEnvironmentName() );
- return;
- }
- // looking for the application server object
- JEEApplicationServer server =
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer( event.getActionCommand() );
- if ( server == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "applicationserver.notfound" ), parent.getEnvironmentName() );
- return;
- }
- // change the current server state
- if ( server.isActive() )
- {
- server.setActive( false );
- parent.getChangeEvents().add( "Disable JEE application server " + server.getName() );
- }
- else
- {
- server.setActive( true );
- parent.getChangeEvents().add( "Enable JEE application server " + server.getName() );
- }
- // change the update flag
- parent.setUpdated( true );
- // update the journal tab pane
- parent.updateJournalPane();
- // update the pane
- update();
- }
- };
-
- // toggle blocker
- private ActionListener toggleBlocker = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !parent.getEnvironment().getLock().equals( KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- parent.getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !parent.adminPermission && !parent.jeeApplicationServersChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- parent.getEnvironmentName() );
- return;
- }
- // looking for the application server object
- JEEApplicationServer server =
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer( event.getActionCommand() );
- if ( server == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "applicationserver.notfound" ), parent.getEnvironmentName() );
- return;
- }
- // change the current blocker state
- if ( server.isBlocker() )
- {
- server.setBlocker( false );
- }
- else
- {
- server.setBlocker( true );
- }
- // change the update flag
- parent.setUpdated( true );
- // update the journal tab pane
- parent.updateJournalPane();
- // update the pane
- update();
- }
- };
-
- /**
- * Create a new <code>ApplicationServersPane</code>.
- *
- * @param parent the parent <code>EnvironmentWindow</code>.
- */
- public ApplicationServersPane( EnvironmentWindow parent )
- {
- super();
- setStyleName( "tab.content" );
-
- // update parent
- this.parent = parent;
-
- Column content = new Column();
- content.setCellSpacing( new Extent( 2 ) );
- add( content );
-
- // general grid layout
- Grid grid = new Grid( 2 );
- grid.setStyleName( "default" );
- grid.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
- grid.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
- content.add( grid );
-
- // add application servers topology
- Label topologyLabel = new Label( Messages.getString( "topology" ) );
- topologyLabel.setStyleName( "default" );
- grid.add( topologyLabel );
- Object[] labels = new Object[]{ Messages.getString( "standalone" ), Messages.getString( "cluster" ) };
- topologyField = new SelectField( labels );
- topologyField.setStyleName( "default" );
- grid.add( topologyField );
-
- // add the create application server button
- if ( parent.adminPermission || parent.jeeApplicationServersChangePermission)
- {
- Button createButton = new Button( Messages.getString( "applicationserver.add" ), Styles.ADD );
- createButton.addActionListener( create );
- content.add( createButton );
- }
-
- // add the JEE application servers grid
- serversGrid = new Grid( 5 );
- serversGrid.setStyleName( "border.grid" );
- serversGrid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
- serversGrid.setColumnWidth( 1, new Extent( 25, Extent.PERCENT ) );
- serversGrid.setColumnWidth( 2, new Extent( 30, Extent.PERCENT ) );
- serversGrid.setColumnWidth( 3, new Extent( 30, Extent.PERCENT ) );
- serversGrid.setColumnWidth( 4, new Extent( 15, Extent.PERCENT ) );
- content.add( serversGrid );
// update
- update();
- }
-
- /**
- * Update the pane
- */
- public void update()
- {
- // update the topology select field
- if ( parent.getEnvironment().getJEEApplicationServers().isCluster() )
+ private ActionListener update = new ActionListener()
{
- topologyField.setSelectedIndex( 1 );
- }
- else
- {
- topologyField.setSelectedIndex( 0 );
- }
- // update the JEE application servers grid
- // remove all grid children
- serversGrid.removeAll();
- // add header
- Label serverActionsHeader = new Label( " " );
- serverActionsHeader.setStyleName( "grid.header" );
- serversGrid.add( serverActionsHeader );
- Label serverNameHeader = new Label( Messages.getString( "name" ) );
- serverNameHeader.setStyleName( "grid.header" );
- serversGrid.add( serverNameHeader );
- Label serverTypeHeader = new Label( Messages.getString( "type" ) );
- serverTypeHeader.setStyleName( "grid.header" );
- serversGrid.add( serverTypeHeader );
- Label serverUrlHeader = new Label( Messages.getString( "jmx" ) );
- serverUrlHeader.setStyleName( "grid.header" );
- serversGrid.add( serverUrlHeader );
- Label serverAgentHeader = new Label( Messages.getString( "agent" ) );
- serverAgentHeader.setStyleName( "grid.header" );
- serversGrid.add( serverAgentHeader );
- // add application servers
- for ( Iterator serverIterator =
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServers().iterator();
- serverIterator.hasNext(); )
- {
- JEEApplicationServer server = (JEEApplicationServer) serverIterator.next();
- // application server name and actions
- Row row = new Row();
- row.setInsets( new Insets( 2 ) );
- row.setCellSpacing( new Extent( 2 ) );
- serversGrid.add( row );
- // copy button
- Button copyButton = new Button( Styles.PAGE_COPY );
- copyButton.setToolTipText( Messages.getString( "copy" ) );
- copyButton.setActionCommand( server.getName() );
- copyButton.addActionListener( copy );
- row.add( copyButton );
- // active button
- Button activeButton;
- if ( server.isActive() )
- {
- activeButton = new Button( Styles.LIGHTBULB );
- activeButton.setToolTipText( Messages.getString( "switch.disable" ) );
- }
- else
- {
- activeButton = new Button( Styles.LIGHTBULB_OFF );
- activeButton.setToolTipText( Messages.getString( "switch.enable" ) );
- }
- if ( parent.adminPermission || parent.jeeApplicationServersChangePermission)
- {
- activeButton.setActionCommand( server.getName() );
- activeButton.addActionListener( toggleActive );
- }
- row.add( activeButton );
- // blocker button
- Button blockerButton;
- if ( server.isBlocker() )
- {
- blockerButton = new Button( Styles.PLUGIN );
- blockerButton.setToolTipText( Messages.getString( "switch.notblocker" ) );
- }
- else
- {
- blockerButton = new Button( Styles.PLUGIN_DISABLED );
- blockerButton.setToolTipText( Messages.getString( "switch.blocker" ) );
- }
- if ( parent.adminPermission || parent.jeeApplicationServersChangePermission)
- {
- blockerButton.setActionCommand( server.getName() );
- blockerButton.addActionListener( toggleBlocker );
- }
- row.add( blockerButton );
- // status button
- Button statusButton = new Button( Styles.INFORMATION );
- statusButton.setToolTipText( Messages.getString( "status" ) );
- statusButton.setActionCommand( server.getName() );
- statusButton.addActionListener( status );
- row.add( statusButton );
- if ( parent.adminPermission || parent.jeeApplicationServersControlPermission)
- {
- // stop button
- Button stopButton = new Button( Styles.FLAG_RED );
- stopButton.setToolTipText( Messages.getString( "stop" ) );
- stopButton.setActionCommand( server.getName() );
- stopButton.addActionListener( stop );
- row.add( stopButton );
- // start button
- Button startButton = new Button( Styles.FLAG_GREEN );
- startButton.setToolTipText( Messages.getString( "start" ) );
- startButton.setActionCommand( server.getName() );
- startButton.addActionListener( start );
- row.add( startButton );
- }
- if ( parent.adminPermission || parent.jeeApplicationServersUpdatePermission)
- {
- // update button
- Button updateButton = new Button( Styles.COG );
- updateButton.setToolTipText( Messages.getString( "update" ) );
- updateButton.setActionCommand( server.getName() );
- updateButton.addActionListener( update );
- row.add( updateButton );
- }
- // delete button
- if ( parent.adminPermission || parent.jeeApplicationServersChangePermission)
- {
- Button deleteButton = new Button( Styles.DELETE );
- deleteButton.setToolTipText( Messages.getString( "delete" ) );
- deleteButton.setActionCommand( server.getName() );
- deleteButton.addActionListener( delete );
- row.add( deleteButton );
- }
- // server name
- Button serverName = new Button( server.getName() );
- serverName.setStyleName( "default" );
- serverName.setActionCommand( server.getName() );
- serverName.addActionListener( edit );
- serversGrid.add( serverName );
- // server type
- Label serverType = new Label( Messages.getString( "unknown" ) );
- if ( server.getClassname().equals( ApplicationServerWindow.JBOSS4_CONTROLLER_CLASSNAME ) )
- {
- serverType = new Label( Messages.getString( "jboss4" ) );
- }
- if ( server.getClassname().equals( ApplicationServerWindow.JBOSS6_CONTROLLER_CLASSNAME ) )
- {
- serverType = new Label( Messages.getString( "jboss6" ) );
- }
- if ( server.getClassname().equals( ApplicationServerWindow.WEBLOGIC_CONTROLLER_CLASSNAME ) )
- {
- serverType = new Label( Messages.getString( "weblogic8" ) );
- }
- if ( server.getClassname().equals( ApplicationServerWindow.WEBSPHERE_CONTROLLER_CLASSNAME ) )
- {
- serverType = new Label( Messages.getString( "websphere5" ) );
- }
- serverType.setStyleName( "default" );
- serversGrid.add( serverType );
- // server JMX URL
- Label serverNetwork = new Label( server.getJmxurl() );
- serverNetwork.setStyleName( "default" );
- serversGrid.add( serverNetwork );
- // server agent
- Label serverAgent = new Label( server.getAgent() );
- serverAgent.setStyleName( "default" );
- serversGrid.add( serverAgent );
- }
- }
+ public void actionPerformed( ActionEvent event )
+ {
+ // get JEE application server name
+ final String serverName = event.getActionCommand();
+ // check if the user has the environment lock
+ if ( !parent.getEnvironment().getLock().equals( KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), parent.getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.adminPermission && !parent.jeeApplicationServersUpdatePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), parent.getEnvironmentName() );
+ return;
+ }
+ // check if no modification has been performed
+ if ( parent.isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ), parent.getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // put message in the log pane and in the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application server " + serverName + " update in progress...",
+ parent.getEnvironmentName() );
+ parent.getChangeEvents().add( "JEE application server " + serverName + " update requested." );
+ // launch async task
+ final UpdateThread updateThread = new UpdateThread();
+ updateThread.serverName = serverName;
+ updateThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( updateThread.ended )
+ {
+ if ( updateThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ updateThread.message, parent.getEnvironmentName() );
+ parent.getChangeEvents().add( updateThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ "JEE application server " + serverName + " updated.",
+ parent.getEnvironmentName() );
+ parent.getChangeEvents().add(
+ "JEE application server " + serverName + " updated." );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ } ) );
+ }
+ };
- /**
- * Get the parent <code>EnvironmentWindow</code>
- *
- * @return the parent <code>EnvironmentWindow</code>
- */
- public EnvironmentWindow getEnvironmentWindow()
- {
- return parent;
- }
+ // start
+ private ActionListener start = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // get JEE application server name
+ final String serverName = event.getActionCommand();
+ // check if the user has the environment lock
+ if ( !parent.getEnvironment().getLock().equals( KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), parent.getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.adminPermission && !parent.jeeApplicationServersControlPermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), parent.getEnvironmentName() );
+ return;
+ }
+ // check if no modification has been performed
+ if ( parent.isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ), parent.getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // put message in the log pane and the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application server " + serverName + " start in progress...",
+ parent.getEnvironmentName() );
+ parent.getChangeEvents().add( "JEE application server " + serverName + " start requested." );
+ // launch async task
+ final StartThread startThread = new StartThread();
+ startThread.serverName = serverName;
+ startThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( startThread.ended )
+ {
+ if ( startThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ startThread.message, parent.getEnvironmentName() );
+ parent.getChangeEvents().add( startThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ "JEE application server " + serverName + " started.",
+ parent.getEnvironmentName() );
+ parent.getChangeEvents().add(
+ "JEE application server " + serverName + " started." );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ } ) );
+ }
+ };
- public SelectField getTopologyField()
- {
- return this.topologyField;
- }
+ // stop
+ private ActionListener stop = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // get JEE application server name
+ final String serverName = event.getActionCommand();
+ // check if the user has the environment lock
+ if ( !parent.getEnvironment().getLock().equals( KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), parent.getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.adminPermission && !parent.jeeApplicationServersControlPermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), parent.getEnvironmentName() );
+ return;
+ }
+ // check if no modification has been performed
+ if ( parent.isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ), parent.getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // put a message in the log pane and in the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application server " + serverName + " stop in progress...",
+ parent.getEnvironmentName() );
+ parent.getChangeEvents().add( "JEE application server " + serverName + " stop requested." );
+ // launch async task
+ final StopThread stopThread = new StopThread();
+ stopThread.serverName = serverName;
+ stopThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( stopThread.ended )
+ {
+ if ( stopThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ stopThread.message, parent.getEnvironmentName() );
+ parent.getChangeEvents().add( stopThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ "JEE application server " + serverName + " stopped.",
+ parent.getEnvironmentName() );
+ parent.getChangeEvents().add(
+ "JEE application server " + serverName + " stopped." );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ } ) );
+ }
+ };
+
+ // status
+ private ActionListener status = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if some change has not yet been saved
+ if ( parent.isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ), parent.getEnvironmentName() );
+ return;
+ }
+ // get JEE application server name
+ final String serverName = event.getActionCommand();
+ // put a message in the log pane and in the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application server " + serverName + " status check in progress...", parent.getEnvironmentName() );
+ parent.getChangeEvents().add( "JEE application server " + serverName + " status check." );
+ // launch async task
+ final StatusThread statusThread = new StatusThread();
+ statusThread.serverName = serverName;
+ statusThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( statusThread.ended )
+ {
+ if ( statusThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning( statusThread.message,
+ parent.getEnvironmentName() );
+ parent.getChangeEvents().add( statusThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE server " + serverName + " status: " + statusThread.message,
+ parent.getEnvironmentName() );
+ parent.getChangeEvents().add(
+ "JEE server " + serverName + " status: " + statusThread.message );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ };
+
+ // delete
+ private ActionListener delete = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getEnvironment().getLock().equals( KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), parent.getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.adminPermission && !parent.jeeApplicationServersChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), parent.getEnvironmentName() );
+ return;
+ }
+ // looking for the application server object
+ final JEEApplicationServer applicationServer =
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer( event.getActionCommand() );
+ if ( applicationServer == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "applicationserver.notfound" ), parent.getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // delete the application server
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServers().remove(
+ applicationServer );
+ // add change event
+ parent.getChangeEvents().add( "Delete JEE application server " + applicationServer.getName() );
+ // change the updated flag
+ parent.setUpdated( true );
+ // update the whole window
+ parent.update();
+ }
+ } ) );
+ }
+ };
+
+ // edit
+ private ActionListener edit = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
+ "applicationserverwindow_" + parent.getEnvironmentName() + "_" + event.getActionCommand() ) == null )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ApplicationServerWindow( ApplicationServersPane.this, event.getActionCommand() ) );
+ }
+ }
+ };
+
+ // create
+ private ActionListener create = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ApplicationServerWindow( ApplicationServersPane.this, null ) );
+ }
+ };
+
+ // copy
+ private ActionListener copy = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // looking for the application server object
+ JEEApplicationServer applicationServer =
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer( event.getActionCommand() );
+ if ( applicationServer == null )
+ {
+ return;
+ }
+ try
+ {
+ // put the application server clone in the copy component
+ KalumetConsoleApplication.getApplication().setCopyComponent( applicationServer.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
+
+ // toggle active
+ private ActionListener toggleActive = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getEnvironment().getLock().equals( KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), parent.getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.adminPermission && !parent.jeeApplicationServersChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), parent.getEnvironmentName() );
+ return;
+ }
+ // looking for the application server object
+ JEEApplicationServer server =
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer( event.getActionCommand() );
+ if ( server == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "applicationserver.notfound" ), parent.getEnvironmentName() );
+ return;
+ }
+ // change the current server state
+ if ( server.isActive() )
+ {
+ server.setActive( false );
+ parent.getChangeEvents().add( "Disable JEE application server " + server.getName() );
+ }
+ else
+ {
+ server.setActive( true );
+ parent.getChangeEvents().add( "Enable JEE application server " + server.getName() );
+ }
+ // change the update flag
+ parent.setUpdated( true );
+ // update the journal tab pane
+ parent.updateJournalPane();
+ // update the pane
+ update();
+ }
+ };
+
+ // toggle blocker
+ private ActionListener toggleBlocker = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !parent.getEnvironment().getLock().equals( KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), parent.getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !parent.adminPermission && !parent.jeeApplicationServersChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), parent.getEnvironmentName() );
+ return;
+ }
+ // looking for the application server object
+ JEEApplicationServer server =
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer( event.getActionCommand() );
+ if ( server == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "applicationserver.notfound" ), parent.getEnvironmentName() );
+ return;
+ }
+ // change the current blocker state
+ if ( server.isBlocker() )
+ {
+ server.setBlocker( false );
+ }
+ else
+ {
+ server.setBlocker( true );
+ }
+ // change the update flag
+ parent.setUpdated( true );
+ // update the journal tab pane
+ parent.updateJournalPane();
+ // update the pane
+ update();
+ }
+ };
+
+ /**
+ * Create a new <code>ApplicationServersPane</code>.
+ *
+ * @param parent the parent <code>EnvironmentWindow</code>.
+ */
+ public ApplicationServersPane( EnvironmentWindow parent )
+ {
+ super();
+ setStyleName( "tab.content" );
+
+ // update parent
+ this.parent = parent;
+
+ Column content = new Column();
+ content.setCellSpacing( new Extent( 2 ) );
+ add( content );
+
+ // general grid layout
+ Grid grid = new Grid( 2 );
+ grid.setStyleName( "default" );
+ grid.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
+ grid.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
+ content.add( grid );
+
+ // add application servers topology
+ Label topologyLabel = new Label( Messages.getString( "topology" ) );
+ topologyLabel.setStyleName( "default" );
+ grid.add( topologyLabel );
+ Object[] labels = new Object[]{ Messages.getString( "standalone" ), Messages.getString( "cluster" ) };
+ topologyField = new SelectField( labels );
+ topologyField.setStyleName( "default" );
+ grid.add( topologyField );
+
+ // add the create application server button
+ if ( parent.adminPermission || parent.jeeApplicationServersChangePermission )
+ {
+ Button createButton = new Button( Messages.getString( "applicationserver.add" ), Styles.ADD );
+ createButton.addActionListener( create );
+ content.add( createButton );
+ }
+
+ // add the JEE application servers grid
+ serversGrid = new Grid( 5 );
+ serversGrid.setStyleName( "border.grid" );
+ serversGrid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
+ serversGrid.setColumnWidth( 1, new Extent( 25, Extent.PERCENT ) );
+ serversGrid.setColumnWidth( 2, new Extent( 30, Extent.PERCENT ) );
+ serversGrid.setColumnWidth( 3, new Extent( 30, Extent.PERCENT ) );
+ serversGrid.setColumnWidth( 4, new Extent( 15, Extent.PERCENT ) );
+ content.add( serversGrid );
+
+ // update
+ update();
+ }
+
+ /**
+ * Update the pane
+ */
+ public void update()
+ {
+ // update the topology select field
+ if ( parent.getEnvironment().getJEEApplicationServers().isCluster() )
+ {
+ topologyField.setSelectedIndex( 1 );
+ }
+ else
+ {
+ topologyField.setSelectedIndex( 0 );
+ }
+ // update the JEE application servers grid
+ // remove all grid children
+ serversGrid.removeAll();
+ // add header
+ Label serverActionsHeader = new Label( " " );
+ serverActionsHeader.setStyleName( "grid.header" );
+ serversGrid.add( serverActionsHeader );
+ Label serverNameHeader = new Label( Messages.getString( "name" ) );
+ serverNameHeader.setStyleName( "grid.header" );
+ serversGrid.add( serverNameHeader );
+ Label serverTypeHeader = new Label( Messages.getString( "type" ) );
+ serverTypeHeader.setStyleName( "grid.header" );
+ serversGrid.add( serverTypeHeader );
+ Label serverUrlHeader = new Label( Messages.getString( "jmx" ) );
+ serverUrlHeader.setStyleName( "grid.header" );
+ serversGrid.add( serverUrlHeader );
+ Label serverAgentHeader = new Label( Messages.getString( "agent" ) );
+ serverAgentHeader.setStyleName( "grid.header" );
+ serversGrid.add( serverAgentHeader );
+ // add application servers
+ for ( Iterator serverIterator =
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServers().iterator();
+ serverIterator.hasNext(); )
+ {
+ JEEApplicationServer server = (JEEApplicationServer) serverIterator.next();
+ // application server name and actions
+ Row row = new Row();
+ row.setInsets( new Insets( 2 ) );
+ row.setCellSpacing( new Extent( 2 ) );
+ serversGrid.add( row );
+ // copy button
+ Button copyButton = new Button( Styles.PAGE_COPY );
+ copyButton.setToolTipText( Messages.getString( "copy" ) );
+ copyButton.setActionCommand( server.getName() );
+ copyButton.addActionListener( copy );
+ row.add( copyButton );
+ // active button
+ Button activeButton;
+ if ( server.isActive() )
+ {
+ activeButton = new Button( Styles.LIGHTBULB );
+ activeButton.setToolTipText( Messages.getString( "switch.disable" ) );
+ }
+ else
+ {
+ activeButton = new Button( Styles.LIGHTBULB_OFF );
+ activeButton.setToolTipText( Messages.getString( "switch.enable" ) );
+ }
+ if ( parent.adminPermission || parent.jeeApplicationServersChangePermission )
+ {
+ activeButton.setActionCommand( server.getName() );
+ activeButton.addActionListener( toggleActive );
+ }
+ row.add( activeButton );
+ // blocker button
+ Button blockerButton;
+ if ( server.isBlocker() )
+ {
+ blockerButton = new Button( Styles.PLUGIN );
+ blockerButton.setToolTipText( Messages.getString( "switch.notblocker" ) );
+ }
+ else
+ {
+ blockerButton = new Button( Styles.PLUGIN_DISABLED );
+ blockerButton.setToolTipText( Messages.getString( "switch.blocker" ) );
+ }
+ if ( parent.adminPermission || parent.jeeApplicationServersChangePermission )
+ {
+ blockerButton.setActionCommand( server.getName() );
+ blockerButton.addActionListener( toggleBlocker );
+ }
+ row.add( blockerButton );
+ // status button
+ Button statusButton = new Button( Styles.INFORMATION );
+ statusButton.setToolTipText( Messages.getString( "status" ) );
+ statusButton.setActionCommand( server.getName() );
+ statusButton.addActionListener( status );
+ row.add( statusButton );
+ if ( parent.adminPermission || parent.jeeApplicationServersControlPermission )
+ {
+ // stop button
+ Button stopButton = new Button( Styles.FLAG_RED );
+ stopButton.setToolTipText( Messages.getString( "stop" ) );
+ stopButton.setActionCommand( server.getName() );
+ stopButton.addActionListener( stop );
+ row.add( stopButton );
+ // start button
+ Button startButton = new Button( Styles.FLAG_GREEN );
+ startButton.setToolTipText( Messages.getString( "start" ) );
+ startButton.setActionCommand( server.getName() );
+ startButton.addActionListener( start );
+ row.add( startButton );
+ }
+ if ( parent.adminPermission || parent.jeeApplicationServersUpdatePermission )
+ {
+ // update button
+ Button updateButton = new Button( Styles.COG );
+ updateButton.setToolTipText( Messages.getString( "update" ) );
+ updateButton.setActionCommand( server.getName() );
+ updateButton.addActionListener( update );
+ row.add( updateButton );
+ }
+ // delete button
+ if ( parent.adminPermission || parent.jeeApplicationServersChangePermission )
+ {
+ Button deleteButton = new Button( Styles.DELETE );
+ deleteButton.setToolTipText( Messages.getString( "delete" ) );
+ deleteButton.setActionCommand( server.getName() );
+ deleteButton.addActionListener( delete );
+ row.add( deleteButton );
+ }
+ // server name
+ Button serverName = new Button( server.getName() );
+ serverName.setStyleName( "default" );
+ serverName.setActionCommand( server.getName() );
+ serverName.addActionListener( edit );
+ serversGrid.add( serverName );
+ // server type
+ Label serverType = new Label( Messages.getString( "unknown" ) );
+ if ( server.getClassname().equals( ApplicationServerWindow.JBOSS4_CONTROLLER_CLASSNAME ) )
+ {
+ serverType = new Label( Messages.getString( "jboss4" ) );
+ }
+ if ( server.getClassname().equals( ApplicationServerWindow.JBOSS6_CONTROLLER_CLASSNAME ) )
+ {
+ serverType = new Label( Messages.getString( "jboss6" ) );
+ }
+ if ( server.getClassname().equals( ApplicationServerWindow.WEBLOGIC_CONTROLLER_CLASSNAME ) )
+ {
+ serverType = new Label( Messages.getString( "weblogic8" ) );
+ }
+ if ( server.getClassname().equals( ApplicationServerWindow.WEBSPHERE_CONTROLLER_CLASSNAME ) )
+ {
+ serverType = new Label( Messages.getString( "websphere5" ) );
+ }
+ serverType.setStyleName( "default" );
+ serversGrid.add( serverType );
+ // server JMX URL
+ Label serverNetwork = new Label( server.getJmxurl() );
+ serverNetwork.setStyleName( "default" );
+ serversGrid.add( serverNetwork );
+ // server agent
+ Label serverAgent = new Label( server.getAgent() );
+ serverAgent.setStyleName( "default" );
+ serversGrid.add( serverAgent );
+ }
+ }
+
+ /**
+ * Get the parent <code>EnvironmentWindow</code>
+ *
+ * @return the parent <code>EnvironmentWindow</code>
+ */
+ public EnvironmentWindow getEnvironmentWindow()
+ {
+ return parent;
+ }
+
+ public SelectField getTopologyField()
+ {
+ return this.topologyField;
+ }
}
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationWindow.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationWindow.java
index a4097d6..1ba44dd 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationWindow.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationWindow.java
@@ -37,524 +37,527 @@
* JEE application window.
*/
public class ApplicationWindow
- extends WindowPane
+ extends WindowPane
{
- private String applicationName;
+ private String applicationName;
- private String serverName;
+ private String serverName;
- private JEEApplication application = null;
+ private JEEApplication application = null;
- private ApplicationsPane parent;
+ private ApplicationsPane parent;
- private ApplicationGeneralPane generalPane;
+ private ApplicationGeneralPane generalPane;
- private ApplicationArchivesPane archivesPane;
+ private ApplicationArchivesPane archivesPane;
- private ApplicationContentManagersPane contentManagersPane;
+ private ApplicationContentManagersPane contentManagersPane;
- private ApplicationConfigurationFilesPane configurationFilesPane;
+ private ApplicationConfigurationFilesPane configurationFilesPane;
- private ApplicationDatabasesPane databasesPane;
+ private ApplicationDatabasesPane databasesPane;
- // update thread
- class UpdateThread
- extends Thread
- {
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // update thread
+ class UpdateThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getEnvironmentWindow().getEnvironment().getAgent() );
- if ( agent == null )
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent( parent.getEnvironmentWindow().getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the webservice
+ JEEApplicationClient client = new JEEApplicationClient( agent.getHostname(), agent.getPort() );
+ client.update( parent.getEnvironmentWindow().getEnvironmentName(), serverName, applicationName, false );
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JEE application " + applicationName + " update failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- // call the webservice
- JEEApplicationClient client = new JEEApplicationClient( agent.getHostname(), agent.getPort() );
- client.update( parent.getEnvironmentWindow().getEnvironmentName(), serverName, applicationName, false );
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JEE application " + applicationName + " update failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
}
- }
- // refresh
- private ActionListener refresh = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // refresh
+ private ActionListener refresh = new ActionListener()
{
- // looking for the JEE application object
- ApplicationWindow.this.application =
- parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- serverName ).getJEEApplication( applicationName );
- if ( ApplicationWindow.this.application == null )
- {
- ApplicationWindow.this.application = new JEEApplication();
- }
- // update the window
- update();
- }
- };
-
- // close
- private ActionListener close = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- ApplicationWindow.this.userClose();
- }
- };
-
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- // delete the application
- parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- serverName ).getJEEApplications().remove( application );
+ // looking for the JEE application object
+ ApplicationWindow.this.application =
+ parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ serverName ).getJEEApplication( applicationName );
+ if ( ApplicationWindow.this.application == null )
+ {
+ ApplicationWindow.this.application = new JEEApplication();
+ }
+ // update the window
+ update();
+ }
+ };
+
+ // close
+ private ActionListener close = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ ApplicationWindow.this.userClose();
+ }
+ };
+
+ // delete
+ private ActionListener delete = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // delete the application
+ parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ serverName ).getJEEApplications().remove( application );
+ // add a change event
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "Delete JEE application " + application.getName() );
+ // change the updated flag
+ parent.getEnvironmentWindow().setUpdated( true );
+ // update the journal log tab pane
+ parent.getEnvironmentWindow().updateJournalPane();
+ // update the parent pane
+ parent.update();
+ // close the window
+ ApplicationWindow.this.userClose();
+ }
+ } ) );
+ }
+ };
+
+ // apply
+ private ActionListener apply = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get the fields value
+ String nameFieldValue = generalPane.getNameField().getText();
+ int activeFieldIndex = generalPane.getActiveField().getSelectedIndex();
+ int blockerFieldIndex = generalPane.getBlockerField().getSelectedIndex();
+ String uriFieldValue = generalPane.getUriField().getText();
+ String agentFieldValue = (String) generalPane.getAgentField().getSelectedItem();
+ // check fields
+ if ( nameFieldValue == null || nameFieldValue.trim().length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "application.mandatory" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // if the user change the JEE application name, check if the name
+ // doesn't already exist
+ if ( applicationName == null || ( applicationName != null && !applicationName.equals( nameFieldValue ) ) )
+ {
+ if ( parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ serverName ).getJEEApplication( nameFieldValue ) != null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "application.exists" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ }
// add a change event
- parent.getEnvironmentWindow().getChangeEvents().add( "Delete JEE application " + application.getName() );
+ if ( applicationName != null )
+ {
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "Change JEE application " + application.getName() );
+ }
+ // update the application object
+ application.setName( nameFieldValue );
+ if ( activeFieldIndex == 0 )
+ {
+ application.setActive( true );
+ }
+ else
+ {
+ application.setActive( false );
+ }
+ if ( blockerFieldIndex == 0 )
+ {
+ application.setBlocker( true );
+ }
+ else
+ {
+ application.setBlocker( false );
+ }
+ application.setUri( uriFieldValue );
+ application.setAgent( agentFieldValue );
+ // add the application object if needed
+ if ( applicationName == null )
+ {
+ try
+ {
+ parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ serverName ).addJEEApplication( application );
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "Add JEE application " + application.getName() );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "application.exists" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ }
+ // update the window definition
+ setTitle( Messages.getString( "application" ) + " " + application.getName() );
+ setId( "applicationwindow_" + parent.getEnvironmentWindow().getEnvironmentName() + "_" + serverName + "_"
+ + application.getName() );
+ applicationName = application.getName();
// change the updated flag
parent.getEnvironmentWindow().setUpdated( true );
// update the journal log tab pane
parent.getEnvironmentWindow().updateJournalPane();
// update the parent pane
parent.update();
- // close the window
- ApplicationWindow.this.userClose();
- }
- } ) );
- }
- };
-
- // apply
- private ActionListener apply = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get the fields value
- String nameFieldValue = generalPane.getNameField().getText();
- int activeFieldIndex = generalPane.getActiveField().getSelectedIndex();
- int blockerFieldIndex = generalPane.getBlockerField().getSelectedIndex();
- String uriFieldValue = generalPane.getUriField().getText();
- String agentFieldValue = (String) generalPane.getAgentField().getSelectedItem();
- // check fields
- if ( nameFieldValue == null || nameFieldValue.trim().length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "application.mandatory" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // if the user change the JEE application name, check if the name
- // doesn't already exist
- if ( applicationName == null || ( applicationName != null && !applicationName.equals( nameFieldValue ) ) )
- {
- if ( parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- serverName ).getJEEApplication( nameFieldValue ) != null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "application.exists" ), getEnvironmentWindow().getEnvironmentName() );
- return;
+ // update the window
+ update();
}
- }
- // add a change event
- if ( applicationName != null )
- {
- parent.getEnvironmentWindow().getChangeEvents().add( "Change JEE application " + application.getName() );
- }
- // update the application object
- application.setName( nameFieldValue );
- if ( activeFieldIndex == 0 )
- {
- application.setActive( true );
- }
- else
- {
- application.setActive( false );
- }
- if ( blockerFieldIndex == 0 )
- {
- application.setBlocker( true );
- }
- else
- {
- application.setBlocker( false );
- }
- application.setUri( uriFieldValue );
- application.setAgent( agentFieldValue );
- // add the application object if needed
- if ( applicationName == null )
- {
- try
- {
- parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- serverName ).addJEEApplication( application );
- parent.getEnvironmentWindow().getChangeEvents().add( "Add JEE application " + application.getName() );
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "application.exists" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- }
- // update the window definition
- setTitle( Messages.getString( "application" ) + " " + application.getName() );
- setId( "applicationwindow_" + parent.getEnvironmentWindow().getEnvironmentName() + "_" + serverName + "_"
- + application.getName() );
- applicationName = application.getName();
- // change the updated flag
- parent.getEnvironmentWindow().setUpdated( true );
- // update the journal log tab pane
- parent.getEnvironmentWindow().updateJournalPane();
- // update the parent pane
- parent.update();
- // update the window
- update();
- }
- };
+ };
- // copy
- private ActionListener copy = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // copy
+ private ActionListener copy = new ActionListener()
{
- try
- {
- KalumetConsoleApplication.getApplication().setCopyComponent( application.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
-
- // paste
- private ActionListener paste = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
- // check if the copy is correct
- if ( copy == null || !( copy instanceof JEEApplication) )
- {
- return;
- }
- application = (JEEApplication) copy;
- applicationName = null;
- // update the parent pane
- parent.update();
- // update the window
- update();
- }
- };
-
- // update
- private ActionListener update = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsUpdatePermission )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if some change has not been saved
- if ( getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- // add a message into the log pane and the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application " + applicationName + " update in progress...",
- parent.getEnvironmentWindow().getEnvironmentName() );
- parent.getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + applicationName + " update requested." );
- // start the update thread
- final UpdateThread updateThread = new UpdateThread();
- updateThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ try
{
- public void run()
- {
- if ( updateThread.ended )
+ KalumetConsoleApplication.getApplication().setCopyComponent( application.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
+
+ // paste
+ private ActionListener paste = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+ // check if the copy is correct
+ if ( copy == null || !( copy instanceof JEEApplication ) )
+ {
+ return;
+ }
+ application = (JEEApplication) copy;
+ applicationName = null;
+ // update the parent pane
+ parent.update();
+ // update the window
+ update();
+ }
+ };
+
+ // update
+ private ActionListener update = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if some change has not been saved
+ if ( getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
{
- if ( updateThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( updateThread.message,
- parent.getEnvironmentWindow().getEnvironmentName() );
- parent.getEnvironmentWindow().getChangeEvents().add( updateThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "JEE application " + applicationName + " updated.",
- parent.getEnvironmentWindow().getEnvironmentName() );
- parent.getEnvironmentWindow().getChangeEvents().add(
- "JEE application " + applicationName + " updated." );
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
- } );
- }
- } ) );
- }
- };
+ public void actionPerformed( ActionEvent event )
+ {
+ // add a message into the log pane and the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application " + applicationName + " update in progress...",
+ parent.getEnvironmentWindow().getEnvironmentName() );
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + applicationName + " update requested." );
+ // start the update thread
+ final UpdateThread updateThread = new UpdateThread();
+ updateThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( updateThread.ended )
+ {
+ if ( updateThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ updateThread.message, parent.getEnvironmentWindow().getEnvironmentName() );
+ parent.getEnvironmentWindow().getChangeEvents().add( updateThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ "JEE application " + applicationName + " updated.",
+ parent.getEnvironmentWindow().getEnvironmentName() );
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "JEE application " + applicationName + " updated." );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ } ) );
+ }
+ };
- /**
- * Create a new <code>ApplicationWindow</code>.
- *
- * @param parent the parent <code>ApplicationsPane</code>.
- * @param applicationServerName the original JEE application server name.
- * @param applicationName the original JEE application name.
- */
- public ApplicationWindow( ApplicationsPane parent, String applicationServerName, String applicationName )
- {
- super();
-
- // update the parent tab pane
- this.parent = parent;
-
- // update the JEE application server name and JEE application name
- this.serverName = applicationServerName;
- this.applicationName = applicationName;
-
- // update the application object from the parent environment
- this.application =
- parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- serverName ).getJEEApplication( this.applicationName );
- if ( this.application == null )
+ /**
+ * Create a new <code>ApplicationWindow</code>.
+ *
+ * @param parent the parent <code>ApplicationsPane</code>.
+ * @param applicationServerName the original JEE application server name.
+ * @param applicationName the original JEE application name.
+ */
+ public ApplicationWindow( ApplicationsPane parent, String applicationServerName, String applicationName )
{
- this.application = new JEEApplication();
+ super();
+
+ // update the parent tab pane
+ this.parent = parent;
+
+ // update the JEE application server name and JEE application name
+ this.serverName = applicationServerName;
+ this.applicationName = applicationName;
+
+ // update the application object from the parent environment
+ this.application =
+ parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ serverName ).getJEEApplication( this.applicationName );
+ if ( this.application == null )
+ {
+ this.application = new JEEApplication();
+ }
+
+ if ( this.applicationName == null )
+ {
+ setTitle( Messages.getString( "application" ) );
+ }
+ else
+ {
+ setTitle( Messages.getString( "application" ) + " " + this.applicationName );
+ }
+ setId( "applicationwindow_" + parent.getEnvironmentWindow().getEnvironmentName() + "_" + serverName + "_"
+ + this.applicationName );
+ setStyleName( "default" );
+ setWidth( new Extent( 600, Extent.PX ) );
+ setHeight( new Extent( 400, Extent.PX ) );
+ setModal( false );
+ setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
+
+ // create a split pane for the control buttons
+ SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
+ add( splitPane );
+
+ // add the control pane
+ Row controlRow = new Row();
+ controlRow.setStyleName( "control" );
+ splitPane.add( controlRow );
+ // add the refresh button
+ Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
+ refreshButton.setStyleName( "control" );
+ refreshButton.addActionListener( refresh );
+ controlRow.add( refreshButton );
+ // add the copy button
+ Button copyButton = new Button( Messages.getString( "copy" ), Styles.PAGE_COPY );
+ copyButton.setStyleName( "control" );
+ copyButton.addActionListener( copy );
+ controlRow.add( copyButton );
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // add the paste button
+ Button pasteButton = new Button( Messages.getString( "paste" ), Styles.PAGE_PASTE );
+ pasteButton.setStyleName( "control" );
+ pasteButton.addActionListener( paste );
+ controlRow.add( pasteButton );
+ }
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ // add the update button
+ Button updateButton = new Button( Messages.getString( "update" ), Styles.COG );
+ updateButton.setStyleName( "control" );
+ updateButton.addActionListener( update );
+ controlRow.add( updateButton );
+ }
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // add the apply button
+ Button applyButton = new Button( Messages.getString( "apply" ), Styles.ACCEPT );
+ applyButton.setStyleName( "control" );
+ applyButton.addActionListener( apply );
+ controlRow.add( applyButton );
+ // add the delete button
+ Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
+ deleteButton.setStyleName( "control" );
+ deleteButton.addActionListener( delete );
+ controlRow.add( deleteButton );
+ }
+ // add the close button
+ Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
+ closeButton.setStyleName( "control" );
+ closeButton.addActionListener( close );
+ controlRow.add( closeButton );
+
+ // add the main tab pane
+ TabPane tabPane = new TabPane();
+ tabPane.setStyleName( "default" );
+ splitPane.add( tabPane );
+
+ // add the JEE application general tab
+ TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "general" ) );
+ generalPane = new ApplicationGeneralPane( this );
+ generalPane.setLayoutData( tabLayoutData );
+ tabPane.add( generalPane );
+
+ // add the JEE application archives tab
+ tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "archives" ) );
+ archivesPane = new ApplicationArchivesPane( this );
+ archivesPane.setLayoutData( tabLayoutData );
+ tabPane.add( archivesPane );
+
+ // add the JEE application configuration files tab
+ tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "configurationfiles" ) );
+ configurationFilesPane = new ApplicationConfigurationFilesPane( this );
+ configurationFilesPane.setLayoutData( tabLayoutData );
+ tabPane.add( configurationFilesPane );
+
+ // add the JEE application databases tab
+ tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "databases" ) );
+ databasesPane = new ApplicationDatabasesPane( this );
+ databasesPane.setLayoutData( tabLayoutData );
+ tabPane.add( databasesPane );
+
+ // add the JEE application content managers tab
+ tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "contentmanagers" ) );
+ contentManagersPane = new ApplicationContentManagersPane( this );
+ contentManagersPane.setLayoutData( tabLayoutData );
+ tabPane.add( contentManagersPane );
}
- if ( this.applicationName == null )
+ public JEEApplication getApplication()
{
- setTitle( Messages.getString( "application" ) );
+ return this.application;
}
- else
+
+ public ApplicationsPane getParentPane()
{
- setTitle( Messages.getString( "application" ) + " " + this.applicationName );
+ return this.parent;
}
- setId( "applicationwindow_" + parent.getEnvironmentWindow().getEnvironmentName() + "_" + serverName + "_"
- + this.applicationName );
- setStyleName( "default" );
- setWidth( new Extent( 600, Extent.PX ) );
- setHeight( new Extent( 400, Extent.PX ) );
- setModal( false );
- setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
- // create a split pane for the control buttons
- SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
- add( splitPane );
-
- // add the control pane
- Row controlRow = new Row();
- controlRow.setStyleName( "control" );
- splitPane.add( controlRow );
- // add the refresh button
- Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
- refreshButton.setStyleName( "control" );
- refreshButton.addActionListener( refresh );
- controlRow.add( refreshButton );
- // add the copy button
- Button copyButton = new Button( Messages.getString( "copy" ), Styles.PAGE_COPY );
- copyButton.setStyleName( "control" );
- copyButton.addActionListener( copy );
- controlRow.add( copyButton );
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission)
+ public String getServerName()
{
- // add the paste button
- Button pasteButton = new Button( Messages.getString( "paste" ), Styles.PAGE_PASTE );
- pasteButton.setStyleName( "control" );
- pasteButton.addActionListener( paste );
- controlRow.add( pasteButton );
+ return this.serverName;
}
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsUpdatePermission )
+
+ public String getApplicationName()
{
- // add the update button
- Button updateButton = new Button( Messages.getString( "update" ), Styles.COG );
- updateButton.setStyleName( "control" );
- updateButton.addActionListener( update );
- controlRow.add( updateButton );
+ return this.applicationName;
}
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission)
+
+ public EnvironmentWindow getEnvironmentWindow()
{
- // add the apply button
- Button applyButton = new Button( Messages.getString( "apply" ), Styles.ACCEPT );
- applyButton.setStyleName( "control" );
- applyButton.addActionListener( apply );
- controlRow.add( applyButton );
- // add the delete button
- Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
- deleteButton.setStyleName( "control" );
- deleteButton.addActionListener( delete );
- controlRow.add( deleteButton );
+ return parent.getEnvironmentWindow();
}
- // add the close button
- Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
- closeButton.setStyleName( "control" );
- closeButton.addActionListener( close );
- controlRow.add( closeButton );
- // add the main tab pane
- TabPane tabPane = new TabPane();
- tabPane.setStyleName( "default" );
- splitPane.add( tabPane );
-
- // add the JEE application general tab
- TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "general" ) );
- generalPane = new ApplicationGeneralPane( this );
- generalPane.setLayoutData( tabLayoutData );
- tabPane.add( generalPane );
-
- // add the JEE application archives tab
- tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "archives" ) );
- archivesPane = new ApplicationArchivesPane( this );
- archivesPane.setLayoutData( tabLayoutData );
- tabPane.add( archivesPane );
-
- // add the JEE application configuration files tab
- tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "configurationfiles" ) );
- configurationFilesPane = new ApplicationConfigurationFilesPane( this );
- configurationFilesPane.setLayoutData( tabLayoutData );
- tabPane.add( configurationFilesPane );
-
- // add the JEE application databases tab
- tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "databases" ) );
- databasesPane = new ApplicationDatabasesPane( this );
- databasesPane.setLayoutData( tabLayoutData );
- tabPane.add( databasesPane );
-
- // add the JEE application content managers tab
- tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "contentmanagers" ) );
- contentManagersPane = new ApplicationContentManagersPane( this );
- contentManagersPane.setLayoutData( tabLayoutData );
- tabPane.add( contentManagersPane );
- }
-
- public JEEApplication getApplication()
- {
- return this.application;
- }
-
- public ApplicationsPane getParentPane()
- {
- return this.parent;
- }
-
- public String getServerName()
- {
- return this.serverName;
- }
-
- public String getApplicationName()
- {
- return this.applicationName;
- }
-
- public EnvironmentWindow getEnvironmentWindow()
- {
- return parent.getEnvironmentWindow();
- }
-
- /**
- * Update the pane.
- */
- public void update()
- {
- generalPane.update();
- archivesPane.update();
- contentManagersPane.update();
- configurationFilesPane.update();
- databasesPane.update();
- }
+ /**
+ * Update the pane.
+ */
+ public void update()
+ {
+ generalPane.update();
+ archivesPane.update();
+ contentManagersPane.update();
+ configurationFilesPane.update();
+ databasesPane.update();
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationsPane.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationsPane.java
index f79f326..125b1d8 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationsPane.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ApplicationsPane.java
@@ -45,797 +45,804 @@
* Environment JEE applications pane.
*/
public class ApplicationsPane
- extends ContentPane
+ extends ContentPane
{
- private EnvironmentWindow parent;
+ private EnvironmentWindow parent;
- private SelectField scopeField;
+ private SelectField scopeField;
- private Grid grid;
+ private Grid grid;
- // update thread
- class UpdateThread
- extends Thread
- {
-
- public String serverName;
-
- public String applicationName;
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // update thread
+ class UpdateThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
- if ( agent == null )
+
+ public String serverName;
+
+ public String applicationName;
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the webservice
+ JEEApplicationClient client = new JEEApplicationClient( agent.getHostname(), agent.getPort() );
+ client.update( parent.getEnvironmentName(), serverName, applicationName, false );
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JEE application " + applicationName + " update failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- // call the webservice
- JEEApplicationClient client = new JEEApplicationClient( agent.getHostname(), agent.getPort() );
- client.update( parent.getEnvironmentName(), serverName, applicationName, false );
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JEE application " + applicationName + " update failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
}
- }
- // scope select
- private ActionListener scopeSelect = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // scope select
+ private ActionListener scopeSelect = new ActionListener()
{
- update();
- }
- };
-
- // toggle active
- private ActionListener toggleActive = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the JEE application object
- JEEApplication application = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJEEApplication( event.getActionCommand() );
- if ( application == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "application.notfound" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // change the JEE application state and add a change event
- if ( application.isActive() )
- {
- application.setActive( false );
- parent.getChangeEvents().add( "Disable JEE application " + application.getName() );
- }
- else
- {
- application.setActive( true );
- parent.getChangeEvents().add( "Enable JEE application " + application.getName() );
- }
- // change the updated flag
- parent.setUpdated( true );
- // update the journal log tab pane
- parent.updateJournalPane();
- // update the pane
- update();
- }
- };
-
- // toggle blocker
- private ActionListener toggleBlocker = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the jee application object
- JEEApplication application = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJEEApplication( event.getActionCommand() );
- if ( application == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "application.notfound" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // change the jee application blocker and add a change event
- if ( application.isBlocker() )
- {
- application.setBlocker( false );
- parent.getChangeEvents().add( "Set not blocker for JEE application " + application.getName() );
- }
- else
- {
- application.setBlocker( true );
- parent.getChangeEvents().add( "Set blocker for JEE application " + application.getName() );
- }
- // change the updated flag
- parent.setUpdated( true );
- // update the journal log tab pane
- parent.updateJournalPane();
- // update the pane
- update();
- }
- };
-
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the jee application object
- final JEEApplication application = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJEEApplication( event.getActionCommand() );
- if ( application == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "application.notfound" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
- // delete the JEE application object
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJEEApplications().remove( application );
- // add a change event
- parent.getChangeEvents().add( "Delete JEE application " + application.getName() );
+ update();
+ }
+ };
+
+ // toggle active
+ private ActionListener toggleActive = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the JEE application object
+ JEEApplication application = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJEEApplication( event.getActionCommand() );
+ if ( application == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "application.notfound" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // change the JEE application state and add a change event
+ if ( application.isActive() )
+ {
+ application.setActive( false );
+ parent.getChangeEvents().add( "Disable JEE application " + application.getName() );
+ }
+ else
+ {
+ application.setActive( true );
+ parent.getChangeEvents().add( "Enable JEE application " + application.getName() );
+ }
// change the updated flag
parent.setUpdated( true );
// update the journal log tab pane
parent.updateJournalPane();
// update the pane
update();
- }
- } ) );
- }
- };
-
- // edit
- private ActionListener edit = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
- "applicationwindow_" + parent.getEnvironmentName() + "_" + (String) scopeField.getSelectedItem() + "_"
- + event.getActionCommand() ) == null )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ApplicationWindow( ApplicationsPane.this, (String) scopeField.getSelectedItem(),
- event.getActionCommand() ) );
- }
- }
- };
-
- // create
- private ActionListener create = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ApplicationWindow( ApplicationsPane.this, (String) scopeField.getSelectedItem(), null ) );
- }
- };
-
- // up
- private ActionListener up = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the JEE application object
- JEEApplication application = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJEEApplication( event.getActionCommand() );
- if ( application == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "application.notfound" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get the JEE application index
- int index = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJEEApplications().indexOf( application );
- // if the JEE application index is the first one or the object is not
- // found, do nothing, the size of the list must constains at least 2
- // JEE applications
- if ( index == 0 || index == -1 || parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJEEApplications().size() < 2 )
- {
- return;
- }
- // get the previous application
- JEEApplication previous =
- (JEEApplication) parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJEEApplications().get( index - 1 );
- // switch the application
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJEEApplications().set( index, previous );
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJEEApplications().set( index - 1, application );
- // update the pane
- update();
- }
- };
-
- // down
- private ActionListener down = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the JEE application object
- JEEApplication application = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJEEApplication( event.getActionCommand() );
- if ( application == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "application.notfound" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get the JEE application index
- int index = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJEEApplications().indexOf( application );
- // if the JEE application index is the last one or the object is not
- // found, the size of the list must contains at least 2 JEE
- // applications
- if ( index == -1 || index == parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJEEApplications().size() - 1 ||
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJEEApplications().size() < 2 )
- {
- return;
- }
- // get the next application
- JEEApplication next =
- (JEEApplication) parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJEEApplications().get( index + 1 );
- // switch the application
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJEEApplications().set( index + 1, application );
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJEEApplications().set( index, next );
- // update the pane
- update();
- }
- };
-
- // copy
- private ActionListener copy = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // looking for the JEE application object
- JEEApplication application = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJEEApplication( event.getActionCommand() );
- if ( application == null )
- {
- return;
- }
- try
- {
- KalumetConsoleApplication.getApplication().setCopyComponent( application.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
-
- // apply
- private ActionListener apply = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get the JEE application name
- String name = event.getActionCommand();
- // get the JEE application uri field
- TextField uriField = (TextField) ApplicationsPane.this.getComponent(
- "applicationuri_" + parent.getEnvironmentName() + "_" + (String) scopeField.getSelectedItem() + "_" + name );
- // get the URI field value
- String uriValue = uriField.getText();
- // looking for the JEE application object
- JEEApplication application = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJEEApplication( name );
- if ( application == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "application.notfound" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // add a change event
- parent.getChangeEvents().add( "Change JEE application " + application.getName() + " URI to " + uriValue );
- // change the JEE application object
- application.setUri( uriValue );
- // change the updated flag
- parent.setUpdated( true );
- // update the journal log tab pane
- parent.updateJournalPane();
- // update the pane
- update();
- }
- };
-
- // update
- private ActionListener update = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsUpdatePermission )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if some change has not been saved
- if ( getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get the selected JEE server and application
- final String serverName = (String) scopeField.getSelectedItem();
- final String applicationName = event.getActionCommand();
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // add a message into the log pane and the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JEE application " + applicationName + " update in progress...", parent.getEnvironmentName() );
- parent.getChangeEvents().add( "JEE application " + applicationName + " update requested." );
- // start the update thread
- final UpdateThread updateThread = new UpdateThread();
- updateThread.serverName = serverName;
- updateThread.applicationName = applicationName;
- updateThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
- {
- public void run()
- {
- if ( updateThread.ended )
- {
- if ( updateThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( updateThread.message,
- parent.getEnvironmentName() );
- parent.getChangeEvents().add( updateThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "JEE application " + applicationName + " updated.", parent.getEnvironmentName() );
- parent.getChangeEvents().add( "JEE application " + applicationName + " updated." );
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
- } );
- }
- } ) );
- }
- };
-
- // test URI
- private ActionListener testUri = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- String name = event.getActionCommand();
- TextField uriField = (TextField) ApplicationsPane.this.getComponent(
- "applicationuri_" + parent.getEnvironmentName() + "_" + (String) scopeField.getSelectedItem() + "_" + name );
- String uri = FileManipulator.format( uriField.getText() );
- boolean exists = false;
- FileManipulator fileManipulator = null;
- try
- {
- fileManipulator = new FileManipulator();
- exists = fileManipulator.exists( uri );
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- "Can't check the URI " + uri + ": " + e.getMessage(), parent.getEnvironmentName() );
- }
- finally
- {
- if ( fileManipulator != null )
- {
- fileManipulator.close();
}
- }
- if ( exists )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm( "URI " + uri + " exists.",
- parent.getEnvironmentName() );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( "URI " + uri + " doesn't exists.",
- parent.getEnvironmentName() );
- }
- }
- };
+ };
- /**
- * Create a new <code>ApplicationsPane</code>.
- *
- * @param parent the parent <code>EnvironmentWindow</code>.
- */
- public ApplicationsPane( EnvironmentWindow parent )
- {
- super();
- setStyleName( "tab.content" );
-
- // update parent
- this.parent = parent;
-
- // column layout
- Column content = new Column();
- content.setCellSpacing( new Extent( 2 ) );
- add( content );
-
- // add the scope field
- Grid layoutGrid = new Grid( 2 );
- layoutGrid.setStyleName( "default" );
- layoutGrid.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
- layoutGrid.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
- content.add( layoutGrid );
- Label scopeLabel = new Label( Messages.getString( "scope" ) );
- layoutGrid.add( scopeLabel );
- scopeField = new SelectField();
- scopeField.addActionListener( scopeSelect );
- scopeField.setStyleName( "default" );
- layoutGrid.add( scopeField );
- DefaultListModel scopeListModel = (DefaultListModel) scopeField.getModel();
- scopeListModel.removeAll();
- // add application servers in the scope select field
- for ( Iterator applicationServerIterator =
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServers().iterator();
- applicationServerIterator.hasNext(); )
+ // toggle blocker
+ private ActionListener toggleBlocker = new ActionListener()
{
- JEEApplicationServer applicationServer = (JEEApplicationServer) applicationServerIterator.next();
- scopeListModel.add( applicationServer.getName() );
- }
- if ( scopeListModel.size() > 0 )
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the jee application object
+ JEEApplication application = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJEEApplication( event.getActionCommand() );
+ if ( application == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "application.notfound" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // change the jee application blocker and add a change event
+ if ( application.isBlocker() )
+ {
+ application.setBlocker( false );
+ parent.getChangeEvents().add( "Set not blocker for JEE application " + application.getName() );
+ }
+ else
+ {
+ application.setBlocker( true );
+ parent.getChangeEvents().add( "Set blocker for JEE application " + application.getName() );
+ }
+ // change the updated flag
+ parent.setUpdated( true );
+ // update the journal log tab pane
+ parent.updateJournalPane();
+ // update the pane
+ update();
+ }
+ };
+
+ // delete
+ private ActionListener delete = new ActionListener()
{
- scopeField.setSelectedIndex( 0 );
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the jee application object
+ final JEEApplication application =
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJEEApplication( event.getActionCommand() );
+ if ( application == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "application.notfound" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // delete the JEE application object
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJEEApplications().remove( application );
+ // add a change event
+ parent.getChangeEvents().add( "Delete JEE application " + application.getName() );
+ // change the updated flag
+ parent.setUpdated( true );
+ // update the journal log tab pane
+ parent.updateJournalPane();
+ // update the pane
+ update();
+ }
+ } ) );
+ }
+ };
+
+ // edit
+ private ActionListener edit = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
+ "applicationwindow_" + parent.getEnvironmentName() + "_" + (String) scopeField.getSelectedItem() + "_"
+ + event.getActionCommand() ) == null )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ApplicationWindow( ApplicationsPane.this, (String) scopeField.getSelectedItem(),
+ event.getActionCommand() ) );
+ }
+ }
+ };
+
+ // create
+ private ActionListener create = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ApplicationWindow( ApplicationsPane.this, (String) scopeField.getSelectedItem(), null ) );
+ }
+ };
+
+ // up
+ private ActionListener up = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the JEE application object
+ JEEApplication application = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJEEApplication( event.getActionCommand() );
+ if ( application == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "application.notfound" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get the JEE application index
+ int index = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJEEApplications().indexOf( application );
+ // if the JEE application index is the first one or the object is not
+ // found, do nothing, the size of the list must constains at least 2
+ // JEE applications
+ if ( index == 0 || index == -1 ||
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJEEApplications().size() < 2 )
+ {
+ return;
+ }
+ // get the previous application
+ JEEApplication previous =
+ (JEEApplication) parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJEEApplications().get( index - 1 );
+ // switch the application
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJEEApplications().set( index, previous );
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJEEApplications().set( index - 1, application );
+ // update the pane
+ update();
+ }
+ };
+
+ // down
+ private ActionListener down = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the JEE application object
+ JEEApplication application = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJEEApplication( event.getActionCommand() );
+ if ( application == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "application.notfound" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get the JEE application index
+ int index = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJEEApplications().indexOf( application );
+ // if the JEE application index is the last one or the object is not
+ // found, the size of the list must contains at least 2 JEE
+ // applications
+ if ( index == -1 || index == parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJEEApplications().size() - 1 ||
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJEEApplications().size() < 2 )
+ {
+ return;
+ }
+ // get the next application
+ JEEApplication next =
+ (JEEApplication) parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJEEApplications().get( index + 1 );
+ // switch the application
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJEEApplications().set( index + 1, application );
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJEEApplications().set( index, next );
+ // update the pane
+ update();
+ }
+ };
+
+ // copy
+ private ActionListener copy = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // looking for the JEE application object
+ JEEApplication application = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJEEApplication( event.getActionCommand() );
+ if ( application == null )
+ {
+ return;
+ }
+ try
+ {
+ KalumetConsoleApplication.getApplication().setCopyComponent( application.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
+
+ // apply
+ private ActionListener apply = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get the JEE application name
+ String name = event.getActionCommand();
+ // get the JEE application uri field
+ TextField uriField = (TextField) ApplicationsPane.this.getComponent(
+ "applicationuri_" + parent.getEnvironmentName() + "_" + (String) scopeField.getSelectedItem() + "_"
+ + name );
+ // get the URI field value
+ String uriValue = uriField.getText();
+ // looking for the JEE application object
+ JEEApplication application = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJEEApplication( name );
+ if ( application == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "application.notfound" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // add a change event
+ parent.getChangeEvents().add( "Change JEE application " + application.getName() + " URI to " + uriValue );
+ // change the JEE application object
+ application.setUri( uriValue );
+ // change the updated flag
+ parent.setUpdated( true );
+ // update the journal log tab pane
+ parent.updateJournalPane();
+ // update the pane
+ update();
+ }
+ };
+
+ // update
+ private ActionListener update = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if some change has not been saved
+ if ( getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get the selected JEE server and application
+ final String serverName = (String) scopeField.getSelectedItem();
+ final String applicationName = event.getActionCommand();
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // add a message into the log pane and the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JEE application " + applicationName + " update in progress...",
+ parent.getEnvironmentName() );
+ parent.getChangeEvents().add( "JEE application " + applicationName + " update requested." );
+ // start the update thread
+ final UpdateThread updateThread = new UpdateThread();
+ updateThread.serverName = serverName;
+ updateThread.applicationName = applicationName;
+ updateThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( updateThread.ended )
+ {
+ if ( updateThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ updateThread.message, parent.getEnvironmentName() );
+ parent.getChangeEvents().add( updateThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ "JEE application " + applicationName + " updated.",
+ parent.getEnvironmentName() );
+ parent.getChangeEvents().add(
+ "JEE application " + applicationName + " updated." );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ } ) );
+ }
+ };
+
+ // test URI
+ private ActionListener testUri = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ String name = event.getActionCommand();
+ TextField uriField = (TextField) ApplicationsPane.this.getComponent(
+ "applicationuri_" + parent.getEnvironmentName() + "_" + (String) scopeField.getSelectedItem() + "_"
+ + name );
+ String uri = FileManipulator.format( uriField.getText() );
+ boolean exists = false;
+ FileManipulator fileManipulator = null;
+ try
+ {
+ fileManipulator = new FileManipulator();
+ exists = fileManipulator.exists( uri );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ "Can't check the URI " + uri + ": " + e.getMessage(), parent.getEnvironmentName() );
+ }
+ finally
+ {
+ if ( fileManipulator != null )
+ {
+ fileManipulator.close();
+ }
+ }
+ if ( exists )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm( "URI " + uri + " exists.",
+ parent.getEnvironmentName() );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning( "URI " + uri + " doesn't exists.",
+ parent.getEnvironmentName() );
+ }
+ }
+ };
+
+ /**
+ * Create a new <code>ApplicationsPane</code>.
+ *
+ * @param parent the parent <code>EnvironmentWindow</code>.
+ */
+ public ApplicationsPane( EnvironmentWindow parent )
+ {
+ super();
+ setStyleName( "tab.content" );
+
+ // update parent
+ this.parent = parent;
+
+ // column layout
+ Column content = new Column();
+ content.setCellSpacing( new Extent( 2 ) );
+ add( content );
+
+ // add the scope field
+ Grid layoutGrid = new Grid( 2 );
+ layoutGrid.setStyleName( "default" );
+ layoutGrid.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
+ layoutGrid.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
+ content.add( layoutGrid );
+ Label scopeLabel = new Label( Messages.getString( "scope" ) );
+ layoutGrid.add( scopeLabel );
+ scopeField = new SelectField();
+ scopeField.addActionListener( scopeSelect );
+ scopeField.setStyleName( "default" );
+ layoutGrid.add( scopeField );
+ DefaultListModel scopeListModel = (DefaultListModel) scopeField.getModel();
+ scopeListModel.removeAll();
+ // add application servers in the scope select field
+ for ( Iterator applicationServerIterator =
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServers().iterator();
+ applicationServerIterator.hasNext(); )
+ {
+ JEEApplicationServer applicationServer = (JEEApplicationServer) applicationServerIterator.next();
+ scopeListModel.add( applicationServer.getName() );
+ }
+ if ( scopeListModel.size() > 0 )
+ {
+ scopeField.setSelectedIndex( 0 );
+ }
+
+ // add the create button
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ Button createButton = new Button( Messages.getString( "application.add" ), Styles.ADD );
+ createButton.addActionListener( create );
+ content.add( createButton );
+ }
+
+ // add JEE applications grid
+ grid = new Grid( 4 );
+ grid.setStyleName( "border.grid" );
+ grid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
+ grid.setColumnWidth( 1, new Extent( 10, Extent.PERCENT ) );
+ grid.setColumnWidth( 2, new Extent( 80, Extent.PERCENT ) );
+ grid.setColumnWidth( 3, new Extent( 10, Extent.PERCENT ) );
+ content.add( grid );
+
+ // update the pane
+ update();
}
- // add the create button
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission)
+ /**
+ * Update the pane
+ */
+ public void update()
{
- Button createButton = new Button( Messages.getString( "application.add" ), Styles.ADD );
- createButton.addActionListener( create );
- content.add( createButton );
+ String applicationServerName = null;
+ // update the scope select field
+ DefaultListModel scopeListModel = (DefaultListModel) scopeField.getModel();
+ if ( scopeListModel.size() > 0 )
+ {
+ applicationServerName = (String) scopeField.getSelectedItem();
+ }
+ scopeListModel.removeAll();
+ int scopeIndex = 0;
+ int found = -1;
+ for ( Iterator applicationServerIterator =
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServers().iterator();
+ applicationServerIterator.hasNext(); )
+ {
+ JEEApplicationServer applicationServer = (JEEApplicationServer) applicationServerIterator.next();
+ scopeListModel.add( applicationServer.getName() );
+ if ( applicationServer.getName().equals( applicationServerName ) )
+ {
+ found = scopeIndex;
+ }
+ scopeIndex++;
+ }
+ // remove all JEE applications grid children
+ grid.removeAll();
+ // check if at least one application server is present
+ if ( scopeListModel.size() < 1 )
+ {
+ return;
+ }
+ // update the scope select field selected index
+ if ( found == -1 )
+ {
+ scopeField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ scopeField.setSelectedIndex( found );
+ }
+ // update the application server name from the scope (in case of
+ // application server deletion)
+ applicationServerName = (String) scopeField.getSelectedItem();
+
+ // add JEE applications grid header
+ Label actionHeader = new Label( " " );
+ actionHeader.setStyleName( "grid.header" );
+ grid.add( actionHeader );
+ Label nameHeader = new Label( Messages.getString( "name" ) );
+ nameHeader.setStyleName( "grid.header" );
+ grid.add( nameHeader );
+ Label uriHeader = new Label( Messages.getString( "uri" ) );
+ uriHeader.setStyleName( "grid.header" );
+ grid.add( uriHeader );
+ Label agentHeader = new Label( Messages.getString( "agent" ) );
+ agentHeader.setStyleName( "grid.header" );
+ grid.add( agentHeader );
+ // add the JEE applications
+ for ( Iterator applicationIterator = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ applicationServerName ).getJEEApplications().iterator(); applicationIterator.hasNext(); )
+ {
+ JEEApplication application = (JEEApplication) applicationIterator.next();
+ // row
+ Row row = new Row();
+ row.setInsets( new Insets( 2 ) );
+ row.setCellSpacing( new Extent( 2 ) );
+ grid.add( row );
+ // copy
+ Button copyButton = new Button( Styles.PAGE_COPY );
+ copyButton.setToolTipText( Messages.getString( "copy" ) );
+ copyButton.setActionCommand( application.getName() );
+ copyButton.addActionListener( copy );
+ row.add( copyButton );
+ // active
+ Button activeButton;
+ if ( application.isActive() )
+ {
+ activeButton = new Button( Styles.LIGHTBULB );
+ activeButton.setToolTipText( Messages.getString( "switch.disable" ) );
+ }
+ else
+ {
+ activeButton = new Button( Styles.LIGHTBULB_OFF );
+ activeButton.setToolTipText( Messages.getString( "switch.enable" ) );
+ }
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ activeButton.setActionCommand( application.getName() );
+ activeButton.addActionListener( toggleActive );
+ }
+ row.add( activeButton );
+ // blocker
+ Button blockerButton;
+ if ( application.isBlocker() )
+ {
+ blockerButton = new Button( Styles.PLUGIN );
+ blockerButton.setToolTipText( Messages.getString( "switch.notblocker" ) );
+ }
+ else
+ {
+ blockerButton = new Button( Styles.PLUGIN_DISABLED );
+ blockerButton.setToolTipText( Messages.getString( "switch.blocker" ) );
+ }
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ blockerButton.setActionCommand( application.getName() );
+ blockerButton.addActionListener( toggleBlocker );
+ }
+ row.add( blockerButton );
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // up
+ Button upButton = new Button( Styles.ARROW_UP );
+ upButton.setToolTipText( Messages.getString( "up" ) );
+ upButton.setActionCommand( application.getName() );
+ upButton.addActionListener( up );
+ row.add( upButton );
+ // down
+ Button downButton = new Button( Styles.ARROW_DOWN );
+ downButton.setToolTipText( Messages.getString( "down" ) );
+ downButton.setActionCommand( application.getName() );
+ downButton.addActionListener( down );
+ row.add( downButton );
+ }
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsUpdatePermission )
+ {
+ // update
+ Button updateButton = new Button( Styles.COG );
+ updateButton.setToolTipText( Messages.getString( "update" ) );
+ updateButton.setActionCommand( application.getName() );
+ updateButton.addActionListener( update );
+ row.add( updateButton );
+ }
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission )
+ {
+ // apply
+ Button applyButton = new Button( Styles.ACCEPT );
+ applyButton.setToolTipText( Messages.getString( "apply" ) );
+ applyButton.setActionCommand( application.getName() );
+ applyButton.addActionListener( apply );
+ row.add( applyButton );
+ // delete
+ Button deleteButton = new Button( Styles.DELETE );
+ deleteButton.setToolTipText( Messages.getString( "delete" ) );
+ deleteButton.setActionCommand( application.getName() );
+ deleteButton.addActionListener( delete );
+ row.add( deleteButton );
+ }
+ // name
+ Button nameField = new Button( application.getName() );
+ nameField.setStyleName( "default" );
+ nameField.setActionCommand( application.getName() );
+ nameField.addActionListener( edit );
+ grid.add( nameField );
+ // uri
+ Row uriRow = new Row();
+ grid.add( uriRow );
+ TextField uriField = new TextField();
+ uriField.setStyleName( "default" );
+ uriField.setWidth( new Extent( 500, Extent.PX ) );
+ uriField.setId( "applicationuri_" + parent.getEnvironmentName() + "_" + applicationServerName + "_"
+ + application.getName() );
+ uriField.setText( application.getUri() );
+ uriRow.add( uriField );
+ // test
+ Button testUriButton = new Button( Styles.WORLD );
+ testUriButton.setToolTipText( Messages.getString( "uri.test" ) );
+ testUriButton.setActionCommand( application.getName() );
+ testUriButton.addActionListener( testUri );
+ uriRow.add( testUriButton );
+ // agent
+ Label agent = new Label( application.getAgent() );
+ agent.setStyleName( "default" );
+ grid.add( agent );
+ }
}
- // add JEE applications grid
- grid = new Grid( 4 );
- grid.setStyleName( "border.grid" );
- grid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
- grid.setColumnWidth( 1, new Extent( 10, Extent.PERCENT ) );
- grid.setColumnWidth( 2, new Extent( 80, Extent.PERCENT ) );
- grid.setColumnWidth( 3, new Extent( 10, Extent.PERCENT ) );
- content.add( grid );
-
- // update the pane
- update();
- }
-
- /**
- * Update the pane
- */
- public void update()
- {
- String applicationServerName = null;
- // update the scope select field
- DefaultListModel scopeListModel = (DefaultListModel) scopeField.getModel();
- if ( scopeListModel.size() > 0 )
+ /**
+ * Return the parent <code>EnvironmentWindow</code>.
+ *
+ * @return the parent <code>EnvironmentWindow</code>.
+ */
+ public EnvironmentWindow getEnvironmentWindow()
{
- applicationServerName = (String) scopeField.getSelectedItem();
+ return this.parent;
}
- scopeListModel.removeAll();
- int scopeIndex = 0;
- int found = -1;
- for ( Iterator applicationServerIterator =
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServers().iterator();
- applicationServerIterator.hasNext(); )
- {
- JEEApplicationServer applicationServer = (JEEApplicationServer) applicationServerIterator.next();
- scopeListModel.add( applicationServer.getName() );
- if ( applicationServer.getName().equals( applicationServerName ) )
- {
- found = scopeIndex;
- }
- scopeIndex++;
- }
- // remove all JEE applications grid children
- grid.removeAll();
- // check if at least one application server is present
- if ( scopeListModel.size() < 1 )
- {
- return;
- }
- // update the scope select field selected index
- if ( found == -1 )
- {
- scopeField.setSelectedIndex( 0 );
- }
- else
- {
- scopeField.setSelectedIndex( found );
- }
- // update the application server name from the scope (in case of
- // application server deletion)
- applicationServerName = (String) scopeField.getSelectedItem();
-
- // add JEE applications grid header
- Label actionHeader = new Label( " " );
- actionHeader.setStyleName( "grid.header" );
- grid.add( actionHeader );
- Label nameHeader = new Label( Messages.getString( "name" ) );
- nameHeader.setStyleName( "grid.header" );
- grid.add( nameHeader );
- Label uriHeader = new Label( Messages.getString( "uri" ) );
- uriHeader.setStyleName( "grid.header" );
- grid.add( uriHeader );
- Label agentHeader = new Label( Messages.getString( "agent" ) );
- agentHeader.setStyleName( "grid.header" );
- grid.add( agentHeader );
- // add the JEE applications
- for ( Iterator applicationIterator = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- applicationServerName ).getJEEApplications().iterator(); applicationIterator.hasNext(); )
- {
- JEEApplication application = (JEEApplication) applicationIterator.next();
- // row
- Row row = new Row();
- row.setInsets( new Insets( 2 ) );
- row.setCellSpacing( new Extent( 2 ) );
- grid.add( row );
- // copy
- Button copyButton = new Button( Styles.PAGE_COPY );
- copyButton.setToolTipText( Messages.getString( "copy" ) );
- copyButton.setActionCommand( application.getName() );
- copyButton.addActionListener( copy );
- row.add( copyButton );
- // active
- Button activeButton;
- if ( application.isActive() )
- {
- activeButton = new Button( Styles.LIGHTBULB );
- activeButton.setToolTipText( Messages.getString( "switch.disable" ) );
- }
- else
- {
- activeButton = new Button( Styles.LIGHTBULB_OFF );
- activeButton.setToolTipText( Messages.getString( "switch.enable" ) );
- }
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- activeButton.setActionCommand( application.getName() );
- activeButton.addActionListener( toggleActive );
- }
- row.add( activeButton );
- // blocker
- Button blockerButton;
- if ( application.isBlocker() )
- {
- blockerButton = new Button( Styles.PLUGIN );
- blockerButton.setToolTipText( Messages.getString( "switch.notblocker" ) );
- }
- else
- {
- blockerButton = new Button( Styles.PLUGIN_DISABLED );
- blockerButton.setToolTipText( Messages.getString( "switch.blocker" ) );
- }
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- blockerButton.setActionCommand( application.getName() );
- blockerButton.addActionListener( toggleBlocker );
- }
- row.add( blockerButton );
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- // up
- Button upButton = new Button( Styles.ARROW_UP );
- upButton.setToolTipText( Messages.getString( "up" ) );
- upButton.setActionCommand( application.getName() );
- upButton.addActionListener( up );
- row.add( upButton );
- // down
- Button downButton = new Button( Styles.ARROW_DOWN );
- downButton.setToolTipText( Messages.getString( "down" ) );
- downButton.setActionCommand( application.getName() );
- downButton.addActionListener( down );
- row.add( downButton );
- }
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsUpdatePermission )
- {
- // update
- Button updateButton = new Button( Styles.COG );
- updateButton.setToolTipText( Messages.getString( "update" ) );
- updateButton.setActionCommand( application.getName() );
- updateButton.addActionListener( update );
- row.add( updateButton );
- }
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeApplicationsChangePermission)
- {
- // apply
- Button applyButton = new Button( Styles.ACCEPT );
- applyButton.setToolTipText( Messages.getString( "apply" ) );
- applyButton.setActionCommand( application.getName() );
- applyButton.addActionListener( apply );
- row.add( applyButton );
- // delete
- Button deleteButton = new Button( Styles.DELETE );
- deleteButton.setToolTipText( Messages.getString( "delete" ) );
- deleteButton.setActionCommand( application.getName() );
- deleteButton.addActionListener( delete );
- row.add( deleteButton );
- }
- // name
- Button nameField = new Button( application.getName() );
- nameField.setStyleName( "default" );
- nameField.setActionCommand( application.getName() );
- nameField.addActionListener( edit );
- grid.add( nameField );
- // uri
- Row uriRow = new Row();
- grid.add( uriRow );
- TextField uriField = new TextField();
- uriField.setStyleName( "default" );
- uriField.setWidth( new Extent( 500, Extent.PX ) );
- uriField.setId(
- "applicationuri_" + parent.getEnvironmentName() + "_" + applicationServerName + "_" + application.getName() );
- uriField.setText( application.getUri() );
- uriRow.add( uriField );
- // test
- Button testUriButton = new Button( Styles.WORLD );
- testUriButton.setToolTipText( Messages.getString( "uri.test" ) );
- testUriButton.setActionCommand( application.getName() );
- testUriButton.addActionListener( testUri );
- uriRow.add( testUriButton );
- // agent
- Label agent = new Label( application.getAgent() );
- agent.setStyleName( "default" );
- grid.add( agent );
- }
- }
-
- /**
- * Return the parent <code>EnvironmentWindow</code>.
- *
- * @return the parent <code>EnvironmentWindow</code>.
- */
- public EnvironmentWindow getEnvironmentWindow()
- {
- return this.parent;
- }
}
\ No newline at end of file
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/CheckerPane.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/CheckerPane.java
index 22b3ade..8000416 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/CheckerPane.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/CheckerPane.java
@@ -28,1351 +28,1383 @@
import nextapp.echo2.app.event.ActionEvent;
import nextapp.echo2.app.event.ActionListener;
import org.apache.kalumet.console.configuration.ConfigurationManager;
-import org.apache.kalumet.model.*;
+import org.apache.kalumet.model.Agent;
+import org.apache.kalumet.model.Archive;
+import org.apache.kalumet.model.ConfigurationFile;
+import org.apache.kalumet.model.JDBCConnectionPool;
+import org.apache.kalumet.model.JDBCDataSource;
import org.apache.kalumet.model.JEEApplication;
-import org.apache.kalumet.ws.client.*;
+import org.apache.kalumet.model.JEEApplicationServer;
+import org.apache.kalumet.model.JMSConnectionFactory;
+import org.apache.kalumet.model.JMSServer;
+import org.apache.kalumet.model.JNDIBinding;
+import org.apache.kalumet.model.Kalumet;
+import org.apache.kalumet.model.SharedLibrary;
+import org.apache.kalumet.ws.client.AgentClient;
+import org.apache.kalumet.ws.client.ArchiveClient;
+import org.apache.kalumet.ws.client.ConfigurationFileClient;
+import org.apache.kalumet.ws.client.JDBCConnectionPoolClient;
+import org.apache.kalumet.ws.client.JDBCDataSourceClient;
import org.apache.kalumet.ws.client.JEEApplicationServerClient;
+import org.apache.kalumet.ws.client.JMSConnectionFactoryClient;
+import org.apache.kalumet.ws.client.JMSServerClient;
+import org.apache.kalumet.ws.client.JNDIBindingClient;
+import org.apache.kalumet.ws.client.SharedLibraryClient;
import java.util.Iterator;
// Version Thread
class VersionThread
- extends Thread
+ extends Thread
{
- private String hostname;
+ private String hostname;
- private int port;
+ private int port;
- private boolean completed = false;
+ private boolean completed = false;
- private boolean failure = false;
+ private boolean failure = false;
- private String errorMessage;
+ private String errorMessage;
- private String version;
+ private String version;
- public VersionThread( String hostname, int port )
- {
- this.hostname = hostname;
- this.port = port;
- }
-
- public boolean getCompleted()
- {
- return this.completed;
- }
-
- public boolean getFailure()
- {
- return this.failure;
- }
-
- public String getErrorMessage()
- {
- return this.errorMessage;
- }
-
- public String getVersion()
- {
- return this.version;
- }
-
- public void run()
- {
- try
+ public VersionThread( String hostname, int port )
{
- // call the webservice
- AgentClient webServiceClient = new AgentClient( hostname, port );
- version = webServiceClient.getVersion();
- completed = true;
+ this.hostname = hostname;
+ this.port = port;
}
- catch ( Exception e )
+
+ public boolean getCompleted()
{
- errorMessage = e.getMessage();
- completed = true;
- failure = true;
+ return this.completed;
}
- }
+
+ public boolean getFailure()
+ {
+ return this.failure;
+ }
+
+ public String getErrorMessage()
+ {
+ return this.errorMessage;
+ }
+
+ public String getVersion()
+ {
+ return this.version;
+ }
+
+ public void run()
+ {
+ try
+ {
+ // call the webservice
+ AgentClient webServiceClient = new AgentClient( hostname, port );
+ version = webServiceClient.getVersion();
+ completed = true;
+ }
+ catch ( Exception e )
+ {
+ errorMessage = e.getMessage();
+ completed = true;
+ failure = true;
+ }
+ }
}
// ApplicationServerStatusThread
class ApplicationServerStatusThread
- extends Thread
+ extends Thread
{
- private String hostname;
+ private String hostname;
- private int port;
+ private int port;
- private String environmentName;
+ private String environmentName;
- private String applicationServerName;
+ private String applicationServerName;
- private boolean completed = false;
+ private boolean completed = false;
- private boolean failure = false;
+ private boolean failure = false;
- private String errorMessage;
+ private String errorMessage;
- private String status;
+ private String status;
- public ApplicationServerStatusThread( String hostname, int port, String environmentName,
- String applicationServerName )
- {
- this.hostname = hostname;
- this.port = port;
- this.environmentName = environmentName;
- this.applicationServerName = applicationServerName;
- }
-
- public boolean getCompleted()
- {
- return this.completed;
- }
-
- public boolean getFailure()
- {
- return this.failure;
- }
-
- public String getErrorMessage()
- {
- return this.errorMessage;
- }
-
- public String getStatus()
- {
- return this.status;
- }
-
- public void run()
- {
- try
+ public ApplicationServerStatusThread( String hostname, int port, String environmentName,
+ String applicationServerName )
{
- // call the webservice
- JEEApplicationServerClient webServiceClient = new JEEApplicationServerClient( hostname, port );
- status = webServiceClient.status( environmentName, applicationServerName );
- completed = true;
+ this.hostname = hostname;
+ this.port = port;
+ this.environmentName = environmentName;
+ this.applicationServerName = applicationServerName;
}
- catch ( Exception e )
+
+ public boolean getCompleted()
{
- errorMessage = e.getMessage();
- completed = true;
- failure = true;
+ return this.completed;
}
- }
+
+ public boolean getFailure()
+ {
+ return this.failure;
+ }
+
+ public String getErrorMessage()
+ {
+ return this.errorMessage;
+ }
+
+ public String getStatus()
+ {
+ return this.status;
+ }
+
+ public void run()
+ {
+ try
+ {
+ // call the webservice
+ JEEApplicationServerClient webServiceClient = new JEEApplicationServerClient( hostname, port );
+ status = webServiceClient.status( environmentName, applicationServerName );
+ completed = true;
+ }
+ catch ( Exception e )
+ {
+ errorMessage = e.getMessage();
+ completed = true;
+ failure = true;
+ }
+ }
}
// ConnectionPoolCheckThread
class ConnectionPoolCheckThread
- extends Thread
+ extends Thread
{
- private String hostname;
+ private String hostname;
- private int port;
+ private int port;
- private String environmentName;
+ private String environmentName;
- private String applicationServerName;
+ private String applicationServerName;
- private String connectionPoolName;
+ private String connectionPoolName;
- private boolean completed = false;
+ private boolean completed = false;
- private boolean failure = false;
+ private boolean failure = false;
- private String errorMessage;
+ private String errorMessage;
- private boolean uptodate;
+ private boolean uptodate;
- public ConnectionPoolCheckThread( String hostname, int port, String environmentName, String applicationServerName,
- String connectionPoolName )
- {
- this.hostname = hostname;
- this.port = port;
- this.environmentName = environmentName;
- this.applicationServerName = applicationServerName;
- this.connectionPoolName = connectionPoolName;
- }
-
- public boolean getCompleted()
- {
- return this.completed;
- }
-
- public boolean getFailure()
- {
- return this.failure;
- }
-
- public String getErrorMessage()
- {
- return this.errorMessage;
- }
-
- public boolean getUptodate()
- {
- return this.uptodate;
- }
-
- public void run()
- {
- try
+ public ConnectionPoolCheckThread( String hostname, int port, String environmentName, String applicationServerName,
+ String connectionPoolName )
{
- // call the webservice
- JDBCConnectionPoolClient webServiceClient = new JDBCConnectionPoolClient( hostname, port );
- uptodate = webServiceClient.check( environmentName, applicationServerName, connectionPoolName );
- completed = true;
+ this.hostname = hostname;
+ this.port = port;
+ this.environmentName = environmentName;
+ this.applicationServerName = applicationServerName;
+ this.connectionPoolName = connectionPoolName;
}
- catch ( Exception e )
+
+ public boolean getCompleted()
{
- errorMessage = e.getMessage();
- completed = true;
- failure = true;
+ return this.completed;
}
- }
+
+ public boolean getFailure()
+ {
+ return this.failure;
+ }
+
+ public String getErrorMessage()
+ {
+ return this.errorMessage;
+ }
+
+ public boolean getUptodate()
+ {
+ return this.uptodate;
+ }
+
+ public void run()
+ {
+ try
+ {
+ // call the webservice
+ JDBCConnectionPoolClient webServiceClient = new JDBCConnectionPoolClient( hostname, port );
+ uptodate = webServiceClient.check( environmentName, applicationServerName, connectionPoolName );
+ completed = true;
+ }
+ catch ( Exception e )
+ {
+ errorMessage = e.getMessage();
+ completed = true;
+ failure = true;
+ }
+ }
}
// DataSourceCheckThread
class DataSourceCheckThread
- extends Thread
+ extends Thread
{
- private String hostname;
+ private String hostname;
- private int port;
+ private int port;
- private String environmentName;
+ private String environmentName;
- private String applicationServerName;
+ private String applicationServerName;
- private String dataSourceName;
+ private String dataSourceName;
- private boolean completed = false;
+ private boolean completed = false;
- private boolean failure = false;
+ private boolean failure = false;
- private String errorMessage;
+ private String errorMessage;
- private boolean uptodate;
+ private boolean uptodate;
- public DataSourceCheckThread( String hostname, int port, String environmentName, String applicationServerName,
- String dataSourceName )
- {
- this.hostname = hostname;
- this.port = port;
- this.environmentName = environmentName;
- this.applicationServerName = applicationServerName;
- this.dataSourceName = dataSourceName;
- }
-
- public boolean getCompleted()
- {
- return this.completed;
- }
-
- public boolean getFailure()
- {
- return this.failure;
- }
-
- public String getErrorMessage()
- {
- return this.errorMessage;
- }
-
- public boolean getUptodate()
- {
- return this.uptodate;
- }
-
- public void run()
- {
- try
+ public DataSourceCheckThread( String hostname, int port, String environmentName, String applicationServerName,
+ String dataSourceName )
{
- // call the webservice
- JDBCDataSourceClient webServiceClient = new JDBCDataSourceClient( hostname, port );
- uptodate = webServiceClient.check( environmentName, applicationServerName, dataSourceName );
- completed = true;
+ this.hostname = hostname;
+ this.port = port;
+ this.environmentName = environmentName;
+ this.applicationServerName = applicationServerName;
+ this.dataSourceName = dataSourceName;
}
- catch ( Exception e )
+
+ public boolean getCompleted()
{
- errorMessage = e.getMessage();
- completed = true;
- failure = true;
+ return this.completed;
}
- }
+
+ public boolean getFailure()
+ {
+ return this.failure;
+ }
+
+ public String getErrorMessage()
+ {
+ return this.errorMessage;
+ }
+
+ public boolean getUptodate()
+ {
+ return this.uptodate;
+ }
+
+ public void run()
+ {
+ try
+ {
+ // call the webservice
+ JDBCDataSourceClient webServiceClient = new JDBCDataSourceClient( hostname, port );
+ uptodate = webServiceClient.check( environmentName, applicationServerName, dataSourceName );
+ completed = true;
+ }
+ catch ( Exception e )
+ {
+ errorMessage = e.getMessage();
+ completed = true;
+ failure = true;
+ }
+ }
}
// JMSConnectionFactoryCheckThread
class JMSConnectionFactoryCheckThread
- extends Thread
+ extends Thread
{
- private String hostname;
+ private String hostname;
- private int port;
+ private int port;
- private String environmentName;
+ private String environmentName;
- private String applicationServerName;
+ private String applicationServerName;
- private String jmsConnectionFactoryName;
+ private String jmsConnectionFactoryName;
- private boolean completed = false;
+ private boolean completed = false;
- private boolean failure = false;
+ private boolean failure = false;
- private String errorMessage;
+ private String errorMessage;
- private boolean uptodate;
+ private boolean uptodate;
- public JMSConnectionFactoryCheckThread( String hostname, int port, String environmentName,
- String applicationServerName, String jmsConnectionFactoryName )
- {
- this.hostname = hostname;
- this.port = port;
- this.environmentName = environmentName;
- this.applicationServerName = applicationServerName;
- this.jmsConnectionFactoryName = jmsConnectionFactoryName;
- }
-
- public boolean getCompleted()
- {
- return this.completed;
- }
-
- public boolean getFailure()
- {
- return this.failure;
- }
-
- public String getErrorMessage()
- {
- return this.errorMessage;
- }
-
- public boolean getUptodate()
- {
- return this.uptodate;
- }
-
- public void run()
- {
- try
+ public JMSConnectionFactoryCheckThread( String hostname, int port, String environmentName,
+ String applicationServerName, String jmsConnectionFactoryName )
{
- // call the webservice
- JMSConnectionFactoryClient webServiceClient = new JMSConnectionFactoryClient( hostname, port );
- uptodate = webServiceClient.check( environmentName, applicationServerName, jmsConnectionFactoryName );
- completed = true;
+ this.hostname = hostname;
+ this.port = port;
+ this.environmentName = environmentName;
+ this.applicationServerName = applicationServerName;
+ this.jmsConnectionFactoryName = jmsConnectionFactoryName;
}
- catch ( Exception e )
+
+ public boolean getCompleted()
{
- errorMessage = e.getMessage();
- completed = true;
- failure = true;
+ return this.completed;
}
- }
+
+ public boolean getFailure()
+ {
+ return this.failure;
+ }
+
+ public String getErrorMessage()
+ {
+ return this.errorMessage;
+ }
+
+ public boolean getUptodate()
+ {
+ return this.uptodate;
+ }
+
+ public void run()
+ {
+ try
+ {
+ // call the webservice
+ JMSConnectionFactoryClient webServiceClient = new JMSConnectionFactoryClient( hostname, port );
+ uptodate = webServiceClient.check( environmentName, applicationServerName, jmsConnectionFactoryName );
+ completed = true;
+ }
+ catch ( Exception e )
+ {
+ errorMessage = e.getMessage();
+ completed = true;
+ failure = true;
+ }
+ }
}
// JMSServerCheckThread
class JMSServerCheckThread
- extends Thread
+ extends Thread
{
- private String hostname;
+ private String hostname;
- private int port;
+ private int port;
- private String environmentName;
+ private String environmentName;
- private String applicationServerName;
+ private String applicationServerName;
- private String jmsServerName;
+ private String jmsServerName;
- private boolean completed = false;
+ private boolean completed = false;
- private boolean failure = false;
+ private boolean failure = false;
- private String errorMessage;
+ private String errorMessage;
- private boolean uptodate;
+ private boolean uptodate;
- public JMSServerCheckThread( String hostname, int port, String environmentName, String applicationServerName,
- String jmsServerName )
- {
- this.hostname = hostname;
- this.port = port;
- this.environmentName = environmentName;
- this.applicationServerName = applicationServerName;
- this.jmsServerName = jmsServerName;
- }
-
- public boolean getCompleted()
- {
- return this.completed;
- }
-
- public boolean getFailure()
- {
- return this.failure;
- }
-
- public String getErrorMessage()
- {
- return this.errorMessage;
- }
-
- public boolean getUptodate()
- {
- return this.uptodate;
- }
-
- public void run()
- {
- try
+ public JMSServerCheckThread( String hostname, int port, String environmentName, String applicationServerName,
+ String jmsServerName )
{
- // call the webservice
- JMSServerClient webServiceClient = new JMSServerClient( hostname, port );
- uptodate = webServiceClient.check( environmentName, applicationServerName, jmsServerName );
- completed = true;
+ this.hostname = hostname;
+ this.port = port;
+ this.environmentName = environmentName;
+ this.applicationServerName = applicationServerName;
+ this.jmsServerName = jmsServerName;
}
- catch ( Exception e )
+
+ public boolean getCompleted()
{
- errorMessage = e.getMessage();
- completed = true;
- failure = true;
+ return this.completed;
}
- }
+
+ public boolean getFailure()
+ {
+ return this.failure;
+ }
+
+ public String getErrorMessage()
+ {
+ return this.errorMessage;
+ }
+
+ public boolean getUptodate()
+ {
+ return this.uptodate;
+ }
+
+ public void run()
+ {
+ try
+ {
+ // call the webservice
+ JMSServerClient webServiceClient = new JMSServerClient( hostname, port );
+ uptodate = webServiceClient.check( environmentName, applicationServerName, jmsServerName );
+ completed = true;
+ }
+ catch ( Exception e )
+ {
+ errorMessage = e.getMessage();
+ completed = true;
+ failure = true;
+ }
+ }
}
// JNDIBindingCheckThread
class JNDIBindingCheckThread
- extends Thread
+ extends Thread
{
- private String hostname;
+ private String hostname;
- private int port;
+ private int port;
- private String environmentName;
+ private String environmentName;
- private String applicationServerName;
+ private String applicationServerName;
- private String nameSpaceBindingName;
+ private String nameSpaceBindingName;
- private boolean completed = false;
+ private boolean completed = false;
- private boolean failure = false;
+ private boolean failure = false;
- private String errorMessage;
+ private String errorMessage;
- private boolean uptodate;
+ private boolean uptodate;
- public JNDIBindingCheckThread( String hostname, int port, String environmentName, String applicationServerName,
- String nameSpaceBindingName )
- {
- this.hostname = hostname;
- this.port = port;
- this.environmentName = environmentName;
- this.applicationServerName = applicationServerName;
- this.nameSpaceBindingName = nameSpaceBindingName;
- }
-
- public boolean getCompleted()
- {
- return this.completed;
- }
-
- public boolean getFailure()
- {
- return this.failure;
- }
-
- public String getErrorMessage()
- {
- return this.errorMessage;
- }
-
- public boolean getUptodate()
- {
- return this.uptodate;
- }
-
- public void run()
- {
- try
+ public JNDIBindingCheckThread( String hostname, int port, String environmentName, String applicationServerName,
+ String nameSpaceBindingName )
{
- // call the webservice
- JNDIBindingClient webServiceClient = new JNDIBindingClient( hostname, port );
- uptodate = webServiceClient.check( environmentName, applicationServerName, nameSpaceBindingName );
- completed = true;
+ this.hostname = hostname;
+ this.port = port;
+ this.environmentName = environmentName;
+ this.applicationServerName = applicationServerName;
+ this.nameSpaceBindingName = nameSpaceBindingName;
}
- catch ( Exception e )
+
+ public boolean getCompleted()
{
- errorMessage = e.getMessage();
- completed = true;
- failure = true;
+ return this.completed;
}
- }
+
+ public boolean getFailure()
+ {
+ return this.failure;
+ }
+
+ public String getErrorMessage()
+ {
+ return this.errorMessage;
+ }
+
+ public boolean getUptodate()
+ {
+ return this.uptodate;
+ }
+
+ public void run()
+ {
+ try
+ {
+ // call the webservice
+ JNDIBindingClient webServiceClient = new JNDIBindingClient( hostname, port );
+ uptodate = webServiceClient.check( environmentName, applicationServerName, nameSpaceBindingName );
+ completed = true;
+ }
+ catch ( Exception e )
+ {
+ errorMessage = e.getMessage();
+ completed = true;
+ failure = true;
+ }
+ }
}
// SharedLibraryCheckThread
class SharedLibraryCheckThread
- extends Thread
+ extends Thread
{
- private String hostname;
+ private String hostname;
- private int port;
+ private int port;
- private String environmentName;
+ private String environmentName;
- private String applicationServerName;
+ private String applicationServerName;
- private String sharedLibraryName;
+ private String sharedLibraryName;
- private boolean completed = false;
+ private boolean completed = false;
- private boolean failure = false;
+ private boolean failure = false;
- private String errorMessage;
+ private String errorMessage;
- private boolean uptodate;
+ private boolean uptodate;
- public SharedLibraryCheckThread( String hostname, int port, String environmentName, String applicationServerName,
- String sharedLibraryName )
- {
- this.hostname = hostname;
- this.port = port;
- this.environmentName = environmentName;
- this.applicationServerName = applicationServerName;
- this.sharedLibraryName = sharedLibraryName;
- }
-
- public boolean getCompleted()
- {
- return this.completed;
- }
-
- public boolean getFailure()
- {
- return this.failure;
- }
-
- public String getErrorMessage()
- {
- return this.errorMessage;
- }
-
- public boolean getUptodate()
- {
- return this.uptodate;
- }
-
- public void run()
- {
- try
+ public SharedLibraryCheckThread( String hostname, int port, String environmentName, String applicationServerName,
+ String sharedLibraryName )
{
- // call the webservice
- SharedLibraryClient webServiceClient = new SharedLibraryClient( hostname, port );
- uptodate = webServiceClient.check( environmentName, applicationServerName, sharedLibraryName );
- completed = true;
+ this.hostname = hostname;
+ this.port = port;
+ this.environmentName = environmentName;
+ this.applicationServerName = applicationServerName;
+ this.sharedLibraryName = sharedLibraryName;
}
- catch ( Exception e )
+
+ public boolean getCompleted()
{
- errorMessage = e.getMessage();
- completed = true;
- failure = true;
+ return this.completed;
}
- }
+
+ public boolean getFailure()
+ {
+ return this.failure;
+ }
+
+ public String getErrorMessage()
+ {
+ return this.errorMessage;
+ }
+
+ public boolean getUptodate()
+ {
+ return this.uptodate;
+ }
+
+ public void run()
+ {
+ try
+ {
+ // call the webservice
+ SharedLibraryClient webServiceClient = new SharedLibraryClient( hostname, port );
+ uptodate = webServiceClient.check( environmentName, applicationServerName, sharedLibraryName );
+ completed = true;
+ }
+ catch ( Exception e )
+ {
+ errorMessage = e.getMessage();
+ completed = true;
+ failure = true;
+ }
+ }
}
// JEEApplicationArchiveCheckThread
class JEEApplicationArchiveCheckThread
- extends Thread
+ extends Thread
{
- private String hostname;
+ private String hostname;
- private int port;
+ private int port;
- private String environmentName;
+ private String environmentName;
- private String applicationServerName;
+ private String applicationServerName;
- private String applicationName;
+ private String applicationName;
- private String archiveName;
+ private String archiveName;
- private boolean completed = false;
+ private boolean completed = false;
- private boolean failure = false;
+ private boolean failure = false;
- private String errorMessage;
+ private String errorMessage;
- private boolean uptodate;
+ private boolean uptodate;
- public JEEApplicationArchiveCheckThread(String hostname, int port, String environmentName,
- String applicationServerName, String applicationName, String archiveName)
- {
- this.hostname = hostname;
- this.port = port;
- this.environmentName = environmentName;
- this.applicationServerName = applicationServerName;
- this.applicationName = applicationName;
- this.archiveName = archiveName;
- }
-
- public boolean getCompleted()
- {
- return this.completed;
- }
-
- public boolean getFailure()
- {
- return this.failure;
- }
-
- public String getErrorMessage()
- {
- return this.errorMessage;
- }
-
- public boolean getUptodate()
- {
- return this.uptodate;
- }
-
- public void run()
- {
- try
+ public JEEApplicationArchiveCheckThread( String hostname, int port, String environmentName,
+ String applicationServerName, String applicationName, String archiveName )
{
- // call the webservice
- ArchiveClient webServiceClient = new ArchiveClient( hostname, port );
- uptodate = webServiceClient.check( environmentName, applicationServerName, applicationName, archiveName );
- completed = true;
+ this.hostname = hostname;
+ this.port = port;
+ this.environmentName = environmentName;
+ this.applicationServerName = applicationServerName;
+ this.applicationName = applicationName;
+ this.archiveName = archiveName;
}
- catch ( Exception e )
+
+ public boolean getCompleted()
{
- errorMessage = e.getMessage();
- completed = true;
- failure = true;
+ return this.completed;
}
- }
+
+ public boolean getFailure()
+ {
+ return this.failure;
+ }
+
+ public String getErrorMessage()
+ {
+ return this.errorMessage;
+ }
+
+ public boolean getUptodate()
+ {
+ return this.uptodate;
+ }
+
+ public void run()
+ {
+ try
+ {
+ // call the webservice
+ ArchiveClient webServiceClient = new ArchiveClient( hostname, port );
+ uptodate = webServiceClient.check( environmentName, applicationServerName, applicationName, archiveName );
+ completed = true;
+ }
+ catch ( Exception e )
+ {
+ errorMessage = e.getMessage();
+ completed = true;
+ failure = true;
+ }
+ }
}
// JEEApplicationConfigurationFileCheckThread
class JEEApplicationConfigurationFileCheckThread
- extends Thread
+ extends Thread
{
- private String hostname;
+ private String hostname;
- private int port;
+ private int port;
- private String environmentName;
+ private String environmentName;
- private String applicationServerName;
+ private String applicationServerName;
- private String applicationName;
+ private String applicationName;
- private String configurationFileName;
+ private String configurationFileName;
- private boolean completed = false;
+ private boolean completed = false;
- private boolean failure = false;
+ private boolean failure = false;
- private String errorMessage;
+ private String errorMessage;
- private boolean uptodate;
+ private boolean uptodate;
- public JEEApplicationConfigurationFileCheckThread(String hostname, int port, String environmentName,
- String applicationServerName, String applicationName,
- String configurationFileName)
- {
- this.hostname = hostname;
- this.port = port;
- this.environmentName = environmentName;
- this.applicationServerName = applicationServerName;
- this.applicationName = applicationName;
- this.configurationFileName = configurationFileName;
- }
-
- public boolean getCompleted()
- {
- return this.completed;
- }
-
- public boolean getFailure()
- {
- return this.failure;
- }
-
- public String getErrorMessage()
- {
- return this.errorMessage;
- }
-
- public boolean getUptodate()
- {
- return this.uptodate;
- }
-
- public void run()
- {
- try
+ public JEEApplicationConfigurationFileCheckThread( String hostname, int port, String environmentName,
+ String applicationServerName, String applicationName,
+ String configurationFileName )
{
- // call the webservice
- ConfigurationFileClient webServiceClient = new ConfigurationFileClient( hostname, port );
- uptodate =
- webServiceClient.check( environmentName, applicationServerName, applicationName, configurationFileName );
- completed = true;
+ this.hostname = hostname;
+ this.port = port;
+ this.environmentName = environmentName;
+ this.applicationServerName = applicationServerName;
+ this.applicationName = applicationName;
+ this.configurationFileName = configurationFileName;
}
- catch ( Exception e )
+
+ public boolean getCompleted()
{
- errorMessage = e.getMessage();
- completed = true;
- failure = true;
+ return this.completed;
}
- }
+
+ public boolean getFailure()
+ {
+ return this.failure;
+ }
+
+ public String getErrorMessage()
+ {
+ return this.errorMessage;
+ }
+
+ public boolean getUptodate()
+ {
+ return this.uptodate;
+ }
+
+ public void run()
+ {
+ try
+ {
+ // call the webservice
+ ConfigurationFileClient webServiceClient = new ConfigurationFileClient( hostname, port );
+ uptodate = webServiceClient.check( environmentName, applicationServerName, applicationName,
+ configurationFileName );
+ completed = true;
+ }
+ catch ( Exception e )
+ {
+ errorMessage = e.getMessage();
+ completed = true;
+ failure = true;
+ }
+ }
}
/**
* Environment checker pane.
*/
public class CheckerPane
- extends ContentPane
+ extends ContentPane
{
- private EnvironmentWindow parent;
+ private EnvironmentWindow parent;
- private Grid grid;
+ private Grid grid;
- // launch
- private ActionListener launch = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // launch
+ private ActionListener launch = new ActionListener()
{
- // check if no modifications are in progress
- if ( parent.isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.locked" ) );
- return;
- }
- // get the agent for the environment
- // load Kalumet configuration
- Kalumet kalumet;
- try
- {
- kalumet = ConfigurationManager.loadStore();
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError(
- Messages.getString( "db.read" ) + ": " + e.getMessage() );
- return;
- }
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
- if ( agent == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "agent.notfound" ) );
- return;
- }
- // put message in the action log pane
- KalumetConsoleApplication.getApplication().getLogPane().addInfo( "Check in progress ..." );
- // clean the results grid
- grid.removeAll();
- // agent check
- Label agentCheck = new Label( "Kalumet agent check" );
- agentCheck.setStyleName( "default" );
- grid.add( agentCheck );
- final Label agentVersionLabel = new Label();
- agentVersionLabel.setStyleName( "default" );
- grid.add( agentVersionLabel );
- final Label agentButton = new Label();
- grid.add( agentButton );
- // launch the version thread
- final VersionThread versionThread = new VersionThread( agent.getHostname(), agent.getPort() );
- versionThread.start();
- // launch the synchronization task for the agent version
- KalumetConsoleApplication.getApplication().enqueueTask( KalumetConsoleApplication.getApplication().getTaskQueue(),
- new Runnable()
- {
- public void run()
- {
- if ( versionThread.getCompleted() )
- {
- if ( versionThread.getFailure() )
- {
- agentVersionLabel.setText( "Agent error: "
- + versionThread.getErrorMessage() );
- agentButton.setIcon( Styles.EXCLAMATION );
- }
- else
- {
- agentVersionLabel.setText(
- versionThread.getVersion() );
- agentButton.setIcon( Styles.ACCEPT );
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(),
- this );
- }
- }
- } );
- // application servers check
- for ( Iterator applicationServerIterator =
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServers().iterator();
- applicationServerIterator.hasNext(); )
- {
- JEEApplicationServer applicationServer = (JEEApplicationServer) applicationServerIterator.next();
- Label applicationServerLabel = new Label( "JEE server " + applicationServer.getName() + " check" );
- applicationServerLabel.setStyleName( "default" );
- grid.add( applicationServerLabel );
- final Label applicationServerStatusLabel = new Label();
- applicationServerStatusLabel.setStyleName( "default" );
- grid.add( applicationServerStatusLabel );
- final Label applicationServerStatusButton = new Label();
- applicationServerStatusButton.setStyleName( "default" );
- grid.add( applicationServerStatusButton );
- // launch the application server status thread
- final ApplicationServerStatusThread applicationServerStatusThread =
- new ApplicationServerStatusThread( agent.getHostname(), agent.getPort(), parent.getEnvironmentName(),
- applicationServer.getName() );
- applicationServerStatusThread.start();
- // launch the synchronisation status thread
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ public void actionPerformed( ActionEvent event )
{
- public void run()
- {
- if ( applicationServerStatusThread.getCompleted() )
+ // check if no modifications are in progress
+ if ( parent.isUpdated() )
{
- if ( applicationServerStatusThread.getFailure() )
- {
- applicationServerStatusLabel.setText(
- "JEE application server error: " + applicationServerStatusThread.getErrorMessage() );
- applicationServerStatusButton.setIcon( Styles.EXCLAMATION );
- }
- else
- {
- applicationServerStatusLabel.setText( applicationServerStatusThread.getStatus() );
- applicationServerStatusButton.setIcon( Styles.ACCEPT );
- }
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ) );
+ return;
}
- else
+ // get the agent for the environment
+ // load Kalumet configuration
+ Kalumet kalumet;
+ try
{
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ kalumet = ConfigurationManager.loadStore();
}
- }
- } );
- // check connection pool
- for ( Iterator connectionPoolIterator = applicationServer.getJDBCConnectionPools().iterator();
- connectionPoolIterator.hasNext(); )
- {
- JDBCConnectionPool connectionPool = (JDBCConnectionPool) connectionPoolIterator.next();
- Label connectionPoolLabel = new Label( " JDBC connection pool " + connectionPool.getName() + " check" );
- connectionPoolLabel.setStyleName( "default" );
- grid.add( connectionPoolLabel );
- final Label connectionPoolStatusLabel = new Label();
- connectionPoolStatusLabel.setStyleName( "default" );
- grid.add( connectionPoolStatusLabel );
- final Label connectionPoolButton = new Label();
- grid.add( connectionPoolButton );
- // launch the connection pool check thread
- final ConnectionPoolCheckThread connectionPoolCheckThread =
- new ConnectionPoolCheckThread( agent.getHostname(), agent.getPort(), parent.getEnvironmentName(),
- applicationServer.getName(), connectionPool.getName() );
- connectionPoolCheckThread.start();
- // launch the synchronisation thread
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
- {
- public void run()
+ catch ( Exception e )
{
- if ( connectionPoolCheckThread.getCompleted() )
- {
- if ( connectionPoolCheckThread.getFailure() )
- {
- connectionPoolStatusLabel.setText(
- "JDBC connection pool check error: " + connectionPoolCheckThread.getErrorMessage() );
- connectionPoolButton.setIcon( Styles.EXCLAMATION );
- }
- else
- {
- if ( connectionPoolCheckThread.getUptodate() )
- {
- connectionPoolStatusLabel.setText( "OK" );
- connectionPoolButton.setIcon( Styles.ACCEPT );
- }
- else
- {
- connectionPoolStatusLabel.setText( "JDBC Connection Pool is not deployed or not up to date" );
- connectionPoolButton.setIcon( Styles.EXCLAMATION );
- }
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ Messages.getString( "db.read" ) + ": " + e.getMessage() );
+ return;
}
- } );
- }
- // check datasources
- for ( Iterator dataSourceIterator = applicationServer.getJDBCDataSources().iterator();
- dataSourceIterator.hasNext(); )
- {
- JDBCDataSource dataSource = (JDBCDataSource) dataSourceIterator.next();
- Label dataSourceLabel = new Label( " JDBC data source " + dataSource.getName() + " check" );
- dataSourceLabel.setStyleName( "default" );
- grid.add( dataSourceLabel );
- final Label dataSourceStatusLabel = new Label();
- dataSourceStatusLabel.setStyleName( "Default" );
- grid.add( dataSourceStatusLabel );
- final Label dataSourceButton = new Label();
- grid.add( dataSourceButton );
- // launch the datasource check thread
- final DataSourceCheckThread dataSourceCheckThread =
- new DataSourceCheckThread( agent.getHostname(), agent.getPort(), parent.getEnvironmentName(),
- applicationServer.getName(), dataSource.getName() );
- dataSourceCheckThread.start();
- // launch the synchronisation thread
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
- {
- public void run()
+ // looking for the agent
+ Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
+ if ( agent == null )
{
- if ( dataSourceCheckThread.getCompleted() )
- {
- if ( dataSourceCheckThread.getFailure() )
- {
- dataSourceStatusLabel.setText(
- "JDBC data source check error: " + dataSourceCheckThread.getErrorMessage() );
- dataSourceButton.setIcon( Styles.EXCLAMATION );
- }
- else
- {
- if ( dataSourceCheckThread.getUptodate() )
- {
- dataSourceStatusLabel.setText( "OK" );
- dataSourceButton.setIcon( Styles.ACCEPT );
- }
- else
- {
- dataSourceStatusLabel.setText( "JDBC data source is not deployed or not up to date." );
- dataSourceButton.setIcon( Styles.EXCLAMATION );
- }
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "agent.notfound" ) );
+ return;
}
- } );
- }
- // check JMS connection factories
- for ( Iterator jmsConnectionFactoryIterator = applicationServer.getJMSConnectionFactories().iterator();
- jmsConnectionFactoryIterator.hasNext(); )
- {
- JMSConnectionFactory jmsConnectionFactory = (JMSConnectionFactory) jmsConnectionFactoryIterator.next();
- Label jmsConnectionFactoryLabel =
- new Label( " JMS connection factory " + jmsConnectionFactory.getName() + " check" );
- jmsConnectionFactoryLabel.setStyleName( "Default" );
- grid.add( jmsConnectionFactoryLabel );
- final Label jmsConnectionFactoryStatusLabel = new Label();
- jmsConnectionFactoryStatusLabel.setStyleName( "Default" );
- grid.add( jmsConnectionFactoryStatusLabel );
- final Label jmsConnectionFactoryButton = new Label();
- grid.add( jmsConnectionFactoryButton );
- // launch the jms connection factory check thread
- final JMSConnectionFactoryCheckThread jmsConnectionFactoryCheckThread =
- new JMSConnectionFactoryCheckThread( agent.getHostname(), agent.getPort(), parent.getEnvironmentName(),
- applicationServer.getName(), jmsConnectionFactory.getName() );
- jmsConnectionFactoryCheckThread.start();
- // launch the synchronisation thread
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
- {
- public void run()
- {
- if ( jmsConnectionFactoryCheckThread.getCompleted() )
- {
- if ( jmsConnectionFactoryCheckThread.getFailure() )
- {
- jmsConnectionFactoryStatusLabel.setText(
- "JMS connection factory check error: " + jmsConnectionFactoryCheckThread.getErrorMessage() );
- jmsConnectionFactoryButton.setIcon( Styles.EXCLAMATION );
- }
- else
- {
- if ( jmsConnectionFactoryCheckThread.getUptodate() )
- {
- jmsConnectionFactoryStatusLabel.setText( "OK" );
- jmsConnectionFactoryButton.setIcon( Styles.ACCEPT );
- }
- else
- {
- jmsConnectionFactoryStatusLabel.setText(
- "JMS connection factory is not deployed or not up to date" );
- jmsConnectionFactoryButton.setIcon( Styles.EXCLAMATION );
- }
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
- } );
- }
- // check JMS servers
- for ( Iterator jmsServerIterator = applicationServer.getJMSServers().iterator(); jmsServerIterator.hasNext(); )
- {
- JMSServer jmsServer = (JMSServer) jmsServerIterator.next();
- Label jmsServerLabel = new Label( " JMS server " + jmsServer.getName() + " check" );
- jmsServerLabel.setStyleName( "Default" );
- grid.add( jmsServerLabel );
- final Label jmsServerStatusLabel = new Label();
- jmsServerStatusLabel.setStyleName( "Default" );
- grid.add( jmsServerStatusLabel );
- final Label jmsServerButton = new Label();
- grid.add( jmsServerButton );
- // launch the jms server check thread
- final JMSServerCheckThread jmsServerCheckThread =
- new JMSServerCheckThread( agent.getHostname(), agent.getPort(), parent.getEnvironmentName(),
- applicationServer.getName(), jmsServer.getName() );
- jmsServerCheckThread.start();
- // launch the synchronisation thread
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
- {
- public void run()
- {
- if ( jmsServerCheckThread.getCompleted() )
- {
- if ( jmsServerCheckThread.getFailure() )
- {
- jmsServerStatusLabel.setText( "JMS server check error: " + jmsServerCheckThread.getErrorMessage() );
- jmsServerButton.setIcon( Styles.EXCLAMATION );
- }
- else
- {
- if ( jmsServerCheckThread.getUptodate() )
- {
- jmsServerStatusLabel.setText( "OK" );
- jmsServerButton.setIcon( Styles.ACCEPT );
- }
- else
- {
- jmsServerStatusLabel.setText( "JMS server is not deployed or not up to date" );
- jmsServerButton.setIcon( Styles.EXCLAMATION );
- }
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
- } );
- }
- // check JNDI bindings
- for ( Iterator jndiBindingIterator = applicationServer.getJNDIBindings().iterator();
- jndiBindingIterator.hasNext(); )
- {
- JNDIBinding jndiBinding = (JNDIBinding) jndiBindingIterator.next();
- Label nameSpaceBindingLabel = new Label( " JNDI binding " + jndiBinding.getName() + " check" );
- nameSpaceBindingLabel.setStyleName( "Default" );
- grid.add( nameSpaceBindingLabel );
- final Label nameSpaceBindingStatusLabel = new Label();
- nameSpaceBindingStatusLabel.setStyleName( "Default" );
- grid.add( nameSpaceBindingStatusLabel );
- final Label nameSpaceBindingButton = new Label();
- grid.add( nameSpaceBindingButton );
- // launch the name space binding check thread
- final JNDIBindingCheckThread JNDIBindingCheckThread =
- new JNDIBindingCheckThread( agent.getHostname(), agent.getPort(), parent.getEnvironmentName(),
- applicationServer.getName(), jndiBinding.getName() );
- JNDIBindingCheckThread.start();
- // launch the synchronisation thread
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
- {
- public void run()
- {
- if ( JNDIBindingCheckThread.getCompleted() )
- {
- if ( JNDIBindingCheckThread.getFailure() )
- {
- nameSpaceBindingStatusLabel.setText(
- "JNDI binding check error: " + JNDIBindingCheckThread.getErrorMessage() );
- nameSpaceBindingButton.setIcon( Styles.EXCLAMATION );
- }
- else
- {
- if ( JNDIBindingCheckThread.getUptodate() )
- {
- nameSpaceBindingStatusLabel.setText( "OK" );
- nameSpaceBindingButton.setIcon( Styles.ACCEPT );
- }
- else
- {
- nameSpaceBindingStatusLabel.setText( "JNDI binding is not deployed or not up to date" );
- nameSpaceBindingButton.setIcon( Styles.EXCLAMATION );
- }
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
- } );
- }
- // check shared libraries
- for ( Iterator sharedLibraryIterator = applicationServer.getSharedLibraries().iterator();
- sharedLibraryIterator.hasNext(); )
- {
- SharedLibrary sharedLibrary = (SharedLibrary) sharedLibraryIterator.next();
- Label sharedLibraryLabel = new Label( " Shared library " + sharedLibrary.getName() + " check" );
- sharedLibraryLabel.setStyleName( "Default" );
- grid.add( sharedLibraryLabel );
- final Label sharedLibraryStatusLabel = new Label();
- sharedLibraryStatusLabel.setStyleName( "Default" );
- grid.add( sharedLibraryLabel );
- final Label sharedLibraryButton = new Label();
- grid.add( sharedLibraryButton );
- // launch the shared library check thread
- final SharedLibraryCheckThread sharedLibraryCheckThread =
- new SharedLibraryCheckThread( agent.getHostname(), agent.getPort(), parent.getEnvironmentName(),
- applicationServer.getName(), sharedLibrary.getName() );
- sharedLibraryCheckThread.start();
- // launch the synchronisation thread
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
- {
- public void run()
- {
- if ( sharedLibraryCheckThread.getCompleted() )
- {
- if ( sharedLibraryCheckThread.getFailure() )
- {
- sharedLibraryStatusLabel.setText(
- "Shared library check error: " + sharedLibraryCheckThread.getErrorMessage() );
- sharedLibraryButton.setIcon( Styles.EXCLAMATION );
- }
- else
- {
- if ( sharedLibraryCheckThread.getUptodate() )
- {
- sharedLibraryStatusLabel.setText( "OK" );
- sharedLibraryButton.setIcon( Styles.ACCEPT );
- }
- else
- {
- sharedLibraryStatusLabel.setText( "Shared library is not deployed or not up to date" );
- sharedLibraryButton.setIcon( Styles.EXCLAMATION );
- }
- }
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
- } );
- }
- // check JEE applications
- for ( Iterator applicationIterator = applicationServer.getJEEApplications().iterator();
- applicationIterator.hasNext(); )
- {
- JEEApplication application = (JEEApplication) applicationIterator.next();
- Label applicationLabel = new Label( " JEE application " + application.getName() + " check" );
- applicationLabel.setStyleName( "Default" );
- grid.add( applicationLabel );
- Label blankLabel = new Label( " " );
- grid.add( blankLabel );
- blankLabel = new Label( " " );
- grid.add( blankLabel );
- // check JEE application archives
- for ( Iterator archiveIterator = application.getArchives().iterator(); archiveIterator.hasNext(); )
- {
- Archive archive = (Archive) archiveIterator.next();
- Label archiveLabel = new Label( " JEE application archive " + archive.getName() + " check" );
- archiveLabel.setStyleName( "Default" );
- grid.add( archiveLabel );
- final Label archiveStatusLabel = new Label();
- archiveStatusLabel.setStyleName( "Default" );
- grid.add( archiveStatusLabel );
- final Label archiveButton = new Label();
- grid.add( archiveButton );
- // launch the application archive check thread
- final JEEApplicationArchiveCheckThread jeeApplicationArchiveCheckThread =
- new JEEApplicationArchiveCheckThread( agent.getHostname(), agent.getPort(), parent.getEnvironmentName(),
- applicationServer.getName(), application.getName(),
- archive.getName() );
- jeeApplicationArchiveCheckThread.start();
- // launch the synchronisation thread
+ // put message in the action log pane
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo( "Check in progress ..." );
+ // clean the results grid
+ grid.removeAll();
+ // agent check
+ Label agentCheck = new Label( "Kalumet agent check" );
+ agentCheck.setStyleName( "default" );
+ grid.add( agentCheck );
+ final Label agentVersionLabel = new Label();
+ agentVersionLabel.setStyleName( "default" );
+ grid.add( agentVersionLabel );
+ final Label agentButton = new Label();
+ grid.add( agentButton );
+ // launch the version thread
+ final VersionThread versionThread = new VersionThread( agent.getHostname(), agent.getPort() );
+ versionThread.start();
+ // launch the synchronization task for the agent version
KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
{
- public void run()
- {
- if ( jeeApplicationArchiveCheckThread.getCompleted() )
+ public void run()
{
- if ( jeeApplicationArchiveCheckThread.getFailure() )
- {
- archiveStatusLabel.setText(
- "JEE application archive check error: " + jeeApplicationArchiveCheckThread.getErrorMessage() );
- archiveButton.setIcon( Styles.EXCLAMATION );
- }
- else
- {
- if ( jeeApplicationArchiveCheckThread.getUptodate() )
+ if ( versionThread.getCompleted() )
{
- archiveStatusLabel.setText( "OK" );
- archiveButton.setIcon( Styles.ACCEPT );
+ if ( versionThread.getFailure() )
+ {
+ agentVersionLabel.setText( "Agent error: " + versionThread.getErrorMessage() );
+ agentButton.setIcon( Styles.EXCLAMATION );
+ }
+ else
+ {
+ agentVersionLabel.setText( versionThread.getVersion() );
+ agentButton.setIcon( Styles.ACCEPT );
+ }
}
else
{
- archiveStatusLabel.setText( "JEE application archive is not deployed or not up to date" );
- archiveButton.setIcon( Styles.EXCLAMATION );
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
}
- }
}
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
} );
- }
- // check JEE application configuration files
- for ( Iterator configurationFileIterator = application.getConfigurationFiles().iterator();
- configurationFileIterator.hasNext(); )
- {
- ConfigurationFile configurationFile = (ConfigurationFile) configurationFileIterator.next();
- Label configurationFileLabel =
- new Label( " JEE application configuration file " + configurationFile.getName() + " check" );
- configurationFileLabel.setStyleName( "Default" );
- grid.add( configurationFileLabel );
- final Label configurationFileStatusLabel = new Label();
- configurationFileStatusLabel.setStyleName( "Default" );
- grid.add( configurationFileStatusLabel );
- final Label configurationFileButton = new Label();
- grid.add( configurationFileButton );
- // launch the application configuration file check thread
- final JEEApplicationConfigurationFileCheckThread jeeApplicationConfigurationFileCheckThread =
- new JEEApplicationConfigurationFileCheckThread( agent.getHostname(), agent.getPort(),
- parent.getEnvironmentName(), applicationServer.getName(),
- application.getName(), configurationFile.getName() );
- jeeApplicationConfigurationFileCheckThread.start();
- // launch the synchronisation thread
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ // application servers check
+ for ( Iterator applicationServerIterator =
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServers().iterator();
+ applicationServerIterator.hasNext(); )
{
- public void run()
- {
- if ( jeeApplicationConfigurationFileCheckThread.getCompleted() )
+ JEEApplicationServer applicationServer = (JEEApplicationServer) applicationServerIterator.next();
+ Label applicationServerLabel = new Label( "JEE server " + applicationServer.getName() + " check" );
+ applicationServerLabel.setStyleName( "default" );
+ grid.add( applicationServerLabel );
+ final Label applicationServerStatusLabel = new Label();
+ applicationServerStatusLabel.setStyleName( "default" );
+ grid.add( applicationServerStatusLabel );
+ final Label applicationServerStatusButton = new Label();
+ applicationServerStatusButton.setStyleName( "default" );
+ grid.add( applicationServerStatusButton );
+ // launch the application server status thread
+ final ApplicationServerStatusThread applicationServerStatusThread =
+ new ApplicationServerStatusThread( agent.getHostname(), agent.getPort(),
+ parent.getEnvironmentName(), applicationServer.getName() );
+ applicationServerStatusThread.start();
+ // launch the synchronisation status thread
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
{
- if ( jeeApplicationConfigurationFileCheckThread.getFailure() )
- {
- configurationFileStatusLabel.setText( "JEE application configuration file check error: "
- + jeeApplicationConfigurationFileCheckThread.getErrorMessage() );
- configurationFileButton.setIcon( Styles.EXCLAMATION );
- }
- else
- {
- if ( jeeApplicationConfigurationFileCheckThread.getUptodate() )
+ public void run()
{
- configurationFileStatusLabel.setText( "OK" );
- configurationFileButton.setIcon( Styles.ACCEPT );
+ if ( applicationServerStatusThread.getCompleted() )
+ {
+ if ( applicationServerStatusThread.getFailure() )
+ {
+ applicationServerStatusLabel.setText( "JEE application server error: "
+ + applicationServerStatusThread.getErrorMessage() );
+ applicationServerStatusButton.setIcon( Styles.EXCLAMATION );
+ }
+ else
+ {
+ applicationServerStatusLabel.setText( applicationServerStatusThread.getStatus() );
+ applicationServerStatusButton.setIcon( Styles.ACCEPT );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
}
- else
- {
- configurationFileStatusLabel.setText( "JEE application configuration file is not up to date" );
- configurationFileButton.setIcon( Styles.EXCLAMATION );
- }
- }
- }
- else
+ } );
+ // check connection pool
+ for ( Iterator connectionPoolIterator = applicationServer.getJDBCConnectionPools().iterator();
+ connectionPoolIterator.hasNext(); )
{
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ JDBCConnectionPool connectionPool = (JDBCConnectionPool) connectionPoolIterator.next();
+ Label connectionPoolLabel =
+ new Label( " JDBC connection pool " + connectionPool.getName() + " check" );
+ connectionPoolLabel.setStyleName( "default" );
+ grid.add( connectionPoolLabel );
+ final Label connectionPoolStatusLabel = new Label();
+ connectionPoolStatusLabel.setStyleName( "default" );
+ grid.add( connectionPoolStatusLabel );
+ final Label connectionPoolButton = new Label();
+ grid.add( connectionPoolButton );
+ // launch the connection pool check thread
+ final ConnectionPoolCheckThread connectionPoolCheckThread =
+ new ConnectionPoolCheckThread( agent.getHostname(), agent.getPort(),
+ parent.getEnvironmentName(), applicationServer.getName(),
+ connectionPool.getName() );
+ connectionPoolCheckThread.start();
+ // launch the synchronisation thread
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( connectionPoolCheckThread.getCompleted() )
+ {
+ if ( connectionPoolCheckThread.getFailure() )
+ {
+ connectionPoolStatusLabel.setText( "JDBC connection pool check error: "
+ + connectionPoolCheckThread.getErrorMessage() );
+ connectionPoolButton.setIcon( Styles.EXCLAMATION );
+ }
+ else
+ {
+ if ( connectionPoolCheckThread.getUptodate() )
+ {
+ connectionPoolStatusLabel.setText( "OK" );
+ connectionPoolButton.setIcon( Styles.ACCEPT );
+ }
+ else
+ {
+ connectionPoolStatusLabel.setText(
+ "JDBC Connection Pool is not deployed or not up to date" );
+ connectionPoolButton.setIcon( Styles.EXCLAMATION );
+ }
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
}
- }
- } );
- }
+ // check datasources
+ for ( Iterator dataSourceIterator = applicationServer.getJDBCDataSources().iterator();
+ dataSourceIterator.hasNext(); )
+ {
+ JDBCDataSource dataSource = (JDBCDataSource) dataSourceIterator.next();
+ Label dataSourceLabel = new Label( " JDBC data source " + dataSource.getName() + " check" );
+ dataSourceLabel.setStyleName( "default" );
+ grid.add( dataSourceLabel );
+ final Label dataSourceStatusLabel = new Label();
+ dataSourceStatusLabel.setStyleName( "Default" );
+ grid.add( dataSourceStatusLabel );
+ final Label dataSourceButton = new Label();
+ grid.add( dataSourceButton );
+ // launch the datasource check thread
+ final DataSourceCheckThread dataSourceCheckThread =
+ new DataSourceCheckThread( agent.getHostname(), agent.getPort(), parent.getEnvironmentName(),
+ applicationServer.getName(), dataSource.getName() );
+ dataSourceCheckThread.start();
+ // launch the synchronisation thread
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( dataSourceCheckThread.getCompleted() )
+ {
+ if ( dataSourceCheckThread.getFailure() )
+ {
+ dataSourceStatusLabel.setText(
+ "JDBC data source check error: " + dataSourceCheckThread.getErrorMessage() );
+ dataSourceButton.setIcon( Styles.EXCLAMATION );
+ }
+ else
+ {
+ if ( dataSourceCheckThread.getUptodate() )
+ {
+ dataSourceStatusLabel.setText( "OK" );
+ dataSourceButton.setIcon( Styles.ACCEPT );
+ }
+ else
+ {
+ dataSourceStatusLabel.setText(
+ "JDBC data source is not deployed or not up to date." );
+ dataSourceButton.setIcon( Styles.EXCLAMATION );
+ }
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ // check JMS connection factories
+ for ( Iterator jmsConnectionFactoryIterator = applicationServer.getJMSConnectionFactories().iterator();
+ jmsConnectionFactoryIterator.hasNext(); )
+ {
+ JMSConnectionFactory jmsConnectionFactory =
+ (JMSConnectionFactory) jmsConnectionFactoryIterator.next();
+ Label jmsConnectionFactoryLabel =
+ new Label( " JMS connection factory " + jmsConnectionFactory.getName() + " check" );
+ jmsConnectionFactoryLabel.setStyleName( "Default" );
+ grid.add( jmsConnectionFactoryLabel );
+ final Label jmsConnectionFactoryStatusLabel = new Label();
+ jmsConnectionFactoryStatusLabel.setStyleName( "Default" );
+ grid.add( jmsConnectionFactoryStatusLabel );
+ final Label jmsConnectionFactoryButton = new Label();
+ grid.add( jmsConnectionFactoryButton );
+ // launch the jms connection factory check thread
+ final JMSConnectionFactoryCheckThread jmsConnectionFactoryCheckThread =
+ new JMSConnectionFactoryCheckThread( agent.getHostname(), agent.getPort(),
+ parent.getEnvironmentName(), applicationServer.getName(),
+ jmsConnectionFactory.getName() );
+ jmsConnectionFactoryCheckThread.start();
+ // launch the synchronisation thread
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( jmsConnectionFactoryCheckThread.getCompleted() )
+ {
+ if ( jmsConnectionFactoryCheckThread.getFailure() )
+ {
+ jmsConnectionFactoryStatusLabel.setText( "JMS connection factory check error: "
+ + jmsConnectionFactoryCheckThread.getErrorMessage() );
+ jmsConnectionFactoryButton.setIcon( Styles.EXCLAMATION );
+ }
+ else
+ {
+ if ( jmsConnectionFactoryCheckThread.getUptodate() )
+ {
+ jmsConnectionFactoryStatusLabel.setText( "OK" );
+ jmsConnectionFactoryButton.setIcon( Styles.ACCEPT );
+ }
+ else
+ {
+ jmsConnectionFactoryStatusLabel.setText(
+ "JMS connection factory is not deployed or not up to date" );
+ jmsConnectionFactoryButton.setIcon( Styles.EXCLAMATION );
+ }
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ // check JMS servers
+ for ( Iterator jmsServerIterator = applicationServer.getJMSServers().iterator();
+ jmsServerIterator.hasNext(); )
+ {
+ JMSServer jmsServer = (JMSServer) jmsServerIterator.next();
+ Label jmsServerLabel = new Label( " JMS server " + jmsServer.getName() + " check" );
+ jmsServerLabel.setStyleName( "Default" );
+ grid.add( jmsServerLabel );
+ final Label jmsServerStatusLabel = new Label();
+ jmsServerStatusLabel.setStyleName( "Default" );
+ grid.add( jmsServerStatusLabel );
+ final Label jmsServerButton = new Label();
+ grid.add( jmsServerButton );
+ // launch the jms server check thread
+ final JMSServerCheckThread jmsServerCheckThread =
+ new JMSServerCheckThread( agent.getHostname(), agent.getPort(), parent.getEnvironmentName(),
+ applicationServer.getName(), jmsServer.getName() );
+ jmsServerCheckThread.start();
+ // launch the synchronisation thread
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( jmsServerCheckThread.getCompleted() )
+ {
+ if ( jmsServerCheckThread.getFailure() )
+ {
+ jmsServerStatusLabel.setText(
+ "JMS server check error: " + jmsServerCheckThread.getErrorMessage() );
+ jmsServerButton.setIcon( Styles.EXCLAMATION );
+ }
+ else
+ {
+ if ( jmsServerCheckThread.getUptodate() )
+ {
+ jmsServerStatusLabel.setText( "OK" );
+ jmsServerButton.setIcon( Styles.ACCEPT );
+ }
+ else
+ {
+ jmsServerStatusLabel.setText( "JMS server is not deployed or not up to date" );
+ jmsServerButton.setIcon( Styles.EXCLAMATION );
+ }
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ // check JNDI bindings
+ for ( Iterator jndiBindingIterator = applicationServer.getJNDIBindings().iterator();
+ jndiBindingIterator.hasNext(); )
+ {
+ JNDIBinding jndiBinding = (JNDIBinding) jndiBindingIterator.next();
+ Label nameSpaceBindingLabel = new Label( " JNDI binding " + jndiBinding.getName() + " check" );
+ nameSpaceBindingLabel.setStyleName( "Default" );
+ grid.add( nameSpaceBindingLabel );
+ final Label nameSpaceBindingStatusLabel = new Label();
+ nameSpaceBindingStatusLabel.setStyleName( "Default" );
+ grid.add( nameSpaceBindingStatusLabel );
+ final Label nameSpaceBindingButton = new Label();
+ grid.add( nameSpaceBindingButton );
+ // launch the name space binding check thread
+ final JNDIBindingCheckThread JNDIBindingCheckThread =
+ new JNDIBindingCheckThread( agent.getHostname(), agent.getPort(), parent.getEnvironmentName(),
+ applicationServer.getName(), jndiBinding.getName() );
+ JNDIBindingCheckThread.start();
+ // launch the synchronisation thread
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( JNDIBindingCheckThread.getCompleted() )
+ {
+ if ( JNDIBindingCheckThread.getFailure() )
+ {
+ nameSpaceBindingStatusLabel.setText(
+ "JNDI binding check error: " + JNDIBindingCheckThread.getErrorMessage() );
+ nameSpaceBindingButton.setIcon( Styles.EXCLAMATION );
+ }
+ else
+ {
+ if ( JNDIBindingCheckThread.getUptodate() )
+ {
+ nameSpaceBindingStatusLabel.setText( "OK" );
+ nameSpaceBindingButton.setIcon( Styles.ACCEPT );
+ }
+ else
+ {
+ nameSpaceBindingStatusLabel.setText(
+ "JNDI binding is not deployed or not up to date" );
+ nameSpaceBindingButton.setIcon( Styles.EXCLAMATION );
+ }
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ // check shared libraries
+ for ( Iterator sharedLibraryIterator = applicationServer.getSharedLibraries().iterator();
+ sharedLibraryIterator.hasNext(); )
+ {
+ SharedLibrary sharedLibrary = (SharedLibrary) sharedLibraryIterator.next();
+ Label sharedLibraryLabel = new Label( " Shared library " + sharedLibrary.getName() + " check" );
+ sharedLibraryLabel.setStyleName( "Default" );
+ grid.add( sharedLibraryLabel );
+ final Label sharedLibraryStatusLabel = new Label();
+ sharedLibraryStatusLabel.setStyleName( "Default" );
+ grid.add( sharedLibraryLabel );
+ final Label sharedLibraryButton = new Label();
+ grid.add( sharedLibraryButton );
+ // launch the shared library check thread
+ final SharedLibraryCheckThread sharedLibraryCheckThread =
+ new SharedLibraryCheckThread( agent.getHostname(), agent.getPort(), parent.getEnvironmentName(),
+ applicationServer.getName(), sharedLibrary.getName() );
+ sharedLibraryCheckThread.start();
+ // launch the synchronisation thread
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( sharedLibraryCheckThread.getCompleted() )
+ {
+ if ( sharedLibraryCheckThread.getFailure() )
+ {
+ sharedLibraryStatusLabel.setText(
+ "Shared library check error: " + sharedLibraryCheckThread.getErrorMessage() );
+ sharedLibraryButton.setIcon( Styles.EXCLAMATION );
+ }
+ else
+ {
+ if ( sharedLibraryCheckThread.getUptodate() )
+ {
+ sharedLibraryStatusLabel.setText( "OK" );
+ sharedLibraryButton.setIcon( Styles.ACCEPT );
+ }
+ else
+ {
+ sharedLibraryStatusLabel.setText(
+ "Shared library is not deployed or not up to date" );
+ sharedLibraryButton.setIcon( Styles.EXCLAMATION );
+ }
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ // check JEE applications
+ for ( Iterator applicationIterator = applicationServer.getJEEApplications().iterator();
+ applicationIterator.hasNext(); )
+ {
+ JEEApplication application = (JEEApplication) applicationIterator.next();
+ Label applicationLabel = new Label( " JEE application " + application.getName() + " check" );
+ applicationLabel.setStyleName( "Default" );
+ grid.add( applicationLabel );
+ Label blankLabel = new Label( " " );
+ grid.add( blankLabel );
+ blankLabel = new Label( " " );
+ grid.add( blankLabel );
+ // check JEE application archives
+ for ( Iterator archiveIterator = application.getArchives().iterator(); archiveIterator.hasNext(); )
+ {
+ Archive archive = (Archive) archiveIterator.next();
+ Label archiveLabel = new Label( " JEE application archive " + archive.getName() + " check" );
+ archiveLabel.setStyleName( "Default" );
+ grid.add( archiveLabel );
+ final Label archiveStatusLabel = new Label();
+ archiveStatusLabel.setStyleName( "Default" );
+ grid.add( archiveStatusLabel );
+ final Label archiveButton = new Label();
+ grid.add( archiveButton );
+ // launch the application archive check thread
+ final JEEApplicationArchiveCheckThread jeeApplicationArchiveCheckThread =
+ new JEEApplicationArchiveCheckThread( agent.getHostname(), agent.getPort(),
+ parent.getEnvironmentName(),
+ applicationServer.getName(), application.getName(),
+ archive.getName() );
+ jeeApplicationArchiveCheckThread.start();
+ // launch the synchronisation thread
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( jeeApplicationArchiveCheckThread.getCompleted() )
+ {
+ if ( jeeApplicationArchiveCheckThread.getFailure() )
+ {
+ archiveStatusLabel.setText( "JEE application archive check error: "
+ + jeeApplicationArchiveCheckThread.getErrorMessage() );
+ archiveButton.setIcon( Styles.EXCLAMATION );
+ }
+ else
+ {
+ if ( jeeApplicationArchiveCheckThread.getUptodate() )
+ {
+ archiveStatusLabel.setText( "OK" );
+ archiveButton.setIcon( Styles.ACCEPT );
+ }
+ else
+ {
+ archiveStatusLabel.setText(
+ "JEE application archive is not deployed or not up to date" );
+ archiveButton.setIcon( Styles.EXCLAMATION );
+ }
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ // check JEE application configuration files
+ for ( Iterator configurationFileIterator = application.getConfigurationFiles().iterator();
+ configurationFileIterator.hasNext(); )
+ {
+ ConfigurationFile configurationFile = (ConfigurationFile) configurationFileIterator.next();
+ Label configurationFileLabel = new Label(
+ " JEE application configuration file " + configurationFile.getName() + " check" );
+ configurationFileLabel.setStyleName( "Default" );
+ grid.add( configurationFileLabel );
+ final Label configurationFileStatusLabel = new Label();
+ configurationFileStatusLabel.setStyleName( "Default" );
+ grid.add( configurationFileStatusLabel );
+ final Label configurationFileButton = new Label();
+ grid.add( configurationFileButton );
+ // launch the application configuration file check thread
+ final JEEApplicationConfigurationFileCheckThread jeeApplicationConfigurationFileCheckThread =
+ new JEEApplicationConfigurationFileCheckThread( agent.getHostname(), agent.getPort(),
+ parent.getEnvironmentName(),
+ applicationServer.getName(),
+ application.getName(),
+ configurationFile.getName() );
+ jeeApplicationConfigurationFileCheckThread.start();
+ // launch the synchronisation thread
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( jeeApplicationConfigurationFileCheckThread.getCompleted() )
+ {
+ if ( jeeApplicationConfigurationFileCheckThread.getFailure() )
+ {
+ configurationFileStatusLabel.setText(
+ "JEE application configuration file check error: "
+ + jeeApplicationConfigurationFileCheckThread.getErrorMessage() );
+ configurationFileButton.setIcon( Styles.EXCLAMATION );
+ }
+ else
+ {
+ if ( jeeApplicationConfigurationFileCheckThread.getUptodate() )
+ {
+ configurationFileStatusLabel.setText( "OK" );
+ configurationFileButton.setIcon( Styles.ACCEPT );
+ }
+ else
+ {
+ configurationFileStatusLabel.setText(
+ "JEE application configuration file is not up to date" );
+ configurationFileButton.setIcon( Styles.EXCLAMATION );
+ }
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ }
+ }
}
- }
+ };
+
+ /**
+ * Create a new <code>EnvironmentCheckerTabPane</code>
+ *
+ * @param parent the parent <code>EnvironmentWindow</code>
+ */
+ public CheckerPane( EnvironmentWindow parent )
+ {
+ super();
+ setStyleName( "tab.content" );
+
+ // update parent
+ this.parent = parent;
+
+ // column layout
+ Column content = new Column();
+ content.setCellSpacing( new Extent( 2 ) );
+ content.setInsets( new Insets( 2 ) );
+ add( content );
+
+ // add the launch button
+ Button launchButton = new Button( Messages.getString( "status" ), Styles.INFORMATION );
+ launchButton.addActionListener( launch );
+ content.add( launchButton );
+
+ // add results grid
+ grid = new Grid( 3 );
+ grid.setStyleName( "border.grid" );
+ content.add( grid );
+
+ // update the pane
+ update();
}
- };
- /**
- * Create a new <code>EnvironmentCheckerTabPane</code>
- *
- * @param parent the parent <code>EnvironmentWindow</code>
- */
- public CheckerPane( EnvironmentWindow parent )
- {
- super();
- setStyleName( "tab.content" );
-
- // update parent
- this.parent = parent;
-
- // column layout
- Column content = new Column();
- content.setCellSpacing( new Extent( 2 ) );
- content.setInsets( new Insets( 2 ) );
- add( content );
-
- // add the launch button
- Button launchButton = new Button( Messages.getString( "status" ), Styles.INFORMATION );
- launchButton.addActionListener( launch );
- content.add( launchButton );
-
- // add results grid
- grid = new Grid( 3 );
- grid.setStyleName( "border.grid" );
- content.add( grid );
-
- // update the pane
- update();
- }
-
- /**
- * Update the pane
- */
- public void update()
- {
- // nothing to do
- }
+ /**
+ * Update the pane
+ */
+ public void update()
+ {
+ // nothing to do
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConfirmWindow.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConfirmWindow.java
index 03c5033..a8d8069 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConfirmWindow.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConfirmWindow.java
@@ -31,58 +31,58 @@
* Confirm window to interact with the user.
*/
public class ConfirmWindow
- extends WindowPane
+ extends WindowPane
{
- public ConfirmWindow( final ActionListener callback )
- {
- super();
-
- this.setStyleName( "default" );
- this.setTitle( Messages.getString( "confirm" ) );
- this.setWidth( new Extent( 220, Extent.PX ) );
- this.setHeight( new Extent( 120, Extent.PX ) );
- this.setModal( true );
-
- SplitPane content = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
- this.add( content );
-
- // control row
- Row controlRow = new Row();
- controlRow.setStyleName( "control" );
- content.add( controlRow );
-
- // add yes button
- Button yesButton = new Button( Messages.getString( "yes" ), Styles.ACCEPT );
- yesButton.setStyleName( "control" );
- yesButton.addActionListener( new ActionListener()
+ public ConfirmWindow( final ActionListener callback )
{
- public void actionPerformed( ActionEvent event )
- {
- // call the callback
- callback.actionPerformed( null );
- // close the confirm window
- ConfirmWindow.this.userClose();
- }
- } );
- controlRow.add( yesButton );
+ super();
- // add the no button
- Button noButton = new Button( Messages.getString( "no" ), Styles.CROSS );
- noButton.setStyleName( "control" );
- noButton.addActionListener( new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- ConfirmWindow.this.userClose();
- }
- } );
- controlRow.add( noButton );
+ this.setStyleName( "default" );
+ this.setTitle( Messages.getString( "confirm" ) );
+ this.setWidth( new Extent( 220, Extent.PX ) );
+ this.setHeight( new Extent( 120, Extent.PX ) );
+ this.setModal( true );
- // add the main label
- Label mainLabel = new Label( Messages.getString( "sure.question" ) );
- content.add( mainLabel );
+ SplitPane content = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
+ this.add( content );
- }
+ // control row
+ Row controlRow = new Row();
+ controlRow.setStyleName( "control" );
+ content.add( controlRow );
+
+ // add yes button
+ Button yesButton = new Button( Messages.getString( "yes" ), Styles.ACCEPT );
+ yesButton.setStyleName( "control" );
+ yesButton.addActionListener( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // call the callback
+ callback.actionPerformed( null );
+ // close the confirm window
+ ConfirmWindow.this.userClose();
+ }
+ } );
+ controlRow.add( yesButton );
+
+ // add the no button
+ Button noButton = new Button( Messages.getString( "no" ), Styles.CROSS );
+ noButton.setStyleName( "control" );
+ noButton.addActionListener( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ ConfirmWindow.this.userClose();
+ }
+ } );
+ controlRow.add( noButton );
+
+ // add the main label
+ Label mainLabel = new Label( Messages.getString( "sure.question" ) );
+ content.add( mainLabel );
+
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionFactoriesPane.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionFactoriesPane.java
index 4492067..de3e744 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionFactoriesPane.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionFactoriesPane.java
@@ -44,883 +44,890 @@
* Environment JMS connection factories pane.
*/
public class ConnectionFactoriesPane
- extends ContentPane
+ extends ContentPane
{
- private EnvironmentWindow parent;
+ private EnvironmentWindow parent;
- private SelectField scopeField;
+ private SelectField scopeField;
- private Grid grid;
+ private Grid grid;
- private boolean newIsActive = true;
+ private boolean newIsActive = true;
- private boolean newIsBlocker = false;
+ private boolean newIsBlocker = false;
- private TextField newNameField;
+ private TextField newNameField;
- // status thread
- class StatusThread
- extends Thread
- {
-
- public String serverName;
-
- public String connectionFactoryName;
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // status thread
+ class StatusThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
- if ( agent == null )
+
+ public String serverName;
+
+ public String connectionFactoryName;
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the webservice
+ JMSConnectionFactoryClient client =
+ new JMSConnectionFactoryClient( agent.getHostname(), agent.getPort() );
+ boolean uptodate = client.check( parent.getEnvironmentName(), serverName, connectionFactoryName );
+ if ( uptodate )
+ {
+ message = "JMS connection factory " + connectionFactoryName + " is up to date.";
+ }
+ else
+ {
+ failure = true;
+ message = "JMS connection factory " + connectionFactoryName + " is not up to date.";
+ }
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JMS connection factory " + connectionFactoryName + " status check failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- // call the webservice
- JMSConnectionFactoryClient client = new JMSConnectionFactoryClient( agent.getHostname(), agent.getPort() );
- boolean uptodate = client.check( parent.getEnvironmentName(), serverName, connectionFactoryName );
- if ( uptodate )
+ }
+
+ // update thread
+ class UpdateThread
+ extends Thread
+ {
+
+ public String serverName;
+
+ public String connectionFactoryName;
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- message = "JMS connection factory " + connectionFactoryName + " is up to date.";
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the webservice
+ JMSConnectionFactoryClient client =
+ new JMSConnectionFactoryClient( agent.getHostname(), agent.getPort() );
+ client.update( parent.getEnvironmentName(), serverName, connectionFactoryName );
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JMS connection factory " + connectionFactoryName + " update failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
}
- else
+ }
+
+ // scope select
+ private ActionListener scopeSelect = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
{
- failure = true;
- message = "JMS connection factory " + connectionFactoryName + " is not up to date.";
+ update();
}
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JMS connection factory " + connectionFactoryName + " status check failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
- }
- }
+ };
- // update thread
- class UpdateThread
- extends Thread
- {
-
- public String serverName;
-
- public String connectionFactoryName;
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // edit
+ private ActionListener edit = new ActionListener()
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
- if ( agent == null )
+ public void actionPerformed( ActionEvent event )
{
- throw new IllegalArgumentException( "agent not found." );
- }
- // call the webservice
- JMSConnectionFactoryClient client = new JMSConnectionFactoryClient( agent.getHostname(), agent.getPort() );
- client.update( parent.getEnvironmentName(), serverName, connectionFactoryName );
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JMS connection factory " + connectionFactoryName + " update failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
- }
- }
-
- // scope select
- private ActionListener scopeSelect = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- update();
- }
- };
-
- // edit
- private ActionListener edit = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check the user has the environment lock
- if ( !getEnvironementWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironementWindow().adminPermission && !getEnvironementWindow().jeeResourcesChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restrictied" ),
- getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // get the JMS connection factory name
- String name = event.getActionCommand();
- // get the JMS connection factory name field
- TextField nameField = (TextField) ConnectionFactoriesPane.this.getComponent(
- "cfname_" + parent.getEnvironmentName() + "_" + (String) scopeField.getSelectedItem() + "_" + name );
- String nameFieldValue = nameField.getText();
- // check the field value
- if ( nameFieldValue == null || nameFieldValue.trim().length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "connectionfactory.mandatory" ), getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // if the use change the JMS connection factory name, check if the name
- // if not already in use
- if ( !name.equals( nameFieldValue ) )
- {
- if ( parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJMSConnectionFactory( nameFieldValue ) != null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "connectionfactory.exists" ), getEnvironementWindow().getEnvironmentName() );
- return;
- }
- }
- // looking for the JMS connection factory object
- JMSConnectionFactory connectionFactory =
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJMSConnectionFactory( name );
- if ( connectionFactory == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "connectionfactory.notfound" ), getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // add a change event
- parent.getChangeEvents().add( "Change JMS connection factory " + connectionFactory.getName() );
- // update the JMS connection factory object
- connectionFactory.setName( nameFieldValue );
- // change the updated flag
- parent.setUpdated( true );
- // update the journal log tab pane
- parent.updateJournalPane();
- // update only the pane
- update();
- }
- };
-
- // create
- private ActionListener create = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironementWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironementWindow().adminPermission && !getEnvironementWindow().jeeResourcesChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // get the new JMS connection factory name field value
- String newNameFieldValue = newNameField.getText();
- // check the mandatory field
- if ( newNameFieldValue == null || newNameFieldValue.trim().length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "connectionfactory.mandatory" ), getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // create a new JMS connection factory object
- JMSConnectionFactory connectionFactory = new JMSConnectionFactory();
- connectionFactory.setName( newNameFieldValue );
- connectionFactory.setActive( newIsActive );
- // add the JMS connection factory
- try
- {
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).addJMSConnectionFactory( connectionFactory );
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "connectionfactory.exists" ), getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // add a change event
- parent.getChangeEvents().add( "Create JMS connection factory " + connectionFactory.getName() );
- // change the updated flag
- parent.setUpdated( true );
- // update the journal log tab pane
- parent.updateJournalPane();
- // update only the pane
- update();
- }
- };
-
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironementWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironementWindow().adminPermission && !getEnvironementWindow().jeeResourcesChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // get the JMS connection factory name
- final String name = event.getActionCommand();
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
+ // check the user has the environment lock
+ if ( !getEnvironementWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironementWindow().adminPermission && !getEnvironementWindow().jeeResourcesChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restrictied" ), getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // get the JMS connection factory name
+ String name = event.getActionCommand();
+ // get the JMS connection factory name field
+ TextField nameField = (TextField) ConnectionFactoriesPane.this.getComponent(
+ "cfname_" + parent.getEnvironmentName() + "_" + (String) scopeField.getSelectedItem() + "_" + name );
+ String nameFieldValue = nameField.getText();
+ // check the field value
+ if ( nameFieldValue == null || nameFieldValue.trim().length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "connectionfactory.mandatory" ), getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // if the use change the JMS connection factory name, check if the name
+ // if not already in use
+ if ( !name.equals( nameFieldValue ) )
+ {
+ if ( parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJMSConnectionFactory( nameFieldValue ) != null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "connectionfactory.exists" ),
+ getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ }
// looking for the JMS connection factory object
JMSConnectionFactory connectionFactory =
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJMSConnectionFactory( name );
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJMSConnectionFactory( name );
if ( connectionFactory == null )
{
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "connectionfactory.notfound" ), getEnvironementWindow().getEnvironmentName() );
- return;
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "connectionfactory.notfound" ), getEnvironementWindow().getEnvironmentName() );
+ return;
}
- // delete the JMS connection factory
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJMSConnectionFactories().remove( connectionFactory );
// add a change event
- parent.getChangeEvents().add( "Delete JMS connection factory " + connectionFactory.getName() );
+ parent.getChangeEvents().add( "Change JMS connection factory " + connectionFactory.getName() );
+ // update the JMS connection factory object
+ connectionFactory.setName( nameFieldValue );
// change the updated flag
parent.setUpdated( true );
// update the journal log tab pane
parent.updateJournalPane();
// update only the pane
update();
- }
- } ) );
- }
- };
+ }
+ };
- // toggle active
- private ActionListener toggleActive = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
+ // create
+ private ActionListener create = new ActionListener()
{
- // check if the user has the environment lock
- if ( !getEnvironementWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironementWindow().adminPermission && !getEnvironementWindow().jeeResourcesChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // looking for the JMS connection factory object
- JMSConnectionFactory connectionFactory =
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJMSConnectionFactory( event.getActionCommand() );
- if ( connectionFactory == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "connectionfactory.notfound" ), getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // change the jms connection factory state and add a change event
- if ( connectionFactory.isActive() )
- {
- connectionFactory.setActive( false );
- parent.getChangeEvents().add( "Disable JMS connection factory " + connectionFactory.getName() );
- }
- else
- {
- connectionFactory.setActive( true );
- parent.getChangeEvents().add( "Enable JMS connection factory " + connectionFactory.getName() );
- }
- // change the updated flag
- parent.setUpdated( true );
- // update the journal log tab pane
- parent.updateJournalPane();
- // update the pane
- update();
- }
- };
-
- // toggle blocker
- private ActionListener toggleBlocker = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironementWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironementWindow().adminPermission && !getEnvironementWindow().jeeResourcesChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // looking for the JMS connection factory object
- JMSConnectionFactory connectionFactory =
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJMSConnectionFactory( event.getActionCommand() );
- if ( connectionFactory == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "connectionfactory.notfound" ), getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // change the jms connection factory blocker state and add a change
- // event
- if ( connectionFactory.isBlocker() )
- {
- connectionFactory.setBlocker( false );
- parent.getChangeEvents().add( "Set not blocker for JMS connection factory " + connectionFactory.getName() );
- }
- else
- {
- connectionFactory.setBlocker( true );
- parent.getChangeEvents().add( "Set blocker for JMS connection factory " + connectionFactory.getName() );
- }
- // change the updated flag
- parent.setUpdated( true );
- // update the journal log tab pane
- parent.updateJournalPane();
- // update the pane
- update();
- }
- };
-
- // new toggle active
- private ActionListener newToggleActive = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // toggle the state
- if ( newIsActive )
- {
- newIsActive = false;
- }
- else
- {
- newIsActive = true;
- }
- // update the pane
- update();
- }
- };
-
- // new toggle blocker
- private ActionListener newToggleBlocker = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // toggle the blocker state
- if ( newIsBlocker )
- {
- newIsBlocker = false;
- }
- else
- {
- newIsBlocker = true;
- }
- // update the pane
- update();
- }
- };
-
- // copy
- private ActionListener copy = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // looking for the JMS connection factory
- JMSConnectionFactory connectionFactory =
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJMSConnectionFactory( event.getActionCommand() );
- if ( connectionFactory == null )
- {
- return;
- }
- try
- {
- KalumetConsoleApplication.getApplication().setCopyComponent( connectionFactory.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
-
- // paste
- private ActionListener paste = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
- // check if the copy object is correct
- if ( copy == null || !( copy instanceof JMSConnectionFactory ) )
- {
- return;
- }
- // update the new fields
- newNameField.setText( ( (JMSConnectionFactory) copy ).getName() );
- }
- };
-
- // status
- private ActionListener status = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if some has not yet been saved
- if ( getEnvironementWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ), getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // get the connection factory
- String connectionFactoryName = event.getActionCommand();
- String serverName = (String) scopeField.getSelectedItem();
- // add a message into the log pane and the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JMS connection factory " + connectionFactoryName + " status check in progress...",
- parent.getEnvironmentName() );
- parent.getChangeEvents().add( "JMS connection factory " + connectionFactoryName + " status check requested." );
- // start the status thread
- final StatusThread statusThread = new StatusThread();
- statusThread.serverName = serverName;
- statusThread.connectionFactoryName = connectionFactoryName;
- statusThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask( KalumetConsoleApplication.getApplication().getTaskQueue(),
- new Runnable()
- {
- public void run()
- {
- if ( statusThread.ended )
- {
- if ( statusThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- statusThread.message,
- parent.getEnvironmentName() );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- statusThread.message,
- parent.getEnvironmentName() );
- }
- parent.getChangeEvents().add(
- statusThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(),
- this );
- }
- }
- } );
- }
- };
-
- // update
- private ActionListener update = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the lock
- if ( !getEnvironementWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironementWindow().adminPermission && !getEnvironementWindow().jeeResourcesUpdatePermission )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // check if some change has not been saved
- if ( getEnvironementWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ), getEnvironementWindow().getEnvironmentName() );
- return;
- }
- // get the connection factory and server name
- final String serverName = (String) scopeField.getSelectedItem();
- final String connectionFactoryName = event.getActionCommand();
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
+ public void actionPerformed( ActionEvent event )
{
- public void actionPerformed( ActionEvent event )
- {
+ // check if the user has the environment lock
+ if ( !getEnvironementWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironementWindow().adminPermission && !getEnvironementWindow().jeeResourcesChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // get the new JMS connection factory name field value
+ String newNameFieldValue = newNameField.getText();
+ // check the mandatory field
+ if ( newNameFieldValue == null || newNameFieldValue.trim().length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "connectionfactory.mandatory" ), getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // create a new JMS connection factory object
+ JMSConnectionFactory connectionFactory = new JMSConnectionFactory();
+ connectionFactory.setName( newNameFieldValue );
+ connectionFactory.setActive( newIsActive );
+ // add the JMS connection factory
+ try
+ {
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).addJMSConnectionFactory( connectionFactory );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "connectionfactory.exists" ), getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // add a change event
+ parent.getChangeEvents().add( "Create JMS connection factory " + connectionFactory.getName() );
+ // change the updated flag
+ parent.setUpdated( true );
+ // update the journal log tab pane
+ parent.updateJournalPane();
+ // update only the pane
+ update();
+ }
+ };
+
+ // delete
+ private ActionListener delete = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironementWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironementWindow().adminPermission && !getEnvironementWindow().jeeResourcesChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // get the JMS connection factory name
+ final String name = event.getActionCommand();
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // looking for the JMS connection factory object
+ JMSConnectionFactory connectionFactory =
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJMSConnectionFactory( name );
+ if ( connectionFactory == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "connectionfactory.notfound" ),
+ getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // delete the JMS connection factory
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJMSConnectionFactories().remove(
+ connectionFactory );
+ // add a change event
+ parent.getChangeEvents().add( "Delete JMS connection factory " + connectionFactory.getName() );
+ // change the updated flag
+ parent.setUpdated( true );
+ // update the journal log tab pane
+ parent.updateJournalPane();
+ // update only the pane
+ update();
+ }
+ } ) );
+ }
+ };
+
+ // toggle active
+ private ActionListener toggleActive = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironementWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironementWindow().adminPermission && !getEnvironementWindow().jeeResourcesChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the JMS connection factory object
+ JMSConnectionFactory connectionFactory =
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJMSConnectionFactory( event.getActionCommand() );
+ if ( connectionFactory == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "connectionfactory.notfound" ), getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // change the jms connection factory state and add a change event
+ if ( connectionFactory.isActive() )
+ {
+ connectionFactory.setActive( false );
+ parent.getChangeEvents().add( "Disable JMS connection factory " + connectionFactory.getName() );
+ }
+ else
+ {
+ connectionFactory.setActive( true );
+ parent.getChangeEvents().add( "Enable JMS connection factory " + connectionFactory.getName() );
+ }
+ // change the updated flag
+ parent.setUpdated( true );
+ // update the journal log tab pane
+ parent.updateJournalPane();
+ // update the pane
+ update();
+ }
+ };
+
+ // toggle blocker
+ private ActionListener toggleBlocker = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironementWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironementWindow().adminPermission && !getEnvironementWindow().jeeResourcesChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the JMS connection factory object
+ JMSConnectionFactory connectionFactory =
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJMSConnectionFactory( event.getActionCommand() );
+ if ( connectionFactory == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "connectionfactory.notfound" ), getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // change the jms connection factory blocker state and add a change
+ // event
+ if ( connectionFactory.isBlocker() )
+ {
+ connectionFactory.setBlocker( false );
+ parent.getChangeEvents().add(
+ "Set not blocker for JMS connection factory " + connectionFactory.getName() );
+ }
+ else
+ {
+ connectionFactory.setBlocker( true );
+ parent.getChangeEvents().add( "Set blocker for JMS connection factory " + connectionFactory.getName() );
+ }
+ // change the updated flag
+ parent.setUpdated( true );
+ // update the journal log tab pane
+ parent.updateJournalPane();
+ // update the pane
+ update();
+ }
+ };
+
+ // new toggle active
+ private ActionListener newToggleActive = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // toggle the state
+ if ( newIsActive )
+ {
+ newIsActive = false;
+ }
+ else
+ {
+ newIsActive = true;
+ }
+ // update the pane
+ update();
+ }
+ };
+
+ // new toggle blocker
+ private ActionListener newToggleBlocker = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // toggle the blocker state
+ if ( newIsBlocker )
+ {
+ newIsBlocker = false;
+ }
+ else
+ {
+ newIsBlocker = true;
+ }
+ // update the pane
+ update();
+ }
+ };
+
+ // copy
+ private ActionListener copy = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // looking for the JMS connection factory
+ JMSConnectionFactory connectionFactory =
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJMSConnectionFactory( event.getActionCommand() );
+ if ( connectionFactory == null )
+ {
+ return;
+ }
+ try
+ {
+ KalumetConsoleApplication.getApplication().setCopyComponent( connectionFactory.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
+
+ // paste
+ private ActionListener paste = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+ // check if the copy object is correct
+ if ( copy == null || !( copy instanceof JMSConnectionFactory ) )
+ {
+ return;
+ }
+ // update the new fields
+ newNameField.setText( ( (JMSConnectionFactory) copy ).getName() );
+ }
+ };
+
+ // status
+ private ActionListener status = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if some has not yet been saved
+ if ( getEnvironementWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ), getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // get the connection factory
+ String connectionFactoryName = event.getActionCommand();
+ String serverName = (String) scopeField.getSelectedItem();
// add a message into the log pane and the journal
KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JMS connection factory " + connectionFactoryName + " update in progress...",
- parent.getEnvironmentName() );
- parent.getChangeEvents().add( "JMS connection factory " + connectionFactoryName + " update requested." );
- // start the update thread
- final UpdateThread updateThread = new UpdateThread();
- updateThread.serverName = serverName;
- updateThread.connectionFactoryName = connectionFactoryName;
- updateThread.start();
+ "JMS connection factory " + connectionFactoryName + " status check in progress...",
+ parent.getEnvironmentName() );
+ parent.getChangeEvents().add(
+ "JMS connection factory " + connectionFactoryName + " status check requested." );
+ // start the status thread
+ final StatusThread statusThread = new StatusThread();
+ statusThread.serverName = serverName;
+ statusThread.connectionFactoryName = connectionFactoryName;
+ statusThread.start();
// sync with the client
KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
{
- public void run()
- {
- if ( updateThread.ended )
+ public void run()
{
- if ( updateThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( updateThread.message,
- parent.getEnvironmentName() );
- parent.getChangeEvents().add( updateThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "JMS connection factory " + connectionFactoryName + " updated.", parent.getEnvironmentName() );
- parent.getChangeEvents().add( "JMS connection factory " + connectionFactoryName + " updated." );
- }
+ if ( statusThread.ended )
+ {
+ if ( statusThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning( statusThread.message,
+ parent.getEnvironmentName() );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo( statusThread.message,
+ parent.getEnvironmentName() );
+ }
+ parent.getChangeEvents().add( statusThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
}
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
- }
- }
} );
- }
- } ) );
- }
- };
-
- /**
- * Create a new <code>ConnectionFactoriesPane</code>.
- *
- * @param parent the parent <code>EnvironmentWindow</code>.
- */
- public ConnectionFactoriesPane( EnvironmentWindow parent )
- {
- super();
- setStyleName( "tab.content" );
-
- // update parent
- this.parent = parent;
-
- // column layout
- Column content = new Column();
- content.setCellSpacing( new Extent( 2 ) );
- add( content );
-
- // add the scope select field
- Grid layoutGrid = new Grid( 2 );
- layoutGrid.setStyleName( "default" );
- layoutGrid.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
- layoutGrid.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
- content.add( layoutGrid );
- Label scopeLabel = new Label( Messages.getString( "scope" ) );
- scopeLabel.setStyleName( "default" );
- layoutGrid.add( scopeLabel );
- scopeField = new SelectField();
- scopeField.addActionListener( scopeSelect );
- scopeField.setStyleName( "default" );
- layoutGrid.add( scopeField );
- DefaultListModel scopeListModel = (DefaultListModel) scopeField.getModel();
- scopeListModel.removeAll();
- // add application servers in the scope select field
- for ( Iterator applicationServerIterator =
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServers().iterator();
- applicationServerIterator.hasNext(); )
- {
- JEEApplicationServer applicationServer = (JEEApplicationServer) applicationServerIterator.next();
- scopeListModel.add( applicationServer.getName() );
- }
- if ( scopeListModel.size() > 0 )
- {
- scopeField.setSelectedIndex( 0 );
- }
-
- // add JMS connection factories grid
- grid = new Grid( 2 );
- grid.setStyleName( "border.grid" );
- grid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
- grid.setColumnWidth( 1, new Extent( 100, Extent.PERCENT ) );
- content.add( grid );
+ }
+ };
// update
- update();
- }
+ private ActionListener update = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !getEnvironementWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironementWindow().adminPermission && !getEnvironementWindow().jeeResourcesUpdatePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // check if some change has not been saved
+ if ( getEnvironementWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ), getEnvironementWindow().getEnvironmentName() );
+ return;
+ }
+ // get the connection factory and server name
+ final String serverName = (String) scopeField.getSelectedItem();
+ final String connectionFactoryName = event.getActionCommand();
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // add a message into the log pane and the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JMS connection factory " + connectionFactoryName + " update in progress...",
+ parent.getEnvironmentName() );
+ parent.getChangeEvents().add(
+ "JMS connection factory " + connectionFactoryName + " update requested." );
+ // start the update thread
+ final UpdateThread updateThread = new UpdateThread();
+ updateThread.serverName = serverName;
+ updateThread.connectionFactoryName = connectionFactoryName;
+ updateThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( updateThread.ended )
+ {
+ if ( updateThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ updateThread.message, parent.getEnvironmentName() );
+ parent.getChangeEvents().add( updateThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ "JMS connection factory " + connectionFactoryName + " updated.",
+ parent.getEnvironmentName() );
+ parent.getChangeEvents().add(
+ "JMS connection factory " + connectionFactoryName + " updated." );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ } ) );
+ }
+ };
- /**
- * Update the pane.
- */
- public void update()
- {
- String applicationServerName = null;
- // update the scope select field
- DefaultListModel scopeListModel = (DefaultListModel) scopeField.getModel();
- if ( scopeListModel.size() > 0 )
+ /**
+ * Create a new <code>ConnectionFactoriesPane</code>.
+ *
+ * @param parent the parent <code>EnvironmentWindow</code>.
+ */
+ public ConnectionFactoriesPane( EnvironmentWindow parent )
{
- applicationServerName = (String) scopeField.getSelectedItem();
- }
- scopeListModel.removeAll();
- int scopeIndex = 0;
- int found = -1;
- for ( Iterator applicationServerIterator =
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServers().iterator();
- applicationServerIterator.hasNext(); )
- {
- JEEApplicationServer applicationServer = (JEEApplicationServer) applicationServerIterator.next();
- scopeListModel.add( applicationServer.getName() );
- if ( applicationServer.getName().equals( applicationServerName ) )
- {
- found = scopeIndex;
- }
- scopeIndex++;
- }
+ super();
+ setStyleName( "tab.content" );
- // remove all JMS connection factories grid children
- grid.removeAll();
+ // update parent
+ this.parent = parent;
- if ( scopeListModel.size() < 1 )
- {
- // no application server present
- return;
- }
- // update the scope select field selected index
- if ( found == -1 )
- {
- scopeField.setSelectedIndex( 0 );
- }
- else
- {
- scopeField.setSelectedIndex( found );
- }
- // update the application server name from the scope (in case of
- // application server deletion)
- applicationServerName = (String) scopeField.getSelectedItem();
+ // column layout
+ Column content = new Column();
+ content.setCellSpacing( new Extent( 2 ) );
+ add( content );
- // add JMS connection factories grid header
- Label connectionFactoryHeader = new Label( " " );
- connectionFactoryHeader.setStyleName( "grid.header" );
- grid.add( connectionFactoryHeader );
- Label connectionFactoryNameHeader = new Label( Messages.getString( "name" ) );
- connectionFactoryNameHeader.setStyleName( "grid.header" );
- grid.add( connectionFactoryNameHeader );
- // add the jms connection factories
- for ( Iterator jmsConnectionFactoryIterator =
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- applicationServerName ).getJMSConnectionFactories().iterator(); jmsConnectionFactoryIterator.hasNext(); )
- {
- JMSConnectionFactory connectionFactory = (JMSConnectionFactory) jmsConnectionFactoryIterator.next();
- // row
- Row row = new Row();
- row.setInsets( new Insets( 2 ) );
- row.setCellSpacing( new Extent( 2 ) );
- grid.add( row );
- // copy
- Button copyButton = new Button( Styles.PAGE_COPY );
- copyButton.setToolTipText( Messages.getString( "copy" ) );
- copyButton.setActionCommand( connectionFactory.getName() );
- copyButton.addActionListener( copy );
- row.add( copyButton );
- // active
- Button activeButton;
- if ( connectionFactory.isActive() )
- {
- activeButton = new Button( Styles.LIGHTBULB );
- activeButton.setToolTipText( Messages.getString( "switch.disable" ) );
- }
- else
- {
- activeButton = new Button( Styles.LIGHTBULB_OFF );
- activeButton.setToolTipText( Messages.getString( "switch.enable" ) );
- }
- if ( getEnvironementWindow().adminPermission || getEnvironementWindow().jeeResourcesChangePermission)
- {
- activeButton.setActionCommand( connectionFactory.getName() );
- activeButton.addActionListener( toggleActive );
- }
- row.add( activeButton );
- // blocker
- Button blockerButton;
- if ( connectionFactory.isBlocker() )
- {
- blockerButton = new Button( Styles.PLUGIN );
- blockerButton.setToolTipText( Messages.getString( "switch.notblocker" ) );
- }
- else
- {
- blockerButton = new Button( Styles.PLUGIN_DISABLED );
- blockerButton.setToolTipText( Messages.getString( "switch.blocker" ) );
- }
- if ( getEnvironementWindow().adminPermission || getEnvironementWindow().jeeResourcesChangePermission)
- {
- blockerButton.setActionCommand( connectionFactory.getName() );
- blockerButton.addActionListener( toggleBlocker );
- }
- row.add( blockerButton );
- // status
- Button statusButton = new Button( Styles.INFORMATION );
- statusButton.setToolTipText( Messages.getString( "status" ) );
- statusButton.setActionCommand( connectionFactory.getName() );
- statusButton.addActionListener( status );
- row.add( statusButton );
- if ( getEnvironementWindow().adminPermission || getEnvironementWindow().jeeResourcesUpdatePermission )
- {
+ // add the scope select field
+ Grid layoutGrid = new Grid( 2 );
+ layoutGrid.setStyleName( "default" );
+ layoutGrid.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
+ layoutGrid.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
+ content.add( layoutGrid );
+ Label scopeLabel = new Label( Messages.getString( "scope" ) );
+ scopeLabel.setStyleName( "default" );
+ layoutGrid.add( scopeLabel );
+ scopeField = new SelectField();
+ scopeField.addActionListener( scopeSelect );
+ scopeField.setStyleName( "default" );
+ layoutGrid.add( scopeField );
+ DefaultListModel scopeListModel = (DefaultListModel) scopeField.getModel();
+ scopeListModel.removeAll();
+ // add application servers in the scope select field
+ for ( Iterator applicationServerIterator =
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServers().iterator();
+ applicationServerIterator.hasNext(); )
+ {
+ JEEApplicationServer applicationServer = (JEEApplicationServer) applicationServerIterator.next();
+ scopeListModel.add( applicationServer.getName() );
+ }
+ if ( scopeListModel.size() > 0 )
+ {
+ scopeField.setSelectedIndex( 0 );
+ }
+
+ // add JMS connection factories grid
+ grid = new Grid( 2 );
+ grid.setStyleName( "border.grid" );
+ grid.setColumnWidth( 0, new Extent( 50, Extent.PX ) );
+ grid.setColumnWidth( 1, new Extent( 100, Extent.PERCENT ) );
+ content.add( grid );
+
// update
- Button updateButton = new Button( Styles.COG );
- updateButton.setToolTipText( Messages.getString( "update" ) );
- updateButton.setActionCommand( connectionFactory.getName() );
- updateButton.addActionListener( update );
- row.add( updateButton );
- }
- if ( getEnvironementWindow().adminPermission || getEnvironementWindow().jeeResourcesChangePermission)
- {
- // edit
- Button editButton = new Button( Styles.ACCEPT );
- editButton.setToolTipText( Messages.getString( "apply" ) );
- editButton.setActionCommand( connectionFactory.getName() );
- editButton.addActionListener( edit );
- row.add( editButton );
- // delete
- Button deleteButton = new Button( Styles.DELETE );
- deleteButton.setToolTipText( Messages.getString( "delete" ) );
- deleteButton.setActionCommand( connectionFactory.getName() );
- deleteButton.addActionListener( delete );
- row.add( deleteButton );
- }
- // name
- TextField nameField = new TextField();
- nameField.setId(
- "cfname_" + parent.getEnvironmentName() + "_" + applicationServerName + "_" + connectionFactory.getName() );
- nameField.setStyleName( "default" );
- nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
- nameField.setText( connectionFactory.getName() );
- grid.add( nameField );
+ update();
}
- // add the blank row to create a new JMS connection factory
- if ( getEnvironementWindow().adminPermission || getEnvironementWindow().jeeResourcesChangePermission)
+ /**
+ * Update the pane.
+ */
+ public void update()
{
- // row
- Row row = new Row();
- row.setInsets( new Insets( 2 ) );
- row.setCellSpacing( new Extent( 2 ) );
- grid.add( row );
- // paste
- Button pasteButton = new Button( Styles.PAGE_PASTE );
- pasteButton.setToolTipText( Messages.getString( "paste" ) );
- pasteButton.addActionListener( paste );
- row.add( pasteButton );
- // active
- Button activeButton;
- if ( newIsActive )
- {
- activeButton = new Button( Styles.LIGHTBULB );
- activeButton.setToolTipText( Messages.getString( "switch.disable" ) );
- }
- else
- {
- activeButton = new Button( Styles.LIGHTBULB_OFF );
- activeButton.setToolTipText( Messages.getString( "switch.enable" ) );
- }
- activeButton.addActionListener( newToggleActive );
- row.add( activeButton );
- // blocker
- Button blockerButton;
- if ( newIsBlocker )
- {
- blockerButton = new Button( Styles.PLUGIN );
- blockerButton.setToolTipText( Messages.getString( "switch.notblocker" ) );
- }
- else
- {
- blockerButton = new Button( Styles.PLUGIN_DISABLED );
- blockerButton.setToolTipText( Messages.getString( "switch.blocker" ) );
- }
- blockerButton.addActionListener( newToggleBlocker );
- row.add( blockerButton );
- // add
- Button addButton = new Button( Styles.ADD );
- addButton.setToolTipText( Messages.getString( "add" ) );
- addButton.addActionListener( create );
- row.add( addButton );
- // name
- newNameField = new TextField();
- newNameField.setStyleName( "default" );
- newNameField.setWidth( new Extent( 100, Extent.PERCENT ) );
- grid.add( newNameField );
- }
- }
+ String applicationServerName = null;
+ // update the scope select field
+ DefaultListModel scopeListModel = (DefaultListModel) scopeField.getModel();
+ if ( scopeListModel.size() > 0 )
+ {
+ applicationServerName = (String) scopeField.getSelectedItem();
+ }
+ scopeListModel.removeAll();
+ int scopeIndex = 0;
+ int found = -1;
+ for ( Iterator applicationServerIterator =
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServers().iterator();
+ applicationServerIterator.hasNext(); )
+ {
+ JEEApplicationServer applicationServer = (JEEApplicationServer) applicationServerIterator.next();
+ scopeListModel.add( applicationServer.getName() );
+ if ( applicationServer.getName().equals( applicationServerName ) )
+ {
+ found = scopeIndex;
+ }
+ scopeIndex++;
+ }
- public EnvironmentWindow getEnvironementWindow()
- {
- return parent;
- }
+ // remove all JMS connection factories grid children
+ grid.removeAll();
+
+ if ( scopeListModel.size() < 1 )
+ {
+ // no application server present
+ return;
+ }
+ // update the scope select field selected index
+ if ( found == -1 )
+ {
+ scopeField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ scopeField.setSelectedIndex( found );
+ }
+ // update the application server name from the scope (in case of
+ // application server deletion)
+ applicationServerName = (String) scopeField.getSelectedItem();
+
+ // add JMS connection factories grid header
+ Label connectionFactoryHeader = new Label( " " );
+ connectionFactoryHeader.setStyleName( "grid.header" );
+ grid.add( connectionFactoryHeader );
+ Label connectionFactoryNameHeader = new Label( Messages.getString( "name" ) );
+ connectionFactoryNameHeader.setStyleName( "grid.header" );
+ grid.add( connectionFactoryNameHeader );
+ // add the jms connection factories
+ for ( Iterator jmsConnectionFactoryIterator =
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ applicationServerName ).getJMSConnectionFactories().iterator();
+ jmsConnectionFactoryIterator.hasNext(); )
+ {
+ JMSConnectionFactory connectionFactory = (JMSConnectionFactory) jmsConnectionFactoryIterator.next();
+ // row
+ Row row = new Row();
+ row.setInsets( new Insets( 2 ) );
+ row.setCellSpacing( new Extent( 2 ) );
+ grid.add( row );
+ // copy
+ Button copyButton = new Button( Styles.PAGE_COPY );
+ copyButton.setToolTipText( Messages.getString( "copy" ) );
+ copyButton.setActionCommand( connectionFactory.getName() );
+ copyButton.addActionListener( copy );
+ row.add( copyButton );
+ // active
+ Button activeButton;
+ if ( connectionFactory.isActive() )
+ {
+ activeButton = new Button( Styles.LIGHTBULB );
+ activeButton.setToolTipText( Messages.getString( "switch.disable" ) );
+ }
+ else
+ {
+ activeButton = new Button( Styles.LIGHTBULB_OFF );
+ activeButton.setToolTipText( Messages.getString( "switch.enable" ) );
+ }
+ if ( getEnvironementWindow().adminPermission || getEnvironementWindow().jeeResourcesChangePermission )
+ {
+ activeButton.setActionCommand( connectionFactory.getName() );
+ activeButton.addActionListener( toggleActive );
+ }
+ row.add( activeButton );
+ // blocker
+ Button blockerButton;
+ if ( connectionFactory.isBlocker() )
+ {
+ blockerButton = new Button( Styles.PLUGIN );
+ blockerButton.setToolTipText( Messages.getString( "switch.notblocker" ) );
+ }
+ else
+ {
+ blockerButton = new Button( Styles.PLUGIN_DISABLED );
+ blockerButton.setToolTipText( Messages.getString( "switch.blocker" ) );
+ }
+ if ( getEnvironementWindow().adminPermission || getEnvironementWindow().jeeResourcesChangePermission )
+ {
+ blockerButton.setActionCommand( connectionFactory.getName() );
+ blockerButton.addActionListener( toggleBlocker );
+ }
+ row.add( blockerButton );
+ // status
+ Button statusButton = new Button( Styles.INFORMATION );
+ statusButton.setToolTipText( Messages.getString( "status" ) );
+ statusButton.setActionCommand( connectionFactory.getName() );
+ statusButton.addActionListener( status );
+ row.add( statusButton );
+ if ( getEnvironementWindow().adminPermission || getEnvironementWindow().jeeResourcesUpdatePermission )
+ {
+ // update
+ Button updateButton = new Button( Styles.COG );
+ updateButton.setToolTipText( Messages.getString( "update" ) );
+ updateButton.setActionCommand( connectionFactory.getName() );
+ updateButton.addActionListener( update );
+ row.add( updateButton );
+ }
+ if ( getEnvironementWindow().adminPermission || getEnvironementWindow().jeeResourcesChangePermission )
+ {
+ // edit
+ Button editButton = new Button( Styles.ACCEPT );
+ editButton.setToolTipText( Messages.getString( "apply" ) );
+ editButton.setActionCommand( connectionFactory.getName() );
+ editButton.addActionListener( edit );
+ row.add( editButton );
+ // delete
+ Button deleteButton = new Button( Styles.DELETE );
+ deleteButton.setToolTipText( Messages.getString( "delete" ) );
+ deleteButton.setActionCommand( connectionFactory.getName() );
+ deleteButton.addActionListener( delete );
+ row.add( deleteButton );
+ }
+ // name
+ TextField nameField = new TextField();
+ nameField.setId( "cfname_" + parent.getEnvironmentName() + "_" + applicationServerName + "_"
+ + connectionFactory.getName() );
+ nameField.setStyleName( "default" );
+ nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ nameField.setText( connectionFactory.getName() );
+ grid.add( nameField );
+ }
+
+ // add the blank row to create a new JMS connection factory
+ if ( getEnvironementWindow().adminPermission || getEnvironementWindow().jeeResourcesChangePermission )
+ {
+ // row
+ Row row = new Row();
+ row.setInsets( new Insets( 2 ) );
+ row.setCellSpacing( new Extent( 2 ) );
+ grid.add( row );
+ // paste
+ Button pasteButton = new Button( Styles.PAGE_PASTE );
+ pasteButton.setToolTipText( Messages.getString( "paste" ) );
+ pasteButton.addActionListener( paste );
+ row.add( pasteButton );
+ // active
+ Button activeButton;
+ if ( newIsActive )
+ {
+ activeButton = new Button( Styles.LIGHTBULB );
+ activeButton.setToolTipText( Messages.getString( "switch.disable" ) );
+ }
+ else
+ {
+ activeButton = new Button( Styles.LIGHTBULB_OFF );
+ activeButton.setToolTipText( Messages.getString( "switch.enable" ) );
+ }
+ activeButton.addActionListener( newToggleActive );
+ row.add( activeButton );
+ // blocker
+ Button blockerButton;
+ if ( newIsBlocker )
+ {
+ blockerButton = new Button( Styles.PLUGIN );
+ blockerButton.setToolTipText( Messages.getString( "switch.notblocker" ) );
+ }
+ else
+ {
+ blockerButton = new Button( Styles.PLUGIN_DISABLED );
+ blockerButton.setToolTipText( Messages.getString( "switch.blocker" ) );
+ }
+ blockerButton.addActionListener( newToggleBlocker );
+ row.add( blockerButton );
+ // add
+ Button addButton = new Button( Styles.ADD );
+ addButton.setToolTipText( Messages.getString( "add" ) );
+ addButton.addActionListener( create );
+ row.add( addButton );
+ // name
+ newNameField = new TextField();
+ newNameField.setStyleName( "default" );
+ newNameField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ grid.add( newNameField );
+ }
+ }
+
+ public EnvironmentWindow getEnvironementWindow()
+ {
+ return parent;
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolCapacityPane.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolCapacityPane.java
index a17a6b8..880a46b 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolCapacityPane.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolCapacityPane.java
@@ -28,94 +28,94 @@
* JDBC connection pool capacity tab pane.
*/
public class ConnectionPoolCapacityPane
- extends ContentPane
+ extends ContentPane
{
- private ConnectionPoolWindow parent;
+ private ConnectionPoolWindow parent;
- private TextField initialField;
+ private TextField initialField;
- private TextField maximalField;
+ private TextField maximalField;
- private TextField incrementField;
+ private TextField incrementField;
- /**
- * Create a new <code>JDBCConnectionPoolCapacityTabPane</code>.
- *
- * @param parent the parent <code>JDBCConnectionPoolWindow</code>.
- */
- public ConnectionPoolCapacityPane( ConnectionPoolWindow parent )
- {
- super();
- setStyleName( "tab.content" );
+ /**
+ * Create a new <code>JDBCConnectionPoolCapacityTabPane</code>.
+ *
+ * @param parent the parent <code>JDBCConnectionPoolWindow</code>.
+ */
+ public ConnectionPoolCapacityPane( ConnectionPoolWindow parent )
+ {
+ super();
+ setStyleName( "tab.content" );
- // update parent
- this.parent = parent;
+ // update parent
+ this.parent = parent;
- // add the capacity layout grid
- Grid layout = new Grid( 2 );
- layout.setStyleName( "default" );
- layout.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
- layout.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
- add( layout );
+ // add the capacity layout grid
+ Grid layout = new Grid( 2 );
+ layout.setStyleName( "default" );
+ layout.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
+ layout.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
+ add( layout );
- // add the initial field
- Label initialLabel = new Label( Messages.getString( "initial" ) );
- initialLabel.setStyleName( "grid.cell" );
- layout.add( initialLabel );
- initialField = new TextField();
- initialField.setStyleName( "default" );
- initialField.setWidth( new Extent( 10, Extent.EX ) );
- layout.add( initialField );
+ // add the initial field
+ Label initialLabel = new Label( Messages.getString( "initial" ) );
+ initialLabel.setStyleName( "grid.cell" );
+ layout.add( initialLabel );
+ initialField = new TextField();
+ initialField.setStyleName( "default" );
+ initialField.setWidth( new Extent( 10, Extent.EX ) );
+ layout.add( initialField );
- // add the maximal field
- Label maximalLabel = new Label( Messages.getString( "maximal" ) );
- maximalLabel.setStyleName( "grid.cell" );
- layout.add( maximalLabel );
- maximalField = new TextField();
- maximalField.setStyleName( "default" );
- maximalField.setWidth( new Extent( 10, Extent.EX ) );
- layout.add( maximalField );
+ // add the maximal field
+ Label maximalLabel = new Label( Messages.getString( "maximal" ) );
+ maximalLabel.setStyleName( "grid.cell" );
+ layout.add( maximalLabel );
+ maximalField = new TextField();
+ maximalField.setStyleName( "default" );
+ maximalField.setWidth( new Extent( 10, Extent.EX ) );
+ layout.add( maximalField );
- // add the increment field
- Label incrementLabel = new Label( Messages.getString( "increment" ) );
- incrementLabel.setStyleName( "grid.cell" );
- layout.add( incrementLabel );
- incrementField = new TextField();
- incrementField.setStyleName( "default" );
- incrementField.setWidth( new Extent( 10, Extent.EX ) );
- layout.add( incrementField );
+ // add the increment field
+ Label incrementLabel = new Label( Messages.getString( "increment" ) );
+ incrementLabel.setStyleName( "grid.cell" );
+ layout.add( incrementLabel );
+ incrementField = new TextField();
+ incrementField.setStyleName( "default" );
+ incrementField.setWidth( new Extent( 10, Extent.EX ) );
+ layout.add( incrementField );
- // update the pane
- update();
- }
+ // update the pane
+ update();
+ }
- /**
- * Update the pane
- */
- public void update()
- {
- // update the JDBC connection pool initial field
- initialField.setText( new Integer( parent.getConnectionPool().getInitial() ).toString() );
- // update the JDBC connection pool maximal field
- maximalField.setText( new Integer( parent.getConnectionPool().getMaximal() ).toString() );
- // update the JDBC connection pool increment field
- incrementField.setText( new Integer( parent.getConnectionPool().getIncrement() ).toString() );
- }
+ /**
+ * Update the pane
+ */
+ public void update()
+ {
+ // update the JDBC connection pool initial field
+ initialField.setText( new Integer( parent.getConnectionPool().getInitial() ).toString() );
+ // update the JDBC connection pool maximal field
+ maximalField.setText( new Integer( parent.getConnectionPool().getMaximal() ).toString() );
+ // update the JDBC connection pool increment field
+ incrementField.setText( new Integer( parent.getConnectionPool().getIncrement() ).toString() );
+ }
- public TextField getInitialField()
- {
- return this.initialField;
- }
+ public TextField getInitialField()
+ {
+ return this.initialField;
+ }
- public TextField getMaximalField()
- {
- return this.maximalField;
- }
+ public TextField getMaximalField()
+ {
+ return this.maximalField;
+ }
- public TextField getIncrementField()
- {
- return this.incrementField;
- }
+ public TextField getIncrementField()
+ {
+ return this.incrementField;
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolDatabasePane.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolDatabasePane.java
index 0cf34e3..cf43462 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolDatabasePane.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolDatabasePane.java
@@ -29,112 +29,112 @@
* JDBC connection pool database tab <code>ContentPane</code>.
*/
public class ConnectionPoolDatabasePane
- extends ContentPane
+ extends ContentPane
{
- // attributes
- private ConnectionPoolWindow parent;
+ // attributes
+ private ConnectionPoolWindow parent;
- private TextField urlField;
+ private TextField urlField;
- private TextField userField;
+ private TextField userField;
- private PasswordField passwordField;
+ private PasswordField passwordField;
- private PasswordField confirmPasswordField;
+ private PasswordField confirmPasswordField;
- /**
- * Create a new <code>JDBCConnectionPoolDatabaseTabPane</code>.<
- *
- * @param parent the parent <code>JDBCConnectionPoolWindow</code>.
- */
- public ConnectionPoolDatabasePane( ConnectionPoolWindow parent )
- {
- super();
- setStyleName( "tab.content" );
+ /**
+ * Create a new <code>JDBCConnectionPoolDatabaseTabPane</code>.<
+ *
+ * @param parent the parent <code>JDBCConnectionPoolWindow</code>.
+ */
+ public ConnectionPoolDatabasePane( ConnectionPoolWindow parent )
+ {
+ super();
+ setStyleName( "tab.content" );
- // update parent
- this.parent = parent;
+ // update parent
+ this.parent = parent;
- // add the database layout grid
- Grid layout = new Grid( 2 );
- layout.setStyleName( "default" );
- layout.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
- layout.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
- add( layout );
+ // add the database layout grid
+ Grid layout = new Grid( 2 );
+ layout.setStyleName( "default" );
+ layout.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
+ layout.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
+ add( layout );
- // add the URL field
- Label urlLabel = new Label( Messages.getString( "jdbc" ) );
- urlLabel.setStyleName( "grid.cell" );
- layout.add( urlLabel );
- urlField = new TextField();
- urlField.setStyleName( "default" );
- urlField.setWidth( new Extent( 100, Extent.PERCENT ) );
- layout.add( urlField );
+ // add the URL field
+ Label urlLabel = new Label( Messages.getString( "jdbc" ) );
+ urlLabel.setStyleName( "grid.cell" );
+ layout.add( urlLabel );
+ urlField = new TextField();
+ urlField.setStyleName( "default" );
+ urlField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ layout.add( urlField );
- // add the user field
- Label userLabel = new Label( Messages.getString( "user" ) );
- userLabel.setStyleName( "grid.cell" );
- layout.add( userLabel );
- userField = new TextField();
- userField.setStyleName( "default" );
- userField.setWidth( new Extent( 100, Extent.PERCENT ) );
- layout.add( userField );
+ // add the user field
+ Label userLabel = new Label( Messages.getString( "user" ) );
+ userLabel.setStyleName( "grid.cell" );
+ layout.add( userLabel );
+ userField = new TextField();
+ userField.setStyleName( "default" );
+ userField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ layout.add( userField );
- // add the password field
- Label passwordLabel = new Label( Messages.getString( "password" ) );
- passwordLabel.setStyleName( "grid.cell" );
- layout.add( passwordLabel );
- passwordField = new PasswordField();
- passwordField.setStyleName( "default" );
- passwordField.setWidth( new Extent( 100, Extent.PERCENT ) );
- layout.add( passwordField );
+ // add the password field
+ Label passwordLabel = new Label( Messages.getString( "password" ) );
+ passwordLabel.setStyleName( "grid.cell" );
+ layout.add( passwordLabel );
+ passwordField = new PasswordField();
+ passwordField.setStyleName( "default" );
+ passwordField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ layout.add( passwordField );
- // add the confirm password field
- Label confirmPasswordLabel = new Label( Messages.getString( "password.confirm" ) );
- confirmPasswordLabel.setStyleName( "grid.cell" );
- layout.add( confirmPasswordLabel );
- confirmPasswordField = new PasswordField();
- confirmPasswordField.setStyleName( "default" );
- confirmPasswordField.setWidth( new Extent( 100, Extent.PERCENT ) );
- layout.add( confirmPasswordField );
+ // add the confirm password field
+ Label confirmPasswordLabel = new Label( Messages.getString( "password.confirm" ) );
+ confirmPasswordLabel.setStyleName( "grid.cell" );
+ layout.add( confirmPasswordLabel );
+ confirmPasswordField = new PasswordField();
+ confirmPasswordField.setStyleName( "default" );
+ confirmPasswordField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ layout.add( confirmPasswordField );
- // update the pane
- update();
- }
+ // update the pane
+ update();
+ }
- /**
- * Update the pane
- */
- public void update()
- {
- // update the JDBC connection pool URL field
- urlField.setText( parent.getConnectionPool().getUrl() );
- // update the JDBC connection pool user field
- userField.setText( parent.getConnectionPool().getUser() );
- // update the JDBC connection pool password field
- passwordField.setText( parent.getConnectionPool().getPassword() );
- confirmPasswordField.setText( parent.getConnectionPool().getPassword() );
- }
+ /**
+ * Update the pane
+ */
+ public void update()
+ {
+ // update the JDBC connection pool URL field
+ urlField.setText( parent.getConnectionPool().getUrl() );
+ // update the JDBC connection pool user field
+ userField.setText( parent.getConnectionPool().getUser() );
+ // update the JDBC connection pool password field
+ passwordField.setText( parent.getConnectionPool().getPassword() );
+ confirmPasswordField.setText( parent.getConnectionPool().getPassword() );
+ }
- public TextField getUrlField()
- {
- return this.urlField;
- }
+ public TextField getUrlField()
+ {
+ return this.urlField;
+ }
- public TextField getUserField()
- {
- return this.userField;
- }
+ public TextField getUserField()
+ {
+ return this.userField;
+ }
- public PasswordField getPasswordField()
- {
- return this.passwordField;
- }
+ public PasswordField getPasswordField()
+ {
+ return this.passwordField;
+ }
- public PasswordField getConfirmPasswordField()
- {
- return this.confirmPasswordField;
- }
+ public PasswordField getConfirmPasswordField()
+ {
+ return this.confirmPasswordField;
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolDriverPane.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolDriverPane.java
index 5f8a709..21a9ca2 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolDriverPane.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolDriverPane.java
@@ -30,136 +30,136 @@
* JDBC connection pool driver tab <code>ContentPane</code>
*/
public class ConnectionPoolDriverPane
- extends ContentPane
+ extends ContentPane
{
- // constants
- private static String[] DRIVERS =
- new String[]{ Messages.getString( "jdbc.driver.oracle.thin" ), Messages.getString( "jdbc.driver.oracle.xa" ),
- Messages.getString( "jdbc.driver.ibm.db2" ), Messages.getString( "jdbc.driver.mysql" ),
- Messages.getString( "jdbc.driver.postgresql" ) };
+ // constants
+ private static String[] DRIVERS =
+ new String[]{ Messages.getString( "jdbc.driver.oracle.thin" ), Messages.getString( "jdbc.driver.oracle.xa" ),
+ Messages.getString( "jdbc.driver.ibm.db2" ), Messages.getString( "jdbc.driver.mysql" ),
+ Messages.getString( "jdbc.driver.postgresql" ) };
- private static String[] HELPERS = new String[]{ " ", Messages.getString( "jdbc.helper.websphere.generic" ),
- Messages.getString( "jdbc.helper.websphere.oracle" ) };
+ private static String[] HELPERS = new String[]{ " ", Messages.getString( "jdbc.helper.websphere.generic" ),
+ Messages.getString( "jdbc.helper.websphere.oracle" ) };
- // attributes
- private ConnectionPoolWindow parent;
+ // attributes
+ private ConnectionPoolWindow parent;
- private SelectField driverField;
+ private SelectField driverField;
- private SelectField helperField;
+ private SelectField helperField;
- private TextField classpathField;
+ private TextField classpathField;
- /**
- * Create a new <code>JDBCConnectionPoolDriverTabPane</code>.
- *
- * @param parent the parent <code>JDBCConnectionPoolWindow</code>.
- */
- public ConnectionPoolDriverPane( ConnectionPoolWindow parent )
- {
- super();
- setStyleName( "tab;content" );
-
- // update parent
- this.parent = parent;
-
- // add the driver layout grid
- Grid layout = new Grid( 2 );
- layout.setStyleName( "default" );
- layout.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
- layout.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
- add( layout );
-
- // add the driver field
- Label driverLabel = new Label( Messages.getString( "jdbc.driver" ) );
- driverLabel.setStyleName( "grid.cell" );
- layout.add( driverLabel );
- driverField = new SelectField( ConnectionPoolDriverPane.DRIVERS );
- driverField.setStyleName( "default" );
- driverField.setWidth( new Extent( 50, Extent.EX ) );
- driverField.setSelectedIndex( 0 );
- layout.add( driverField );
-
- // add the helper field
- Label helperLabel = new Label( Messages.getString( "jdbc.helper" ) );
- helperLabel.setStyleName( "grid.cell" );
- layout.add( helperLabel );
- helperField = new SelectField( ConnectionPoolDriverPane.HELPERS );
- helperField.setStyleName( "default" );
- helperField.setWidth( new Extent( 50, Extent.EX ) );
- helperField.setSelectedIndex( 0 );
- layout.add( helperField );
-
- // add the classpath field
- Label classpathLabel = new Label( Messages.getString( "classpath" ) );
- classpathLabel.setStyleName( "grid.cell" );
- layout.add( classpathLabel );
- classpathField = new TextField();
- classpathField.setStyleName( "default" );
- classpathField.setWidth( new Extent( 100, Extent.PERCENT ) );
- layout.add( classpathField );
-
- // update the pane
- update();
- }
-
- /**
- * Update the pane
- */
- public void update()
- {
- // update the JDBC connection pool driver field
- if ( StringUtils.containsIgnoreCase( parent.getConnectionPool().getDriver(), "oracle" ) )
+ /**
+ * Create a new <code>JDBCConnectionPoolDriverTabPane</code>.
+ *
+ * @param parent the parent <code>JDBCConnectionPoolWindow</code>.
+ */
+ public ConnectionPoolDriverPane( ConnectionPoolWindow parent )
{
- if ( StringUtils.containsIgnoreCase( parent.getConnectionPool().getDriver(), "xa" ) )
- {
- driverField.setSelectedIndex( 1 );
- }
- else
- {
+ super();
+ setStyleName( "tab;content" );
+
+ // update parent
+ this.parent = parent;
+
+ // add the driver layout grid
+ Grid layout = new Grid( 2 );
+ layout.setStyleName( "default" );
+ layout.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
+ layout.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
+ add( layout );
+
+ // add the driver field
+ Label driverLabel = new Label( Messages.getString( "jdbc.driver" ) );
+ driverLabel.setStyleName( "grid.cell" );
+ layout.add( driverLabel );
+ driverField = new SelectField( ConnectionPoolDriverPane.DRIVERS );
+ driverField.setStyleName( "default" );
+ driverField.setWidth( new Extent( 50, Extent.EX ) );
driverField.setSelectedIndex( 0 );
- }
- }
- if ( StringUtils.containsIgnoreCase( parent.getConnectionPool().getDriver(), "db2" ) )
- {
- driverField.setSelectedIndex( 2 );
- }
- if ( StringUtils.containsIgnoreCase( parent.getConnectionPool().getDriver(), "mysql" ) )
- {
- driverField.setSelectedIndex( 3 );
- }
- if ( StringUtils.containsIgnoreCase( parent.getConnectionPool().getDriver(), "postgres" ) )
- {
- driverField.setSelectedIndex( 4 );
- }
- // update the JDBC connection pool helper field
- helperField.setSelectedIndex( 0 );
- if ( StringUtils.containsIgnoreCase( parent.getConnectionPool().getHelperclass(), "generic" ) )
- {
- helperField.setSelectedIndex( 1 );
- }
- if ( StringUtils.containsIgnoreCase( parent.getConnectionPool().getHelperclass(), "oracle" ) )
- {
- helperField.setSelectedIndex( 2 );
- }
- // update the JDBC connection pool classpath field
- classpathField.setText( parent.getConnectionPool().getClasspath() );
- }
+ layout.add( driverField );
- public SelectField getDriverField()
- {
- return this.driverField;
- }
+ // add the helper field
+ Label helperLabel = new Label( Messages.getString( "jdbc.helper" ) );
+ helperLabel.setStyleName( "grid.cell" );
+ layout.add( helperLabel );
+ helperField = new SelectField( ConnectionPoolDriverPane.HELPERS );
+ helperField.setStyleName( "default" );
+ helperField.setWidth( new Extent( 50, Extent.EX ) );
+ helperField.setSelectedIndex( 0 );
+ layout.add( helperField );
- public SelectField getHelperField()
- {
- return this.helperField;
- }
+ // add the classpath field
+ Label classpathLabel = new Label( Messages.getString( "classpath" ) );
+ classpathLabel.setStyleName( "grid.cell" );
+ layout.add( classpathLabel );
+ classpathField = new TextField();
+ classpathField.setStyleName( "default" );
+ classpathField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ layout.add( classpathField );
- public TextField getClasspathField()
- {
- return this.classpathField;
- }
+ // update the pane
+ update();
+ }
+
+ /**
+ * Update the pane
+ */
+ public void update()
+ {
+ // update the JDBC connection pool driver field
+ if ( StringUtils.containsIgnoreCase( parent.getConnectionPool().getDriver(), "oracle" ) )
+ {
+ if ( StringUtils.containsIgnoreCase( parent.getConnectionPool().getDriver(), "xa" ) )
+ {
+ driverField.setSelectedIndex( 1 );
+ }
+ else
+ {
+ driverField.setSelectedIndex( 0 );
+ }
+ }
+ if ( StringUtils.containsIgnoreCase( parent.getConnectionPool().getDriver(), "db2" ) )
+ {
+ driverField.setSelectedIndex( 2 );
+ }
+ if ( StringUtils.containsIgnoreCase( parent.getConnectionPool().getDriver(), "mysql" ) )
+ {
+ driverField.setSelectedIndex( 3 );
+ }
+ if ( StringUtils.containsIgnoreCase( parent.getConnectionPool().getDriver(), "postgres" ) )
+ {
+ driverField.setSelectedIndex( 4 );
+ }
+ // update the JDBC connection pool helper field
+ helperField.setSelectedIndex( 0 );
+ if ( StringUtils.containsIgnoreCase( parent.getConnectionPool().getHelperclass(), "generic" ) )
+ {
+ helperField.setSelectedIndex( 1 );
+ }
+ if ( StringUtils.containsIgnoreCase( parent.getConnectionPool().getHelperclass(), "oracle" ) )
+ {
+ helperField.setSelectedIndex( 2 );
+ }
+ // update the JDBC connection pool classpath field
+ classpathField.setText( parent.getConnectionPool().getClasspath() );
+ }
+
+ public SelectField getDriverField()
+ {
+ return this.driverField;
+ }
+
+ public SelectField getHelperField()
+ {
+ return this.helperField;
+ }
+
+ public TextField getClasspathField()
+ {
+ return this.classpathField;
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolGeneralPane.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolGeneralPane.java
index 1249386..5e9b893 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolGeneralPane.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolGeneralPane.java
@@ -29,111 +29,111 @@
* JDBC connection pool general tab <code>ContentPane</code>.
*/
public class ConnectionPoolGeneralPane
- extends ContentPane
+ extends ContentPane
{
- // attributes
- private ConnectionPoolWindow parent;
+ // attributes
+ private ConnectionPoolWindow parent;
- private TextField nameField;
+ private TextField nameField;
- private SelectField activeField;
+ private SelectField activeField;
- private SelectField blockerField;
+ private SelectField blockerField;
- /**
- * Create a new <code>JDBCConnectionPoolGeneralTabPane</code>.
- *
- * @param parent the parent <code>JDBCConnectionPoolWindow</code>.
- */
- public ConnectionPoolGeneralPane( ConnectionPoolWindow parent )
- {
- super();
- setStyleName( "tab.content" );
-
- // update parent
- this.parent = parent;
-
- // add the general grid layout
- Grid layout = new Grid( 2 );
- layout.setStyleName( "default" );
- layout.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
- layout.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
- add( layout );
-
- // add the name field
- Label nameLabel = new Label( Messages.getString( "name" ) );
- nameLabel.setStyleName( "grid.cell" );
- layout.add( nameLabel );
- nameField = new TextField();
- nameField.setStyleName( "default" );
- nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
- layout.add( nameField );
-
- // add the active field
- Label jdbcConnectionPoolActiveLabel = new Label( Messages.getString( "active" ) );
- jdbcConnectionPoolActiveLabel.setStyleName( "grid.cell" );
- layout.add( jdbcConnectionPoolActiveLabel );
- activeField = new SelectField( MainScreen.LABELS );
- activeField.setStyleName( "default" );
- activeField.setWidth( new Extent( 10, Extent.EX ) );
- activeField.setSelectedIndex( 0 );
- layout.add( activeField );
-
- // add the blocker field
- Label jdbcConnectionPoolBlockerLabel = new Label( Messages.getString( "blocker" ) );
- jdbcConnectionPoolBlockerLabel.setStyleName( "grid.cell" );
- layout.add( jdbcConnectionPoolBlockerLabel );
- blockerField = new SelectField( MainScreen.LABELS );
- blockerField.setStyleName( "default" );
- blockerField.setWidth( new Extent( 10, Extent.EX ) );
- blockerField.setSelectedIndex( 0 );
- layout.add( blockerField );
-
- // update the pane
- update();
- }
-
- /**
- * Update the pane.
- */
- public void update()
- {
- // update the JDBC connection pool name field
- nameField.setText( parent.getConnectionPool().getName() );
- // update the JDBC connection pool active field
- if ( parent.getConnectionPool().isActive() )
+ /**
+ * Create a new <code>JDBCConnectionPoolGeneralTabPane</code>.
+ *
+ * @param parent the parent <code>JDBCConnectionPoolWindow</code>.
+ */
+ public ConnectionPoolGeneralPane( ConnectionPoolWindow parent )
{
- activeField.setSelectedIndex( 0 );
- }
- else
- {
- activeField.setSelectedIndex( 1 );
- }
- // update the JDBC connection pool blocker field
- if ( parent.getConnectionPool().isBlocker() )
- {
- blockerField.setSelectedIndex( 0 );
- }
- else
- {
- blockerField.setSelectedIndex( 1 );
- }
- }
+ super();
+ setStyleName( "tab.content" );
- public TextField getNameField()
- {
- return this.nameField;
- }
+ // update parent
+ this.parent = parent;
- public SelectField getActiveField()
- {
- return this.activeField;
- }
+ // add the general grid layout
+ Grid layout = new Grid( 2 );
+ layout.setStyleName( "default" );
+ layout.setColumnWidth( 0, new Extent( 20, Extent.PERCENT ) );
+ layout.setColumnWidth( 1, new Extent( 80, Extent.PERCENT ) );
+ add( layout );
- public SelectField getBlockerField()
- {
- return this.blockerField;
- }
+ // add the name field
+ Label nameLabel = new Label( Messages.getString( "name" ) );
+ nameLabel.setStyleName( "grid.cell" );
+ layout.add( nameLabel );
+ nameField = new TextField();
+ nameField.setStyleName( "default" );
+ nameField.setWidth( new Extent( 100, Extent.PERCENT ) );
+ layout.add( nameField );
+
+ // add the active field
+ Label jdbcConnectionPoolActiveLabel = new Label( Messages.getString( "active" ) );
+ jdbcConnectionPoolActiveLabel.setStyleName( "grid.cell" );
+ layout.add( jdbcConnectionPoolActiveLabel );
+ activeField = new SelectField( MainScreen.LABELS );
+ activeField.setStyleName( "default" );
+ activeField.setWidth( new Extent( 10, Extent.EX ) );
+ activeField.setSelectedIndex( 0 );
+ layout.add( activeField );
+
+ // add the blocker field
+ Label jdbcConnectionPoolBlockerLabel = new Label( Messages.getString( "blocker" ) );
+ jdbcConnectionPoolBlockerLabel.setStyleName( "grid.cell" );
+ layout.add( jdbcConnectionPoolBlockerLabel );
+ blockerField = new SelectField( MainScreen.LABELS );
+ blockerField.setStyleName( "default" );
+ blockerField.setWidth( new Extent( 10, Extent.EX ) );
+ blockerField.setSelectedIndex( 0 );
+ layout.add( blockerField );
+
+ // update the pane
+ update();
+ }
+
+ /**
+ * Update the pane.
+ */
+ public void update()
+ {
+ // update the JDBC connection pool name field
+ nameField.setText( parent.getConnectionPool().getName() );
+ // update the JDBC connection pool active field
+ if ( parent.getConnectionPool().isActive() )
+ {
+ activeField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ activeField.setSelectedIndex( 1 );
+ }
+ // update the JDBC connection pool blocker field
+ if ( parent.getConnectionPool().isBlocker() )
+ {
+ blockerField.setSelectedIndex( 0 );
+ }
+ else
+ {
+ blockerField.setSelectedIndex( 1 );
+ }
+ }
+
+ public TextField getNameField()
+ {
+ return this.nameField;
+ }
+
+ public SelectField getActiveField()
+ {
+ return this.activeField;
+ }
+
+ public SelectField getBlockerField()
+ {
+ return this.blockerField;
+ }
}
\ No newline at end of file
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolWindow.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolWindow.java
index f0ba4ab..1dc2e18 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolWindow.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolWindow.java
@@ -37,693 +37,690 @@
* JDBC connection pool window.
*/
public class ConnectionPoolWindow
- extends WindowPane
+ extends WindowPane
{
- private String connectionPoolName;
+ private String connectionPoolName;
- private String applicationServerName;
+ private String applicationServerName;
- private JDBCConnectionPool connectionPool = null;
+ private JDBCConnectionPool connectionPool = null;
- private ConnectionPoolsPane parent;
+ private ConnectionPoolsPane parent;
- private ConnectionPoolGeneralPane generalPane;
+ private ConnectionPoolGeneralPane generalPane;
- private ConnectionPoolDriverPane driverPane;
+ private ConnectionPoolDriverPane driverPane;
- private ConnectionPoolDatabasePane databasePane;
+ private ConnectionPoolDatabasePane databasePane;
- private ConnectionPoolCapacityPane capacityPane;
+ private ConnectionPoolCapacityPane capacityPane;
- // status thread
- class StatusThread
- extends Thread
- {
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // status thread
+ class StatusThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getEnvironmentWindow().getEnvironment().getAgent() );
- if ( agent == null )
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
- }
- // call the webservice
- JDBCConnectionPoolClient client = new JDBCConnectionPoolClient( agent.getHostname(), agent.getPort() );
- boolean uptodate =
- client.check( parent.getEnvironmentWindow().getEnvironmentName(), applicationServerName, connectionPoolName );
- if ( uptodate )
- {
- message = "JDBC connection pool " + connectionPoolName + " is up to date.";
- }
- else
- {
- failure = true;
- message = "JDBC connection pool " + connectionPoolName + " is not up to date.";
- }
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JDBC connection pool " + connectionPoolName + " status check failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
- }
- }
-
- // update thread
- class UpdateThread
- extends Thread
- {
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
- {
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getEnvironmentWindow().getEnvironment().getAgent() );
- if ( agent == null )
- {
- throw new IllegalArgumentException( "agent not found." );
- }
- // call the webservice
- JDBCConnectionPoolClient client = new JDBCConnectionPoolClient( agent.getHostname(), agent.getPort() );
- client.update( parent.getEnvironmentWindow().getEnvironmentName(), applicationServerName, connectionPoolName );
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JDBC connection pool " + connectionPoolName + " update failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
- }
- }
-
- // close
- private ActionListener close = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- ConnectionPoolWindow.this.userClose();
- }
- };
-
- // refresh
- private ActionListener refresh = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // looking for original JDBC connection pool object
- connectionPool =
- parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- applicationServerName ).getJDBCConnectionPool( connectionPoolName );
- if ( connectionPool == null )
- {
- connectionPool = new JDBCConnectionPool();
- }
- // update the window
- update();
- }
- };
-
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeResourcesChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // remove the connection pool
- parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- applicationServerName ).getJDBCConnectionPools().remove( connectionPool );
- // add a change event
- parent.getEnvironmentWindow().getChangeEvents().add(
- "Delete JDBC connection pool " + connectionPool.getName() );
- // change the updated flag
- parent.getEnvironmentWindow().setUpdated( true );
- // update the whole parent window
- parent.getEnvironmentWindow().update();
- // close the window
- ConnectionPoolWindow.this.userClose();
- }
- } ) );
- }
- };
-
- // apply
- private ActionListener apply = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeResourcesChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricited" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get fields value
- String nameFieldValue = generalPane.getNameField().getText();
- int activeFieldIndex = generalPane.getActiveField().getSelectedIndex();
- int blockerFieldIndex = generalPane.getBlockerField().getSelectedIndex();
- int driverFieldIndex = driverPane.getDriverField().getSelectedIndex();
- int helperFieldIndex = driverPane.getHelperField().getSelectedIndex();
- String classpathFieldValue = driverPane.getClasspathField().getText();
- String urlFieldValue = databasePane.getUrlField().getText();
- String userFieldValue = databasePane.getUserField().getText();
- String passwordFieldValue = databasePane.getPasswordField().getText();
- String confirmPasswordFieldValue = databasePane.getConfirmPasswordField().getText();
- String initialFieldValue = capacityPane.getInitialField().getText();
- String maximalFieldValue = capacityPane.getMaximalField().getText();
- String incrementFieldValue = capacityPane.getIncrementField().getText();
- // check select fields
- if ( activeFieldIndex < 0 || driverFieldIndex < 0 || helperFieldIndex < 0 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "connectionpool.selected" ) );
- return;
- }
- // check name, url, user are mandatory
- if ( nameFieldValue == null || nameFieldValue.trim().length() < 1 || urlFieldValue == null
- || urlFieldValue.trim().length() < 1 || userFieldValue == null || userFieldValue.trim().length() < 1 )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "connectionpool.mandatory" ) );
- return;
- }
- // check number value
- int jdbcConnectionPoolInitialFieldNumber;
- int jdbcConnectionPoolMaximalFieldNumber;
- int jdbcConnectionPoolIncrementFieldNumber;
- try
- {
- jdbcConnectionPoolInitialFieldNumber = new Integer( initialFieldValue ).intValue();
- jdbcConnectionPoolMaximalFieldNumber = new Integer( maximalFieldValue ).intValue();
- jdbcConnectionPoolIncrementFieldNumber = new Integer( incrementFieldValue ).intValue();
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "connectionpool.notinteger" ) );
- return;
- }
- // check password matching
- if ( !passwordFieldValue.equals( confirmPasswordFieldValue ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "connectionpool.passwordmatch" ) );
- return;
- }
- // if the user change the JDBC connection pool name, check if the JDBC
- // connection pool name doesn't already exist
- if ( connectionPoolName == null || ( connectionPoolName != null && !connectionPoolName.equals(
- nameFieldValue ) ) )
- {
- if ( parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- applicationServerName ).getJDBCConnectionPool( nameFieldValue ) != null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "connectionpool.exists" ) );
- return;
- }
- }
- // add a change event
- if ( connectionPoolName != null )
- {
- parent.getEnvironmentWindow().getChangeEvents().add(
- "Change JDBC connection pool " + connectionPool.getName() );
- }
- // update the connection pool object
- connectionPool.setName( nameFieldValue );
- if ( activeFieldIndex == 0 )
- {
- connectionPool.setActive( true );
- }
- else
- {
- connectionPool.setActive( false );
- }
- if ( blockerFieldIndex == 0 )
- {
- connectionPool.setBlocker( true );
- }
- else
- {
- connectionPool.setBlocker( false );
- }
- if ( driverFieldIndex == 0 )
- {
- connectionPool.setDriver( "oracle.jdbc.driver.OracleDriver" );
- }
- if ( driverFieldIndex == 1 )
- {
- connectionPool.setDriver( "oracle.jdbc.xa.client.OracleXADataSource" );
- }
- if ( driverFieldIndex == 2 )
- {
- connectionPool.setDriver( "com.ibm.db2.jcc.DB2Driver" );
- }
- if ( driverFieldIndex == 3 )
- {
- connectionPool.setDriver( "com.mysql.jdbc.Driver" );
- }
- if ( driverFieldIndex == 4 )
- {
- connectionPool.setDriver( "org.postgresql.Driver" );
- }
- if ( helperFieldIndex == 0 )
- {
- connectionPool.setHelperclass( null );
- }
- if ( helperFieldIndex == 1 )
- {
- connectionPool.setHelperclass( "com.ibm.websphere.rsadapter.GenericDataStoreHelper" );
- }
- if ( helperFieldIndex == 2 )
- {
- connectionPool.setHelperclass( "com.ibm.websphere.rsadapter.OracleDataStoreHelper" );
- }
- connectionPool.setClasspath( classpathFieldValue );
- connectionPool.setUrl( urlFieldValue );
- connectionPool.setUser( userFieldValue );
- connectionPool.setPassword( passwordFieldValue );
- connectionPool.setInitial( jdbcConnectionPoolInitialFieldNumber );
- connectionPool.setMaximal( jdbcConnectionPoolMaximalFieldNumber );
- connectionPool.setIncrement( jdbcConnectionPoolIncrementFieldNumber );
- // add the application server object if needed
- if ( connectionPoolName == null )
- {
- try
- {
- parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- applicationServerName ).addJDBCConnectionPool( connectionPool );
- parent.getEnvironmentWindow().getChangeEvents().add( "Add JDBC connection pool " + connectionPool.getName() );
- }
- catch ( Exception e )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "connectionpool.exists" ) );
- return;
- }
- }
- // update the window definition
- setTitle( Messages.getString( "connectionpool" ) + " " + connectionPool.getName() );
- setId(
- "connectionpoolwindow_" + parent.getEnvironmentWindow().getEnvironmentName() + "_" + applicationServerName + "_"
- + connectionPool.getName() );
- connectionPoolName = connectionPool.getName();
- // change the updated flag
- parent.getEnvironmentWindow().setUpdated( true );
- // update the window
- update();
- // update the whole environment window
- parent.getEnvironmentWindow().update();
- }
- };
-
- // copy
- private ActionListener copy = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- try
- {
- KalumetConsoleApplication.getApplication().setCopyComponent( connectionPool.clone() );
- }
- catch ( Exception e )
- {
- return;
- }
- }
- };
-
- // paste
- private ActionListener paste = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the copy is correct
- Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
- if ( copy == null || !( copy instanceof JDBCConnectionPool ) )
- {
- return;
- }
- connectionPool = (JDBCConnectionPool) copy;
- connectionPoolName = null;
- // update the parent pane
- parent.update();
- // update the window
- update();
- }
- };
-
- // status
- private ActionListener status = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if some change has not yet been saved
- if ( getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // add a message into the log pane and the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JDBC connection pool " + connectionPoolName + " status check in progress...",
- parent.getEnvironmentWindow().getEnvironmentName() );
- parent.getEnvironmentWindow().getChangeEvents().add(
- "JDBC connection pool " + connectionPoolName + " status check requested." );
- // start the status thread
- final StatusThread statusThread = new StatusThread();
- statusThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask( KalumetConsoleApplication.getApplication().getTaskQueue(),
- new Runnable()
- {
- public void run()
- {
- if ( statusThread.ended )
- {
- if ( statusThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- statusThread.message,
- parent.getEnvironmentWindow().getEnvironmentName() );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- statusThread.message,
- parent.getEnvironmentWindow().getEnvironmentName() );
- }
- parent.getEnvironmentWindow().getChangeEvents().add(
- statusThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(),
- this );
- }
- }
- } );
- }
- };
-
- // update
- private ActionListener update = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeResourcesUpdatePermission )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if some change has not been saved
- if ( getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // add a message into the log pane and the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JDBC connection pool " + connectionPoolName + " update in progress...",
- parent.getEnvironmentWindow().getEnvironmentName() );
- parent.getEnvironmentWindow().getChangeEvents().add(
- "JDBC connection pool " + connectionPoolName + " update requested." );
- // start the update thread
- final UpdateThread updateThread = new UpdateThread();
- updateThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ try
{
- public void run()
- {
- if ( updateThread.ended )
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent( parent.getEnvironmentWindow().getEnvironment().getAgent() );
+ if ( agent == null )
{
- if ( updateThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( updateThread.message,
- parent.getEnvironmentWindow().getEnvironmentName() );
- parent.getEnvironmentWindow().getChangeEvents().add( updateThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "JDBC connection pool " + connectionPoolName + " updated.",
- parent.getEnvironmentWindow().getEnvironmentName() );
- parent.getEnvironmentWindow().getChangeEvents().add(
- "JDBC connection pool " + connectionPoolName + " updated." );
- }
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the webservice
+ JDBCConnectionPoolClient client = new JDBCConnectionPoolClient( agent.getHostname(), agent.getPort() );
+ boolean uptodate =
+ client.check( parent.getEnvironmentWindow().getEnvironmentName(), applicationServerName,
+ connectionPoolName );
+ if ( uptodate )
+ {
+ message = "JDBC connection pool " + connectionPoolName + " is up to date.";
}
else
{
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ failure = true;
+ message = "JDBC connection pool " + connectionPoolName + " is not up to date.";
}
- }
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JDBC connection pool " + connectionPoolName + " status check failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
+ }
+ }
+
+ // update thread
+ class UpdateThread
+ extends Thread
+ {
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
+ {
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent( parent.getEnvironmentWindow().getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the webservice
+ JDBCConnectionPoolClient client = new JDBCConnectionPoolClient( agent.getHostname(), agent.getPort() );
+ client.update( parent.getEnvironmentWindow().getEnvironmentName(), applicationServerName,
+ connectionPoolName );
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JDBC connection pool " + connectionPoolName + " update failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
+ }
+ }
+
+ // close
+ private ActionListener close = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ ConnectionPoolWindow.this.userClose();
+ }
+ };
+
+ // refresh
+ private ActionListener refresh = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // looking for original JDBC connection pool object
+ connectionPool =
+ parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ applicationServerName ).getJDBCConnectionPool( connectionPoolName );
+ if ( connectionPool == null )
+ {
+ connectionPool = new JDBCConnectionPool();
+ }
+ // update the window
+ update();
+ }
+ };
+
+ // delete
+ private ActionListener delete = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeResourcesChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // remove the connection pool
+ parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ applicationServerName ).getJDBCConnectionPools().remove( connectionPool );
+ // add a change event
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "Delete JDBC connection pool " + connectionPool.getName() );
+ // change the updated flag
+ parent.getEnvironmentWindow().setUpdated( true );
+ // update the whole parent window
+ parent.getEnvironmentWindow().update();
+ // close the window
+ ConnectionPoolWindow.this.userClose();
+ }
+ } ) );
+ }
+ };
+
+ // apply
+ private ActionListener apply = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeResourcesChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricited" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get fields value
+ String nameFieldValue = generalPane.getNameField().getText();
+ int activeFieldIndex = generalPane.getActiveField().getSelectedIndex();
+ int blockerFieldIndex = generalPane.getBlockerField().getSelectedIndex();
+ int driverFieldIndex = driverPane.getDriverField().getSelectedIndex();
+ int helperFieldIndex = driverPane.getHelperField().getSelectedIndex();
+ String classpathFieldValue = driverPane.getClasspathField().getText();
+ String urlFieldValue = databasePane.getUrlField().getText();
+ String userFieldValue = databasePane.getUserField().getText();
+ String passwordFieldValue = databasePane.getPasswordField().getText();
+ String confirmPasswordFieldValue = databasePane.getConfirmPasswordField().getText();
+ String initialFieldValue = capacityPane.getInitialField().getText();
+ String maximalFieldValue = capacityPane.getMaximalField().getText();
+ String incrementFieldValue = capacityPane.getIncrementField().getText();
+ // check select fields
+ if ( activeFieldIndex < 0 || driverFieldIndex < 0 || helperFieldIndex < 0 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "connectionpool.selected" ) );
+ return;
+ }
+ // check name, url, user are mandatory
+ if ( nameFieldValue == null || nameFieldValue.trim().length() < 1 || urlFieldValue == null
+ || urlFieldValue.trim().length() < 1 || userFieldValue == null || userFieldValue.trim().length() < 1 )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "connectionpool.mandatory" ) );
+ return;
+ }
+ // check number value
+ int jdbcConnectionPoolInitialFieldNumber;
+ int jdbcConnectionPoolMaximalFieldNumber;
+ int jdbcConnectionPoolIncrementFieldNumber;
+ try
+ {
+ jdbcConnectionPoolInitialFieldNumber = new Integer( initialFieldValue ).intValue();
+ jdbcConnectionPoolMaximalFieldNumber = new Integer( maximalFieldValue ).intValue();
+ jdbcConnectionPoolIncrementFieldNumber = new Integer( incrementFieldValue ).intValue();
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "connectionpool.notinteger" ) );
+ return;
+ }
+ // check password matching
+ if ( !passwordFieldValue.equals( confirmPasswordFieldValue ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "connectionpool.passwordmatch" ) );
+ return;
+ }
+ // if the user change the JDBC connection pool name, check if the JDBC
+ // connection pool name doesn't already exist
+ if ( connectionPoolName == null || ( connectionPoolName != null && !connectionPoolName.equals(
+ nameFieldValue ) ) )
+ {
+ if ( parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ applicationServerName ).getJDBCConnectionPool( nameFieldValue ) != null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "connectionpool.exists" ) );
+ return;
+ }
+ }
+ // add a change event
+ if ( connectionPoolName != null )
+ {
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "Change JDBC connection pool " + connectionPool.getName() );
+ }
+ // update the connection pool object
+ connectionPool.setName( nameFieldValue );
+ if ( activeFieldIndex == 0 )
+ {
+ connectionPool.setActive( true );
+ }
+ else
+ {
+ connectionPool.setActive( false );
+ }
+ if ( blockerFieldIndex == 0 )
+ {
+ connectionPool.setBlocker( true );
+ }
+ else
+ {
+ connectionPool.setBlocker( false );
+ }
+ if ( driverFieldIndex == 0 )
+ {
+ connectionPool.setDriver( "oracle.jdbc.driver.OracleDriver" );
+ }
+ if ( driverFieldIndex == 1 )
+ {
+ connectionPool.setDriver( "oracle.jdbc.xa.client.OracleXADataSource" );
+ }
+ if ( driverFieldIndex == 2 )
+ {
+ connectionPool.setDriver( "com.ibm.db2.jcc.DB2Driver" );
+ }
+ if ( driverFieldIndex == 3 )
+ {
+ connectionPool.setDriver( "com.mysql.jdbc.Driver" );
+ }
+ if ( driverFieldIndex == 4 )
+ {
+ connectionPool.setDriver( "org.postgresql.Driver" );
+ }
+ if ( helperFieldIndex == 0 )
+ {
+ connectionPool.setHelperclass( null );
+ }
+ if ( helperFieldIndex == 1 )
+ {
+ connectionPool.setHelperclass( "com.ibm.websphere.rsadapter.GenericDataStoreHelper" );
+ }
+ if ( helperFieldIndex == 2 )
+ {
+ connectionPool.setHelperclass( "com.ibm.websphere.rsadapter.OracleDataStoreHelper" );
+ }
+ connectionPool.setClasspath( classpathFieldValue );
+ connectionPool.setUrl( urlFieldValue );
+ connectionPool.setUser( userFieldValue );
+ connectionPool.setPassword( passwordFieldValue );
+ connectionPool.setInitial( jdbcConnectionPoolInitialFieldNumber );
+ connectionPool.setMaximal( jdbcConnectionPoolMaximalFieldNumber );
+ connectionPool.setIncrement( jdbcConnectionPoolIncrementFieldNumber );
+ // add the application server object if needed
+ if ( connectionPoolName == null )
+ {
+ try
+ {
+ parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ applicationServerName ).addJDBCConnectionPool( connectionPool );
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "Add JDBC connection pool " + connectionPool.getName() );
+ }
+ catch ( Exception e )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "connectionpool.exists" ) );
+ return;
+ }
+ }
+ // update the window definition
+ setTitle( Messages.getString( "connectionpool" ) + " " + connectionPool.getName() );
+ setId( "connectionpoolwindow_" + parent.getEnvironmentWindow().getEnvironmentName() + "_"
+ + applicationServerName + "_" + connectionPool.getName() );
+ connectionPoolName = connectionPool.getName();
+ // change the updated flag
+ parent.getEnvironmentWindow().setUpdated( true );
+ // update the window
+ update();
+ // update the whole environment window
+ parent.getEnvironmentWindow().update();
+ }
+ };
+
+ // copy
+ private ActionListener copy = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ try
+ {
+ KalumetConsoleApplication.getApplication().setCopyComponent( connectionPool.clone() );
+ }
+ catch ( Exception e )
+ {
+ return;
+ }
+ }
+ };
+
+ // paste
+ private ActionListener paste = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the copy is correct
+ Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+ if ( copy == null || !( copy instanceof JDBCConnectionPool ) )
+ {
+ return;
+ }
+ connectionPool = (JDBCConnectionPool) copy;
+ connectionPoolName = null;
+ // update the parent pane
+ parent.update();
+ // update the window
+ update();
+ }
+ };
+
+ // status
+ private ActionListener status = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if some change has not yet been saved
+ if ( getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // add a message into the log pane and the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JDBC connection pool " + connectionPoolName + " status check in progress...",
+ parent.getEnvironmentWindow().getEnvironmentName() );
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "JDBC connection pool " + connectionPoolName + " status check requested." );
+ // start the status thread
+ final StatusThread statusThread = new StatusThread();
+ statusThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( statusThread.ended )
+ {
+ if ( statusThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning( statusThread.message,
+ parent.getEnvironmentWindow().getEnvironmentName() );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo( statusThread.message,
+ parent.getEnvironmentWindow().getEnvironmentName() );
+ }
+ parent.getEnvironmentWindow().getChangeEvents().add( statusThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
} );
- }
- } ) );
- }
- };
+ }
+ };
- /**
- * Create a new <code>ConnectionPoolWindow</code>.
- *
- * @param parent the <code>ConnectionPoolsPane</code>.
- * @param applicationServerName the original JEE application server name.
- * @param connectionPoolName the original JDBC connection pool name.
- */
- public ConnectionPoolWindow( ConnectionPoolsPane parent, String applicationServerName, String connectionPoolName )
- {
- super();
-
- // update the parent tab pane
- this.parent = parent;
-
- // update the connection pool name
- this.connectionPoolName = connectionPoolName;
- this.applicationServerName = applicationServerName;
-
- // update the connection pool object from the parent environment
- this.connectionPool =
- parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- this.applicationServerName ).getJDBCConnectionPool( connectionPoolName );
- if ( this.connectionPool == null )
+ // update
+ private ActionListener update = new ActionListener()
{
- this.connectionPool = new JDBCConnectionPool();
- }
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeResourcesUpdatePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if some change has not been saved
+ if ( getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // add a message into the log pane and the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JDBC connection pool " + connectionPoolName + " update in progress...",
+ parent.getEnvironmentWindow().getEnvironmentName() );
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "JDBC connection pool " + connectionPoolName + " update requested." );
+ // start the update thread
+ final UpdateThread updateThread = new UpdateThread();
+ updateThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( updateThread.ended )
+ {
+ if ( updateThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(
+ updateThread.message, parent.getEnvironmentWindow().getEnvironmentName() );
+ parent.getEnvironmentWindow().getChangeEvents().add( updateThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
+ "JDBC connection pool " + connectionPoolName + " updated.",
+ parent.getEnvironmentWindow().getEnvironmentName() );
+ parent.getEnvironmentWindow().getChangeEvents().add(
+ "JDBC connection pool " + connectionPoolName + " updated." );
+ }
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
+ } );
+ }
+ } ) );
+ }
+ };
- if ( this.connectionPoolName == null )
+ /**
+ * Create a new <code>ConnectionPoolWindow</code>.
+ *
+ * @param parent the <code>ConnectionPoolsPane</code>.
+ * @param applicationServerName the original JEE application server name.
+ * @param connectionPoolName the original JDBC connection pool name.
+ */
+ public ConnectionPoolWindow( ConnectionPoolsPane parent, String applicationServerName, String connectionPoolName )
{
- setTitle( Messages.getString( "connectionpool" ) );
+ super();
+
+ // update the parent tab pane
+ this.parent = parent;
+
+ // update the connection pool name
+ this.connectionPoolName = connectionPoolName;
+ this.applicationServerName = applicationServerName;
+
+ // update the connection pool object from the parent environment
+ this.connectionPool =
+ parent.getEnvironmentWindow().getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ this.applicationServerName ).getJDBCConnectionPool( connectionPoolName );
+ if ( this.connectionPool == null )
+ {
+ this.connectionPool = new JDBCConnectionPool();
+ }
+
+ if ( this.connectionPoolName == null )
+ {
+ setTitle( Messages.getString( "connectionpool" ) );
+ }
+ else
+ {
+ setTitle( Messages.getString( "connectionpool" ) + " " + this.connectionPoolName );
+ }
+ setId( "connectionpoolwindow_" + parent.getEnvironmentWindow().getEnvironmentName() + "_"
+ + this.applicationServerName + "_" + this.connectionPoolName );
+ setStyleName( "default" );
+ setWidth( new Extent( 600, Extent.PX ) );
+ setHeight( new Extent( 400, Extent.PX ) );
+ setModal( false );
+ setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
+
+ // create a split pane for the control button
+ SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
+ add( splitPane );
+
+ // add the control pane
+ Row controlRow = new Row();
+ controlRow.setStyleName( "control" );
+ splitPane.add( controlRow );
+ // add the refresh button
+ Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
+ refreshButton.setStyleName( "control" );
+ refreshButton.addActionListener( refresh );
+ controlRow.add( refreshButton );
+ // add the copy button
+ Button copyButton = new Button( Messages.getString( "copy" ), Styles.PAGE_COPY );
+ copyButton.setStyleName( "control" );
+ copyButton.addActionListener( copy );
+ controlRow.add( copyButton );
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeResourcesChangePermission )
+ {
+ // add the paste button
+ Button pasteButton = new Button( Messages.getString( "paste" ), Styles.PAGE_PASTE );
+ pasteButton.setStyleName( "control" );
+ pasteButton.addActionListener( paste );
+ controlRow.add( pasteButton );
+ // add the apply button
+ Button applyButton = new Button( Messages.getString( "apply" ), Styles.ACCEPT );
+ applyButton.setStyleName( "control" );
+ applyButton.addActionListener( apply );
+ controlRow.add( applyButton );
+ }
+ // add the status button
+ Button statusButton = new Button( Messages.getString( "status" ), Styles.INFORMATION );
+ statusButton.setStyleName( "control" );
+ statusButton.addActionListener( status );
+ controlRow.add( statusButton );
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeResourcesUpdatePermission )
+ {
+ // add the update button
+ Button updateButton = new Button( Messages.getString( "update" ), Styles.COG );
+ updateButton.setStyleName( "control" );
+ updateButton.addActionListener( update );
+ controlRow.add( updateButton );
+ }
+ if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeResourcesChangePermission )
+ {
+ // add the delete button
+ Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
+ deleteButton.setStyleName( "control" );
+ deleteButton.addActionListener( delete );
+ controlRow.add( deleteButton );
+ }
+ // add the close button
+ Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
+ closeButton.setStyleName( "control" );
+ closeButton.addActionListener( close );
+ controlRow.add( closeButton );
+
+ // add the main tab pane
+ TabPane tabPane = new TabPane();
+ tabPane.setStyleName( "default" );
+ splitPane.add( tabPane );
+
+ // add the general tab
+ TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "general" ) );
+ generalPane = new ConnectionPoolGeneralPane( this );
+ generalPane.setLayoutData( tabLayoutData );
+ tabPane.add( generalPane );
+
+ // add the driver tab
+ tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "driver" ) );
+ driverPane = new ConnectionPoolDriverPane( this );
+ driverPane.setLayoutData( tabLayoutData );
+ tabPane.add( driverPane );
+
+ // add the database tab
+ tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "database" ) );
+ databasePane = new ConnectionPoolDatabasePane( this );
+ databasePane.setLayoutData( tabLayoutData );
+ tabPane.add( databasePane );
+
+ // add the capacity tab
+ tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle( Messages.getString( "capacity" ) );
+ capacityPane = new ConnectionPoolCapacityPane( this );
+ capacityPane.setLayoutData( tabLayoutData );
+ tabPane.add( capacityPane );
+
+ // update the window
+ update();
}
- else
+
+ /**
+ * Update the pane.
+ */
+ public void update()
{
- setTitle( Messages.getString( "connectionpool" ) + " " + this.connectionPoolName );
+ generalPane.update();
+ driverPane.update();
+ databasePane.update();
+ capacityPane.update();
}
- setId(
- "connectionpoolwindow_" + parent.getEnvironmentWindow().getEnvironmentName() + "_" + this.applicationServerName
- + "_" + this.connectionPoolName );
- setStyleName( "default" );
- setWidth( new Extent( 600, Extent.PX ) );
- setHeight( new Extent( 400, Extent.PX ) );
- setModal( false );
- setDefaultCloseOperation( WindowPane.DISPOSE_ON_CLOSE );
- // create a split pane for the control button
- SplitPane splitPane = new SplitPane( SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent( 32 ) );
- add( splitPane );
-
- // add the control pane
- Row controlRow = new Row();
- controlRow.setStyleName( "control" );
- splitPane.add( controlRow );
- // add the refresh button
- Button refreshButton = new Button( Messages.getString( "reload" ), Styles.DATABASE_REFRESH );
- refreshButton.setStyleName( "control" );
- refreshButton.addActionListener( refresh );
- controlRow.add( refreshButton );
- // add the copy button
- Button copyButton = new Button( Messages.getString( "copy" ), Styles.PAGE_COPY );
- copyButton.setStyleName( "control" );
- copyButton.addActionListener( copy );
- controlRow.add( copyButton );
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeResourcesChangePermission)
+ public JDBCConnectionPool getConnectionPool()
{
- // add the paste button
- Button pasteButton = new Button( Messages.getString( "paste" ), Styles.PAGE_PASTE );
- pasteButton.setStyleName( "control" );
- pasteButton.addActionListener( paste );
- controlRow.add( pasteButton );
- // add the apply button
- Button applyButton = new Button( Messages.getString( "apply" ), Styles.ACCEPT );
- applyButton.setStyleName( "control" );
- applyButton.addActionListener( apply );
- controlRow.add( applyButton );
+ return this.connectionPool;
}
- // add the status button
- Button statusButton = new Button( Messages.getString( "status" ), Styles.INFORMATION );
- statusButton.setStyleName( "control" );
- statusButton.addActionListener( status );
- controlRow.add( statusButton );
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeResourcesUpdatePermission )
+
+ public String getConnectionPoolName()
{
- // add the update button
- Button updateButton = new Button( Messages.getString( "update" ), Styles.COG );
- updateButton.setStyleName( "control" );
- updateButton.addActionListener( update );
- controlRow.add( updateButton );
+ return this.connectionPoolName;
}
- if ( getEnvironmentWindow().adminPermission || getEnvironmentWindow().jeeResourcesChangePermission)
+
+ public EnvironmentWindow getEnvironmentWindow()
{
- // add the delete button
- Button deleteButton = new Button( Messages.getString( "delete" ), Styles.DELETE );
- deleteButton.setStyleName( "control" );
- deleteButton.addActionListener( delete );
- controlRow.add( deleteButton );
+ return parent.getEnvironmentWindow();
}
- // add the close button
- Button closeButton = new Button( Messages.getString( "close" ), Styles.CROSS );
- closeButton.setStyleName( "control" );
- closeButton.addActionListener( close );
- controlRow.add( closeButton );
-
- // add the main tab pane
- TabPane tabPane = new TabPane();
- tabPane.setStyleName( "default" );
- splitPane.add( tabPane );
-
- // add the general tab
- TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "general" ) );
- generalPane = new ConnectionPoolGeneralPane( this );
- generalPane.setLayoutData( tabLayoutData );
- tabPane.add( generalPane );
-
- // add the driver tab
- tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "driver" ) );
- driverPane = new ConnectionPoolDriverPane( this );
- driverPane.setLayoutData( tabLayoutData );
- tabPane.add( driverPane );
-
- // add the database tab
- tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "database" ) );
- databasePane = new ConnectionPoolDatabasePane( this );
- databasePane.setLayoutData( tabLayoutData );
- tabPane.add( databasePane );
-
- // add the capacity tab
- tabLayoutData = new TabPaneLayoutData();
- tabLayoutData.setTitle( Messages.getString( "capacity" ) );
- capacityPane = new ConnectionPoolCapacityPane( this );
- capacityPane.setLayoutData( tabLayoutData );
- tabPane.add( capacityPane );
-
- // update the window
- update();
- }
-
- /**
- * Update the pane.
- */
- public void update()
- {
- generalPane.update();
- driverPane.update();
- databasePane.update();
- capacityPane.update();
- }
-
- public JDBCConnectionPool getConnectionPool()
- {
- return this.connectionPool;
- }
-
- public String getConnectionPoolName()
- {
- return this.connectionPoolName;
- }
-
- public EnvironmentWindow getEnvironmentWindow()
- {
- return parent.getEnvironmentWindow();
- }
}
\ No newline at end of file
diff --git a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolsPane.java b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolsPane.java
index a8b0656..cbf7e87 100644
--- a/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolsPane.java
+++ b/kalumet-modules/console/src/main/java/org/apache/kalumet/console/app/ConnectionPoolsPane.java
@@ -33,8 +33,8 @@
import nextapp.echo2.app.list.ListModel;
import org.apache.kalumet.console.configuration.ConfigurationManager;
import org.apache.kalumet.model.Agent;
-import org.apache.kalumet.model.JEEApplicationServer;
import org.apache.kalumet.model.JDBCConnectionPool;
+import org.apache.kalumet.model.JEEApplicationServer;
import org.apache.kalumet.model.Kalumet;
import org.apache.kalumet.ws.client.JDBCConnectionPoolClient;
@@ -44,684 +44,688 @@
* Environment JDBC connection pools pane.
*/
public class ConnectionPoolsPane
- extends ContentPane
+ extends ContentPane
{
- private EnvironmentWindow parent;
+ private EnvironmentWindow parent;
- private SelectField scopeField;
+ private SelectField scopeField;
- private Grid grid;
+ private Grid grid;
- // status thread
- class StatusThread
- extends Thread
- {
-
- public String connectionPoolName;
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
+ // status thread
+ class StatusThread
+ extends Thread
{
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
- if ( agent == null )
+
+ public String connectionPoolName;
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
{
- throw new IllegalArgumentException( "agent not found." );
- }
- // call the web service
- JDBCConnectionPoolClient client = new JDBCConnectionPoolClient( agent.getHostname(), agent.getPort() );
- boolean uptodate =
- client.check( parent.getEnvironmentName(), (String) scopeField.getSelectedItem(), connectionPoolName );
- if ( uptodate )
- {
- message = "JDBC connection pool " + connectionPoolName + " is up to date.";
- }
- else
- {
- failure = true;
- message = "JDBC connection pool " + connectionPoolName + " is not up to date.";
- }
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JDBC connection pool " + connectionPoolName + " status failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
- }
-
- }
-
- // update thread
- class UpdateThread
- extends Thread
- {
-
- public String connectionPoolName;
-
- public boolean ended = false;
-
- public boolean failure = false;
-
- public String message;
-
- public void run()
- {
- try
- {
- // load Kalumet configuration
- Kalumet kalumet = ConfigurationManager.loadStore();
- // looking for the agent
- Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
- if ( agent == null )
- {
- throw new IllegalArgumentException( "agent not found." );
- }
- // call the web service
- JDBCConnectionPoolClient client = new JDBCConnectionPoolClient( agent.getHostname(), agent.getPort() );
- client.update( parent.getEnvironmentName(), (String) scopeField.getSelectedItem(), connectionPoolName );
- }
- catch ( Exception e )
- {
- failure = true;
- message = "JDBC Connection pool " + connectionPoolName + " update failed: " + e.getMessage();
- }
- finally
- {
- ended = true;
- }
- }
-
- }
-
- // scope select
- private ActionListener scopeSelect = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- update();
- }
- };
-
- // delete
- private ActionListener delete = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeResourcesChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricted" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the JDBC connection pool object
- final JDBCConnectionPool connectionPool =
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJDBCConnectionPool( event.getActionCommand() );
- if ( connectionPool == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "connectionpool.notfound" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // delete the connection pool
- parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJDBCConnectionPools().remove( connectionPool );
- // add change event and update the log pane
- parent.getChangeEvents().add( "Delete JDBC connection pool " + connectionPool.getName() );
- // change the updated flag
- parent.setUpdated( true );
- // update the whole window
- parent.update();
- }
- } ) );
- }
- };
-
- // status
- private ActionListener status = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if some change has not yet been saved
- if ( getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get JDBC connection pool name
- final String connectionPoolName = event.getActionCommand();
- // put a message in the log pane and in the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JDBC connection pool " + connectionPoolName + " status check in progress...", parent.getEnvironmentName() );
- parent.getChangeEvents().add( "JDBC connection pool " + connectionPoolName + " status check." );
- // start the status thread
- final StatusThread statusThread = new StatusThread();
- statusThread.connectionPoolName = connectionPoolName;
- statusThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask( KalumetConsoleApplication.getApplication().getTaskQueue(),
- new Runnable()
- {
- public void run()
- {
- if ( statusThread.ended )
- {
- if ( statusThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- statusThread.message,
- parent.getEnvironmentName() );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- statusThread.message,
- parent.getEnvironmentName() );
- }
- parent.getChangeEvents().add(
- statusThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(),
- this );
- }
- }
- } );
- }
- };
-
- // update
- private ActionListener update = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the log
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeResourcesUpdatePermission )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricited" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if something has been changed
- if ( getEnvironmentWindow().isUpdated() )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "environment.notsaved" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // get JDBC connection pool name
- final String connectionPoolName = event.getActionCommand();
- // display confirm window
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConfirmWindow( new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // put a message in the log pane and the journal
- KalumetConsoleApplication.getApplication().getLogPane().addInfo(
- "JDBC connection pool " + connectionPoolName + " update in progress..." );
- parent.getChangeEvents().add( "JDBC connection pool " + connectionPoolName + " update requested." );
- // start the update thread
- final UpdateThread updateThread = new UpdateThread();
- updateThread.connectionPoolName = connectionPoolName;
- updateThread.start();
- // sync with the client
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ try
{
- public void run()
- {
- if ( updateThread.ended )
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
+ if ( agent == null )
{
- if ( updateThread.failure )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addError( updateThread.message,
- parent.getEnvironmentName() );
- parent.getChangeEvents().add( updateThread.message );
- }
- else
- {
- KalumetConsoleApplication.getApplication().getLogPane().addConfirm(
- "JDBC connection pool " + connectionPoolName + " updated.", parent.getEnvironmentName() );
- parent.getChangeEvents().add( "JDBC connection pool " + connectionPoolName + " updated." );
- }
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the web service
+ JDBCConnectionPoolClient client = new JDBCConnectionPoolClient( agent.getHostname(), agent.getPort() );
+ boolean uptodate = client.check( parent.getEnvironmentName(), (String) scopeField.getSelectedItem(),
+ connectionPoolName );
+ if ( uptodate )
+ {
+ message = "JDBC connection pool " + connectionPoolName + " is up to date.";
}
else
{
- KalumetConsoleApplication.getApplication().enqueueTask(
- KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ failure = true;
+ message = "JDBC connection pool " + connectionPoolName + " is not up to date.";
}
- }
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JDBC connection pool " + connectionPoolName + " status failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
+ }
+
+ }
+
+ // update thread
+ class UpdateThread
+ extends Thread
+ {
+
+ public String connectionPoolName;
+
+ public boolean ended = false;
+
+ public boolean failure = false;
+
+ public String message;
+
+ public void run()
+ {
+ try
+ {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent( parent.getEnvironment().getAgent() );
+ if ( agent == null )
+ {
+ throw new IllegalArgumentException( "agent not found." );
+ }
+ // call the web service
+ JDBCConnectionPoolClient client = new JDBCConnectionPoolClient( agent.getHostname(), agent.getPort() );
+ client.update( parent.getEnvironmentName(), (String) scopeField.getSelectedItem(), connectionPoolName );
+ }
+ catch ( Exception e )
+ {
+ failure = true;
+ message = "JDBC Connection pool " + connectionPoolName + " update failed: " + e.getMessage();
+ }
+ finally
+ {
+ ended = true;
+ }
+ }
+
+ }
+
+ // scope select
+ private ActionListener scopeSelect = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ update();
+ }
+ };
+
+ // delete
+ private ActionListener delete = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if the user has the environment lock
+ if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
+ KalumetConsoleApplication.getApplication().getUserid() ) )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.locked" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // check if the user can do it
+ if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeResourcesChangePermission )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "action.restricted" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // looking for the JDBC connection pool object
+ final JDBCConnectionPool connectionPool =
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJDBCConnectionPool( event.getActionCommand() );
+ if ( connectionPool == null )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "connectionpool.notfound" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
+ new ConfirmWindow( new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // delete the connection pool
+ parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
+ (String) scopeField.getSelectedItem() ).getJDBCConnectionPools().remove( connectionPool );
+ // add change event and update the log pane
+ parent.getChangeEvents().add( "Delete JDBC connection pool " + connectionPool.getName() );
+ // change the updated flag
+ parent.setUpdated( true );
+ // update the whole window
+ parent.update();
+ }
+ } ) );
+ }
+ };
+
+ // status
+ private ActionListener status = new ActionListener()
+ {
+ public void actionPerformed( ActionEvent event )
+ {
+ // check if some change has not yet been saved
+ if ( getEnvironmentWindow().isUpdated() )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(
+ Messages.getString( "environment.notsaved" ), getEnvironmentWindow().getEnvironmentName() );
+ return;
+ }
+ // get JDBC connection pool name
+ final String connectionPoolName = event.getActionCommand();
+ // put a message in the log pane and in the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo(
+ "JDBC connection pool " + connectionPoolName + " status check in progress...",
+ parent.getEnvironmentName() );
+ parent.getChangeEvents().add( "JDBC connection pool " + connectionPoolName + " status check." );
+ // start the status thread
+ final StatusThread statusThread = new StatusThread();
+ statusThread.connectionPoolName = connectionPoolName;
+ statusThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable()
+ {
+ public void run()
+ {
+ if ( statusThread.ended )
+ {
+ if ( statusThread.failure )
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning( statusThread.message,
+ parent.getEnvironmentName() );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo( statusThread.message,
+ parent.getEnvironmentName() );
+ }
+ parent.getChangeEvents().add( statusThread.message );
+ }
+ else
+ {
+ KalumetConsoleApplication.getApplication().enqueueTask(
+ KalumetConsoleApplication.getApplication().getTaskQueue(), this );
+ }
+ }
} );
- }
- } ) );
- }
- };
-
- // edit
- private ActionListener edit = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- if ( KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
- "connectionpoolwindow_" + parent.getEnvironmentName() + "_" + (String) scopeField.getSelectedItem() + "_"
- + event.getActionCommand() ) == null )
- {
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConnectionPoolWindow( ConnectionPoolsPane.this, (String) scopeField.getSelectedItem(),
- event.getActionCommand() ) );
- }
- }
- };
-
- // create
- private ActionListener create = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- ListModel listModel = scopeField.getModel();
- if ( listModel.size() == 0 )
- {
- return;
- }
- KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(
- new ConnectionPoolWindow( ConnectionPoolsPane.this, (String) scopeField.getSelectedItem(), null ) );
- }
- };
-
- // toggle active
- private ActionListener toggleActive = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock
- if ( !getEnvironmentWindow().getEnvironment().getLock().equals(
- KalumetConsoleApplication.getApplication().getUserid() ) )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "environment.locked" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // check if the user can do it
- if ( !getEnvironmentWindow().adminPermission && !getEnvironmentWindow().jeeResourcesChangePermission)
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning( Messages.getString( "action.restricited" ),
- getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // looking for the connection pool object
- JDBCConnectionPool connectionPool = parent.getEnvironment().getJEEApplicationServers().getJEEApplicationServer(
- (String) scopeField.getSelectedItem() ).getJDBCConnectionPool( event.getActionCommand() );
- if ( connectionPool == null )
- {
- KalumetConsoleApplication.getApplication().getLogPane().addWarning(
- Messages.getString( "connectionpool.notfound" ), getEnvironmentWindow().getEnvironmentName() );
- return;
- }
- // change the connection pool state and add a change event
- if ( connectionPool.isActive() )
- {
- connectionPool.setActive( false );
- parent.getChangeEvents().add( "Disable JDBC connection pool " + connectionPool.getName() );
- }
- else
- {
- connectionPool.setActive( true );
- parent.getChangeEvents().add( "Enable JDBC connection pool " + connectionPool.getName() );
- }
- // change the updated flag
- parent.setUpdated( true );
- // update the journal log tab pane
- parent.updateJournalPane();
- // update the pane
- update();
- }
- };
-
- // toggle blocker
- private ActionListener toggleBlocker = new ActionListener()
- {
- public void actionPerformed( ActionEvent event )
- {
- // check if the user has the environment lock