aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base/archiva-proxy/src
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/archiva-base/archiva-proxy/src
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/archiva-base/archiva-proxy/src')
-rw-r--r--archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java29
1 files changed, 27 insertions, 2 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 */