continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r724269 - in /continuum/trunk: continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/ continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/ continuum-core/src/main/java/org/apache/maven/continuum/ continuum-core/...
Date Mon, 08 Dec 2008 06:46:00 GMT
Author: ctan
Date: Sun Dec  7 22:46:00 2008
New Revision: 724269

URL: http://svn.apache.org/viewvc?rev=724269&view=rev
Log:
[CONTINUUM-2010] added group cancel build
- remove prepare build task in queues
- remove build task in queues
- cancel current build task

Removed:
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/AbstractBuildQueueAction.java
Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.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/scm/queue/PrepareBuildProjectsTask.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/CancelBuildAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java
    continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
    continuum/trunk/continuum-webapp/src/main/resources/struts.xml
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java?rev=724269&r1=724268&r2=724269&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java
(original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java
Sun Dec  7 22:46:00 2008
@@ -19,6 +19,9 @@
     void cancelBuildTask( int projectId )
         throws TaskQueueManagerException;
 
+    boolean cancelCheckout( int projectId )
+        throws TaskQueueManagerException;
+
     boolean cancelCurrentBuild()
         throws TaskQueueManagerException;
 
@@ -89,6 +92,9 @@
     boolean removeFromBuildingQueue( int projectId, int buildDefinitionId, int trigger, String
projectName )
         throws TaskQueueManagerException;
 
+    boolean removeFromPrepareBuildQueue( int projectGroupId, String scmRootAddress )
+        throws TaskQueueManagerException;
+
     /**
      * Remove local repository from the purge queue
      * 

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java?rev=724269&r1=724268&r2=724269&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
Sun Dec  7 22:46:00 2008
@@ -95,14 +95,62 @@
     {
         Task currentTask = getBuildTaskQueueExecutor().getCurrentTask();
         
-        if ( currentTask instanceof BuildProjectTask )
+        if ( currentTask != null )
         {
-            if ( ( (BuildProjectTask) currentTask ).getProjectId() == projectId )
+            if ( currentTask instanceof BuildProjectTask )
             {
-                getLogger().info( "Cancelling task for project " + projectId );
-                getBuildTaskQueueExecutor().cancelTask( currentTask );
+                if ( ( (BuildProjectTask) currentTask ).getProjectId() == projectId )
+                {
+                    getLogger().info( "Cancelling task for project " + projectId );
+                    getBuildTaskQueueExecutor().cancelTask( currentTask );
+                }
+                else
+                {
+                    getLogger().warn( "Current task is not for the given projectId (" + projectId
+ "): "
+                                          + ( (BuildProjectTask) currentTask ).getProjectId()
+ "; not cancelling" );
+                }
+            }
+            else
+            {
+                getLogger().warn( "Current task not a BuildProjectTask - not cancelling"
);
             }
         }
+        else
+        {
+            getLogger().warn( "No task running - not cancelling" );
+        }
+    }
+
+    public boolean cancelCheckout( int projectId )
+        throws TaskQueueManagerException
+    {
+        Task task = getCheckoutTaskQueueExecutor().getCurrentTask();
+
+        if ( task != null )
+        {
+            if ( task instanceof CheckOutTask )
+            {
+                if ( ( (CheckOutTask) task ).getProjectId() == projectId )
+                {
+                    getLogger().info( "Cancelling checkout for project " + projectId );
+                    return getCheckoutTaskQueueExecutor().cancelTask( task );
+                }
+                else
+                {
+                    getLogger().warn( "Current task is not for the given projectId (" + projectId
+ "): "
+                                          + ( (CheckOutTask) task ).getProjectId() + "; not
cancelling checkout" );
+                }
+            }
+            else
+            {
+                getLogger().warn( "Current task not a CheckOutTask - not cancelling checkout"
);
+            }
+        }
+        else
+        {
+            getLogger().warn( "No task running - not cancelling checkout" );
+        }
+        return false;
     }
 
     public boolean cancelCurrentBuild()
@@ -624,6 +672,28 @@
         }
     }
 
+    public boolean removeFromPrepareBuildQueue( int projectGroupId, String scmRootAddress
)
+        throws TaskQueueManagerException
+    {
+        try
+        {
+            List<PrepareBuildProjectsTask> queue = prepareBuildQueue.getQueueSnapshot();
+            
+            for ( PrepareBuildProjectsTask task : queue )
+            {
+                if ( task != null && task.getProjectGroupId() == projectGroupId &&
task.getScmRootAddress().equals( scmRootAddress ) )
+                {
+                    return prepareBuildQueue.remove( task );
+                }
+            }
+            return false;
+        }
+        catch ( TaskQueueException e )
+        {
+            throw new TaskQueueManagerException( "Error while getting the prepare build projects
task in queue", e );
+        }
+    }
+    
     public void contextualize( Context context )
         throws ContextException
     {

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=724269&r1=724268&r2=724269&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
Sun Dec  7 22:46:00 2008
@@ -878,7 +878,7 @@
             projectsList = getProjects();
         }
 
-        Map<String, Map<Integer, Integer>> map = new HashMap<String, Map<Integer,
Integer>>();
+        Map<ProjectScmRoot, Map<Integer, Integer>> map = new HashMap<ProjectScmRoot,
Map<Integer, Integer>>();
 
         for ( Project project : projectsList )
         {
@@ -895,14 +895,7 @@
                         {
                             ProjectScmRoot scmRoot = getProjectScmRootByProject( project.getId()
);
                             
-                            String scmRootAddress = "";
-
-                            if ( scmRoot != null )
-                            {
-                                scmRootAddress = scmRoot.getScmRootAddress();
-                            }
-
-                            Map<Integer, Integer> projectsAndBuildDefinitionsMap =
map.get( scmRootAddress );
+                            Map<Integer, Integer> projectsAndBuildDefinitionsMap =
map.get( scmRoot );
                             
                             if ( projectsAndBuildDefinitionsMap == null )
                             {
@@ -911,7 +904,7 @@
                             
                             projectsAndBuildDefinitionsMap.put( project.getId(), buildDefId
);
                             
-                            map.put( scmRootAddress, projectsAndBuildDefinitionsMap );
+                            map.put( scmRoot, projectsAndBuildDefinitionsMap );
                         }
                     } 
                     catch ( TaskQueueManagerException e )
@@ -922,7 +915,7 @@
             }
         }
 
-        prepareBuildProjects( map.values(), ContinuumProjectState.TRIGGER_SCHEDULED );
+        prepareBuildProjects( map, ContinuumProjectState.TRIGGER_SCHEDULED );
     }
 
     public void buildProject( int projectId )
@@ -964,7 +957,8 @@
         Map<Integer, Integer> projectsBuildDefinitionsMap = new HashMap<Integer,
Integer>();
         projectsBuildDefinitionsMap.put( projectId, buildDef.getId() );
         
-        prepareBuildProjects( projectsBuildDefinitionsMap, trigger );
+        ProjectScmRoot scmRoot = getProjectScmRootByProject( projectId );
+        prepareBuildProjects( projectsBuildDefinitionsMap, trigger, scmRoot.getScmRootAddress(),
scmRoot.getProjectGroup().getId() );
     }
 
     public void buildProject( int projectId, int buildDefinitionId, int trigger )
@@ -987,7 +981,8 @@
         Map<Integer, Integer> projectsBuildDefinitionsMap = new HashMap<Integer,
Integer>();
         projectsBuildDefinitionsMap.put( projectId, buildDefinitionId );
 
-        prepareBuildProjects( projectsBuildDefinitionsMap, trigger );
+        ProjectScmRoot scmRoot = getProjectScmRootByProject( projectId );
+        prepareBuildProjects( projectsBuildDefinitionsMap, trigger, scmRoot.getScmRootAddress(),
scmRoot.getProjectGroup().getId() );
     }
 
     public BuildResult getBuildResult( int buildId )
@@ -3199,7 +3194,7 @@
                                       boolean checkDefaultBuildDefinitionForProject, int
trigger )
         throws ContinuumException
     {
-        Map<String, Map<Integer, Integer>> map = new HashMap<String, Map<Integer,
Integer>>();
+        Map<ProjectScmRoot, Map<Integer, Integer>> map = new HashMap<ProjectScmRoot,
Map<Integer, Integer>>();
 
         for ( Project project : projects )
         {
@@ -3271,13 +3266,7 @@
 
             ProjectScmRoot scmRoot = getProjectScmRootByProject( projectId );
 
-            String scmRootAddress = "";
-            if ( scmRoot != null )
-            {
-                scmRootAddress = scmRoot.getScmRootAddress();
-            }
-
-            Map<Integer, Integer> projectsAndBuildDefinitionsMap = map.get( scmRootAddress
);
+            Map<Integer, Integer> projectsAndBuildDefinitionsMap = map.get( scmRoot
);
 
             if ( projectsAndBuildDefinitionsMap == null )
             {
@@ -3286,16 +3275,16 @@
 
             projectsAndBuildDefinitionsMap.put( projectId, buildDefId );
 
-            map.put( scmRootAddress, projectsAndBuildDefinitionsMap );
+            map.put( scmRoot, projectsAndBuildDefinitionsMap );
         }
 
-        prepareBuildProjects( map.values(), trigger );
+        prepareBuildProjects( map, trigger );
     }
 
     private void prepareBuildProjects( Collection<Project> projects, int buildDefinitionId,
int trigger )
         throws ContinuumException
     {
-        Map<String, Map<Integer,Integer>> map = new HashMap<String, Map<Integer,
Integer>>();
+        Map<ProjectScmRoot, Map<Integer,Integer>> map = new HashMap<ProjectScmRoot,
Map<Integer, Integer>>();
 
         for ( Project project : projects )
         {
@@ -3315,14 +3304,8 @@
                 }
                 
                 ProjectScmRoot scmRoot = getProjectScmRootByProject( projectId );
-
-                String scmRootAddress = "";
-                if ( scmRoot != null )
-                {
-                    scmRootAddress = scmRoot.getScmRootAddress();
-                }
                 
-                Map<Integer, Integer> projectsAndBuildDefinitionsMap = map.get( scmRootAddress
);
+                Map<Integer, Integer> projectsAndBuildDefinitionsMap = map.get( scmRoot
);
                 
                 if ( projectsAndBuildDefinitionsMap == null )
                 {
@@ -3331,7 +3314,7 @@
                 
                 projectsAndBuildDefinitionsMap.put( projectId, buildDefinitionId );
                 
-                map.put( scmRootAddress, projectsAndBuildDefinitionsMap );
+                map.put( scmRoot, projectsAndBuildDefinitionsMap );
             }
             catch ( TaskQueueManagerException e )
             {
@@ -3339,24 +3322,26 @@
             }
         }
 
-        prepareBuildProjects( map.values(), trigger );
+        prepareBuildProjects( map, trigger );
     }
 
-    private void prepareBuildProjects( Collection<Map<Integer, Integer>> projectsBuildDefinitions,
int trigger )
+    private void prepareBuildProjects( Map<ProjectScmRoot, Map<Integer, Integer>>
map, int trigger )
         throws ContinuumException
     {
-        for ( Map<Integer, Integer> map : projectsBuildDefinitions )
+        for ( ProjectScmRoot scmRoot : map.keySet() )
         {
-            prepareBuildProjects( map, trigger );
+            prepareBuildProjects( map.get( scmRoot ), trigger, scmRoot.getScmRootAddress(),
scmRoot.getProjectGroup().getId() );
         }
     }
 
-    private void prepareBuildProjects( Map<Integer, Integer> projectsBuildDefinitionsMap,
int trigger )
+    private void prepareBuildProjects( Map<Integer, Integer> projectsBuildDefinitionsMap,
int trigger, 
+                                       String scmRootAddress, int projectGroupId )
         throws ContinuumException
     {
         try
         {
-            PrepareBuildProjectsTask task = new PrepareBuildProjectsTask( projectsBuildDefinitionsMap,
trigger );
+            PrepareBuildProjectsTask task = new PrepareBuildProjectsTask( projectsBuildDefinitionsMap,
trigger,
+                                                                          projectGroupId,
scmRootAddress );
             taskQueueManager.getPrepareBuildQueue().put( task );
         }
         catch ( TaskQueueException e )

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTask.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTask.java?rev=724269&r1=724268&r2=724269&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTask.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTask.java
Sun Dec  7 22:46:00 2008
@@ -11,10 +11,17 @@
 
     private int trigger;
 
-    public PrepareBuildProjectsTask( Map<Integer, Integer> projectsBuildDefinitionsMap,
int trigger )
+    private int projectGroupId;
+
+    private String scmRootAddress;
+
+    public PrepareBuildProjectsTask( Map<Integer, Integer> projectsBuildDefinitionsMap,
int trigger, 
+                                     int projectGroupId, String scmRootAddress )
     {
         this.projectsBuildDefinitionsMap = projectsBuildDefinitionsMap;
         this.trigger = trigger;
+        this.projectGroupId = projectGroupId;
+        this.scmRootAddress = scmRootAddress;
     }
     
     public long getMaxExecutionTime()
@@ -42,7 +49,27 @@
     {
         this.trigger = trigger;
     }
-    
+
+    public int getProjectGroupId()
+    {
+        return projectGroupId;
+    }
+
+    public void setProjectGroupId( int projectGroupId )
+    {
+        this.projectGroupId = projectGroupId;
+    }
+
+    public String getScmRootAddress()
+    {
+        return scmRootAddress;
+    }
+
+    public void setScmRootAddress( String scmRootAddress )
+    {
+        this.scmRootAddress = scmRootAddress;
+    }
+
     public int getHashCode()
     {
         return this.hashCode();

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java?rev=724269&r1=724268&r2=724269&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java
Sun Dec  7 22:46:00 2008
@@ -86,15 +86,15 @@
                 
                 getLogger().info( "Initializing prepare build" );
                 context = initializeContext( projectId, buildDefinitionId );
-                
-                getLogger().info( "Starting prepare build of project: " + AbstractContinuumAction.getProject(
context ).getName() );
-                startPrepareBuild( context );
-                
+
                 if ( !checkProjectScmRoot( context ) )
                 {
                     break;
                 }
-                
+
+                getLogger().info( "Starting prepare build of project: " + AbstractContinuumAction.getProject(
context ).getName() );
+                startPrepareBuild( context );
+
                 try
                 {
                     if ( AbstractContinuumAction.getBuildDefinition( context ).isBuildFresh()
)
@@ -102,7 +102,7 @@
                         getLogger().info( "Purging existing working copy" );
                         cleanWorkingDirectory( context );
                     }
-                    
+
                     // ----------------------------------------------------------------------
                     // TODO: Centralize the error handling from the SCM related actions.
                     // ContinuumScmResult should return a ContinuumScmResult from all
@@ -110,7 +110,7 @@
                     // ----------------------------------------------------------------------
                     getLogger().info( "Updating working dir" );
                     updateWorkingDirectory( context );
-            
+
                     getLogger().info( "Merging SCM results" );
                     //CONTINUUM-1393
                     if ( !AbstractContinuumAction.getBuildDefinition( context ).isBuildFresh()
)
@@ -131,10 +131,13 @@
             endPrepareBuild( context );
         }
 
-        int projectGroupId = AbstractContinuumAction.getProjectGroupId( context );
-        buildProjects( projectGroupId, projectsBuildDefinitionsMap, trigger );
+        if ( checkProjectScmRoot( context ) )
+        {
+            int projectGroupId = AbstractContinuumAction.getProjectGroupId( context );
+            buildProjects( projectGroupId, projectsBuildDefinitionsMap, trigger );
+        }
     }
-    
+
     private Map initializeContext( int projectId, int buildDefinitionId )
         throws TaskExecutionException
     {
@@ -287,7 +290,7 @@
         try
         {
             project.setScmResult( scmResult );
-            
+
             projectDao.updateProject( project );
         }
         catch ( ContinuumStoreException e )
@@ -413,7 +416,7 @@
         {
             projectScmRoot.setState( ContinuumProjectState.ERROR );
             projectScmRoot.setError( error );
-            
+
             projectScmRootDao.updateProjectScmRoot( projectScmRoot );
             
             context.put( AbstractContinuumAction.KEY_PROJECT_SCM_ROOT, projectScmRoot );

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/CancelBuildAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/CancelBuildAction.java?rev=724269&r1=724268&r2=724269&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/CancelBuildAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/CancelBuildAction.java
Sun Dec  7 22:46:00 2008
@@ -19,13 +19,16 @@
  * under the License.
  */
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 
 import org.apache.commons.lang.ArrayUtils;
+import org.apache.continuum.model.project.ProjectScmRoot;
 import org.apache.continuum.taskqueue.manager.TaskQueueManager;
 import org.apache.continuum.taskqueue.manager.TaskQueueManagerException;
 import org.apache.maven.continuum.ContinuumException;
-import org.apache.maven.continuum.web.action.admin.AbstractBuildQueueAction;
+import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -35,7 +38,7 @@
  * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="cancelBuild"
  */
 public class CancelBuildAction
-    extends AbstractBuildQueueAction
+    extends ContinuumActionSupport
 {
 
     private int projectId;
@@ -52,13 +55,19 @@
         try
         {
             checkBuildProjectInGroupAuthorization( getProjectGroupName() );
+
+            TaskQueueManager taskQueueManager = getContinuum().getTaskQueueManager();
+
+            taskQueueManager.cancelBuildTask( projectId );
         }
         catch ( AuthorizationRequiredException e )
         {
             return REQUIRES_AUTHORIZATION;
         }
-
-        cancelBuild( projectId );
+        catch ( TaskQueueManagerException e )
+        {
+            throw new ContinuumException( "Error while canceling build", e );
+        }
 
         return SUCCESS;
     }
@@ -81,20 +90,65 @@
         try
         {
             taskQueueManager.removeProjectsFromBuildingQueue( projectsId );
+            
+            // now we must check if the current build is one of this
+        	int index = ArrayUtils.indexOf( projectsId, taskQueueManager.getCurrentProjectIdBuilding()
);
+        	if ( index > 0 )
+        	{
+            	taskQueueManager.cancelBuildTask( projectsId[index] );
+        	}
         }
         catch ( TaskQueueManagerException e )
         {
             throw new ContinuumException( "Unable to remove projects from building queue",
e );
         }
-        // now we must check if the current build is one of this
-        int index = ArrayUtils.indexOf( projectsId, getCurrentProjectIdBuilding() );
-        if ( index > 0 )
-        {
-            cancelBuild( projectsId[index] );
-        }
+
         return SUCCESS;
     }
 
