[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 * @todo exception handling needs work - "not modified" is not really an exceptional case, and it has more layers than
* your average brown onion * your average brown onion
*/ */
@Service ("repositoryProxyConnectors#default") @Service ( "repositoryProxyConnectors#default" )
public class DefaultRepositoryProxyConnectors public class DefaultRepositoryProxyConnectors
implements RepositoryProxyConnectors, RegistryListener implements RepositoryProxyConnectors, RegistryListener
{ {
@ -106,21 +106,21 @@ public class DefaultRepositoryProxyConnectors
* *
*/ */
@Inject @Inject
@Named (value = "archivaConfiguration#default") @Named ( value = "archivaConfiguration#default" )
private ArchivaConfiguration archivaConfiguration; private ArchivaConfiguration archivaConfiguration;
/** /**
* *
*/ */
@Inject @Inject
@Named (value = "repositoryContentFactory#default") @Named ( value = "repositoryContentFactory#default" )
private RepositoryContentFactory repositoryFactory; private RepositoryContentFactory repositoryFactory;
/** /**
* *
*/ */
@Inject @Inject
@Named (value = "metadataTools#default") @Named ( value = "metadataTools#default" )
private MetadataTools metadataTools; private MetadataTools metadataTools;
/** /**
@ -161,7 +161,7 @@ public class DefaultRepositoryProxyConnectors
* *
*/ */
@Inject @Inject
@Named (value = "archivaTaskScheduler#repository") @Named ( value = "archivaTaskScheduler#repository" )
private ArchivaTaskScheduler scheduler; private ArchivaTaskScheduler scheduler;
@Inject @Inject
@ -175,7 +175,7 @@ public class DefaultRepositoryProxyConnectors
} }
@SuppressWarnings ("unchecked") @SuppressWarnings ( "unchecked" )
private void initConnectorsAndNetworkProxies() private void initConnectorsAndNetworkProxies()
{ {
@ -705,8 +705,10 @@ public class DefaultRepositoryProxyConnectors
} }
wagon = ( networkProxy != null && networkProxy.isUseNtlm() ) wagon = ( networkProxy != null && networkProxy.isUseNtlm() )
? wagonFactory.getWagon( new WagonFactoryRequest().protocol( "wagon#" + protocol + "-ntlm" ) ) ? wagonFactory.getWagon( new WagonFactoryRequest( "wagon#" + protocol + "-ntlm",
: wagonFactory.getWagon( new WagonFactoryRequest().protocol( "wagon#" + protocol ) ); remoteRepository.getRepository().getExtraHeaders() ) )
: wagonFactory.getWagon( new WagonFactoryRequest( "wagon#" + protocol,
remoteRepository.getRepository().getExtraHeaders() ) );
if ( wagon == null ) if ( wagon == null )
{ {
throw new ProxyException( "Unsupported target repository protocol: " + protocol ); 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 new URL( this.remoteRepository.getUrl() ).getProtocol() + ( ( this.networkProxy != null
&& this.networkProxy.isUseNtlm() ) ? "-ntlm" : "" ); && this.networkProxy.isUseNtlm() ) ? "-ntlm" : "" );
final StreamWagon wagon = final StreamWagon wagon = (StreamWagon) wagonFactory.getWagon(
(StreamWagon) wagonFactory.getWagon( new WagonFactoryRequest().protocol( wagonProtocol ) ); new WagonFactoryRequest( wagonProtocol, this.remoteRepository.getExtraHeaders() ) );
int timeoutInMilliseconds = remoteRepository.getTimeout() * 1000; int timeoutInMilliseconds = remoteRepository.getTimeout() * 1000;
// FIXME olamy having 2 config values // FIXME olamy having 2 config values
wagon.setReadTimeout( timeoutInMilliseconds ); 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 // if it's a ntlm proxy we have to lookup the wagon light which support thats
// wagon http client doesn't support that // wagon http client doesn't support that
wagon = ( networkProxy != null && networkProxy.isUseNtlm() ) wagon = ( networkProxy != null && networkProxy.isUseNtlm() )
? wagonFactory.getWagon( new WagonFactoryRequest().protocol( "wagon#" + protocol + "-ntlm" ) ) ? wagonFactory.getWagon(
: wagonFactory.getWagon( new WagonFactoryRequest().protocol( "wagon#" + protocol ) ); new WagonFactoryRequest( "wagon#" + protocol + "-ntlm", remoteRepository.getExtraHeaders() ) )
wagon = wagonFactory.getWagon( new WagonFactoryRequest().protocol( "wagon#" + protocol ) ); : wagonFactory.getWagon(
new WagonFactoryRequest( "wagon#" + protocol, remoteRepository.getExtraHeaders() ) );
wagon = wagonFactory.getWagon(
new WagonFactoryRequest( "wagon#" + protocol, remoteRepository.getExtraHeaders() ) );
if ( wagon == null ) if ( wagon == null )
{ {
throw new RuntimeException( "Unsupported remote repository protocol: " + protocol ); throw new RuntimeException( "Unsupported remote repository protocol: " + protocol );