summaryrefslogtreecommitdiffstats
path: root/archiva-modules/plugins/maven2-repository
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-10-24 21:33:16 +0000
committerOlivier Lamy <olamy@apache.org>2012-10-24 21:33:16 +0000
commit5f42d3dcac2229031a1276c69fc0d34e8ae4dbf7 (patch)
tree204ede4c273f7f178bf2678df94b6a7c218f6d5b /archiva-modules/plugins/maven2-repository
parenta51724b013f4035bf06154266cf3ed0fce74c09e (diff)
downloadarchiva-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/plugins/maven2-repository')
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java28
1 files changed, 25 insertions, 3 deletions
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();
+ }
}