You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ct...@apache.org on 2008/09/03 04:07:05 UTC
svn commit: r691471 -
/continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
Author: ctan
Date: Tue Sep 2 19:07:03 2008
New Revision: 691471
URL: http://svn.apache.org/viewvc?rev=691471&view=rev
Log:
[CONTINUUM-1864] Transient State
modified how scm result is captured when updating the working directory
Modified:
continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
Modified: continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java?rev=691471&r1=691470&r2=691471&view=diff
==============================================================================
--- continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java (original)
+++ continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java Tue Sep 2 19:07:03 2008
@@ -33,6 +33,7 @@
import org.apache.maven.continuum.project.ContinuumProjectState;
import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.apache.maven.continuum.utils.ContinuumUtils;
import org.apache.maven.continuum.utils.WorkingDirectoryService;
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.ScmFile;
@@ -42,6 +43,7 @@
import java.io.File;
import java.util.Date;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -71,12 +73,12 @@
/**
* @plexus.requirement
*/
- private BuildResultDao buildResultDao;
-
+ private ProjectDao projectDao;
+
/**
* @plexus.requirement
*/
- private ProjectDao projectDao;
+ private BuildResultDao buildResultDao;
public void execute( Map context )
throws ScmRepositoryException, NoSuchScmProviderException, ScmException, ContinuumObjectNotFoundException,
@@ -94,12 +96,15 @@
UpdateScmResult scmResult;
+ ScmResult result;
+
Date latestUpdateDate = null;
+
try
{
- BuildResult result = buildResultDao.getLatestBuildResultForProject( project.getId() );
+ BuildResult buildResult = buildResultDao.getLatestBuildResultForProject( project.getId() );
- latestUpdateDate = new Date( result.getStartTime() );
+ latestUpdateDate = new Date( buildResult.getStartTime() );
}
catch ( Exception e )
{
@@ -133,7 +138,38 @@
getLogger().info( "Updated " + scmResult.getUpdatedFiles().size() + " files." );
}
- context.put( KEY_UPDATE_SCM_RESULT, convertScmResult( scmResult ) );
+ result = convertScmResult( scmResult );
+ }
+ catch ( ScmRepositoryException e )
+ {
+ result = new ScmResult();
+
+ result.setSuccess( false );
+
+ result.setProviderMessage( e.getMessage() + ": " + getValidationMessages( e ) );
+
+ getLogger().error( e.getMessage(), e);
+ }
+ catch ( NoSuchScmProviderException e )
+ {
+ // TODO: this is not making it back into a result of any kind - log it at least. Same is probably the case for ScmException
+ result = new ScmResult();
+
+ result.setSuccess( false );
+
+ result.setProviderMessage( e.getMessage() );
+
+ getLogger().error( e.getMessage(), e);
+ }
+ catch ( ScmException e )
+ {
+ result = new ScmResult();
+
+ result.setSuccess( false );
+
+ result.setException( ContinuumUtils.throwableMessagesToString( e ) );
+
+ getLogger().error( e.getMessage(), e);
}
finally
{
@@ -155,6 +191,9 @@
notifier.checkoutComplete( project, buildDefinition );
}
+
+ context.put( KEY_UPDATE_SCM_RESULT, result );
+ context.put( KEY_PROJECT, project );
}
private ContinuumScmConfiguration createScmConfiguration( Project project, File workingDirectory )
@@ -275,4 +314,25 @@
return cmd;
}
+
+ private String getValidationMessages( ScmRepositoryException ex )
+ {
+ List<String> messages = ex.getValidationMessages();
+
+ StringBuffer message = new StringBuffer();
+
+ if ( messages != null && !messages.isEmpty() )
+ {
+ for ( Iterator<String> i = messages.iterator(); i.hasNext(); )
+ {
+ message.append( i.next() );
+
+ if ( i.hasNext() )
+ {
+ message.append( System.getProperty( "line.separator" ) );
+ }
+ }
+ }
+ return message.toString();
+ }
}