Browse Source

[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
tags/archiva-1.4-M1
Olivier Lamy 12 years ago
parent
commit
604b421c28

+ 1
- 1
archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml View File

@@ -124,7 +124,7 @@
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http</artifactId>
<scope>test</scope>
<scope>provided</scope>
</dependency>

</dependencies>

+ 21
- 0
archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java View File

@@ -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

Loading…
Cancel
Save