]> source.dussan.org Git - archiva.git/commitdiff
move ntlm wagon trick in wagonFactory to avoid duplicate code
authorOlivier Lamy <olamy@apache.org>
Wed, 31 Oct 2012 21:40:38 +0000 (21:40 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 31 Oct 2012 21:40:38 +0000 (21:40 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1404367 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-proxy-common/pom.xml
archiva-modules/archiva-base/archiva-proxy-common/src/main/java/org/apache/archiva/proxy/common/DefaultWagonFactory.java
archiva-modules/archiva-base/archiva-proxy-common/src/main/java/org/apache/archiva/proxy/common/WagonFactoryRequest.java
archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java

index b55beafebfd6ccb1cf2860372e4ca8c4437b114c..cc3285a0e7aca8743ab243296b76c401c5cb7a04 100644 (file)
       <groupId>org.apache.archiva</groupId>
       <artifactId>archiva-plexus-bridge</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>archiva-repository-admin-api</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.apache.maven.wagon</groupId>
       <artifactId>wagon-provider-api</artifactId>
@@ -87,6 +91,7 @@
               org.springframework.stereotype;version="[3,4)",
               org.springframework.context;version="[3,4)",
               org.springframework.beans;version="[3,4)",
+              org.apache.archiva.admin.model.beans;version=${project.version},
               org.apache.maven.wagon*,
               org.slf4j;resolution:=optional
             </Import-Package>
index 8d711b82ea571002fd4884f1630f92dd7ede2198..50e9d616cc4ad0bf30d47868dcee64b2827fc025 100755 (executable)
@@ -62,6 +62,13 @@ public class DefaultWagonFactory
                 ? wagonFactoryRequest.getProtocol()
                 : "wagon#" + wagonFactoryRequest.getProtocol();
 
+            // if it's a ntlm proxy we have to lookup the wagon light which support thats
+            // wagon http client doesn't support that
+            if ( wagonFactoryRequest.getNetworkProxy() != null && wagonFactoryRequest.getNetworkProxy().isUseNtlm() )
+            {
+                protocol = protocol + "-ntlm";
+            }
+
             Wagon wagon = applicationContext.getBean( protocol, Wagon.class );
             wagon.addTransferListener( debugTransferListener );
             configureUserAgent( wagon, wagonFactoryRequest );
index 13ffce6d0794944d7a9ed7cf1e8c53e1be1c0e04..613f20cde53e2d053112b4c8b367500ae6661bdd 100644 (file)
@@ -18,6 +18,8 @@ package org.apache.archiva.proxy.common;
  * under the License.
  */
 
+import org.apache.archiva.admin.model.beans.NetworkProxy;
+
 import java.util.HashMap;
 import java.util.Map;
 
@@ -37,6 +39,8 @@ public class WagonFactoryRequest
 
     private String userAgent = "Java-Archiva";
 
+    private NetworkProxy networkProxy;
+
     public WagonFactoryRequest()
     {
         // no op
@@ -100,6 +104,22 @@ public class WagonFactoryRequest
         return this;
     }
 
+    public NetworkProxy getNetworkProxy()
+    {
+        return networkProxy;
+    }
+
+    public void setNetworkProxy( NetworkProxy networkProxy )
+    {
+        this.networkProxy = networkProxy;
+    }
+
+    public WagonFactoryRequest networkProxy( NetworkProxy networkProxy )
+    {
+        this.networkProxy = networkProxy;
+        return this;
+    }
+
     @Override
     public boolean equals( Object o )
     {
index 5c08d8d4b50677aff14d8eb5171ed11bc937b717..eb8053c6f1864a73c94a1cfb68f2bb2422b6db39 100644 (file)
@@ -132,12 +132,11 @@ public class DownloadRemoteIndexTask
             tempIndexDirectory.deleteOnExit();
             String baseIndexUrl = indexingContext.getIndexUpdateUrl();
 
-            String wagonProtocol =
-                new URL( this.remoteRepository.getUrl() ).getProtocol() + ( ( this.networkProxy != null
-                    && this.networkProxy.isUseNtlm() ) ? "-ntlm" : "" );
+            String wagonProtocol = new URL( this.remoteRepository.getUrl() ).getProtocol();
 
             final StreamWagon wagon = (StreamWagon) wagonFactory.getWagon(
-                new WagonFactoryRequest( wagonProtocol, this.remoteRepository.getExtraHeaders() ) );
+                new WagonFactoryRequest( wagonProtocol, this.remoteRepository.getExtraHeaders() ).networkProxy(
+                    this.networkProxy ) );
             int timeoutInMilliseconds = remoteRepository.getTimeout() * 1000;
             // FIXME olamy having 2 config values
             wagon.setReadTimeout( timeoutInMilliseconds );
index 54531276256e482a9b8009b5493d8c7df4fe6c2f..08aacd166f40a0367f653e2096beaeb5d0bc740f 100644 (file)
@@ -235,18 +235,10 @@ public class RepositoryModelResolver
                 String protocol = getProtocol( remoteRepository.getUrl() );
                 final NetworkProxy networkProxy = this.networkProxyMap.get( remoteRepository.getId() );
 
-                // if it's a ntlm proxy we have to lookup the wagon light which support thats
-                // wagon http client doesn't support that
-                wagon = ( networkProxy != null && networkProxy.isUseNtlm() )
-                    ? wagonFactory.getWagon(
-                    new WagonFactoryRequest( "wagon#" + protocol + "-ntlm", remoteRepository.getExtraHeaders() ) )
-                    : wagonFactory.getWagon(
-                        new WagonFactoryRequest( "wagon#" + protocol, remoteRepository.getExtraHeaders() ) );
-                if ( wagon == null )
-                {
-                    wagon = wagonFactory.getWagon(
-                        new WagonFactoryRequest( "wagon#" + protocol, remoteRepository.getExtraHeaders() ) );
-                }
+                wagon = wagonFactory.getWagon(
+                    new WagonFactoryRequest( "wagon#" + protocol, remoteRepository.getExtraHeaders() ).networkProxy(
+                        networkProxy ) );
+
                 if ( wagon == null )
                 {
                     throw new RuntimeException( "Unsupported remote repository protocol: " + protocol );