continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r756523 - /continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Date Fri, 20 Mar 2009 15:21:24 GMT
Author: ctan
Date: Fri Mar 20 15:21:24 2009
New Revision: 756523

URL: http://svn.apache.org/viewvc?rev=756523&view=rev
Log:
[CONTINUUM-2126] also move project scm root when moving a project to another group

Submitted By: Jose Morales Martinez


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=756523&r1=756522&r2=756523&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 Mar 20 15:21:24 2009
@@ -111,6 +111,7 @@
 import org.codehaus.plexus.util.dag.CycleDetectedException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 
 /**
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
@@ -2764,10 +2765,17 @@
             boolean removeWorkingDirectory = false;
 
             Project p = projectDao.getProject( project.getId() );
+            ProjectScmRoot projectScmRoot = null;
 
             if ( !p.getScmUrl().equals( project.getScmUrl() ) )
             {
                 removeWorkingDirectory = true;
+                projectScmRoot = getProjectScmRootByProject( project.getId() );
+            }
+
+            if ( !p.getProjectGroup().equals( project.getProjectGroup() ) )
+            {
+                projectScmRoot = getProjectScmRootByProject( project.getId() );
             }
 
             if ( StringUtils.isEmpty( p.getScmTag() ) && !StringUtils.isEmpty( project.getScmTag()
) )
@@ -2796,6 +2804,11 @@
             }
 
             projectDao.updateProject( project );
+
+            if ( projectScmRoot != null )
+            {
+                updateProjectScmRoot( projectScmRoot, project );
+            }
         }
         catch ( ContinuumStoreException ex )
         {
@@ -3585,6 +3598,36 @@
         }
     }
 
+    private void updateProjectScmRoot( ProjectScmRoot oldScmRoot, Project project )
+        throws ContinuumException
+    {
+        try
+        {
+            removeProjectScmRoot( oldScmRoot );
+            ProjectScmRoot scmRoot =
+                projectScmRootDao.getProjectScmRootByProjectGroupAndScmRootAddress( project.getProjectGroup().getId(),
+                                                                                    project.getScmUrl()
);
+            if ( scmRoot == null )
+            {
+                ProjectScmRoot newScmRoot = new ProjectScmRoot();
+                if ( project.getScmUrl().equals( oldScmRoot.getScmRootAddress() ) )
+                {
+                    BeanUtils.copyProperties( oldScmRoot, newScmRoot, new String[] { "id",
"projectGroup" } );
+                }
+                else
+                {
+                    newScmRoot.setScmRootAddress( project.getScmUrl() );
+                }
+                newScmRoot.setProjectGroup( project.getProjectGroup() );
+                projectScmRootDao.addProjectScmRoot( newScmRoot );
+            }
+        }
+        catch ( ContinuumStoreException ex )
+        {
+            throw logAndCreateException( "Error while updating project.", ex );
+        }
+    }
+
     private boolean isProjectInReleaseStage( Project project )
         throws ContinuumException
     {



Mime
View raw message