diff options
Diffstat (limited to 'archiva-modules')
3 files changed, 87 insertions, 8 deletions
diff --git a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java index 788ae80fe..d9f1ea640 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java @@ -23,6 +23,7 @@ import com.google.common.io.Files; import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.beans.NetworkProxy; import org.apache.archiva.admin.model.beans.ProxyConnectorRuleType; +import org.apache.archiva.admin.model.beans.RemoteRepository; import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin; import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.Configuration; @@ -921,7 +922,7 @@ public class DefaultRepositoryProxyConnectors if ( !origFile.exists() ) { log.debug( "Retrieving {} from {}", remotePath, remoteRepository.getRepository().getName() ); - wagon.get( remotePath, destFile ); + wagon.get( addParameters( remotePath, remoteRepository.getRepository() ), destFile ); success = true; // You wouldn't get here on failure, a WagonException would have been thrown. @@ -930,7 +931,8 @@ public class DefaultRepositoryProxyConnectors else { log.debug( "Retrieving {} from {} if updated", remotePath, remoteRepository.getRepository().getName() ); - success = wagon.getIfNewer( remotePath, destFile, origFile.lastModified() ); + success = wagon.getIfNewer( addParameters( remotePath, remoteRepository.getRepository() ), destFile, + origFile.lastModified() ); if ( !success ) { throw new NotModifiedException( @@ -1249,6 +1251,29 @@ public class DefaultRepositoryProxyConnectors } } + protected String addParameters( String path, RemoteRepository remoteRepository ) + { + if ( remoteRepository.getExtraParameters().isEmpty() ) + { + return path; + } + + boolean question = false; + + StringBuilder res = new StringBuilder( path == null ? "" : path ); + + for ( Entry<String, String> entry : remoteRepository.getExtraParameters().entrySet() ) + { + if ( !question ) + { + res.append( '?' ).append( entry.getKey() ).append( '=' ).append( entry.getValue() ); + } + } + + return res.toString(); + } + + public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue ) { /* do nothing */ 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(); + } + } + + } diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java index 2c7bfb2b8..934cb33f6 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java @@ -262,7 +262,7 @@ public class RepositoryModelResolver String metadataPath = StringUtils.substringBeforeLast( artifactPath, "/" ) + "/" + METADATA_FILENAME; - wagon.get( metadataPath, tmpMetadataResource ); + wagon.get( addParameters( metadataPath, remoteRepository ), tmpMetadataResource ); log.debug( "Successfully downloaded metadata." ); @@ -288,7 +288,7 @@ public class RepositoryModelResolver log.info( "Retrieving {} from {}", artifactPath, remoteRepository.getName() ); - wagon.get( artifactPath, tmpResource ); + wagon.get( addParameters( artifactPath, remoteRepository ), tmpResource ); log.debug( "Downloaded successfully." ); @@ -426,7 +426,7 @@ public class RepositoryModelResolver log.info( "Retrieving {} from {}", remotePath, remoteRepository.getName() ); - wagon.get( remotePath, destFile ); + wagon.get( addParameters( remotePath, remoteRepository ), destFile ); log.debug( "Downloaded successfully." ); @@ -485,4 +485,26 @@ public class RepositoryModelResolver } } } + + 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(); + } } |