continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r724016 - /continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java
Date Sat, 06 Dec 2008 17:29:31 GMT
Author: olamy
Date: Sat Dec  6 09:29:30 2008
New Revision: 724016

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


Modified:
    continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java

Modified: continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java?rev=724016&r1=724015&r2=724016&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java
Sat Dec  6 09:29:30 2008
@@ -21,15 +21,18 @@
 
 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;
@@ -38,6 +41,9 @@
 import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
 import org.codehaus.plexus.util.StringUtils;
 
+import com.opensymphony.webwork.ServletActionContext;
+import com.opensymphony.webwork.interceptor.ServletRequestAware;
+
 /**
  * Action to add a Maven project to Continuum, either Maven 1 or Maven 2.
  *
@@ -46,6 +52,7 @@
  */
 public abstract class AddMavenProjectAction
     extends ContinuumActionSupport
+    implements ServletRequestAware
 {
     private static final long serialVersionUID = -3965565189557706469L;
 
@@ -79,6 +86,8 @@
     
     private List<String> errorMessages = new ArrayList<String>();
 
+    private HttpServletRequest httpServletRequest;
+    
     public String execute()
         throws ContinuumException, BuildDefinitionServiceException
     {
@@ -110,10 +119,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 +150,12 @@
                 addActionError( "add.project.unknown.error" );
                 return doDefault();
             }
+            catch ( UnsupportedEncodingException e )
+            {
+                addActionError( "add.project.unknown.error" );
+                return doDefault();
+            }
+            
         }
         else
         {
@@ -428,4 +452,9 @@
     {
         this.errorMessages = errorMessages;
     }
+
+    public void setServletRequest( HttpServletRequest httpServletRequest )
+    {
+        this.httpServletRequest = httpServletRequest;
+    }
 }



Mime
View raw message