aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2011-09-26 20:34:42 +0000
committerOlivier Lamy <olamy@apache.org>2011-09-26 20:34:42 +0000
commit604b421c28446ba9480e564291f4c33811e7d39b (patch)
tree4d9f5faa59dc920f6d29ca11f5c6fac89ac17f0a
parent506abf01c8fb0fb97f452bce46c1b073c6a72be3 (diff)
downloadarchiva-604b421c28446ba9480e564291f4c33811e7d39b.tar.gz
archiva-604b421c28446ba9480e564291f4c33811e7d39b.zip
[MRM-1524] downloading (optionnaly) remote index to display remote artifacts in search results : add a download remote time out field as file are more import
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1176039 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml2
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java21
2 files changed, 22 insertions, 1 deletions
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml
index 6fb27601e..f653f34e9 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml
@@ -124,7 +124,7 @@
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http</artifactId>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
</dependencies>
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java
index 24eccecd6..7aeb6fe56 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java
@@ -39,6 +39,8 @@ import org.apache.maven.wagon.events.TransferEvent;
import org.apache.maven.wagon.events.TransferListener;
import org.apache.maven.wagon.proxy.ProxyInfo;
import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.shared.http.HttpConfiguration;
+import org.apache.maven.wagon.shared.http.HttpMethodConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,6 +49,7 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
@@ -120,6 +123,8 @@ public class DownloadRemoteIndexTask
String baseIndexUrl = indexingContext.getIndexUpdateUrl();
final Wagon wagon = wagonFactory.getWagon( new URL( this.remoteRepository.getUrl() ).getProtocol() );
+ setupWagonReadTimeout( wagon );
+
// TODO transferListener
wagon.addTransferListener( new DownloadListener() );
ProxyInfo proxyInfo = null;
@@ -244,6 +249,22 @@ public class DownloadRemoteIndexTask
}
}
+ private void setupWagonReadTimeout( Wagon wagon )
+ {
+ try
+ {
+ HttpConfiguration httpConfiguration = new HttpConfiguration().setAll(
+ new HttpMethodConfiguration().setReadTimeout( remoteRepository.getRemoteDownloadTimeout() ) );
+ Method setHttpConfigurationMethod =
+ wagon.getClass().getMethod( "setHttpConfiguration", HttpConfiguration.class );
+ setHttpConfigurationMethod.invoke( wagon, httpConfiguration );
+ }
+ catch ( Exception e )
+ {
+ log.debug( "unable to set download remote time out for index {}", e.getMessage(), e );
+ }
+ }
+
public static class DownloadListener
implements TransferListener