continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r724017 - in /continuum/trunk: ./ continuum-docs/src/site/xdoc/ continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java
Date Sat, 06 Dec 2008 17:35:48 GMT
Author: olamy
Date: Sat Dec  6 09:35:48 2008
New Revision: 724017

URL: http://svn.apache.org/viewvc?rev=724017&view=rev
Log:
merge -r  724015:724016 from 1.2.x branch
[CONTINUUM-1981] Error while using Windows domain in username when adding a M2 project
Submitted by George Gastaldi (applied with minor change)


Modified:
    continuum/trunk/   (props changed)
    continuum/trunk/continuum-docs/src/site/xdoc/   (props changed)
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java

Propchange: continuum/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Dec  6 09:35:48 2008
@@ -1 +1 @@
-/continuum/branches/continuum-1.2.x:690684,690689-690799,698449-698533,698817-698819,699529,700250,700273,700936,705894,705910,708339,722279,722624,723119,723487
+/continuum/branches/continuum-1.2.x:690684,690689-690799,698449-698533,698817-698819,699529,700250,700273,700936,705894,705910,708339,722279,722624,723119,723487,724016

Propchange: continuum/trunk/continuum-docs/src/site/xdoc/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Dec  6 09:35:48 2008
@@ -1,2 +1,2 @@
-/continuum/branches/continuum-1.2.x/continuum-docs/src/site/xdoc:698449-698533,698817-698819,699529,700250,700273,700936,705894,705910,708339,722279,722624,723119,723487
+/continuum/branches/continuum-1.2.x/continuum-docs/src/site/xdoc:698449-698533,698817-698819,699529,700250,700273,700936,705894,705910,708339,722279,722624,723119,723487,724016
 /continuum/trunk/continuum-docs/src/site/xdoc:690494-690520

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java?rev=724017&r1=724016&r2=724017&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java
Sat Dec  6 09:35:48 2008
@@ -21,21 +21,25 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 
+import javax.servlet.http.HttpServletRequest;
+
 import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.builddefinition.BuildDefinitionServiceException;
 import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
+import org.apache.struts2.interceptor.ServletRequestAware;
 import org.codehaus.plexus.util.StringUtils;
 
 /**
@@ -46,6 +50,7 @@
  */
 public abstract class AddMavenProjectAction
     extends ContinuumActionSupport
+    implements ServletRequestAware
 {
     private static final long serialVersionUID = -3965565189557706469L;
 
@@ -79,6 +84,8 @@
     
     private List<String> errorMessages = new ArrayList<String>();
 
+    private HttpServletRequest httpServletRequest;
+    
     public String execute()
         throws ContinuumException, BuildDefinitionServiceException
     {
@@ -110,10 +117,19 @@
                 URL url = new URL( pomUrl );
                 if ( pomUrl.startsWith( "http" ) && !StringUtils.isEmpty( scmUsername
) )
                 {
+                    String encoding = this.httpServletRequest.getCharacterEncoding();
+                    if ( StringUtils.isEmpty( encoding ) )
+                    {
+                         encoding = System.getProperty( "file.encoding" );
+                    }
+
+                    String encodedUsername = URLEncoder.encode( scmUsername, encoding );
+                    String encodedPassword = URLEncoder.encode( scmPassword, encoding );
+
                     StringBuffer urlBuffer = new StringBuffer();
                     urlBuffer.append( url.getProtocol() ).append( "://" );
-                    urlBuffer.append( scmUsername ).append( ':' ).append( scmPassword ).append(
'@' ).append(
-                        url.getHost() );
+                    urlBuffer.append( encodedUsername ).append( ':' ).append( encodedPassword
).append( '@' )
+                        .append( url.getHost() );
                     if ( url.getPort() != -1 )
                     {
                         urlBuffer.append( ":" ).append( url.getPort() );
@@ -132,6 +148,12 @@
                 addActionError( "add.project.unknown.error" );
                 return doDefault();
             }
+            catch ( UnsupportedEncodingException e )
+            {
+                addActionError( "add.project.unknown.error" );
+                return doDefault();
+            }
+            
         }
         else
         {
@@ -428,4 +450,9 @@
     {
         this.errorMessages = errorMessages;
     }
+
+    public void setServletRequest( HttpServletRequest httpServletRequest )
+    {
+        this.httpServletRequest = httpServletRequest;
+    }
 }



Mime
View raw message