continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r744012 - /continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Date Fri, 13 Feb 2009 06:56:51 GMT
Author: ctan
Date: Fri Feb 13 06:56:50 2009
New Revision: 744012

URL: http://svn.apache.org/viewvc?rev=744012&view=rev
Log:
[CONTINUUM-2077] removed the project scm root of the projects that were deleted


Modified:
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java

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=744012&r1=744011&r2=744012&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
Fri Feb 13 06:56:50 2009
@@ -404,20 +404,6 @@
             {
                 removeProject( projectIds[i] );
             }
-
-            List<ProjectScmRoot> projectScmRoots = getProjectScmRootByProjectGroup(
projectGroupId );
-
-            for ( ProjectScmRoot projectScmRoot : projectScmRoots )
-            {
-                try
-                {
-                    projectScmRootDao.removeProjectScmRoot( projectScmRoot );
-                }
-                catch ( ContinuumStoreException e )
-                {
-                    throw new ContinuumException( "unable to delete project scm root: " +
projectScmRoot.getScmRootAddress() );
-                }
-            }
         }
 
         log.info( "Remove project group " + projectGroup.getName() + "(" + projectGroup.getId()
+ ")" );
@@ -623,6 +609,8 @@
 
             List<ContinuumReleaseResult> releaseResults = releaseResultDao.getContinuumReleaseResultsByProject(
projectId );
 
+            ProjectScmRoot scmRoot = getProjectScmRootByProject( projectId );
+
             try
             {
                 for ( ContinuumReleaseResult releaseResult : releaseResults )
@@ -681,6 +669,8 @@
             FileUtils.deleteDirectory( buildOutputDirectory );
 
             projectDao.removeProject( projectDao.getProject( projectId ) );
+
+            removeProjectScmRoot( scmRoot );
         }
         catch ( ContinuumStoreException ex )
         {
@@ -3293,6 +3283,43 @@
         }
     }
 
+    private void removeProjectScmRoot( ProjectScmRoot projectScmRoot )
+        throws ContinuumException
+    {
+        //get all projects in the group
+        ProjectGroup group = getProjectGroupWithProjects( projectScmRoot.getProjectGroup().getId()
);
+
+        List<Project> projects = group.getProjects();
+
+        boolean found = false;
+        for ( Project project : projects )
+        {
+            if ( project.getScmUrl() != null && project.getScmUrl().startsWith( projectScmRoot.getScmRootAddress()
) )
+            {
+                found = true;
+                break;
+            }
+        }
+
+        if ( !found )
+        {
+            log.info( "Removing project scm root '" + projectScmRoot.getScmRootAddress()
+ "'" );
+            try
+            {
+                projectScmRootDao.removeProjectScmRoot( projectScmRoot );
+            }
+    		catch ( ContinuumStoreException e )
+    		{
+    		    log.error( "Failed to remove project scm root '" + projectScmRoot.getScmRootAddress()
+ "'", e );
+    		    throw new ContinuumException( "Error while removing project scm root '" + projectScmRoot.getScmRootAddress()
+ "'", e );
+    		}
+        }
+        else
+        {
+            log.info( "Project scm root '" + projectScmRoot.getScmRootAddress() + "' still
has projects, not removing" );
+        }
+    }
+
     public BuildQueue addBuildQueue( BuildQueue buildQueue ) throws ContinuumException
     {
         try



Mime
View raw message