continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r776613 - in /continuum/branches/continuum-1.3.x: continuum-api/src/main/java/org/apache/continuum/buildmanager/ continuum-core/src/main/java/org/apache/continuum/buildmanager/ continuum-core/src/main/java/org/apache/maven/continuum/
Date Wed, 20 May 2009 08:34:21 GMT
Author: ctan
Date: Wed May 20 08:34:20 2009
New Revision: 776613

URL: http://svn.apache.org/viewvc?rev=776613&view=rev
Log:
[CONTINUUM-2209] prevent deletion of projects, project groups and build results while project
is currently building or being checked out.

Modified:
    continuum/branches/continuum-1.3.x/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildsManager.java
    continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
    continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java

Modified: continuum/branches/continuum-1.3.x/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildsManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildsManager.java?rev=776613&r1=776612&r2=776613&view=diff
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildsManager.java
(original)
+++ continuum/branches/continuum-1.3.x/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildsManager.java
Wed May 20 08:34:20 2009
@@ -345,7 +345,26 @@
     boolean isBuildInProgress();
 
     /**
-     * Return currently preparing build project 
+     * Checks if at least one of the projects is currently building.
+     * @param projectIds
+     * @return
+     * @throws BuildManagerException
+     */
+    boolean isAnyProjectCurrentlyBuilding( int[] projectIds )
+        throws BuildManagerException;
+
+    /**
+     * Checks whether project is currently being checked out.
+     * 
+     * @param projectId
+     * @return
+     * @throws BuildManagerException
+     */
+    boolean isProjectCurrentlyBeingCheckedOut( int projectId )
+        throws BuildManagerException;
+
+    /**
+     * Return currently preparing build project.
      * @return
      * @throws BuildManagerException
      */
@@ -353,7 +372,7 @@
         throws BuildManagerException;
 
     /**
-     * Return all projects in prepare build queue
+     * Return all projects in prepare build queue.
      * @return
      * @throws BuildManagerException
      */
@@ -361,7 +380,7 @@
         throws BuildManagerException;
 
     /**
-     * Remove a project from a prepare build queue
+     * Remove a project from a prepare build queue.
      * @param projectGroupId
      * @param scmRootId
      * @return

Modified: continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java?rev=776613&r1=776612&r2=776613&view=diff
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
(original)
+++ continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
Wed May 20 08:34:20 2009
@@ -1351,6 +1351,36 @@
         }
     }
 
+    public boolean isProjectCurrentlyBeingCheckedOut( int projectId )
+        throws BuildManagerException
+    {
+        Map<String, CheckOutTask> checkouts = getCurrentCheckouts();
+        for( String key : checkouts.keySet() )
+        {
+            CheckOutTask task = checkouts.get( key );
+            if( task.getProjectId() == projectId )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public boolean isAnyProjectCurrentlyBuilding( int[] projectIds )
+        throws BuildManagerException
+    {
+        for ( int i = 0; i < projectIds.length; i++ )
+        {
+            if ( isProjectInAnyCurrentBuild( projectIds[i] ) ) 
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     public void contextualize( Context context )
         throws ContextException
     {

Modified: continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=776613&r1=776612&r2=776613&view=diff
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Wed May 20 08:34:20 2009
@@ -402,6 +402,18 @@
                     throw new ContinuumException(
                         "Unable to delete group. At least one project in group is still being
checked out." );
                 }
+
+                if ( parallelBuildsManager.isAnyProjectCurrentlyBuilding( projectIds ) )
+                {
+                    throw new ContinuumException(
+                        "Unable to delete group. At least one project in group is still building."
);
+                }
+
+                if ( isAnyProjectsInReleaseStage( projects ) )
+                {
+                    throw new ContinuumException(
+                        "Unable to delete group. At least one project in group is in release
stage" );
+                }
             }
             catch ( BuildManagerException e )
             {
@@ -608,6 +620,42 @@
         {
             Project project = getProjectWithBuilds( projectId );
 
+            try
+            {
+                if ( parallelBuildsManager.isProjectCurrentlyBeingCheckedOut( projectId )
)
+                {
+                    throw new ContinuumException( "Unable to remove project " + projectId
+ 
+                        " because it is currently being checked out" );
+                }
+
+                if ( parallelBuildsManager.isProjectInAnyCurrentBuild( projectId ) )
+                {
+                    throw new ContinuumException( "Unable to remove project " + projectId
+ 
+                        " because it is currently building" );
+                }
+            }
+            catch ( BuildManagerException e )
+            {
+                throw new ContinuumException( e.getMessage(), e );
+            }
+
+            if ( isProjectInReleaseStage( project ) )
+            {
+                throw new ContinuumException( "Unable to remove project " + projectId + 
+                    " because it is in release stage" );
+            }
+
+            try
+            {
+                parallelBuildsManager.removeProjectFromCheckoutQueue( projectId );
+
+                parallelBuildsManager.removeProjectFromBuildQueue( projectId );
+            }
+            catch ( BuildManagerException e )
+            {
+                throw new ContinuumException( e.getMessage(), e );
+            }
+
             List<ContinuumReleaseResult> releaseResults =
                 releaseResultDao.getContinuumReleaseResultsByProject( projectId );
 
@@ -639,21 +687,6 @@
 
             log.info( "Remove project " + project.getName() + "(" + projectId + ")" );
 
-            try
-            {
-                parallelBuildsManager.removeProjectFromCheckoutQueue( projectId );
-
-                parallelBuildsManager.removeProjectFromBuildQueue( projectId );
-
-                //parallelBuildsManager.cancelCheckout( projectId );
-
-                parallelBuildsManager.cancelBuild( projectId );
-            }
-            catch ( BuildManagerException e )
-            {
-                throw new ContinuumException( e.getMessage(), e );
-            }
-
             for ( Object o : project.getBuildResults() )
             {
                 BuildResult br = (BuildResult) o;
@@ -1052,6 +1085,36 @@
         throws ContinuumException
     {
         BuildResult buildResult = getBuildResult( buildId );
+        
+        // check first if build result is currently being used by a building project
+        Project project = buildResult.getProject();
+        BuildResult bResult = getLatestBuildResultForProject( project.getId() );
+
+        try
+        {
+            if ( bResult != null && buildResult.getId() == bResult.getId() &&

+                 parallelBuildsManager.isProjectInAnyCurrentBuild( project.getId() ) )
+            {
+                throw new ContinuumException( "Unable to remove build result because it is
currently being used by" +
+                        "a building project " + project.getId() );
+            }
+        }
+        catch ( BuildManagerException e )
+        {
+            throw new ContinuumException( e.getMessage(), e );
+        }
+
+        buildResult.setModifiedDependencies( null );
+        buildResult.setBuildDefinition( null );
+
+        try
+        {
+            buildResultDao.updateBuildResult( buildResult );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw logAndCreateException( "Error while removing build result in database.",
e );
+        }
         removeBuildResult( buildResult );
     }
 
@@ -3530,6 +3593,20 @@
         return false;
     }
 
+    private boolean isAnyProjectsInReleaseStage( List<Project> projects )
+        throws ContinuumException
+    {
+        for ( Project project : projects )
+        {
+            if ( isProjectInReleaseStage( project ) )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     private Collection<Project> getProjectsNotInReleaseStage( Collection<Project>
projectsList )
         throws ContinuumException
     {



Mime
View raw message