continuum-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Venisse <emman...@venisse.net>
Subject Re: Problems with MungedHttpsURL
Date Wed, 12 Sep 2007 12:25:44 GMT
Can you file an issue and attach to it your patch? We'll look at it later.

Thanks
Emmanuel

Dariusz Nowak a écrit :
> Dear Developers,
> 
> For a long time I have tried to be able to add a new Maven2 project from 
> our SVN repository.
> Unfortunately it was not possible neither in 1.0.2 nor 1.1-b2.
> 
> Finally I have found the cause of problems. It is the MungedHttpsURL 
> class. I do not know why but it does not work with my company's SVN 
> server. Every time I tried to create a new project 401 HTTP error was 
> returned to the continuum.
> 
> After hacking continuum to use HttpClient everything started to work. 
> Attached my changes.
> 
> Please let me know what information you need to fix the issue in future 
> releases.
> 
> BR,
> Dariusz
> 
> 
> --- 
> src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java

>       (revision 572578)
> +++ 
> src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java

>       (working copy)
> @@ -34,6 +34,10 @@
>  import java.net.URL;
>  import java.net.UnknownHostException;
> 
> +import org.apache.commons.httpclient.HttpClient;
> +import org.apache.commons.httpclient.UsernamePasswordCredentials;
> +import org.apache.commons.httpclient.methods.GetMethod;
> +
>  /**
>   * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
>   * @version $Id$
> @@ -51,11 +55,32 @@
>          getLogger().info( "Downloading " + metadata.toExternalForm() );
> 
>          InputStream is = null;
> +
> +        GetMethod get = null;
> 
>          if ( metadata.getProtocol().startsWith( "http" ) )
>          {
> -            is =
> -                new MungedHttpsURL( metadata.toExternalForm(), 
> username, password ).getURLConnection().getInputStream();
> +
> +//            is =
> +//                new MungedHttpsURL( metadata.toExternalForm(), 
> username, password ).getURLConnection().getInputStream();
> +            HttpClient client = new HttpClient();
> +
> +            getLogger().info("Using HttpClient to get the resource, 
> credentials - user: " + username + ", password: " + password);
> +
> +            if (username != null) {
> +                client.getState().setCredentials(null, null, new 
> UsernamePasswordCredentials(username, password));
> +            }
> +
> +            get = new GetMethod(metadata.toExternalForm());
> +
> +            if (username != null) {
> +                get.setDoAuthentication(true);
> +            }
> +            int status = client.executeMethod(get);
> +
> +            getLogger().info("Request status: " + status);
> +
> +            is = get.getResponseBodyAsStream();
>          }
>          else
>          {
> @@ -115,6 +140,9 @@
>          is.close();
> 
>          writer.close();
> +        if (get != null) {
> +                get.releaseConnection();
> +        }
> 
>          return file;
>      }
> 
> 
> 
> 


Mime
View raw message