continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r749538 [2/2] - in /continuum/trunk: continuum-core/src/test/java/org/apache/maven/continuum/execution/ continuum-core/src/test/java/org/apache/maven/continuum/project/builder/ continuum-webapp/src/main/java/org/apache/continuum/web/action/...
Date Tue, 03 Mar 2009 05:54:50 GMT
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=749538&r1=749537&r2=749538&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
Tue Mar  3 05:54:49 2009
@@ -49,6 +49,8 @@
 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 <a href="mailto:olamy@apache.org">olamy</a>
@@ -57,30 +59,32 @@
  * @since 24 sept. 07
  */
 public class QueuesAction
-	extends ContinuumActionSupport
-	implements SecureAction, LogEnabled
+    extends ContinuumActionSupport
+    implements SecureAction
 {
+    private Logger logger = LoggerFactory.getLogger( this.getClass() );
+
     private static final String DISTRIBUTED_BUILD_SUCCESS = "distributed-build-success";
 
-	private List<String> selectedBuildTaskHashCodes;
-	    
-	private List<String> selectedCheckOutTaskHashCodes;
-	
-	private int buildDefinitionId;
-	
-	private int projectId;
-	
-	private int trigger;
-	
-	private String projectName;
-	
-	private Map<String, BuildProjectTask> currentBuildProjectTasks = new HashMap<String,
BuildProjectTask>();
-	
-	private Map<String, CheckOutTask> currentCheckoutTasks = new HashMap<String, CheckOutTask>();
-	
-	private Map<String, List<BuildProjectTask>> buildsInQueue = new HashMap<String,
List<BuildProjectTask>>();
-	
-	private Map<String, List<CheckOutTask>> checkoutsInQueue = new HashMap<String,
List<CheckOutTask>>();
+    private List<String> selectedBuildTaskHashCodes;
+
+    private List<String> selectedCheckOutTaskHashCodes;
+
+    private int buildDefinitionId;
+
+    private int projectId;
+
+    private int trigger;
+
+    private String projectName;
+
+    private Map<String, BuildProjectTask> currentBuildProjectTasks = new HashMap<String,
BuildProjectTask>();
+
+    private Map<String, CheckOutTask> currentCheckoutTasks = new HashMap<String,
CheckOutTask>();
+
+    private Map<String, List<BuildProjectTask>> buildsInQueue = new HashMap<String,
List<BuildProjectTask>>();
+
+    private Map<String, List<CheckOutTask>> checkoutsInQueue = new HashMap<String,
List<CheckOutTask>>();
 
     /**
      * @plexus.requirement
@@ -99,106 +103,106 @@
 
     private List<String> selectedDistributedBuildTaskHashCodes;
 
-	// -----------------------------------------------------
-	//  webwork
-	// -----------------------------------------------------     
-	
-	public String cancelCurrent()
-	    throws Exception
-	{        
-	    try 
-	    {
-	        checkManageQueuesAuthorization();
-	    }
-	    catch( AuthorizationRequiredException authzE )
-	    {
-	        addActionError( authzE.getMessage() );
-	        return REQUIRES_AUTHORIZATION;
-	    }
-	    catch ( AuthenticationRequiredException e )
-	    {
-	        addActionError( e.getMessage() );
-	        return REQUIRES_AUTHENTICATION;
-	    }
-	
-	    try
-	    {
-	        getContinuum().getBuildsManager().cancelBuild( projectId );
-	    }
-	    catch ( BuildManagerException e )
-	    {
-	        addActionError( e.getMessage() );
-	        return ERROR;
-	    }
-	
-	    return SUCCESS;
-	}
-	
-	public String removeCheckout()
-	    throws Exception
-	{
-	    try 
-	    {
-	        checkManageQueuesAuthorization();
-	    }
-	    catch( AuthorizationRequiredException authzE )
-	    {
-	        addActionError( authzE.getMessage() );
-	        return REQUIRES_AUTHORIZATION;
-	    }
-	    catch ( AuthenticationRequiredException e )
-	    {
-	        addActionError( e.getMessage() );
-	        return REQUIRES_AUTHENTICATION;
-	    }
-	     
-	    try
-	    {
-	        getContinuum().getBuildsManager().removeProjectFromCheckoutQueue( projectId );
-	    }
-	    catch ( BuildManagerException e )
-	    {
-	        addActionError( e.getMessage() );
-	        return ERROR;
-	    }
-	    
-	    return SUCCESS;
-	}
-	
-	public String cancelCurrentCheckout()
-	    throws Exception
-	{
-	    try 
-	    {
-	        checkManageQueuesAuthorization();
-	    }
-	    catch( AuthorizationRequiredException authzE )
-	    {
-	        addActionError( authzE.getMessage() );
-	        return REQUIRES_AUTHORIZATION;
-	    }
-	    catch ( AuthenticationRequiredException e )
-	    {
-	        addActionError( e.getMessage() );
-	        return REQUIRES_AUTHENTICATION;
-	    }
-	    try
-	    {
-	        cancelCheckout( projectId );
-	    }
-	    catch ( BuildManagerException e )
-	    {
-	        addActionError( e.getMessage() );
-	        return ERROR;
-	    }
-	    
-	    return SUCCESS;
-	}
-	
-	public String display()
-	    throws Exception
-	{
-	    if ( getContinuum().getConfiguration().isDistributedBuildEnabled() )
+    // -----------------------------------------------------
+    //  webwork
+    // -----------------------------------------------------
+
+    public String cancelCurrent()
+        throws Exception
+    {
+        try
+        {
+            checkManageQueuesAuthorization();
+        }
+        catch ( AuthorizationRequiredException authzE )
+        {
+            addActionError( authzE.getMessage() );
+            return REQUIRES_AUTHORIZATION;
+        }
+        catch ( AuthenticationRequiredException e )
+        {
+            addActionError( e.getMessage() );
+            return REQUIRES_AUTHENTICATION;
+        }
+
+        try
+        {
+            getContinuum().getBuildsManager().cancelBuild( projectId );
+        }
+        catch ( BuildManagerException e )
+        {
+            addActionError( e.getMessage() );
+            return ERROR;
+        }
+
+        return SUCCESS;
+    }
+
+    public String removeCheckout()
+        throws Exception
+    {
+        try
+        {
+            checkManageQueuesAuthorization();
+        }
+        catch ( AuthorizationRequiredException authzE )
+        {
+            addActionError( authzE.getMessage() );
+            return REQUIRES_AUTHORIZATION;
+        }
+        catch ( AuthenticationRequiredException e )
+        {
+            addActionError( e.getMessage() );
+            return REQUIRES_AUTHENTICATION;
+        }
+
+        try
+        {
+            getContinuum().getBuildsManager().removeProjectFromCheckoutQueue( projectId );
+        }
+        catch ( BuildManagerException e )
+        {
+            addActionError( e.getMessage() );
+            return ERROR;
+        }
+
+        return SUCCESS;
+    }
+
+    public String cancelCurrentCheckout()
+        throws Exception
+    {
+        try
+        {
+            checkManageQueuesAuthorization();
+        }
+        catch ( AuthorizationRequiredException authzE )
+        {
+            addActionError( authzE.getMessage() );
+            return REQUIRES_AUTHORIZATION;
+        }
+        catch ( AuthenticationRequiredException e )
+        {
+            addActionError( e.getMessage() );
+            return REQUIRES_AUTHENTICATION;
+        }
+        try
+        {
+            cancelCheckout( projectId );
+        }
+        catch ( BuildManagerException e )
+        {
+            addActionError( e.getMessage() );
+            return ERROR;
+        }
+
+        return SUCCESS;
+    }
+
+    public String display()
+        throws Exception
+    {
+        if ( getContinuum().getConfiguration().isDistributedBuildEnabled() )
         {
             distributedBuildSummary = new ArrayList<DistributedBuildSummary>();
 
@@ -206,28 +210,29 @@
 
             for ( String url : map.keySet() )
             {
-               PrepareBuildProjectsTask task = map.get( url );
-               
-               ProjectGroup projectGroup = getContinuum().getProjectGroup( task.getProjectGroupId()
);
-               
-               DistributedBuildSummary summary = new DistributedBuildSummary();
-               summary.setUrl( url );
-               summary.setProjectGroupId( task.getProjectGroupId() );
-               summary.setProjectGroupName( projectGroup.getName() );
-               summary.setScmRootAddress( task.getScmRootAddress() );
-               
-               ProjectScmRoot scmRoot = getContinuum().getProjectScmRootByProjectGroupAndScmRootAddress(
task.getProjectGroupId(), 
-                                                                                        
                task.getScmRootAddress() );
-               if ( scmRoot.getState() == ContinuumProjectState.UPDATING )
-               {
-                   summary.setCancelEnabled( false );
-               }
-               else
-               {
-                   summary.setCancelEnabled( true );
-               }
+                PrepareBuildProjectsTask task = map.get( url );
+
+                ProjectGroup projectGroup = getContinuum().getProjectGroup( task.getProjectGroupId()
);
 
-               distributedBuildSummary.add( summary );
+                DistributedBuildSummary summary = new DistributedBuildSummary();
+                summary.setUrl( url );
+                summary.setProjectGroupId( task.getProjectGroupId() );
+                summary.setProjectGroupName( projectGroup.getName() );
+                summary.setScmRootAddress( task.getScmRootAddress() );
+
+                ProjectScmRoot scmRoot =
+                    getContinuum().getProjectScmRootByProjectGroupAndScmRootAddress( task.getProjectGroupId(),
+                                                                                     task.getScmRootAddress()
);
+                if ( scmRoot.getState() == ContinuumProjectState.UPDATING )
+                {
+                    summary.setCancelEnabled( false );
+                }
+                else
+                {
+                    summary.setCancelEnabled( true );
+                }
+
+                distributedBuildSummary.add( summary );
             }
 
             distributedBuildQueues = aggregateQueues();
@@ -236,168 +241,169 @@
         }
         else
         {
-	        try
-	        {
-	            // current builds
-	            Map<String, Task> currentBuilds = getContinuum().getBuildsManager().getCurrentBuilds();
-	            Set<String> keySet = currentBuilds.keySet();
-	            for( String key : keySet )
-	            {
-	                BuildProjectTask buildTask = (BuildProjectTask) currentBuilds.get( key );
-	                currentBuildProjectTasks.put( key, buildTask );
-	            }
-	        }
-	        catch ( BuildManagerException e )
-	        {
-	            addActionError( e.getMessage() );
-	            return ERROR;
-	        }
-
-   	        try
-	        {
-	            // queued builds
-	            Map<String, List<Task>> builds = getContinuum().getBuildsManager().getProjectsInBuildQueues();
-	            Set<String> keySet = builds.keySet();            
-	            for( String key : keySet )
-	            {
-	                List<BuildProjectTask> buildTasks = new ArrayList<BuildProjectTask>();
-	                for( Task task : builds.get( key ) )
-	                {
-	                    BuildProjectTask buildTask = (BuildProjectTask) task;
-	                    buildTasks.add( buildTask ); 
-	                }
-	                buildsInQueue.put( key, buildTasks );
-	            }
-	        }
-	        catch ( BuildManagerException e )
-	        {
-	            addActionError( e.getMessage() );
-	            return ERROR;
-	        }
-
- 	        try
-	        {
-	            // current checkouts
-	            Map<String, Task> currentCheckouts = getContinuum().getBuildsManager().getCurrentCheckouts();
-	            Set<String> keySet = currentCheckouts.keySet();
-	            for( String key : keySet )
-	            {
-	                CheckOutTask checkoutTask = (CheckOutTask) currentCheckouts.get( key );
-   	                currentCheckoutTasks.put( key, checkoutTask );
-	            }
-	        }
-	        catch ( BuildManagerException e )
-	        {
-	            addActionError( e.getMessage() );
-	            return ERROR;
-	        }
-
-	        try
-	        {
-	            // queued checkouts
-	            Map<String, List<Task>> checkouts = getContinuum().getBuildsManager().getProjectsInCheckoutQueues();
-	            Set<String> keySet = checkouts.keySet();
-	            for( String key : keySet )
-	            {
-	                List<CheckOutTask> checkoutTasks = new ArrayList<CheckOutTask>();
-	                for( Task task : checkouts.get( key ) )
-	                {
-	                    CheckOutTask checkoutTask = (CheckOutTask) task;
-	                    checkoutTasks.add( checkoutTask ); 
-	                }
-	                checkoutsInQueue.put( key, checkoutTasks );
-	            }
-	        }
-	        catch ( BuildManagerException e )
-	        {
-	            addActionError( e.getMessage() );
-	            return ERROR;
-	        }
-	    }
-
-	    return SUCCESS;
-	}
-	
-	public String remove()
-	    throws Exception
-	{
-	    try 
-	    {
-	        checkManageQueuesAuthorization();
-	    }
-	    catch( AuthorizationRequiredException authzE )
-	    {
-	        addActionError( authzE.getMessage() );
-	        return REQUIRES_AUTHORIZATION;
-	    }
-	    catch ( AuthenticationRequiredException e )
-	    {
-	        addActionError( e.getMessage() );
-	        return REQUIRES_AUTHENTICATION;
-	    }
-	            
-	    getContinuum().getBuildsManager().removeProjectFromBuildQueue( projectId, buildDefinitionId,
trigger, projectName );
-	    Project project = getContinuum().getProject( projectId );
-	    project.setState( project.getOldState() );
-	    getContinuum().updateProject( project );
-	
-	    return SUCCESS;
-	}
-	
-	public String removeBuildEntries()
-	    throws Exception
-	{
-	    try 
-	    {
-	        checkManageQueuesAuthorization();
-	    }
-	    catch( AuthorizationRequiredException authzE )
-	    {
-	        addActionError( authzE.getMessage() );
-	        return REQUIRES_AUTHORIZATION;
-	    }
-	    catch ( AuthenticationRequiredException e )
-	    {
-	        addActionError( e.getMessage() );
-	        return REQUIRES_AUTHENTICATION;
-	    }
-	    
-	    getContinuum().getBuildsManager().removeProjectsFromBuildQueueWithHashcodes(
-	             listToIntArray( this.getSelectedBuildTaskHashCodes() ) );
-	    return SUCCESS;
-	}
-	
-	public String removeCheckoutEntries()
-	    throws Exception
-	{
-	    try 
-	    {
-	        checkManageQueuesAuthorization();
-	    }
-	    catch( AuthorizationRequiredException authzE )
-	    {
-	        addActionError( authzE.getMessage() );
-	        return REQUIRES_AUTHORIZATION;
-	    }
-	    catch ( AuthenticationRequiredException e )
-	    {
-	        addActionError( e.getMessage() );
-	        return REQUIRES_AUTHENTICATION;
-	    }
-	 
-	    getContinuum().getBuildsManager().removeProjectsFromCheckoutQueueWithHashcodes(
-	                listToIntArray( this.getSelectedCheckOutTaskHashCodes() ) );
-	    return SUCCESS;
-	}
+            try
+            {
+                // current builds
+                Map<String, Task> currentBuilds = getContinuum().getBuildsManager().getCurrentBuilds();
+                Set<String> keySet = currentBuilds.keySet();
+                for ( String key : keySet )
+                {
+                    BuildProjectTask buildTask = (BuildProjectTask) currentBuilds.get( key
);
+                    currentBuildProjectTasks.put( key, buildTask );
+                }
+            }
+            catch ( BuildManagerException e )
+            {
+                addActionError( e.getMessage() );
+                return ERROR;
+            }
+
+            try
+            {
+                // queued builds
+                Map<String, List<Task>> builds = getContinuum().getBuildsManager().getProjectsInBuildQueues();
+                Set<String> keySet = builds.keySet();
+                for ( String key : keySet )
+                {
+                    List<BuildProjectTask> buildTasks = new ArrayList<BuildProjectTask>();
+                    for ( Task task : builds.get( key ) )
+                    {
+                        BuildProjectTask buildTask = (BuildProjectTask) task;
+                        buildTasks.add( buildTask );
+                    }
+                    buildsInQueue.put( key, buildTasks );
+                }
+            }
+            catch ( BuildManagerException e )
+            {
+                addActionError( e.getMessage() );
+                return ERROR;
+            }
+
+            try
+            {
+                // current checkouts
+                Map<String, Task> currentCheckouts = getContinuum().getBuildsManager().getCurrentCheckouts();
+                Set<String> keySet = currentCheckouts.keySet();
+                for ( String key : keySet )
+                {
+                    CheckOutTask checkoutTask = (CheckOutTask) currentCheckouts.get( key
);
+                    currentCheckoutTasks.put( key, checkoutTask );
+                }
+            }
+            catch ( BuildManagerException e )
+            {
+                addActionError( e.getMessage() );
+                return ERROR;
+            }
+
+            try
+            {
+                // queued checkouts
+                Map<String, List<Task>> checkouts = getContinuum().getBuildsManager().getProjectsInCheckoutQueues();
+                Set<String> keySet = checkouts.keySet();
+                for ( String key : keySet )
+                {
+                    List<CheckOutTask> checkoutTasks = new ArrayList<CheckOutTask>();
+                    for ( Task task : checkouts.get( key ) )
+                    {
+                        CheckOutTask checkoutTask = (CheckOutTask) task;
+                        checkoutTasks.add( checkoutTask );
+                    }
+                    checkoutsInQueue.put( key, checkoutTasks );
+                }
+            }
+            catch ( BuildManagerException e )
+            {
+                addActionError( e.getMessage() );
+                return ERROR;
+            }
+        }
+
+        return SUCCESS;
+    }
+
+    public String remove()
+        throws Exception
+    {
+        try
+        {
+            checkManageQueuesAuthorization();
+        }
+        catch ( AuthorizationRequiredException authzE )
+        {
+            addActionError( authzE.getMessage() );
+            return REQUIRES_AUTHORIZATION;
+        }
+        catch ( AuthenticationRequiredException e )
+        {
+            addActionError( e.getMessage() );
+            return REQUIRES_AUTHENTICATION;
+        }
+
+        getContinuum().getBuildsManager().removeProjectFromBuildQueue( projectId, buildDefinitionId,
trigger,
+                                                                       projectName );
+        Project project = getContinuum().getProject( projectId );
+        project.setState( project.getOldState() );
+        getContinuum().updateProject( project );
+
+        return SUCCESS;
+    }
+
+    public String removeBuildEntries()
+        throws Exception
+    {
+        try
+        {
+            checkManageQueuesAuthorization();
+        }
+        catch ( AuthorizationRequiredException authzE )
+        {
+            addActionError( authzE.getMessage() );
+            return REQUIRES_AUTHORIZATION;
+        }
+        catch ( AuthenticationRequiredException e )
+        {
+            addActionError( e.getMessage() );
+            return REQUIRES_AUTHENTICATION;
+        }
+
+        getContinuum().getBuildsManager().removeProjectsFromBuildQueueWithHashcodes(
+            listToIntArray( this.getSelectedBuildTaskHashCodes() ) );
+        return SUCCESS;
+    }
+
+    public String removeCheckoutEntries()
+        throws Exception
+    {
+        try
+        {
+            checkManageQueuesAuthorization();
+        }
+        catch ( AuthorizationRequiredException authzE )
+        {
+            addActionError( authzE.getMessage() );
+            return REQUIRES_AUTHORIZATION;
+        }
+        catch ( AuthenticationRequiredException e )
+        {
+            addActionError( e.getMessage() );
+            return REQUIRES_AUTHENTICATION;
+        }
+
+        getContinuum().getBuildsManager().removeProjectsFromCheckoutQueueWithHashcodes(
+            listToIntArray( this.getSelectedCheckOutTaskHashCodes() ) );
+        return SUCCESS;
+    }
 
     public String cancelDistributedBuild()
         throws Exception
     {
-        try 
+        try
         {
             checkManageQueuesAuthorization();
         }
-        catch( AuthorizationRequiredException authzE )
+        catch ( AuthorizationRequiredException authzE )
         {
             addActionError( authzE.getMessage() );
             return REQUIRES_AUTHORIZATION;
@@ -416,11 +422,11 @@
     public String removeDistributedBuildEntry()
         throws Exception
     {
-        try 
+        try
         {
             checkManageQueuesAuthorization();
         }
-        catch( AuthorizationRequiredException authzE )
+        catch ( AuthorizationRequiredException authzE )
         {
             addActionError( authzE.getMessage() );
             return REQUIRES_AUTHORIZATION;
@@ -439,11 +445,11 @@
     public String removeDistributedBuildEntries()
         throws Exception
     {
-        try 
+        try
         {
             checkManageQueuesAuthorization();
         }
-        catch( AuthorizationRequiredException authzE )
+        catch ( AuthorizationRequiredException authzE )
         {
             addActionError( authzE.getMessage() );
             return REQUIRES_AUTHORIZATION;
@@ -454,174 +460,172 @@
             return REQUIRES_AUTHENTICATION;
         }
 
-        getContinuum().getTaskQueueManager()
-            .removeTasksFromDistributedBuildQueueWithHashCodes( listToIntArray( this.getSelectedDistributedBuildTaskHashCodes()
) );
+        getContinuum().getTaskQueueManager().removeTasksFromDistributedBuildQueueWithHashCodes(
+            listToIntArray( this.getSelectedDistributedBuildTaskHashCodes() ) );
 
         return SUCCESS;
     }
 
-	private int[] listToIntArray( List<String> strings )
-	{
-	    if ( strings == null || strings.isEmpty() )
-	    {
-	        return new int[0];
-	    }
-	    int[] array = new int[0];
-	    for ( String intString : strings )
-	    {
-	        array = ArrayUtils.add( array, Integer.parseInt( intString ) );
-	    }
-	    return array;
-	}
-	
-	
-	// -----------------------------------------------------
-	//  security
-	// -----------------------------------------------------    
-	
-	public SecureActionBundle getSecureActionBundle()
-	    throws SecureActionException
-	{
-	    SecureActionBundle bundle = new SecureActionBundle();
-	    bundle.setRequiresAuthentication( true );
-	    bundle.addRequiredAuthorization( ContinuumRoleConstants.CONTINUUM_VIEW_QUEUES, Resource.GLOBAL
);
-	
-	    return bundle;
-	}
-	
-	private boolean cancelCheckout(int projectId)
-	    throws BuildManagerException
-	{   
-	    Map<String, Task> tasks = getContinuum().getBuildsManager().getCurrentCheckouts();
-	    if( tasks != null )
-	    {  
-	        Set<String> keySet = tasks.keySet();
-	        for( String key : keySet )
-	        {
-	            Task task = tasks.get( key );
-	            if( task != null && task instanceof CheckOutTask )                 
  
-	            {
-	                if ( ( (CheckOutTask) task ).getProjectId() == projectId )
-	                {
-	                    getLogger().info( "Cancelling checkout for project " + projectId );
-	                    return getContinuum().getBuildsManager().cancelCheckout( projectId );
-	                }
-	                else
-	                {
-	                    getLogger().warn(
-	                                      "Current task is not for the given projectId (" +
projectId + "): "
-	                                          + ( (CheckOutTask) task ).getProjectId() + ";
not cancelling checkout" );
-	                }
-	            }
-	        }
-	    }
-	    else
-	    {
-	        getLogger().warn( "No task running - not cancelling checkout" );
-	    }
-	    
-	    return false;
-	}  
-	
-	public int getBuildDefinitionId()
-	{
-	    return buildDefinitionId;
-	}
-	
-	public void setBuildDefinitionId( int buildDefinitionId )
-	{
-	    this.buildDefinitionId = buildDefinitionId;
-	}
-	
-	public int getProjectId()
-	{
-	    return projectId;
-	}
-	
-	public void setProjectId( int projectId )
-	{
-	    this.projectId = projectId;
-	}
-	
-	public int getTrigger()
-	{
-	    return trigger;
-	}
-	
-	public void setTrigger( int trigger )
-	{
-	    this.trigger = trigger;
-	}
-	
-	public String getProjectName()
-	{
-	    return projectName;
-	}
-	
-	public void setProjectName( String projectName )
-	{
-	    this.projectName = projectName;
-	}
-	
-	public List<String> getSelectedBuildTaskHashCodes()
-	{
-	    return selectedBuildTaskHashCodes;
-	}
-	
-	public void setSelectedBuildTaskHashCodes( List<String> selectedBuildTaskHashCodes
)
-	{
-	    this.selectedBuildTaskHashCodes = selectedBuildTaskHashCodes;
-	}
-	
-	public List<String> getSelectedCheckOutTaskHashCodes()
-	{
-	    return selectedCheckOutTaskHashCodes;
-	}
-	
-	public void setSelectedCheckOutTaskHashCodes( List<String> selectedCheckOutTaskHashCodes
)
-	{
-	    this.selectedCheckOutTaskHashCodes = selectedCheckOutTaskHashCodes;
-	}
-	
-	public Map<String, BuildProjectTask> getCurrentBuildProjectTasks()
-	{
-	    return currentBuildProjectTasks;
-	}
-	
-	public void setCurrentBuildProjectTasks( Map<String, BuildProjectTask> currentBuildProjectTasks
)
-	{
-	    this.currentBuildProjectTasks = currentBuildProjectTasks;
-	}
-	
-	public Map<String, CheckOutTask> getCurrentCheckoutTasks()
-	{
-	    return currentCheckoutTasks;
-	}
-	
-	public void setCurrentCheckoutTasks( Map<String, CheckOutTask> currentCheckoutTasks
)
-	{
-	    this.currentCheckoutTasks = currentCheckoutTasks;
-	}
-	
-	public Map<String, List<BuildProjectTask>> getBuildsInQueue()
-	{
-	    return buildsInQueue;
-	}
-	
-	public void setBuildsInQueue( Map<String, List<BuildProjectTask>> buildsInQueue
)
-	{
-	    this.buildsInQueue = buildsInQueue;
-	}
-	
-	public Map<String, List<CheckOutTask>> getCheckoutsInQueue()
-	{
-	    return checkoutsInQueue;
-	}
-	
-	public void setCheckoutsInQueue( Map<String, List<CheckOutTask>> checkoutsInQueue
)
-	{
-	    this.checkoutsInQueue = checkoutsInQueue;
-	}
+    private int[] listToIntArray( List<String> strings )
+    {
+        if ( strings == null || strings.isEmpty() )
+        {
+            return new int[0];
+        }
+        int[] array = new int[0];
+        for ( String intString : strings )
+        {
+            array = ArrayUtils.add( array, Integer.parseInt( intString ) );
+        }
+        return array;
+    }
+
+    // -----------------------------------------------------
+    //  security
+    // -----------------------------------------------------
+
+    public SecureActionBundle getSecureActionBundle()
+        throws SecureActionException
+    {
+        SecureActionBundle bundle = new SecureActionBundle();
+        bundle.setRequiresAuthentication( true );
+        bundle.addRequiredAuthorization( ContinuumRoleConstants.CONTINUUM_VIEW_QUEUES, Resource.GLOBAL
);
+
+        return bundle;
+    }
+
+    private boolean cancelCheckout( int projectId )
+        throws BuildManagerException
+    {
+        Map<String, Task> tasks = getContinuum().getBuildsManager().getCurrentCheckouts();
+        if ( tasks != null )
+        {
+            Set<String> keySet = tasks.keySet();
+            for ( String key : keySet )
+            {
+                Task task = tasks.get( key );
+                if ( task != null && task instanceof CheckOutTask )
+                {
+                    if ( ( (CheckOutTask) task ).getProjectId() == projectId )
+                    {
+                        logger.info( "Cancelling checkout for project " + projectId );
+                        return getContinuum().getBuildsManager().cancelCheckout( projectId
);
+                    }
+                    else
+                    {
+                        logger.warn( "Current task is not for the given projectId (" + projectId
+ "): " +
+                            ( (CheckOutTask) task ).getProjectId() + "; not cancelling checkout"
);
+                    }
+                }
+            }
+        }
+        else
+        {
+            logger.warn( "No task running - not cancelling checkout" );
+        }
+
+        return false;
+    }
+
+    public int getBuildDefinitionId()
+    {
+        return buildDefinitionId;
+    }
+
+    public void setBuildDefinitionId( int buildDefinitionId )
+    {
+        this.buildDefinitionId = buildDefinitionId;
+    }
+
+    public int getProjectId()
+    {
+        return projectId;
+    }
+
+    public void setProjectId( int projectId )
+    {
+        this.projectId = projectId;
+    }
+
+    public int getTrigger()
+    {
+        return trigger;
+    }
+
+    public void setTrigger( int trigger )
+    {
+        this.trigger = trigger;
+    }
+
+    public String getProjectName()
+    {
+        return projectName;
+    }
+
+    public void setProjectName( String projectName )
+    {
+        this.projectName = projectName;
+    }
+
+    public List<String> getSelectedBuildTaskHashCodes()
+    {
+        return selectedBuildTaskHashCodes;
+    }
+
+    public void setSelectedBuildTaskHashCodes( List<String> selectedBuildTaskHashCodes
)
+    {
+        this.selectedBuildTaskHashCodes = selectedBuildTaskHashCodes;
+    }
+
+    public List<String> getSelectedCheckOutTaskHashCodes()
+    {
+        return selectedCheckOutTaskHashCodes;
+    }
+
+    public void setSelectedCheckOutTaskHashCodes( List<String> selectedCheckOutTaskHashCodes
)
+    {
+        this.selectedCheckOutTaskHashCodes = selectedCheckOutTaskHashCodes;
+    }
+
+    public Map<String, BuildProjectTask> getCurrentBuildProjectTasks()
+    {
+        return currentBuildProjectTasks;
+    }
+
+    public void setCurrentBuildProjectTasks( Map<String, BuildProjectTask> currentBuildProjectTasks
)
+    {
+        this.currentBuildProjectTasks = currentBuildProjectTasks;
+    }
+
+    public Map<String, CheckOutTask> getCurrentCheckoutTasks()
+    {
+        return currentCheckoutTasks;
+    }
+
+    public void setCurrentCheckoutTasks( Map<String, CheckOutTask> currentCheckoutTasks
)
+    {
+        this.currentCheckoutTasks = currentCheckoutTasks;
+    }
+
+    public Map<String, List<BuildProjectTask>> getBuildsInQueue()
+    {
+        return buildsInQueue;
+    }
+
+    public void setBuildsInQueue( Map<String, List<BuildProjectTask>> buildsInQueue
)
+    {
+        this.buildsInQueue = buildsInQueue;
+    }
+
+    public Map<String, List<CheckOutTask>> getCheckoutsInQueue()
+    {
+        return checkoutsInQueue;
+    }
+
+    public void setCheckoutsInQueue( Map<String, List<CheckOutTask>> checkoutsInQueue
)
+    {
+        this.checkoutsInQueue = checkoutsInQueue;
+    }
 
     public List<DistributedBuildSummary> getDistributedBuildSummary()
     {
@@ -673,29 +677,33 @@
         this.scmRootAddress = scmRootAddress;
     }
 
-    private List<PrepareBuildProjectsTask> aggregateQueues() throws TaskQueueManagerException
+    private List<PrepareBuildProjectsTask> aggregateQueues()
+        throws TaskQueueManagerException
     {
         List<PrepareBuildProjectsTask> aggregatedQueues = new ArrayList<PrepareBuildProjectsTask>();
 
-        List<PrepareBuildProjectsTask> overallQueues = getContinuum().getTaskQueueManager().getDistributedBuildProjectsInQueue();
+        List<PrepareBuildProjectsTask> overallQueues =
+            getContinuum().getTaskQueueManager().getDistributedBuildProjectsInQueue();
 
-        Map <String, DistributedBuildTaskQueueExecutor> agentTaskQueueExecutors = distributedBuildManager.getTaskQueueExecutors();
+        Map<String, DistributedBuildTaskQueueExecutor> agentTaskQueueExecutors =
+            distributedBuildManager.getTaskQueueExecutors();
 
         for ( String url : agentTaskQueueExecutors.keySet() )
         {
             try
             {
-                getLogger().debug("size of each queue snapshot " + url + " : " + agentTaskQueueExecutors.get(
url ).getQueue().getQueueSnapshot().size()); 
-                aggregatedQueues.addAll( agentTaskQueueExecutors.get( url ).getQueue().getQueueSnapshot()
) ;
+                logger.debug( "size of each queue snapshot " + url + " : " +
+                    agentTaskQueueExecutors.get( url ).getQueue().getQueueSnapshot().size()
);
+                aggregatedQueues.addAll( agentTaskQueueExecutors.get( url ).getQueue().getQueueSnapshot()
);
             }
             catch ( TaskQueueException e )
             {
                 //silently ignore error
-                getLogger().error( "Error encountered retrieving queue snapshot from queue
:" + url, e );
+                logger.error( "Error encountered retrieving queue snapshot from queue :"
+ url, e );
             }
         }
 
-        getLogger().debug("size of agg. queue " + aggregatedQueues.size() );
+        logger.debug( "size of agg. queue " + aggregatedQueues.size() );
         aggregatedQueues.addAll( overallQueues );
 
         return aggregatedQueues;

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/BuildDefinitionSummaryAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/BuildDefinitionSummaryAction.java?rev=749538&r1=749537&r2=749538&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/BuildDefinitionSummaryAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/BuildDefinitionSummaryAction.java
Tue Mar  3 05:54:49 2009
@@ -30,6 +30,8 @@
 import org.apache.maven.continuum.web.action.AbstractBuildDefinitionAction;
 import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
 import org.apache.maven.continuum.web.model.BuildDefinitionSummary;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * BuildDefinitionSummaryAction:
@@ -41,6 +43,8 @@
 public class BuildDefinitionSummaryAction
     extends AbstractBuildDefinitionAction
 {
+    private Logger logger = LoggerFactory.getLogger( this.getClass() );
+
     private int projectGroupId;
 
     private String projectGroupName;
@@ -77,7 +81,7 @@
         }
         catch ( ContinuumException e )
         {
-            getLogger().info( "unable to build summary" );
+            logger.info( "unable to build summary" );
             return ERROR;
         }
         catch ( AuthorizationRequiredException authzE )
@@ -111,7 +115,7 @@
         }
         catch ( ContinuumException e )
         {
-            getLogger().info( "unable to build summary" );
+            logger.info( "unable to build summary" );
             return ERROR;
         }
         catch ( AuthorizationRequiredException authzE )
@@ -182,7 +186,6 @@
         return summaryList;
     }
 
-    
 
     public int getProjectId()
     {

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/NotifierSummaryAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/NotifierSummaryAction.java?rev=749538&r1=749537&r2=749538&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/NotifierSummaryAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/NotifierSummaryAction.java
Tue Mar  3 05:54:49 2009
@@ -31,6 +31,8 @@
 import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
 import org.apache.maven.continuum.web.model.NotifierSummary;
 import org.codehaus.plexus.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -48,6 +50,8 @@
 public class NotifierSummaryAction
     extends ContinuumActionSupport
 {
+    private Logger logger = LoggerFactory.getLogger( this.getClass() );
+
     /**
      * Identifier for the {@link ProjectGroup} for which the Notifier summary
      * needs to be prepared for.
@@ -78,7 +82,7 @@
      */
     public String summarizeForProject()
     {
-        getLogger().debug( "Obtaining summary for Project Id: " + projectId );
+        logger.debug( "Obtaining summary for Project Id: " + projectId );
 
         try
         {
@@ -88,7 +92,7 @@
         }
         catch ( ContinuumException e )
         {
-            getLogger().error( "Unable to prepare Notifier summaries for Project Id: " +
projectId, e );
+            logger.error( "Unable to prepare Notifier summaries for Project Id: " + projectId,
e );
             return ERROR;
         }
         catch ( AuthorizationRequiredException authzE )
@@ -119,7 +123,7 @@
      */
     public String summarizeForProjectGroup()
     {
-        getLogger().debug( "Obtaining summary for ProjectGroup Id:" + projectGroupId );
+        logger.debug( "Obtaining summary for ProjectGroup Id:" + projectGroupId );
 
         try
         {
@@ -138,7 +142,7 @@
         }
         catch ( ContinuumException e )
         {
-            getLogger().error( "Unable to prepare Notifier summaries for ProjectGroup Id:
" + projectGroupId, e );
+            logger.error( "Unable to prepare Notifier summaries for ProjectGroup Id: " +
projectGroupId, e );
             return ERROR;
         }
         catch ( AuthorizationRequiredException authzE )

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/validator/InstallationValidator.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/validator/InstallationValidator.java?rev=749538&r1=749537&r2=749538&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/validator/InstallationValidator.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/validator/InstallationValidator.java
Tue Mar  3 05:54:49 2009
@@ -24,9 +24,9 @@
 import org.apache.maven.continuum.execution.ExecutorConfigurator;
 import org.apache.maven.continuum.installation.InstallationException;
 import org.apache.maven.continuum.installation.InstallationService;
-import org.codehaus.plexus.logging.LogEnabled;
-import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.List;
 
@@ -39,11 +39,10 @@
  */
 public class InstallationValidator
     extends ValidatorSupport
-    implements LogEnabled
 {
     private String fieldName;
 
-    private Logger logger;
+    private Logger logger = LoggerFactory.getLogger( this.getClass() );
 
     /**
      * @plexus.requirement role-hint="default"
@@ -79,8 +78,8 @@
                 if ( executorConfigurator.getVersionArgument() != null )
                 {
                     // just try to get version infos to validate path is valid
-                    List<String> versionInfos = installationService
-                        .getExecutorConfiguratorVersion( varValue, executorConfigurator,
null );
+                    List<String> versionInfos =
+                        installationService.getExecutorConfiguratorVersion( varValue, executorConfigurator,
null );
                 }
             }
         }
@@ -102,12 +101,4 @@
     {
         this.fieldName = fieldName;
     }
-
-    /**
-     * @see org.codehaus.plexus.logging.LogEnabled#enableLogging(org.codehaus.plexus.logging.Logger)
-     */
-    public void enableLogging( Logger logger )
-    {
-        this.logger = logger;
-    }
 }

Modified: continuum/trunk/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/TestAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/TestAction.java?rev=749538&r1=749537&r2=749538&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/TestAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/TestAction.java
Tue Mar  3 05:54:49 2009
@@ -1,5 +1,8 @@
 package org.apache.maven.continuum.web.action;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -28,12 +31,14 @@
 public class TestAction
     extends PlexusActionSupport
 {
+    private Logger logger = LoggerFactory.getLogger( this.getClass() );
+
     private String testString;
 
     public String execute()
         throws Exception
     {
-        getLogger().info( testString );
+        logger.info( testString );
 
         return INPUT;
     }



Mime
View raw message