diff options
author | Olivier Lamy <olamy@apache.org> | 2012-10-24 21:33:16 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2012-10-24 21:33:16 +0000 |
commit | 5f42d3dcac2229031a1276c69fc0d34e8ae4dbf7 (patch) | |
tree | 204ede4c273f7f178bf2678df94b6a7c218f6d5b /archiva-modules/archiva-scheduler | |
parent | a51724b013f4035bf06154266cf3ed0fce74c09e (diff) | |
download | archiva-5f42d3dcac2229031a1276c69fc0d34e8ae4dbf7.tar.gz archiva-5f42d3dcac2229031a1276c69fc0d34e8ae4dbf7.zip |
[MRM-1705] Feature to add custom parameters and/or headers when requesting an external repositories.
add parameters.
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1401896 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-scheduler')
-rw-r--r-- | archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java | 38 |
1 files changed, 35 insertions, 3 deletions
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 f8d9271c1..5c08d8d4b 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 @@ -57,6 +57,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.Arrays; import java.util.List; +import java.util.Map; /** * @author Olivier Lamy @@ -168,7 +169,8 @@ public class DownloadRemoteIndexTask indexDirectory.mkdirs(); } - ResourceFetcher resourceFetcher = new WagonResourceFetcher( log, tempIndexDirectory, wagon ); + ResourceFetcher resourceFetcher = + new WagonResourceFetcher( log, tempIndexDirectory, wagon, remoteRepository ); IndexUpdateRequest request = new IndexUpdateRequest( indexingContext, resourceFetcher ); request.setForceFullUpdate( this.fullDownload ); request.setLocalIndexCacheDir( indexCacheDirectory ); @@ -295,11 +297,15 @@ public class DownloadRemoteIndexTask Wagon wagon; - private WagonResourceFetcher( Logger log, File tempIndexDirectory, Wagon wagon ) + RemoteRepository remoteRepository; + + private WagonResourceFetcher( Logger log, File tempIndexDirectory, Wagon wagon, + RemoteRepository remoteRepository ) { this.log = log; this.tempIndexDirectory = tempIndexDirectory; this.wagon = wagon; + this.remoteRepository = remoteRepository; } public void connect( String id, String url ) @@ -326,7 +332,7 @@ public class DownloadRemoteIndexTask file.delete(); } file.deleteOnExit(); - wagon.get( name, file ); + wagon.get( addParameters( name, this.remoteRepository ), file ); return new FileInputStream( file ); } catch ( AuthorizationException e ) @@ -342,7 +348,33 @@ public class DownloadRemoteIndexTask throw new FileNotFoundException( e.getMessage() ); } } + + // FIXME remove crappy copy/paste + protected String addParameters( String path, RemoteRepository remoteRepository ) + { + if ( remoteRepository.getExtraParameters().isEmpty() ) + { + return path; + } + + boolean question = false; + + StringBuilder res = new StringBuilder( path == null ? "" : path ); + + for ( Map.Entry<String, String> entry : remoteRepository.getExtraParameters().entrySet() ) + { + if ( !question ) + { + res.append( '?' ).append( entry.getKey() ).append( '=' ).append( entry.getValue() ); + } + } + + return res.toString(); + } + } + + } |