continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r431403 - in /maven/continuum/trunk: ./ continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ continuum-core/src/main/java/org/apache/maven/continuum/ continuum-core/src/main/java/org/apache/maven/continuum/core/action/ co...
Date Mon, 14 Aug 2006 18:37:03 GMT
Author: carlos
Date: Mon Aug 14 11:37:02 2006
New Revision: 431403

URL: http://svn.apache.org/viewvc?rev=431403&view=rev
Log:
[CONTINUUM-777] Handle errors when adding new projects

Modified:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadata.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/DefaultMavenOneMetadataHelper.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/MavenOneMetadataHelper.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenOneProjectAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
    maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
    maven/continuum/trunk/pom.xml

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java?rev=431403&r1=431402&r2=431403&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java
Mon Aug 14 11:37:02 2006
@@ -1,7 +1,7 @@
 package org.apache.maven.continuum.project.builder;
 
 /*
- * Copyright 2004-2005 The Apache Software Foundation.
+ * Copyright 2004-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,7 +26,9 @@
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.MalformedURLException;
 import java.net.URL;
+import java.net.UnknownHostException;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -105,6 +107,40 @@
         writer.close();
 
         return file;
+    }
+
+    /**
+     * Create metadata file and handle exceptions, adding the errors to the result object.
+     * 
+     * @param result holder with result and errors.
+     * @param metadata
+     * @param username
+     * @param password
+     * @return
+     */
+    protected File createMetadataFile( ContinuumProjectBuildingResult result, URL metadata,
String username,
+                                       String password )
+    {
+        try
+        {
+            return createMetadataFile( metadata, username, password );
+        }
+        catch ( MalformedURLException e )
+        {
+            getLogger().info( "Malformed URL: " + metadata, e );
+            result.addError( ContinuumProjectBuildingResult.ERROR_MALFORMED_URL );
+        }
+        catch ( UnknownHostException e )
+        {
+            getLogger().info( "Unknown host: " + metadata, e );
+            result.addError( ContinuumProjectBuildingResult.ERROR_UNKNOWN_HOST );
+        }
+        catch ( IOException e )
+        {
+            getLogger().warn( "Could not download the URL: " + metadata, e );
+            result.addError( ContinuumProjectBuildingResult.ERROR_UNKNOWN );
+        }
+        return null;
     }
 
 }

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java?rev=431403&r1=431402&r2=431403&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java
Mon Aug 14 11:37:02 2006
@@ -1,7 +1,7 @@
 package org.apache.maven.continuum.project.builder;
 
 /*
- * Copyright 2004-2005 The Apache Software Foundation.
+ * Copyright 2004-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,16 +23,34 @@
 import java.util.List;
 
 /**
+ * Holder for results of adding projects to Continuum. Contains added projects, project groups
+ * and errors that happened during the add.
+ * 
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
  * @version $Id$
  */
 public class ContinuumProjectBuildingResult
 {
+    public static final String ERROR_MALFORMED_URL = "add.project.malformed.url.error";
+
+    public static final String ERROR_UNKNOWN_HOST = "add.project.unknown.host.error";
+    
+    public static final String ERROR_XML_PARSE = "add.project.xml.parse.error";
+
+    public static final String ERROR_EXTEND = "add.project.extend.error";
+
+    public static final String ERROR_MISSING_GROUPID = "add.project.missing.groupid.error";
+
+    public static final String ERROR_MISSING_ARTIFACTID = "add.project.missing.artifactid.error";
+
+    public static final String ERROR_UNKNOWN = "add.project.unknown.error";
+    
     private List projects = new ArrayList();
 
     private List projectGroups = new ArrayList();
 
-    private List warnings = new ArrayList();
+    private List errors = new ArrayList();
 
     public void addProject( Project project )
     {
@@ -61,13 +79,47 @@
         return projectGroups;
     }
 
-    public void addWarning( String warning )
+    /**
+     * Add a warning that happened during adding the project to Continuum.
+     * 
+     * @param warningKey warning id (so it can be internationalized later)
+     * @deprecated Use {@link #addError(String)} instead
+     */
+    public void addWarning( String warningKey )
+    {
+        addError( warningKey );
+    }
+
+    /**
+     * Add an error that happened during adding the project to Continuum.
+     * 
+     * @param errorKey error id (so it can be internationalized later)
+     */
+    public void addError( String errorKey )
+    {
+        errors.add( errorKey );
+    }
+
+    /**
+     * Get the warnings that happened during adding the project to Continuum.
+     * There is an entry with the warning key (so it can be internationalized later) for
each warning.
+     * 
+     * @return {@link List} &lt; {@link String} >
+     * @deprecated Use {@link #getErrors()} instead
+     */
+    public List getWarnings()
     {
-        warnings.add( warning );
+        return getErrors();
     }
 
-    public List getWarnings()
+    /**
+     * Get the errors that happened during adding the project to Continuum.
+     * There is an entry with the error key (so it can be internationalized later) for each
error.
+     * 
+     * @return {@link List} &lt; {@link String} >
+     */
+    public List getErrors()
     {
-        return warnings;
+        return errors;
     }
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=431403&r1=431402&r2=431403&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Mon Aug 14 11:37:02 2006
@@ -828,15 +828,15 @@
         {
             getLogger().info( "Created " + result.getProjectGroups().size() + " project groups."
);
         }
-        getLogger().info( result.getWarnings().size() + " warnings." );
+        getLogger().info( result.getErrors().size() + " errors." );
 
         // ----------------------------------------------------------------------
         // Look for any warnings.
         // ----------------------------------------------------------------------
 
-        if ( result.getWarnings().size() > 0 )
+        if ( result.getErrors().size() > 0 )
         {
-            for ( Iterator i = result.getWarnings().iterator(); i.hasNext(); )
+            for ( Iterator i = result.getErrors().iterator(); i.hasNext(); )
             {
                 getLogger().info( (String) i.next() );
             }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadata.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadata.java?rev=431403&r1=431402&r2=431403&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadata.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadata.java
Mon Aug 14 11:37:02 2006
@@ -76,14 +76,18 @@
                 }
                 else
                 {
-                    throw new ContinuumException( "'" + u + "' is not a valid secureURL."
);
+                    result = new ContinuumProjectBuildingResult();
+
+                    result.addError( ContinuumProjectBuildingResult.ERROR_MALFORMED_URL );
                 }
             }
 
         }
         catch ( MalformedURLException e )
         {
-            throw new ContinuumException( "'" + u + "' is not a valid URL.", e );
+            result = new ContinuumProjectBuildingResult();
+
+            result.addError( ContinuumProjectBuildingResult.ERROR_MALFORMED_URL );
         }
 
         context.put( KEY_PROJECT_BUILDING_RESULT, result );

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/DefaultMavenOneMetadataHelper.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/DefaultMavenOneMetadataHelper.java?rev=431403&r1=431402&r2=431403&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/DefaultMavenOneMetadataHelper.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/DefaultMavenOneMetadataHelper.java
Mon Aug 14 11:37:02 2006
@@ -1,7 +1,7 @@
 package org.apache.maven.continuum.execution.maven.m1;
 
 /*
- * Copyright 2004-2005 The Apache Software Foundation.
+ * Copyright 2004-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,13 +21,16 @@
 import org.apache.maven.continuum.model.project.ProjectDeveloper;
 import org.apache.maven.continuum.model.project.ProjectNotifier;
 import org.apache.maven.continuum.notification.ContinuumRecipientSource;
+import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 import java.io.File;
 import java.io.FileReader;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -45,18 +48,40 @@
     // MavenOneMetadataHelper Implementation
     // ----------------------------------------------------------------------
 
+    /**
+     * @deprecated Use {@link #mapMetadata(ContinuumProjectBuildingResult,File,Project)}
instead
+     */
     public void mapMetadata( File metadata, Project project )
         throws MavenOneMetadataHelperException
     {
+        mapMetadata( new ContinuumProjectBuildingResult(), metadata, project );
+    }
+
+    public void mapMetadata( ContinuumProjectBuildingResult result, File metadata, Project
project )
+        throws MavenOneMetadataHelperException
+    {
         Xpp3Dom mavenProject;
 
         try
         {
             mavenProject = Xpp3DomBuilder.build( new FileReader( metadata ) );
         }
-        catch ( Exception e )
+        catch ( XmlPullParserException e )
         {
-            throw new MavenOneMetadataHelperException( "Error while reading maven POM ("
+ e.getMessage() + ").", e );
+            result.addError( ContinuumProjectBuildingResult.ERROR_XML_PARSE );
+            
+            getLogger().info( "Error while reading maven POM (" + e.getMessage() + ").",
e );
+            
+            return;
+        }
+        // TODO catch other IO exceptions and handle them more appropiately?
+        catch ( IOException e )
+        {
+            result.addError( ContinuumProjectBuildingResult.ERROR_UNKNOWN );
+            
+            getLogger().info( "Error while reading maven POM (" + e.getMessage() + ").",
e );
+            
+            return;
         }
 
         // ----------------------------------------------------------------------
@@ -69,7 +94,11 @@
 
         if ( extend != null )
         {
-            throw new MavenOneMetadataHelperException( "Cannot use a POM with an 'extend'
element." );
+            result.addError( ContinuumProjectBuildingResult.ERROR_EXTEND );
+            
+            getLogger().info( "Cannot use a POM with an 'extend' element." );
+            
+            return;
         }
 
         // ----------------------------------------------------------------------
@@ -94,14 +123,22 @@
 
             if ( StringUtils.isEmpty( groupId ) )
             {
-                throw new MavenOneMetadataHelperException( "Missing 'groupId' element in
the POM." );
+                result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_GROUPID );
+
+                getLogger().info( "Missing 'groupId' element in the POM." );
+
+                return;
             }
 
             artifactId = getValue( mavenProject, "artifactId", project.getArtifactId() );
 
             if ( StringUtils.isEmpty( artifactId ) )
             {
-                throw new MavenOneMetadataHelperException( "Missing 'artifactId' element
in the POM." );
+                result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_ARTIFACTID
);
+
+                getLogger().info( "Missing 'artifactId' element in the POM." );
+
+                return;
             }
         }
 
@@ -113,6 +150,7 @@
 
         if ( StringUtils.isEmpty( project.getVersion() ) && StringUtils.isEmpty(
version ) )
         {
+            // TODO add to result and don't throw exception
             throw new MavenOneMetadataHelperException( "Missing 'version' element in the
POM." );
         }
 
@@ -124,6 +162,7 @@
 
         if ( StringUtils.isEmpty( project.getName() ) && StringUtils.isEmpty( name
) )
         {
+            // TODO add to result and don't throw exception
             throw new MavenOneMetadataHelperException( "Missing 'name' element in POM." );
         }
 
@@ -151,6 +190,7 @@
             }
             else
             {
+                // TODO add to result and don't throw exception
                 throw new MavenOneMetadataHelperException( "Missing 'repository' element
in the POM." );
             }
         }
@@ -162,6 +202,7 @@
 
             if ( StringUtils.isEmpty( scmConnection ) )
             {
+                // TODO add to result and don't throw exception
                 throw new MavenOneMetadataHelperException(
                     "Missing both anonymous and developer SCM connection URLs." );
             }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/MavenOneMetadataHelper.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/MavenOneMetadataHelper.java?rev=431403&r1=431402&r2=431403&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/MavenOneMetadataHelper.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/MavenOneMetadataHelper.java
Mon Aug 14 11:37:02 2006
@@ -1,7 +1,7 @@
 package org.apache.maven.continuum.execution.maven.m1;
 
 /*
- * Copyright 2004-2005 The Apache Software Foundation.
+ * Copyright 2004-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
  */
 
 import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 
 import java.io.File;
 
@@ -28,6 +29,19 @@
 {
     String ROLE = MavenOneMetadataHelper.class.getName();
 
+    /**
+     * @deprecated Use {@link #mapMetadata(ContinuumProjectBuildingResult,File,Project)}
instead
+     */
     void mapMetadata( File metadata, Project project )
+        throws MavenOneMetadataHelperException;
+
+    /**
+     * 
+     * @param result contains errors that happened during the process
+     * @param metadata
+     * @param project
+     * @throws MavenOneMetadataHelperException
+     */
+    void mapMetadata( ContinuumProjectBuildingResult result, File metadata, Project project
)
         throws MavenOneMetadataHelperException;
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java?rev=431403&r1=431402&r2=431403&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
Mon Aug 14 11:37:02 2006
@@ -336,6 +336,7 @@
 
             getLogger().error( msg, e );
 
+            // TODO add to result and don't throw exception
             throw new MavenBuilderHelperException( msg, e );
         }
 
@@ -348,6 +349,7 @@
 
         if ( scm == null )
         {
+            // TODO add to result and don't throw exception
             throw new MavenBuilderHelperException(
                 "Missing 'scm' element in the " + getProjectName( project ) + " POM." );
         }
@@ -356,6 +358,7 @@
 
         if ( StringUtils.isEmpty( url ) )
         {
+            // TODO add to result and don't throw exception
             throw new MavenBuilderHelperException(
                 "Missing 'connection' element in the 'scm' element in the " + getProjectName(
project ) + " POM." );
         }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java?rev=431403&r1=431402&r2=431403&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java
Mon Aug 14 11:37:02 2006
@@ -1,7 +1,7 @@
 package org.apache.maven.continuum.project.builder.maven;
 
 /*
- * Copyright 2004-2005 The Apache Software Foundation.
+ * Copyright 2004-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -65,16 +65,10 @@
 
         File pomFile;
 
-        try
-        {
-            pomFile = createMetadataFile( url, username, password );
-        }
-        catch ( IOException e )
+        pomFile = createMetadataFile( result, url, username, password );
+        
+        if ( pomFile == null )
         {
-            getLogger().warn( "Could not download the URL", e );
-
-            result.addWarning( "Could not download the URL '" + url + "'." );
-
             return result;
         }
 
@@ -82,7 +76,12 @@
 
         try
         {
-            metadataHelper.mapMetadata( pomFile, project );
+            metadataHelper.mapMetadata( result, pomFile, project );
+            
+            if ( result.getErrors().size() > 0 )
+            {
+                return result;
+            }
 
             BuildDefinition bd = new BuildDefinition();
 
@@ -102,7 +101,7 @@
             }
             catch ( ContinuumStoreException e )
             {
-                getLogger().warn( "Can't get default schedule.", e );
+                getLogger().error( "Can't get default schedule.", e );
             }
 
             project.addBuildDefinition( bd );
@@ -111,7 +110,9 @@
         }
         catch ( MavenOneMetadataHelperException e )
         {
-            result.addWarning( e.getMessage() );
+            getLogger().error( "Unknown error while processing metadata", e );
+            
+            result.addError( ContinuumProjectBuildingResult.ERROR_UNKNOWN );
         }
 
         ProjectGroup projectGroup = new ProjectGroup();
@@ -122,7 +123,7 @@
 
         if ( StringUtils.isEmpty( project.getGroupId() ) )
         {
-            result.addWarning( "groupId is null." );
+            result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_GROUPID );
         }
 
         projectGroup.setGroupId( project.getGroupId() );

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java?rev=431403&r1=431402&r2=431403&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
Mon Aug 14 11:37:02 2006
@@ -1,7 +1,7 @@
 package org.apache.maven.continuum.project.builder.maven;
 
 /*
- * Copyright 2004-2005 The Apache Software Foundation.
+ * Copyright 2004-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -100,12 +100,14 @@
         }
         catch ( MavenBuilderHelperException e )
         {
+            // TODO add to result with error key
             result.addWarning( e.getMessage() );
 
             return;
         }
         catch ( IOException e )
         {
+            // TODO add to result with error key
             result.addWarning( "Could not download " + url + ": " + e.getMessage() );
 
             return;
@@ -161,7 +163,8 @@
             }
             catch ( MavenBuilderHelperException e )
             {
-                result.addWarning( ContinuumUtils.throwableToString( e ) );
+                // TODO add to result with error key
+                result.addError( ContinuumUtils.throwableToString( e ) );
             }
 
             result.addProject( continuumProject, MavenTwoBuildExecutor.ID );
@@ -200,7 +203,8 @@
             }
             catch ( MalformedURLException e )
             {
-                result.addWarning( "Could not download project from '" + urlString + "'."
);
+                // TODO add to result with error key
+                result.addError( "Could not download project from '" + urlString + "'." );
 
                 continue;
             }
@@ -219,7 +223,8 @@
 
         if ( StringUtils.isEmpty( mavenProject.getGroupId() ) )
         {
-            result.addWarning( "groupId is null." );
+            // TODO add to result with error key
+            result.addError( "groupId is null." );
 
             return null;
         }

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenOneProjectAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenOneProjectAction.java?rev=431403&r1=431402&r2=431403&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenOneProjectAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenOneProjectAction.java
Mon Aug 14 11:37:02 2006
@@ -16,14 +16,14 @@
  * limitations under the License.
  */
 
-import org.apache.maven.continuum.Continuum;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.Iterator;
+
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.codehaus.plexus.util.StringUtils;
 
-import java.io.File;
-import java.net.MalformedURLException;
-
 /**
  * @author Nick Gonzalez
  * @version $Id$
@@ -71,19 +71,16 @@
 
         ContinuumProjectBuildingResult result = null;
 
-        try
-        {
-            result = continuum.addMavenOneProject( m1Pom );
-        }
-        catch ( ContinuumException e )
-        {
-            //TODO add errors to show to the user
-            return INPUT;
-        }
+        result = continuum.addMavenOneProject( m1Pom );
 
-        if( result.getWarnings().size() > 0 )
+        if ( result.getErrors().size() > 0 )
         {
-            addActionMessage( result.getWarnings().toArray().toString() );
+            Iterator it = result.getErrors().iterator();
+
+            while ( it.hasNext() )
+            {
+                addActionError( (String) it.next() );
+            }
         }
 
         return SUCCESS;

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java?rev=431403&r1=431402&r2=431403&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
Mon Aug 14 11:37:02 2006
@@ -16,13 +16,17 @@
  * limitations under the License.
  */
 
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.net.MalformedURLException;
+import java.net.UnknownHostException;
+import java.util.Iterator;
+
 import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.project.builder.ContinuumProjectBuilderException;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.codehaus.plexus.util.StringUtils;
 
-import java.io.File;
-import java.net.MalformedURLException;
-
 /**
  * @author Nick Gonzalez
  * @version $Id$
@@ -64,25 +68,24 @@
             }
             else
             {
+                // no url or file was filled
+                // TODO add action error, one must be filled in
                 return INPUT;
             }
         }
 
         ContinuumProjectBuildingResult result = null;
 
-        try
-        {
-            result = continuum.addMavenTwoProject( m2Pom );
-        }
-        catch ( ContinuumException e )
-        {
-            //TODO add errors to show to the user
-            return INPUT;
-        }
+        result = continuum.addMavenTwoProject( m2Pom );
 
-        if ( result.getWarnings().size() > 0 )
+        if ( result.getErrors().size() > 0 )
         {
-            addActionMessage( result.getWarnings().toArray().toString() );
+            Iterator it = result.getErrors().iterator();
+
+            while ( it.hasNext() )
+            {
+                addActionError( (String) it.next() );
+            }
 
             return INPUT;
         }

Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties?rev=431403&r1=431402&r2=431403&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
Mon Aug 14 11:37:02 2006
@@ -101,6 +101,17 @@
 configuration.submit.edit = Edit
 
 # ----------------------------------------------------------------------
+# Page: Add Project
+# ----------------------------------------------------------------------
+add.project.unknown.host.error = The specified host is either unknown or inaccessible.
+add.project.malformed.url.error = The URL provided is malformed.
+add.project.xml.parse.error = The XML content of the POM can not be parsed.
+add.project.extend.error = Cannot use a POM with an 'extend' element
+add.project.missing.groupid.error = Missing 'groupId' element in the POM.
+add.project.missing.artifactid.error = Missing 'artifactId' element in the POM.
+add.project.unknown.error = The specified resource cannot be accessed.
+
+# ----------------------------------------------------------------------
 # Page: AddMavenOneProject
 # ----------------------------------------------------------------------
 add.m1.project.page.title = Continuum - Add Maven 1 Project

Modified: maven/continuum/trunk/pom.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/pom.xml?rev=431403&r1=431402&r2=431403&view=diff
==============================================================================
--- maven/continuum/trunk/pom.xml (original)
+++ maven/continuum/trunk/pom.xml Mon Aug 14 11:37:02 2006
@@ -98,6 +98,12 @@
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>jmock</groupId>
+      <artifactId>jmock</artifactId>
+      <version>1.0.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-container-default</artifactId>
       <version>1.0-alpha-10-SNAPSHOT</version>



Mime
View raw message