+    public String cancelGroupBuild()
+        throws ContinuumException
+    {
+        try
+        {
+            checkBuildProjectInGroupAuthorization( getContinuum().getProjectGroup( projectGroupId).getName()
);
+        }
+        catch ( AuthorizationRequiredException e )
+        {
+            return REQUIRES_AUTHORIZATION;
+        }
+
+        TaskQueueManager taskQueueManager = getContinuum().getTaskQueueManager();
+
+        List<ProjectScmRoot> scmRoots = getContinuum().getProjectScmRootByProjectGroup(
projectGroupId );
+        
+        if ( scmRoots != null )
+        {
+            for ( ProjectScmRoot scmRoot : scmRoots )
+            {
+                try
+                {
+                    taskQueueManager.removeFromPrepareBuildQueue( projectGroupId, scmRoot.getScmRootAddress()
);
+                }
+                catch ( TaskQueueManagerException e )
+                {
+                    throw new ContinuumException( "Unable to cancel group build", e );
+                }
+            }
+        }
+        Collection<Project> projects = getContinuum().getProjectsInGroup( projectGroupId
);
+
+        List<String> projectIds = new ArrayList<String>();
+        
+        for ( Project project : projects )
+        {
+            projectIds.add( Integer.toString( project.getId() ) );
+        }
+
+        setSelectedProjects( projectIds );
+
+        return cancelBuilds();
+    }
 
     public void setProjectId( int projectId )
     {

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java?rev=724269&r1=724268&r2=724269&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java
Sun Dec  7 22:46:00 2008
@@ -27,6 +27,7 @@
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.scm.queue.CheckOutTask;
 import org.apache.maven.continuum.security.ContinuumRoleConstants;
+import org.apache.maven.continuum.web.action.ContinuumActionSupport;
 import org.apache.maven.continuum.web.exception.AuthenticationRequiredException;
 import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
 import org.codehaus.plexus.logging.LogEnabled;
@@ -44,7 +45,7 @@
  * @since 24 sept. 07
  */
 public class QueuesAction
-    extends AbstractBuildQueueAction
+    extends ContinuumActionSupport
     implements SecureAction, LogEnabled
 {
     
@@ -104,8 +105,9 @@
             addActionError( e.getMessage() );
             return REQUIRES_AUTHENTICATION;
         }
-        
-        cancelBuild( projectId );
+
+        taskQueueManager.cancelBuildTask( projectId );
+
         return SUCCESS;
     }
     
