[MRM-1705] Feature to add custom parameters and/or headers when requesting an external repositories.

correctly use headers.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1401889 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-10-24 21:14:46 +00:00
parent 45ded60339
commit a51724b013
3 changed files with 18 additions and 13 deletions

View File

@ -96,7 +96,7 @@ import java.util.concurrent.ConcurrentHashMap;
* @todo exception handling needs work - "not modified" is not really an exceptional case, and it has more layers than
* your average brown onion
*/
@Service ("repositoryProxyConnectors#default")
@Service ( "repositoryProxyConnectors#default" )
public class DefaultRepositoryProxyConnectors
implements RepositoryProxyConnectors, RegistryListener
{
@ -106,21 +106,21 @@ public class DefaultRepositoryProxyConnectors
*
*/
@Inject
@Named (value = "archivaConfiguration#default")
@Named ( value = "archivaConfiguration#default" )
private ArchivaConfiguration archivaConfiguration;
/**
*
*/
@Inject
@Named (value = "repositoryContentFactory#default")
@Named ( value = "repositoryContentFactory#default" )
private RepositoryContentFactory repositoryFactory;
/**
*
*/
@Inject
@Named (value = "metadataTools#default")
@Named ( value = "metadataTools#default" )
private MetadataTools metadataTools;
/**
@ -161,7 +161,7 @@ public class DefaultRepositoryProxyConnectors
*
*/
@Inject
@Named (value = "archivaTaskScheduler#repository")
@Named ( value = "archivaTaskScheduler#repository" )
private ArchivaTaskScheduler scheduler;
@Inject
@ -175,7 +175,7 @@ public class DefaultRepositoryProxyConnectors
}
@SuppressWarnings ("unchecked")
@SuppressWarnings ( "unchecked" )
private void initConnectorsAndNetworkProxies()
{
@ -705,8 +705,10 @@ public class DefaultRepositoryProxyConnectors
}
wagon = ( networkProxy != null && networkProxy.isUseNtlm() )
? wagonFactory.getWagon( new WagonFactoryRequest().protocol( "wagon#" + protocol + "-ntlm" ) )
: wagonFactory.getWagon( new WagonFactoryRequest().protocol( "wagon#" + protocol ) );
? wagonFactory.getWagon( new WagonFactoryRequest( "wagon#" + protocol + "-ntlm",
remoteRepository.getRepository().getExtraHeaders() ) )
: wagonFactory.getWagon( new WagonFactoryRequest( "wagon#" + protocol,
remoteRepository.getRepository().getExtraHeaders() ) );
if ( wagon == null )
{
throw new ProxyException( "Unsupported target repository protocol: " + protocol );

View File

@ -135,8 +135,8 @@ public class DownloadRemoteIndexTask
new URL( this.remoteRepository.getUrl() ).getProtocol() + ( ( this.networkProxy != null
&& this.networkProxy.isUseNtlm() ) ? "-ntlm" : "" );
final StreamWagon wagon =
(StreamWagon) wagonFactory.getWagon( new WagonFactoryRequest().protocol( wagonProtocol ) );
final StreamWagon wagon = (StreamWagon) wagonFactory.getWagon(
new WagonFactoryRequest( wagonProtocol, this.remoteRepository.getExtraHeaders() ) );
int timeoutInMilliseconds = remoteRepository.getTimeout() * 1000;
// FIXME olamy having 2 config values
wagon.setReadTimeout( timeoutInMilliseconds );

View File

@ -238,9 +238,12 @@ public class RepositoryModelResolver
// if it's a ntlm proxy we have to lookup the wagon light which support thats
// wagon http client doesn't support that
wagon = ( networkProxy != null && networkProxy.isUseNtlm() )
? wagonFactory.getWagon( new WagonFactoryRequest().protocol( "wagon#" + protocol + "-ntlm" ) )
: wagonFactory.getWagon( new WagonFactoryRequest().protocol( "wagon#" + protocol ) );
wagon = wagonFactory.getWagon( new WagonFactoryRequest().protocol( "wagon#" + protocol ) );
? wagonFactory.getWagon(
new WagonFactoryRequest( "wagon#" + protocol + "-ntlm", remoteRepository.getExtraHeaders() ) )
: wagonFactory.getWagon(
new WagonFactoryRequest( "wagon#" + protocol, remoteRepository.getExtraHeaders() ) );
wagon = wagonFactory.getWagon(
new WagonFactoryRequest( "wagon#" + protocol, remoteRepository.getExtraHeaders() ) );
if ( wagon == null )
{
throw new RuntimeException( "Unsupported remote repository protocol: " + protocol );