continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmora...@apache.org
Subject svn commit: r780735 - in /continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/ continuum-api/src/main/java/org/apache/maven/continuum/build/settings/ continuum-core/src/main/java/org/apache/continuum/purge/ continuum-core/src/main/j...
Date Mon, 01 Jun 2009 17:27:30 GMT
Author: jmorales
Date: Mon Jun  1 17:27:30 2009
New Revision: 780735

URL: http://svn.apache.org/viewvc?rev=780735&view=rev
Log:
merge -r r780709 from branch 1.3.x 
[CONTINUUM-2195] [CONTINUUM-2236] .Scheduler is updated when update or add a purgeConfiguration
or buildDefinition with schedule. Also delete schedules that are not associated with a buildDefinition
or purgeConfiguration when execute job process. I have created two groups for jobs whe add
a job to scheduler:
- PurgeConfiguration group.
- BuildDefinitionGroup.

Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
    continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/build/settings/SchedulesActivator.java
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/build/settings/DefaultSchedulesActivator.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumBuildJob.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumPurgeJob.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/PurgeConfigurationAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction.java

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?rev=780735&r1=780734&r2=780735&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
(original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
Mon Jun  1 17:27:30 2009
@@ -118,6 +118,7 @@
      * @throws ContinuumException
      * @deprecated
      */
+    @Deprecated
     void checkoutProject( int projectId )
         throws ContinuumException;
 
@@ -440,18 +441,21 @@
     /**
      * @deprecated
      */
+    @Deprecated
     List<BuildDefinition> getBuildDefinitions( int projectId )
         throws ContinuumException;
 
     /**
      * @deprecated
      */
+    @Deprecated
     BuildDefinition getBuildDefinition( int projectId, int buildDefinitionId )
         throws ContinuumException;
 
     /**
      * @deprecated
      */
+    @Deprecated
     void removeBuildDefinition( int projectId, int buildDefinitionId )
         throws ContinuumException;
 
@@ -528,6 +532,10 @@
 
     void removeSchedule( int scheduleId )
         throws ContinuumException;
+    
+    void activePurgeSchedule( Schedule schedule );
+    
+    void activeBuildDefinitionSchedule( Schedule schedule );
 
     // ----------------------------------------------------------------------
     // Working copy

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/build/settings/SchedulesActivator.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/build/settings/SchedulesActivator.java?rev=780735&r1=780734&r2=780735&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/build/settings/SchedulesActivator.java
(original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/build/settings/SchedulesActivator.java
Mon Jun  1 17:27:30 2009
@@ -48,6 +48,22 @@
      */
     void activateSchedule( Schedule schedule, Continuum continuum )
         throws SchedulesActivationException;
+    
+    /**
+     * Activate schedule only for PurgeConfiguration associated.
+     * 
+     * @throws SchedulesActivationException
+     */
+    void activatePurgeSchedule( Schedule schedule, Continuum continuum )
+        throws SchedulesActivationException;
+
+    /**
+     * Activate schedule only for BuildDefinitions associated.
+     * 
+     * @throws SchedulesActivationException
+     */
+    void activateBuildSchedule( Schedule schedule, Continuum continuum )
+        throws SchedulesActivationException;
 
     /**
      * Unactivate schedule by looking at the scheduling information contained within.
@@ -56,4 +72,18 @@
      */
     void unactivateSchedule( Schedule schedule, Continuum continuum )
         throws SchedulesActivationException;
+
+    /**
+     * Unactivate schedule purgeConfigurations if it is not in a purgeConfiguration.
+     */
+    void unactivateOrphanPurgeSchedule( Schedule schedule )
+        throws SchedulesActivationException;
+
+    /**
+     * Unactivate schedule buildDefinitions if it is not in a buildDefinition.
+     * 
+     * @throws SchedulesActivationException
+     */
+    void unactivateOrphanBuildSchedule( Schedule schedule )
+        throws SchedulesActivationException;
 }

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java?rev=780735&r1=780734&r2=780735&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java
Mon Jun  1 17:27:30 2009
@@ -27,8 +27,13 @@
 import org.apache.continuum.purge.task.PurgeTask;
 import org.apache.continuum.taskqueue.manager.TaskQueueManager;
 import org.apache.continuum.taskqueue.manager.TaskQueueManagerException;
+import org.apache.maven.continuum.build.settings.DefaultSchedulesActivator;
+import org.apache.maven.continuum.build.settings.SchedulesActivationException;
+import org.apache.maven.continuum.build.settings.SchedulesActivator;
 import org.apache.maven.continuum.model.project.Schedule;
 import org.codehaus.plexus.taskqueue.TaskQueueException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.List;
 
@@ -43,10 +48,12 @@
 public class DefaultContinuumPurgeManager
     implements ContinuumPurgeManager
 {
+    private static final Logger log = LoggerFactory.getLogger( DefaultContinuumPurgeManager.class
);
+    
     /**
      * @plexus.requirement
      */
-    private ProjectDao projectDao;
+    private SchedulesActivator schedulesActivator;
 
     /**
      * @plexus.requirement
@@ -87,6 +94,20 @@
                 purgeDirectory( dirPurge );
             }
         }
+        
+        if ( ( repoPurgeList == null || repoPurgeList.isEmpty() ) && ( dirPurgeList
== null || dirPurgeList.isEmpty() ) )
+        {
+            // This purge is not enable for a purge process.
+            try
+            {
+                schedulesActivator.unactivateOrphanPurgeSchedule( schedule );
+            }
+            catch ( SchedulesActivationException e )
+            {
+                log.debug( String.format( "Can't unactivate orphan schedule '%s' for purgeConfiguration",
+                                          schedule.getName() ) );
+            }
+        }
     }
 
     public void purgeRepository( RepositoryPurgeConfiguration repoPurge )

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=780735&r1=780734&r2=780735&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Mon Jun  1 17:27:30 2009
@@ -270,6 +270,7 @@
     {
         Runtime.getRuntime().addShutdownHook( new Thread()
         {
+            @Override
             public void run()
             {
                 try
@@ -927,7 +928,16 @@
             if ( projectsMap == null || projectsMap.size() == 0 )
             {
                 log.debug( "no builds attached to schedule" );
-                // We don't have projects attached to this schedule
+                try
+                {
+                    schedulesActivator.unactivateOrphanBuildSchedule( schedule );
+                }
+                catch ( SchedulesActivationException e )
+                {
+                    log.debug( "Can't unactivate orphan shcedule for buildDefinitions" );
+                }
+                // We don't have projects attached to this schedule. This is because it's
only is setting for a
+                // templateBuildDefinition
                 return;
             }
 
@@ -2091,11 +2101,14 @@
         throws ContinuumException
     {
         HashMap<String, Object> context = new HashMap<String, Object>();
+        Schedule schedule = buildDefinition.getSchedule();
 
         AbstractContinuumAction.setBuildDefinition( context, buildDefinition );
         AbstractContinuumAction.setProjectId( context, projectId );
 
         executeAction( "add-build-definition-to-project", context );
+        
+        activeBuildDefinitionSchedule( schedule );
 
         return AbstractContinuumAction.getBuildDefinition( context );
     }
@@ -2104,8 +2117,10 @@
         throws ContinuumException
     {
         HashMap<String, Object> context = new HashMap<String, Object>();
+        BuildDefinition buildDefinition = getBuildDefinition( buildDefinitionId );
+        Schedule schedule = buildDefinition.getSchedule();
 
-        AbstractContinuumAction.setBuildDefinition( context, getBuildDefinition( buildDefinitionId
) );
+        AbstractContinuumAction.setBuildDefinition( context, buildDefinition );
         AbstractContinuumAction.setProjectId( context, projectId );
 
         executeAction( "remove-build-definition-from-project", context );
@@ -2115,11 +2130,14 @@
         throws ContinuumException
     {
         HashMap<String, Object> context = new HashMap<String, Object>();
+        Schedule schedule = buildDefinition.getSchedule();
 
         AbstractContinuumAction.setBuildDefinition( context, buildDefinition );
         AbstractContinuumAction.setProjectId( context, projectId );
 
         executeAction( "update-build-definition-from-project", context );
+        
+        activeBuildDefinitionSchedule( schedule );
 
         return AbstractContinuumAction.getBuildDefinition( context );
     }
@@ -2128,11 +2146,14 @@
         throws ContinuumException
     {
         HashMap<String, Object> context = new HashMap<String, Object>();
+        Schedule schedule = buildDefinition.getSchedule();
 
         AbstractContinuumAction.setBuildDefinition( context, buildDefinition );
         AbstractContinuumAction.setProjectGroupId( context, projectGroupId );
 
         executeAction( "add-build-definition-to-project-group", context );
+        
+        activeBuildDefinitionSchedule( schedule );
 
         return AbstractContinuumAction.getBuildDefinition( context );
     }
@@ -2152,11 +2173,14 @@
         throws ContinuumException
     {
         HashMap<String, Object> context = new HashMap<String, Object>();
+        Schedule schedule = buildDefinition.getSchedule();
 
         AbstractContinuumAction.setBuildDefinition( context, buildDefinition );
         AbstractContinuumAction.setProjectGroupId( context, projectGroupId );
 
         executeAction( "update-build-definition-from-project-group", context );
+        
+        activeBuildDefinitionSchedule( schedule );
 
         return AbstractContinuumAction.getBuildDefinition( context );
     }
@@ -2258,6 +2282,9 @@
     private void updateSchedule( Schedule schedule, boolean updateScheduler )
         throws ContinuumException
     {
+        
+        Schedule old = getSchedule( schedule.getId() );
+        
         storeSchedule( schedule );
 
         if ( updateScheduler )
@@ -2266,14 +2293,15 @@
             {
                 if ( schedule.isActive() )
                 {
-                    // I unactivate it before if it's already active
-                    schedulesActivator.unactivateSchedule( schedule, this );
+                    // I unactivate old shcedule (could change name) before if it's already
active
+                    schedulesActivator.unactivateSchedule( old, this );
 
                     schedulesActivator.activateSchedule( schedule, this );
                 }
                 else
                 {
-                    schedulesActivator.unactivateSchedule( schedule, this );
+                    // Unactivate old because could change name in new schedule
+                    schedulesActivator.unactivateSchedule( old, this );
                 }
             }
             catch ( SchedulesActivationException e )
@@ -2347,7 +2375,30 @@
             throw logAndCreateException( "Error while storing schedule.", ex );
         }
     }
-
+    
+    public void activePurgeSchedule( Schedule schedule )
+    {
+        try
+        {
+            schedulesActivator.activatePurgeSchedule( schedule, this );
+        }
+        catch ( SchedulesActivationException e )
+        {
+            log.error( "Can't activate schedule for purgeConfiguration" );
+        }
+    }
+    
+    public void activeBuildDefinitionSchedule( Schedule schedule )
+    {
+        try
+        {
+            schedulesActivator.activateBuildSchedule( schedule, this );
+        }
+        catch ( SchedulesActivationException e )
+        {
+            log.error( "Can't activate schedule for buildDefinition" );
+        }
+    }
     // ----------------------------------------------------------------------
     // Working copy
     // ----------------------------------------------------------------------

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/build/settings/DefaultSchedulesActivator.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/build/settings/DefaultSchedulesActivator.java?rev=780735&r1=780734&r2=780735&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/build/settings/DefaultSchedulesActivator.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/build/settings/DefaultSchedulesActivator.java
Mon Jun  1 17:27:30 2009
@@ -82,7 +82,7 @@
      */
     private Scheduler scheduler;
 
-    //private int delay = 3600;
+    // private int delay = 3600;
     private static final int delay = 1;
 
     public void activateSchedules( Continuum continuum )
@@ -94,42 +94,27 @@
 
         for ( Schedule schedule : schedules )
         {
-            if ( StringUtils.isEmpty( schedule.getCronExpression() ) )
-            {
-                // TODO: this can possibly be removed but it's here now to
-                // weed out any bugs
-                log.info( "Not scheduling " + schedule.getName() );
-
-                continue;
-            }
-
-            try
+            if ( schedule.isActive() )
             {
-                // check schedule job class
-                if ( isScheduleFromBuildJob( schedule ) )
+                try
                 {
-                    schedule( schedule, continuum, ContinuumBuildJob.class );
+                    activateSchedule( schedule, continuum );
                 }
-
-                if ( isScheduleFromPurgeJob( schedule ) )
+                catch ( SchedulesActivationException e )
                 {
-                    schedule( schedule, continuum, ContinuumPurgeJob.class );
-                }
-            }
-            catch ( SchedulesActivationException e )
-            {
-                log.error( "Can't activate schedule '" + schedule.getName() + "'", e );
+                    log.error( "Can't activate schedule '" + schedule.getName() + "'", e
);
 
-                schedule.setActive( false );
+                    schedule.setActive( false );
 
-                try
-                {
-                    scheduleDao.storeSchedule( schedule );
-                }
-                catch ( ContinuumStoreException e1 )
-                {
-                    throw new SchedulesActivationException( "Can't desactivate schedule '"
+ schedule.getName() + "'",
-                                                            e );
+                    try
+                    {
+                        scheduleDao.storeSchedule( schedule );
+                    }
+                    catch ( ContinuumStoreException e1 )
+                    {
+                        throw new SchedulesActivationException( "Can't desactivate schedule
'" + schedule.getName()
+                            + "'", e );
+                    }
                 }
             }
         }
@@ -138,16 +123,31 @@
     public void activateSchedule( Schedule schedule, Continuum continuum )
         throws SchedulesActivationException
     {
-        log.info( "Activating schedule " + schedule.getName() );
+        if ( schedule != null )
+        {
+            log.info( "Activating schedule " + schedule.getName() );
 
-        if ( isScheduleFromBuildJob( schedule ) )
+            activateBuildSchedule( schedule, continuum );
+
+            activatePurgeSchedule( schedule, continuum );
+        }
+    }
+
+    public void activateBuildSchedule( Schedule schedule, Continuum continuum )
+        throws SchedulesActivationException
+    {
+        if ( schedule != null && schedule.isActive() && isScheduleFromBuildJob(
schedule ) )
         {
-            schedule( schedule, continuum, ContinuumBuildJob.class );
+            schedule( schedule, continuum, ContinuumBuildJob.class, ContinuumBuildJob.BUILD_GROUP
);
         }
+    }
 
-        if ( isScheduleFromPurgeJob( schedule ) )
+    public void activatePurgeSchedule( Schedule schedule, Continuum continuum )
+        throws SchedulesActivationException
+    {
+        if ( schedule != null && schedule.isActive() && isScheduleFromPurgeJob(
schedule ) )
         {
-            schedule( schedule, continuum, ContinuumPurgeJob.class );
+            schedule( schedule, continuum, ContinuumPurgeJob.class, ContinuumPurgeJob.PURGE_GROUP
);
         }
     }
 
@@ -156,16 +156,50 @@
     {
         log.info( "Deactivating schedule " + schedule.getName() );
 
-        unschedule( schedule );
+        unactivateBuildSchedule( schedule );
+        unactivatePurgeSchedule( schedule );
+    }
+
+    public void unactivateOrphanBuildSchedule( Schedule schedule )
+        throws SchedulesActivationException
+    {
+        if ( schedule != null && !isScheduleFromBuildJob( schedule ) )
+        {
+            unactivateBuildSchedule( schedule );
+        }
     }
 
-    protected void schedule( Schedule schedule, Continuum continuum, Class jobClass )
+    public void unactivateOrphanPurgeSchedule( Schedule schedule )
         throws SchedulesActivationException
     {
-        if ( !schedule.isActive() )
+        if ( schedule != null && !isScheduleFromPurgeJob( schedule ) )
         {
-            log.info( "Schedule \"" + schedule.getName() + "\" is disabled." );
+            unactivatePurgeSchedule( schedule );
+        }
+    }
+
+    private void unactivateBuildSchedule( Schedule schedule )
+        throws SchedulesActivationException
+    {
+        log.debug( "Deactivating schedule " + schedule.getName() + " for Build Process" );
 
+        unschedule( schedule, ContinuumBuildJob.BUILD_GROUP );
+    }
+
+    private void unactivatePurgeSchedule( Schedule schedule )
+        throws SchedulesActivationException
+    {
+        log.debug( "Deactivating schedule " + schedule.getName() + " for Purge Process" );
+
+        unschedule( schedule, ContinuumPurgeJob.PURGE_GROUP );
+    }
+
+    protected void schedule( Schedule schedule, Continuum continuum, Class jobClass, String
group )
+        throws SchedulesActivationException
+    {
+        if ( StringUtils.isEmpty( schedule.getCronExpression() ) )
+        {
+            log.info( "Not scheduling " + schedule.getName() );
             return;
         }
 
@@ -177,9 +211,9 @@
 
         dataMap.put( ContinuumSchedulerConstants.SCHEDULE, schedule );
 
-        //the name + group makes the job unique
+        // the name + group makes the job unique
 
-        JobDetail jobDetail = new JobDetail( schedule.getName(), org.quartz.Scheduler.DEFAULT_GROUP,
jobClass );
+        JobDetail jobDetail = new JobDetail( schedule.getName(), group, jobClass );
 
         jobDetail.setJobDataMap( dataMap );
 
@@ -189,7 +223,7 @@
 
         trigger.setName( schedule.getName() );
 
-        trigger.setGroup( org.quartz.Scheduler.DEFAULT_GROUP );
+        trigger.setGroup( group );
 
         Date startTime = new Date( System.currentTimeMillis() + delay * 1000 );
 
@@ -218,7 +252,7 @@
         }
     }
 
-    private void unschedule( Schedule schedule )
+    private void unschedule( Schedule schedule, String group )
         throws SchedulesActivationException
     {
         try
@@ -227,10 +261,10 @@
             {
                 log.info( "Stopping active schedule \"" + schedule.getName() + "\"." );
 
-                scheduler.interruptSchedule( schedule.getName(), org.quartz.Scheduler.DEFAULT_GROUP
);
+                scheduler.interruptSchedule( schedule.getName(), group );
             }
 
-            scheduler.unscheduleJob( schedule.getName(), org.quartz.Scheduler.DEFAULT_GROUP
);
+            scheduler.unscheduleJob( schedule.getName(), group );
         }
         catch ( SchedulerException e )
         {
@@ -241,7 +275,9 @@
     private boolean isScheduleFromBuildJob( Schedule schedule )
     {
         List<BuildDefinition> buildDef = buildDefinitionDao.getBuildDefinitionsBySchedule(
schedule.getId() );
-
+        // Take account templateBuildDefinition too.
+        // A improvement will be add schedule only for active buildDefinition, but it would
need activate
+        // schedule job in add project and add group process
         return buildDef.size() > 0;
 
     }

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumBuildJob.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumBuildJob.java?rev=780735&r1=780734&r2=780735&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumBuildJob.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumBuildJob.java
Mon Jun  1 17:27:30 2009
@@ -34,6 +34,8 @@
 public class ContinuumBuildJob
     extends AbstractJob
 {
+    public static final String BUILD_GROUP = "BUILD_GROUP";
+
     public void execute( JobExecutionContext context )
     {
         if ( isInterrupted() )

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumPurgeJob.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumPurgeJob.java?rev=780735&r1=780734&r2=780735&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumPurgeJob.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumPurgeJob.java
Mon Jun  1 17:27:30 2009
@@ -36,6 +36,8 @@
 public class ContinuumPurgeJob
     extends AbstractJob
 {
+    public static final String PURGE_GROUP = "PURGE_GROUP";
+	
     public void execute( JobExecutionContext context )
     {
         if ( isInterrupted() )

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/PurgeConfigurationAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/PurgeConfigurationAction.java?rev=780735&r1=780734&r2=780735&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/PurgeConfigurationAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/PurgeConfigurationAction.java
Mon Jun  1 17:27:30 2009
@@ -35,15 +35,19 @@
 import org.apache.continuum.purge.PurgeConfigurationService;
 import org.apache.continuum.repository.RepositoryService;
 import org.apache.continuum.taskqueue.manager.TaskQueueManager;
+import org.apache.maven.continuum.build.settings.SchedulesActivationException;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.model.project.Schedule;
 import org.apache.maven.continuum.security.ContinuumRoleConstants;
 import org.apache.maven.continuum.web.action.ContinuumConfirmAction;
+import org.apache.maven.continuum.web.action.ScheduleAction;
 import org.apache.struts2.ServletActionContext;
 import org.codehaus.plexus.redback.rbac.Resource;
 import org.codehaus.redback.integration.interceptor.SecureAction;
 import org.codehaus.redback.integration.interceptor.SecureActionBundle;
 import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author Maria Catherine Tan
@@ -55,6 +59,8 @@
     extends ContinuumConfirmAction
     implements Preparable, SecureAction
 {
+    private static final Logger logger = LoggerFactory.getLogger( PurgeConfigurationAction.class
);
+
     private static final String PURGE_TYPE_REPOSITORY = "repository";
 
     private static final String PURGE_TYPE_DIRECTORY = "directory";
@@ -117,6 +123,7 @@
      */
     private RepositoryService repositoryService;
 
+    @Override
     public void prepare()
         throws Exception
     {
@@ -153,6 +160,7 @@
         directoryTypes.add( PURGE_DIRECTORY_BUILDOUTPUT );
     }
 
+    @Override
     public String input()
         throws Exception
     {
@@ -258,6 +266,11 @@
             updateDefaultPurgeConfiguration();
         }
 
+        if ( purgeConfig.isEnabled() && purgeConfig.getSchedule() != null )
+        {
+            getContinuum().activePurgeSchedule( purgeConfig.getSchedule() );
+        }
+
         return SUCCESS;
     }
 
@@ -379,11 +392,13 @@
         this.enabled = enabled;
     }
 
+    @Override
     public boolean isConfirmed()
     {
         return this.confirmed;
     }
 
+    @Override
     public void setConfirmed( boolean confirmed )
     {
         this.confirmed = confirmed;

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction.java?rev=780735&r1=780734&r2=780735&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction.java
Mon Jun  1 17:27:30 2009
@@ -81,6 +81,7 @@
     //  Webwork Methods
     // ------------------------------------------------------- 
 
+    @Override
     public void prepare()
         throws Exception
     {
@@ -230,6 +231,7 @@
     public String saveBuildDefinition()
         throws Exception
     {
+        Schedule schedule = null;
         if ( buildDefinition.getProfile() != null )
         {
             Profile profile = getContinuum().getProfileService().getProfile( buildDefinition.getProfile().getId()
);
@@ -246,7 +248,8 @@
         {
             if ( buildDefinition.getSchedule().getId() > 0 )
             {
-                buildDefinition.setSchedule( getContinuum().getSchedule( buildDefinition.getSchedule().getId()
) );
+                schedule = getContinuum().getSchedule( buildDefinition.getSchedule().getId()
);
+                buildDefinition.setSchedule( schedule );
             }
         }
 
@@ -259,6 +262,11 @@
             this.buildDefinition =
                 this.getContinuum().getBuildDefinitionService().addBuildDefinition( buildDefinition
);
         }
+        
+        if ( schedule != null )
+        {
+            getContinuum().activeBuildDefinitionSchedule( schedule );
+        }
 
         return SUCCESS;
     }



Mime
View raw message