You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by br...@apache.org on 2005/08/18 11:48:13 UTC

svn commit: r233304 - in /maven/continuum/trunk: continuum-core-it/src/test/java/org/apache/maven/continuum/it/ continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/ continuum-core/src/main/java/org/apache/maven/continuum/core/action...

Author: brett
Date: Thu Aug 18 02:47:55 2005
New Revision: 233304

URL: http://svn.apache.org/viewcvs?rev=233304&view=rev
Log:
put back scm exceptions, clean up

Modified:
    maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/AbstractIntegrationTest.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreCheckOutScmResultAction.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java
    maven/continuum/trunk/continuum-model/src/main/mdo/continuum.mdo
    maven/continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo

Modified: maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/AbstractIntegrationTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/AbstractIntegrationTest.java?rev=233304&r1=233303&r2=233304&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/AbstractIntegrationTest.java (original)
+++ maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/AbstractIntegrationTest.java Thu Aug 18 02:47:55 2005
@@ -485,20 +485,11 @@
 
         if ( project.getCheckoutResult() == null )
         {
-/* TODO
-            print( "check out error message: " + project.getCheckOutErrorMessage() );
-            print( "check out error exception: " );
-            print( project.getCheckOutErrorException() );
-*/
-
             fail( "project.scmResult == null" );
         }
 
-/* TODO
-        assertEquals( message + "Checkout error message != null", null, project.getCheckOutErrorMessage() );
-        assertEquals( message + "Checkout error exception != null", null, project.getCheckOutErrorException() );
-*/
         assertTrue( message + "scmResult.success != true", project.getCheckoutResult().isSuccess() );