@@ -132,6 +134,7 @@
     }
 
     public String cancelCurrentCheckout()
+        throws Exception
     {
         try 
         {
@@ -148,7 +151,7 @@
             return REQUIRES_AUTHENTICATION;
         }
         
-        cancelCheckout( projectId );
+        taskQueueManager.cancelCheckout( projectId );
         return SUCCESS;
     }
     
@@ -261,39 +264,6 @@
 
         return bundle;
     }
-    
-    private boolean cancelCheckout(int projectId)
-    {
-        Task task = getCheckoutTaskQueueExecutor().getCurrentTask();
-
-        if ( task != null )
-        {
-            if ( task instanceof CheckOutTask )
-            {
-                if ( ( (CheckOutTask) task ).getProjectId() == projectId )
-                {
-                    getLogger().info( "Cancelling checkout for project " + projectId );
-                    return getCheckoutTaskQueueExecutor().cancelTask( task );
-                }
-                else
-                {
-                    getLogger().warn(
-                                      "Current task is not for the given projectId (" + projectId
+ "): "
-                                          + ( (CheckOutTask) task ).getProjectId() + "; not
cancelling checkout" );
-                }
-            }
-            else
-            {
-                getLogger().warn( "Current task not a CheckOutTask - not cancelling checkout"
);
-            }
-        }
-        else
-        {
-            getLogger().warn( "No task running - not cancelling checkout" );
-        }
-        return false;
-    }
-    
 
     public List<BuildProjectTask> getBuildProjectTasks()
     {
@@ -414,8 +384,5 @@
     public void setSelectedCheckOutTaskHashCodes( List<String> selectedCheckOutTaskHashCodes
)
     {
         this.selectedCheckOutTaskHashCodes = selectedCheckOutTaskHashCodes;
-    }
-
-
-    
+    }    
 }

