continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r726476 - in /continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder: distributed/manager/DefaultDistributedBuildManager.java utils/ContinuumBuildConstant.java
Date Sun, 14 Dec 2008 15:36:06 GMT
Author: ctan
Date: Sun Dec 14 07:36:06 2008
New Revision: 726476

URL: http://svn.apache.org/viewvc?rev=726476&view=rev
Log:
- more fix in distributed build manager

Modified:
    continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
    continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java

Modified: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java?rev=726476&r1=726475&r2=726476&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
(original)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
Sun Dec 14 07:36:06 2008
@@ -284,14 +284,12 @@
         }
     }
 
-    public void updateProjectScmRoot( Map context )
+    public void updateScmResult( Map context )
         throws ContinuumException
     {
         try
         {
             int projectId = ContinuumBuildConstant.getProjectId( context );
-            int projectGroupId = ContinuumBuildConstant.getProjectGroupId( context );
-            String scmRootAddress = ContinuumBuildConstant.getScmRootAddress( context );
 
             log.info( "update scm result of project" + projectId );
             Project project = projectDao.getProjectWithScmDetails( projectId );
@@ -301,42 +299,14 @@
             scmResult.setCommandOutput( ContinuumBuildConstant.getScmCommandOutput( context
) );
             scmResult.setException( ContinuumBuildConstant.getScmException( context ) );
             scmResult.setProviderMessage( ContinuumBuildConstant.getScmProviderMessage( context
) );
-
-            String error = convertScmResultToError( scmResult );
-
-            if ( error == null )
-            {
-                scmResult.setSuccess( true );
-            }
-            else
-            {
-                scmResult.setSuccess( false );
-            }
+            scmResult.setSuccess( ContinuumBuildConstant.isScmSuccess( context ) );
 
             project.setScmResult( scmResult );
             projectDao.updateProject( project );
-
-            ProjectScmRoot scmRoot = projectScmRootDao.getProjectScmRootByProjectGroupAndScmRootAddress(
projectGroupId, scmRootAddress );
-
-            if ( error != null )
-            {
-                log.info( "scm error, not building" );
-                scmRoot.setError( error );
-                scmRoot.setState( ContinuumProjectState.ERROR );
-                projectScmRootDao.updateProjectScmRoot( scmRoot );
-            }
-            else if ( ContinuumBuildConstant.isPrepareBuildFinished( context ) )
-            {
-                log.info( "prepare build finished" );
-                scmRoot.setState( ContinuumProjectState.UPDATED );
-                projectScmRootDao.updateProjectScmRoot( scmRoot );
-
-                //TODO: set state of project to building
-            }
         }
         catch ( ContinuumStoreException e )
         {
-            throw new ContinuumException( "Error updating project scm root", e );
+            throw new ContinuumException( "Error updating project's scm result", e );
         }
     }
 
@@ -400,6 +370,36 @@
         }
     }
 
+    public void prepareBuildFinished( Map context )
+        throws ContinuumException
+    {
+        int projectGroupId = ContinuumBuildConstant.getProjectGroupId( context );
+        String scmRootAddress = ContinuumBuildConstant.getScmRootAddress( context );
+
+        try
+        {
+            ProjectScmRoot scmRoot = projectScmRootDao.getProjectScmRootByProjectGroupAndScmRootAddress(
projectGroupId, scmRootAddress );
+            
+            String error = ContinuumBuildConstant.getScmError( context );
+            
+            if ( StringUtils.isEmpty( error ) )
+            {
+                scmRoot.setState( ContinuumProjectState.UPDATED );
+            }
+            else
+            {
+                scmRoot.setState( ContinuumProjectState.ERROR );
+                scmRoot.setError( error );
+            }
+
+            projectScmRootDao.updateProjectScmRoot( scmRoot );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new ContinuumException( "Error while updating project scm root '" + scmRootAddress
+ "'", e );
+        }
+    }
+
     public Map<String, PrepareBuildProjectsTask> getDistributedBuildProjects()
     {
         Map<String, PrepareBuildProjectsTask> map = new HashMap<String, PrepareBuildProjectsTask>();
@@ -504,45 +504,5 @@
         return null;
     }
 
-    private String convertScmResultToError( ScmResult result )
-    {
-        String error = "";
-
-        if ( result == null )
-        {
-            error = "Scm result is null.";
-        }
-        else
-        {
-            if ( result.getCommandLine() != null )
-            {
-                error = "Command line: " + StringUtils.clean( result.getCommandLine() ) +
-                    System.getProperty( "line.separator" );
-            }
-
-            if ( result.getProviderMessage() != null )
-            {
-                error = "Provider message: " + StringUtils.clean( result.getProviderMessage()
) +
-                    System.getProperty( "line.separator" );
-            }
-
-            if ( result.getCommandOutput() != null )
-            {
-                error += "Command output: " + System.getProperty( "line.separator" );
-                error += "-------------------------------------------------------------------------------"
+
-                    System.getProperty( "line.separator" );
-                error += StringUtils.clean( result.getCommandOutput() ) + System.getProperty(
"line.separator" );
-                error += "-------------------------------------------------------------------------------"
+
-                    System.getProperty( "line.separator" );
-            }
-
-            if ( result.getException() != null )
-            {
-                error += "Exception:" + System.getProperty( "line.separator" );
-                error += result.getException();
-            }
-        }
-
-        return error;
-    }
+    
 }

Modified: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java?rev=726476&r1=726475&r2=726476&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java
(original)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java
Sun Dec 14 07:36:06 2008
@@ -44,12 +44,14 @@
 
     public static final String KEY_SCM_EXCEPTION = "scm-exception";
 
-    public static final String KEY_PREPARE_BUILD_FINISHED = "prepare-build-finished";
+    public static final String KEY_SCM_SUCCESS = "scm-success";
 
     public static final String KEY_PROJECT_GROUP_ID = "project-group-id";
 
     public static final String KEY_SCM_ROOT_ADDRESS = "scm-root-address";
 
+    public static final String KEY_SCM_ERROR = "scm-error";
+
     public static int getProjectId( Map context )
     {
         return getInteger( context, KEY_PROJECT_ID );
@@ -110,9 +112,9 @@
         return getString( context, KEY_SCM_PROVIDER_MESSAGE );
     }
 
-    public static boolean isPrepareBuildFinished( Map context )
+    public static boolean isScmSuccess( Map context )
     {
-        return getBoolean( context, KEY_PREPARE_BUILD_FINISHED );
+        return getBoolean( context, KEY_SCM_SUCCESS );
     }
 
     public static int getProjectGroupId( Map context )
@@ -125,6 +127,11 @@
         return getString( context, KEY_SCM_ROOT_ADDRESS );
     }
 
+    public static String getScmError( Map context )
+    {
+        return getString( context, KEY_SCM_ERROR );
+    }
+
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------



Mime
View raw message