+        assertEquals( message + "Checkout error exception != null", null, project.getCheckoutResult().getException() );
     }
 
     /**

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java?rev=233304&r1=233303&r2=233304&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java Thu Aug 18 02:47:55 2005
@@ -131,36 +131,17 @@
 
                     actionManager.lookup( "checkout-project" ).execute( actionContext );
 
-                    ScmResult checkOutScmResult = AbstractContinuumAction.getCheckoutResult( actionContext, null );
-
-                    String checkoutErrorMessage = AbstractContinuumAction.getCheckoutErrorMessage( actionContext,
-                                                                                                   null );
-
-                    String checkoutErrorException = AbstractContinuumAction.getCheckoutErrorException( actionContext,
-                                                                                                       null );
+                    scmResult = AbstractContinuumAction.getCheckoutResult( actionContext, null );
 
                     // ----------------------------------------------------------------------
                     // Check to see if there was a error while checking out the project
                     // ----------------------------------------------------------------------
 
-                    if ( !StringUtils.isEmpty( checkoutErrorMessage ) ||
-                        !StringUtils.isEmpty( checkoutErrorException ) || checkOutScmResult == null )
+                    if ( scmResult == null || !scmResult.isSuccess() )
                     {
                         build = makeBuildResult( scmResult, startTime, trigger );
 
-                        String error = "";
-
-                        if ( !StringUtils.isEmpty( checkoutErrorMessage ) )
-                        {
-                            error = "Error message:" + System.getProperty( "line.separator" );
-                            error += checkoutErrorException;
-                        }
-
-                        if ( !StringUtils.isEmpty( checkoutErrorException ) )
-                        {
-                            error += "Exception:" + System.getProperty( "line.separator" );
-                            error += checkoutErrorException;
-                        }
+                        String error = convertScmResultToError( scmResult );
 
                         build.setError( error );
 
@@ -169,7 +150,7 @@
                         return;
                     }
 
-                    actionContext.put( AbstractContinuumAction.KEY_UPDATE_SCM_RESULT, checkOutScmResult );
+                    actionContext.put( AbstractContinuumAction.KEY_UPDATE_SCM_RESULT, scmResult );
                 }
 
                 scmResult = (ScmResult) actionContext.get( AbstractContinuumAction.KEY_UPDATE_SCM_RESULT );
@@ -200,7 +181,7 @@
 
                 // This can happen if the "update project from scm" action fails
 
-                String error;
+                String error = null;
 
                 if ( e instanceof ContinuumScmException )
                 {
@@ -208,25 +189,13 @@
 
                     ScmResult result = ex.getResult();
 
-                    error = "";
-
                     if ( result != null )
                     {
-                        error += "Provider message: " + StringUtils.clean( result.getProviderMessage() ) +
-                            System.getProperty( "line.separator" );
-                        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" );
+                        error = convertScmResultToError( result );
                     }
 
-                    error += "Exception:" + System.getProperty( "line.separator" );
-                    error += ContinuumUtils.throwableToString( e );
                 }
-                else
+                if ( error == null )
                 {
                     error = ContinuumUtils.throwableToString( e );
                 }
@@ -256,6 +225,31 @@
         {
             notifierDispatcher.buildComplete( project, build );
         }
+    }
+
+    private String convertScmResultToError( ScmResult result )
+    {
+        String error = "";
+        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: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java?rev=233304&r1=233303&r2=233304&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java Thu Aug 18 02:47:55 2005
@@ -52,10 +52,6 @@
 
     public static final String KEY_CHECKOUT_SCM_RESULT = "checkout-result";
 
-    public static final String KEY_CHECKOUT_ERROR_MESSAGE = "checkout-error-message";
-
-    public static final String KEY_CHECKOUT_ERROR_EXCEPTION = "checkout-error-exception";
-
     public static final String KEY_UPDATE_SCM_RESULT = "update-result";
 
     public static final String KEY_TRIGGER = "forced";
@@ -116,16 +112,6 @@
     public static ScmResult getCheckoutResult( Map context, Object defaultValue )
     {
         return (ScmResult) getObject( context, KEY_CHECKOUT_SCM_RESULT, defaultValue );
-    }
-
-    public static String getCheckoutErrorMessage( Map context, String defaultValue )
-    {
-        return getString( context, KEY_CHECKOUT_ERROR_MESSAGE, defaultValue );
-    }
-
-    public static String getCheckoutErrorException( Map context, String defaultValue )
-    {
-        return getString( context, KEY_CHECKOUT_ERROR_EXCEPTION, defaultValue );
     }
 
     public static ScmResult getUpdateScmResult( Map context )

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java?rev=233304&r1=233303&r2=233304&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java Thu Aug 18 02:47:55 2005
@@ -23,7 +23,6 @@
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.utils.ContinuumUtils;
 import org.apache.maven.scm.manager.NoSuchScmProviderException;
-import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
 import java.util.Map;
@@ -50,70 +49,40 @@
         // Check out the project
         // ----------------------------------------------------------------------
 
+        ScmResult result;
         try
         {
-            ScmResult result = scm.checkOut( project, workingDirectory );
-
-            context.put( KEY_CHECKOUT_SCM_RESULT, result );
-        }
-        catch ( Throwable e )
-        {
-            handleThrowable( e, context );
+            result = scm.checkOut( project, workingDirectory );
         }
-    }
-
-    public static void handleThrowable( Throwable e, Map context )
-    {
-        String errorMessage;
-
-        Throwable exception;
-
-        if ( e instanceof ContinuumScmException )
+        catch ( ContinuumScmException e )
         {
             // TODO: Dissect the scm exception to be able to give better feedback
             Throwable cause = e.getCause();
 
             if ( cause instanceof NoSuchScmProviderException )
             {
-                errorMessage = cause.getMessage();
-
-                exception = null;
+                result = new ScmResult();
+                result.setSuccess( false );
+                result.setProviderMessage( cause.getMessage() );
+            }
+            else if ( e.getResult() != null )
+            {
+                result = e.getResult();
             }
             else
             {
-                ContinuumScmException ex = (ContinuumScmException) e;
-
-                ScmResult result = ex.getResult();
-
-                if ( result != null )
-                {
-                    errorMessage = "";
-                    errorMessage += "Provider message: " + StringUtils.clean( result.getProviderMessage() ) +
-                        System.getProperty( "line.separator" );
-                    errorMessage += "Command output: " + System.getProperty( "line.separator" );
-                    errorMessage += "-------------------------------------------------------------------------------" +
-                        System.getProperty( "line.separator" );
-                    errorMessage += StringUtils.clean( result.getCommandOutput() );
-                    errorMessage += "-------------------------------------------------------------------------------" +
-                        System.getProperty( "line.separator" );
-                }
-                else
-                {
-                    errorMessage = "";
-                }
-
-                exception = e;
+                result = new ScmResult();
+                result.setSuccess( false );
+                result.setException( ContinuumUtils.throwableMessagesToString( e ) );
             }
         }
-        else
+        catch ( Throwable t )
         {
-            errorMessage = "Unknown exception, type: " + e.getClass().getName();
-
-            exception = e;
+            // TODO: do we want this here, or should it be to the logs?
+            result = new ScmResult();
+            result.setSuccess( false );
+            result.setException( ContinuumUtils.throwableMessagesToString( t ) );
         }
-
-        context.put( KEY_CHECKOUT_ERROR_MESSAGE, errorMessage );
-
-        context.put( KEY_CHECKOUT_ERROR_EXCEPTION, ContinuumUtils.throwableToString( exception ) );
+        context.put( KEY_CHECKOUT_SCM_RESULT, result );
     }
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreCheckOutScmResultAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreCheckOutScmResultAction.java?rev=233304&r1=233303&r2=233304&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreCheckOutScmResultAction.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreCheckOutScmResultAction.java Thu Aug 18 02:47:55 2005
@@ -44,25 +44,10 @@
 
             ScmResult scmResult = AbstractContinuumAction.getCheckoutResult( context, null );
 
-            // TODO: delete
-            String checkoutErrorMessage = AbstractContinuumAction.getCheckoutErrorMessage( context, null );
-
-            String checkoutErrorException = AbstractContinuumAction.getCheckoutErrorException( context, null );
-
-            // ----------------------------------------------------------------------
-            //
-            // ----------------------------------------------------------------------
-
             Project project = store.getProject( getProjectId( context ) );
 
             project.setCheckoutResult( scmResult );
 
-/* TODO: these should be in the SCM result?
-            project.setCheckOutErrorMessage( checkoutErrorMessage );
-
-            project.setCheckOutErrorException( checkoutErrorException );
-
-*/
             store.updateProject( project );
         }
         catch ( ContinuumStoreException e )

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java?rev=233304&r1=233303&r2=233304&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java (original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java Thu Aug 18 02:47:55 2005
@@ -42,12 +42,12 @@
         BuildResult build = new BuildResult();
         build.setStartTime( System.currentTimeMillis() );
         build.setState( ContinuumProjectState.BUILDING );
-        build.setTrigger( ContinuumProjectState.TRIGGER_UNKNOWN ); // TODO
+        build.setTrigger( ContinuumProjectState.TRIGGER_UNKNOWN );
 
-/* TODO
-        build = store.addBuildResult( project, build );
+        store.addBuildResult( project, build );
+
+        build = store.getBuildResult( build.getId() );
 
         notificationDispatcher.buildComplete( project, build );
-*/
     }
 }

Modified: maven/continuum/trunk/continuum-model/src/main/mdo/continuum.mdo
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-model/src/main/mdo/continuum.mdo?rev=233304&r1=233303&r2=233304&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-model/src/main/mdo/continuum.mdo (original)
+++ maven/continuum/trunk/continuum-model/src/main/mdo/continuum.mdo Thu Aug 18 02:47:55 2005
@@ -390,6 +390,11 @@
           <type>String</type>
         </field>
         <field>
+          <name>exception</name>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
+        <field>
           <name>changes</name>
           <version>1.0.0+</version>
           <association>

Modified: maven/continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo?rev=233304&r1=233303&r2=233304&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo (original)
+++ maven/continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo Thu Aug 18 02:47:55 2005
@@ -150,6 +150,9 @@
       <field name="success"/>
       <field name="providerMessage"/>
       <field name="commandOutput"/>
+      <field name="exception">
+        <column length="8192"/>
+      </field>
       <field name="changes" default-fetch-group="true">
         <collection element-type="ChangeSet" dependent-element="true"/>
       </field>