Modified: continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties?rev=724269&r1=724268&r2=724269&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
(original)
+++ continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
Sun Dec  7 22:46:00 2008
@@ -185,6 +185,7 @@
 projectGroup.tab.releaseResults = Release Results
 projectGroup.scmRoot.title = Project Group Scm Root
 projectGroup.scmRoot.label = Scm Root URL
+projectGroup.cancelGroupBuild = Cancel Group Build
 
 # ----------------------------------------------------------------------
 # Page: Project Group - Members

Modified: continuum/trunk/continuum-webapp/src/main/resources/struts.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/resources/struts.xml?rev=724269&r1=724268&r2=724269&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/resources/struts.xml (original)
+++ continuum/trunk/continuum-webapp/src/main/resources/struts.xml Sun Dec  7 22:46:00 2008
@@ -444,6 +444,13 @@
       </result>
     </action>    
 
+    <action name="cancelGroupBuild" class="cancelBuild" method="cancelGroupBuild">
+      <result name="success" type="redirect-action">
+        <param name="actionName">projectGroupSummary</param>
+        <param name="projectGroupId">${projectGroupId}</param>
+      </result>
+    </action>
+
     <!--
     - continuum release
     -->

Modified: continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp?rev=724269&r1=724268&r2=724269&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp (original)
+++ continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp Sun
Dec  7 22:46:00 2008
@@ -175,6 +175,14 @@
                 </form>
               </redback:ifAuthorized>
             </td>
+            <td>
+              <redback:ifAuthorized permission="continuum-build-project-in-group" resource="${projectGroup.name}">
+                <form action="cancelGroupBuild.action" method="post">
+                  <input type="hidden" name="projectGroupId" value="<s:property value="projectGroupId"/>"/>
+                  <input type="submit" name="cancel" value="<s:text name="projectGroup.cancelGroupBuild"/>"/>
+                </form>
+              </redback:ifAuthorized>
+            </td>
           </tr>
         </table>
       </div>



Mime
View raw message