You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ev...@apache.org on 2007/01/04 10:58:00 UTC
svn commit: r492486 - in /maven/continuum/trunk/continuum-webapp/src/main:
java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
resources/localization/Continuum.properties
Author: evenisse
Date: Thu Jan 4 01:57:59 2007
New Revision: 492486
URL: http://svn.apache.org/viewvc?view=rev&rev=492486
Log:
[CONTINUUM-1098] Add error message on uploaded pom with modules
Submitted by: Franz Allan Valencia See
Modified:
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
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?view=diff&rev=492486&r1=492485&r2=492486
==============================================================================
--- 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 Thu Jan 4 01:57:59 2007
@@ -18,8 +18,15 @@
import org.apache.maven.continuum.ContinuumException;
import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.List;
/**
* Add a Maven 2 project to Continuum.
@@ -35,11 +42,59 @@
public class AddMavenTwoProjectAction
extends AddMavenProjectAction
{
-
+ // TODO: remove this part once uploading of an m2 project with modules is supported ( CONTINUUM-1098 )
+ public static final String ERROR_UPLOADING_M2_PROJECT_WITH_MODULES = "add.m2.project.upload.modules.error";
+ public static final String ERROR_READING_POM_EXCEPTION_MESSAGE = "Error reading POM";
+ public static final String FILE_SCHEME = "file:/";
+
protected ContinuumProjectBuildingResult doExecute( String pomUrl, int selectedProjectGroup, boolean checkProtocol )
throws ContinuumException
{
- return getContinuum().addMavenTwoProject( pomUrl, selectedProjectGroup, checkProtocol );
+ ContinuumProjectBuildingResult result = null;
+
+ // TODO: remove this part once uploading of an m2 project with modules is supported ( CONTINUUM-1098 )
+ if ( checkProtocol == false )
+ {
+ MavenXpp3Reader m2pomReader = new MavenXpp3Reader();
+
+ try
+ {
+ String filePath = pomUrl;
+ if ( filePath.startsWith( FILE_SCHEME ) )
+ {
+ filePath = filePath.substring( FILE_SCHEME.length() );
+ }
+
+ Model model = m2pomReader.read( new FileReader( filePath ) );
+
+ List modules = model.getModules();
+
+ if ( modules != null && modules.size() != 0 )
+ {
+ result = new ContinuumProjectBuildingResult();
+ result.addError( ERROR_UPLOADING_M2_PROJECT_WITH_MODULES );
+ }
+ }
+ catch ( FileNotFoundException e )
+ {
+ throw new ContinuumException( ERROR_READING_POM_EXCEPTION_MESSAGE, e );
+ }
+ catch ( IOException e )
+ {
+ throw new ContinuumException( ERROR_READING_POM_EXCEPTION_MESSAGE, e );
+ }
+ catch ( XmlPullParserException e )
+ {
+ throw new ContinuumException( ERROR_READING_POM_EXCEPTION_MESSAGE, e );
+ }
+ }
+
+ if ( result == null )
+ {
+ result = getContinuum().addMavenTwoProject( pomUrl, selectedProjectGroup, checkProtocol );
+ }
+
+ return result;
}
public String doDefault()
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?view=diff&rev=492486&r1=492485&r2=492486
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties Thu Jan 4 01:57:59 2007
@@ -205,6 +205,8 @@
add.m2.project.m2PomFile.message = Enter the local filename of the Maven 2 POM to upload (works only for a single project without modules).
add.m2.project.m2PomFile.error = You must enter a valid URL
add.m2.project.projectGroup = Project Group
+# TODO: remove this part once uploading of an m2 project with modules is supported ( CONTINUUM-1098 )
+add.m2.project.upload.modules.error = Cannot upload a Maven 2 project with modules.
# ----------------------------------------------------------------------
# Page: AddProject (ant or shell)