mirror of https://github.com/apache/archiva.git
[MRM-1599] NTLM proxy no longer works
use a new wagon with spring bean http-ntlm if proxy use ntlm git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1240623 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e258bfb349
commit
5d6774f5f2
|
@ -41,6 +41,11 @@
|
|||
<artifactId>wagon-file</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-http-lightweight</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-http</artifactId>
|
||||
|
|
|
@ -37,16 +37,13 @@ public class DefaultWagonFactory
|
|||
implements WagonFactory
|
||||
{
|
||||
|
||||
private PlexusSisuBridge plexusSisuBridge;
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
private DebugTransferListener debugTransferListener = new DebugTransferListener();
|
||||
|
||||
@Inject
|
||||
public DefaultWagonFactory( PlexusSisuBridge plexusSisuBridge, ApplicationContext applicationContext )
|
||||
public DefaultWagonFactory( ApplicationContext applicationContext )
|
||||
{
|
||||
this.plexusSisuBridge = plexusSisuBridge;
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
|
@ -55,18 +52,12 @@ public class DefaultWagonFactory
|
|||
{
|
||||
try
|
||||
{
|
||||
// with sisu inject bridge hint is file or http
|
||||
// so remove wagon#
|
||||
//protocol = StringUtils.remove( protocol, "wagon#" );
|
||||
// spring beans will be named wagon#protocol (http, https, file )
|
||||
protocol = StringUtils.startsWith( protocol, "wagon#" ) ? protocol : "wagon#" + protocol;
|
||||
//Wagon wagon = plexusSisuBridge.lookup( Wagon.class, protocol );
|
||||
|
||||
Wagon wagon = applicationContext.getBean( protocol, Wagon.class );
|
||||
wagon.addTransferListener( debugTransferListener );
|
||||
return wagon;
|
||||
}
|
||||
//catch ( PlexusSisuBridgeException e )
|
||||
catch ( BeansException e )
|
||||
{
|
||||
throw new WagonFactoryException( e.getMessage(), e );
|
||||
|
|
|
@ -30,7 +30,7 @@ public interface WagonFactory
|
|||
* Create a new Wagon instance for the given protocol.
|
||||
*
|
||||
* @param protocol the protocol to find the Wagon for, which must be prefixed with <code>wagon#</code>, for example
|
||||
* <code>wagon#http</code>.
|
||||
* <code>wagon#http</code>. <b>to have a wagon supporting ntlm add -ntlm</b>
|
||||
* @return the Wagon instance
|
||||
*/
|
||||
Wagon getWagon( String protocol )
|
||||
|
|
|
@ -34,4 +34,8 @@
|
|||
|
||||
<bean name="wagon#https" scope="prototype" class="org.apache.maven.wagon.providers.http.HttpWagon"/>
|
||||
|
||||
<bean name="wagon#http-ntlm" scope="prototype" class="org.apache.maven.wagon.providers.http.LightweightHttpWagon"/>
|
||||
|
||||
<bean name="wagon#https-ntlm" scope="prototype" class="org.apache.maven.wagon.providers.http.LightweightHttpsWagon"/>
|
||||
|
||||
</beans>
|
|
@ -20,6 +20,9 @@ package org.apache.archiva.proxy;
|
|||
*/
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.archiva.admin.model.RepositoryAdminException;
|
||||
import org.apache.archiva.admin.model.beans.NetworkProxy;
|
||||
import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
|
||||
import org.apache.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.archiva.configuration.ConfigurationNames;
|
||||
import org.apache.archiva.configuration.NetworkProxyConfiguration;
|
||||
|
@ -156,14 +159,15 @@ public class DefaultRepositoryProxyConnectors
|
|||
@Named( value = "archivaTaskScheduler#repository" )
|
||||
private ArchivaTaskScheduler scheduler;
|
||||
|
||||
@Inject
|
||||
private NetworkProxyAdmin networkProxyAdmin;
|
||||
|
||||
@PostConstruct
|
||||
public void initialize()
|
||||
{
|
||||
initConnectorsAndNetworkProxies();
|
||||
archivaConfiguration.addChangeListener( this );
|
||||
//this.postDownloadPolicies = applicationContext.getBeansOfType( PostDownloadPolicy.class );
|
||||
//his.preDownloadPolicies = applicationContext.getBeansOfType( PreDownloadPolicy.class );
|
||||
//this.downloadErrorPolicies = applicationContext.getBeansOfType( DownloadErrorPolicy.class );
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
|
@ -309,6 +313,11 @@ public class DefaultRepositoryProxyConnectors
|
|||
validatePolicies( this.downloadErrorPolicies, connector.getPolicies(), requestProperties, artifact,
|
||||
targetRepository, localFile, e, previousExceptions );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
validatePolicies( this.downloadErrorPolicies, connector.getPolicies(), requestProperties, artifact,
|
||||
targetRepository, localFile, e, previousExceptions );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !previousExceptions.isEmpty() )
|
||||
|
@ -378,6 +387,13 @@ public class DefaultRepositoryProxyConnectors
|
|||
+ path + ", continuing to next repository. Error message: " + e.getMessage() );
|
||||
log.debug( "Full stack trace", e );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
log.warn(
|
||||
"Transfer error from repository \"" + targetRepository.getRepository().getId() + "\" for resource "
|
||||
+ path + ", continuing to next repository. Error message: " + e.getMessage() );
|
||||
log.debug( "Full stack trace", e );
|
||||
}
|
||||
}
|
||||
|
||||
log.debug( "Exhausted all target repositories, resource {} not found.", path );
|
||||
|
@ -440,6 +456,13 @@ public class DefaultRepositoryProxyConnectors
|
|||
+ ", continuing to next repository. Error message: " + e.getMessage() );
|
||||
log.debug( "Full stack trace", e );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
log.warn( "Transfer error from repository \"" + targetRepository.getRepository().getId()
|
||||
+ "\" for versioned Metadata " + logicalPath
|
||||
+ ", continuing to next repository. Error message: " + e.getMessage() );
|
||||
log.debug( "Full stack trace", e );
|
||||
}
|
||||
}
|
||||
|
||||
if ( hasBeenUpdated( localFile, originalTimestamp ) )
|
||||
|
@ -556,7 +579,7 @@ public class DefaultRepositoryProxyConnectors
|
|||
private File transferFile( ProxyConnector connector, RemoteRepositoryContent remoteRepository, String remotePath,
|
||||
ManagedRepositoryContent repository, File resource, Properties requestProperties,
|
||||
boolean executeConsumers )
|
||||
throws ProxyException, NotModifiedException
|
||||
throws ProxyException, NotModifiedException, RepositoryAdminException
|
||||
{
|
||||
String url = remoteRepository.getURL().getUrl();
|
||||
if ( !url.endsWith( "/" ) )
|
||||
|
@ -616,7 +639,14 @@ public class DefaultRepositoryProxyConnectors
|
|||
{
|
||||
RepositoryURL repoUrl = remoteRepository.getURL();
|
||||
String protocol = repoUrl.getProtocol();
|
||||
wagon = wagonFactory.getWagon( "wagon#" + protocol );
|
||||
NetworkProxy networkProxy = null;
|
||||
if ( StringUtils.isNotBlank( connector.getProxyId() ) )
|
||||
{
|
||||
networkProxy = networkProxyAdmin.getNetworkProxy( connector.getProxyId() );
|
||||
}
|
||||
|
||||
wagon = ( networkProxy != null && networkProxy.isUseNtlm() ) ? wagonFactory.getWagon(
|
||||
"wagon#" + protocol + "-ntlm" ) : wagonFactory.getWagon( "wagon#" + protocol );
|
||||
if ( wagon == null )
|
||||
{
|
||||
throw new ProxyException( "Unsupported target repository protocol: " + protocol );
|
||||
|
@ -909,7 +939,7 @@ public class DefaultRepositoryProxyConnectors
|
|||
|
||||
private void validatePolicies( Map<String, DownloadErrorPolicy> policies, Map<String, String> settings,
|
||||
Properties request, ArtifactReference artifact, RemoteRepositoryContent content,
|
||||
File localFile, ProxyException exception, Map<String, Exception> previousExceptions )
|
||||
File localFile, Exception exception, Map<String, Exception> previousExceptions )
|
||||
throws ProxyDownloadException
|
||||
{
|
||||
boolean process = true;
|
||||
|
|
|
@ -127,7 +127,11 @@ public class DownloadRemoteIndexTask
|
|||
tempIndexDirectory.deleteOnExit();
|
||||
String baseIndexUrl = indexingContext.getIndexUpdateUrl();
|
||||
|
||||
final Wagon wagon = wagonFactory.getWagon( new URL( this.remoteRepository.getUrl() ).getProtocol() );
|
||||
String wagonProtocol =
|
||||
new URL( this.remoteRepository.getUrl() ).getProtocol() + ( ( this.networkProxy != null
|
||||
&& this.networkProxy.isUseNtlm() ) ? "-ntlm" : "" );
|
||||
|
||||
final Wagon wagon = wagonFactory.getWagon( wagonProtocol );
|
||||
setupWagonReadTimeout( wagon );
|
||||
|
||||
wagon.addTransferListener( new DownloadListener() );
|
||||
|
|
|
@ -44,6 +44,10 @@
|
|||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>metadata-model</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-repository-admin-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.archiva.metadata.repository;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.archiva.admin.model.RepositoryAdminException;
|
||||
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
||||
import org.apache.archiva.metadata.model.ProjectMetadata;
|
||||
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
|
||||
|
@ -30,10 +31,8 @@ import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataN
|
|||
import org.apache.archiva.repository.events.RepositoryListener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import java.util.ArrayList;
|
||||
|
@ -71,8 +70,6 @@ public class DefaultMetadataResolver
|
|||
* TODO: Also need to accommodate availability of proxy module
|
||||
* ... could be a different type since we need methods to modify the storage metadata, which would also allow more
|
||||
* appropriate methods to pass in the already determined repository configuration, for example, instead of the ID
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Inject
|
||||
@Named( value = "repositoryStorage#maven2" )
|
||||
|
@ -103,10 +100,8 @@ public class DefaultMetadataResolver
|
|||
{
|
||||
metadata = repositoryStorage.readProjectVersionMetadata( repoId, namespace, projectId, projectVersion );
|
||||
|
||||
if ( log.isDebugEnabled() )
|
||||
{
|
||||
log.debug( "Resolved project version metadata from storage: " + metadata );
|
||||
}
|
||||
log.debug( "Resolved project version metadata from storage: {}", metadata );
|
||||
|
||||
// FIXME: make this a more generic post-processing that plugins can take advantage of
|
||||
// eg. maven projects should be able to process parent here
|
||||
if ( !metadata.getDependencies().isEmpty() )
|
||||
|
@ -140,6 +135,14 @@ public class DefaultMetadataResolver
|
|||
}
|
||||
throw new MetadataResolutionException( e.getMessage(), e );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
for ( RepositoryListener listener : listeners )
|
||||
{
|
||||
listener.addArtifactProblem( session, repoId, namespace, projectId, projectVersion, e );
|
||||
}
|
||||
throw new MetadataResolutionException( e.getMessage(), e );
|
||||
}
|
||||
catch ( RepositoryStorageMetadataNotFoundException e )
|
||||
{
|
||||
for ( RepositoryListener listener : listeners )
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.archiva.metadata.repository.storage;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.archiva.admin.model.RepositoryAdminException;
|
||||
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
||||
import org.apache.archiva.metadata.model.ProjectMetadata;
|
||||
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
|
||||
|
@ -33,19 +34,26 @@ public interface RepositoryStorage
|
|||
|
||||
ProjectVersionMetadata readProjectVersionMetadata( String repoId, String namespace, String projectId,
|
||||
String projectVersion )
|
||||
throws RepositoryStorageMetadataInvalidException, RepositoryStorageMetadataNotFoundException;
|
||||
throws RepositoryStorageMetadataInvalidException, RepositoryStorageMetadataNotFoundException,
|
||||
RepositoryAdminException;
|
||||
|
||||
Collection<String> listRootNamespaces( String repoId, Filter<String> filter );
|
||||
Collection<String> listRootNamespaces( String repoId, Filter<String> filter )
|
||||
throws RepositoryAdminException;
|
||||
|
||||
Collection<String> listNamespaces( String repoId, String namespace, Filter<String> filter );
|
||||
Collection<String> listNamespaces( String repoId, String namespace, Filter<String> filter )
|
||||
throws RepositoryAdminException;
|
||||
|
||||
Collection<String> listProjects( String repoId, String namespace, Filter<String> filter );
|
||||
Collection<String> listProjects( String repoId, String namespace, Filter<String> filter )
|
||||
throws RepositoryAdminException;
|
||||
|
||||
Collection<String> listProjectVersions( String repoId, String namespace, String projectId, Filter<String> filter );
|
||||
Collection<String> listProjectVersions( String repoId, String namespace, String projectId, Filter<String> filter )
|
||||
throws RepositoryAdminException;
|
||||
|
||||
Collection<ArtifactMetadata> readArtifactsMetadata( String repoId, String namespace, String projectId,
|
||||
String projectVersion, Filter<String> filter );
|
||||
String projectVersion, Filter<String> filter )
|
||||
throws RepositoryAdminException;
|
||||
|
||||
// FIXME: reconsider this API, do we want to expose storage format in the form of a path?
|
||||
ArtifactMetadata readArtifactMetadataFromPath( String repoId, String path );
|
||||
ArtifactMetadata readArtifactMetadataFromPath( String repoId, String path )
|
||||
throws RepositoryAdminException;
|
||||
}
|
||||
|
|
|
@ -19,8 +19,18 @@ package org.apache.archiva.dependency.tree.maven2;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.archiva.admin.model.RepositoryAdminException;
|
||||
import org.apache.archiva.admin.model.beans.ManagedRepository;
|
||||
import org.apache.archiva.admin.model.beans.NetworkProxy;
|
||||
import org.apache.archiva.admin.model.beans.ProxyConnector;
|
||||
import org.apache.archiva.admin.model.beans.RemoteRepository;
|
||||
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
|
||||
import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
|
||||
import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
|
||||
import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
|
||||
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
|
||||
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
|
||||
import org.apache.archiva.common.utils.Slf4JPlexusLogger;
|
||||
import org.apache.archiva.metadata.repository.MetadataResolutionException;
|
||||
import org.apache.archiva.metadata.repository.MetadataResolver;
|
||||
import org.apache.archiva.metadata.repository.RepositorySession;
|
||||
|
@ -29,12 +39,6 @@ import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
|
|||
import org.apache.archiva.metadata.repository.storage.maven2.RepositoryModelResolver;
|
||||
import org.apache.archiva.proxy.common.WagonFactory;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.archiva.common.utils.Slf4JPlexusLogger;
|
||||
import org.apache.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.archiva.configuration.NetworkProxyConfiguration;
|
||||
import org.apache.archiva.configuration.ProxyConnectorConfiguration;
|
||||
import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||
|
@ -71,11 +75,13 @@ import org.apache.maven.shared.dependency.tree.traversal.BuildingDependencyNodeV
|
|||
import org.apache.maven.shared.dependency.tree.traversal.CollectingDependencyNodeVisitor;
|
||||
import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
|
||||
import org.apache.maven.shared.dependency.tree.traversal.FilteringDependencyNodeVisitor;
|
||||
import org.apache.maven.wagon.proxy.ProxyInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -86,9 +92,6 @@ import java.util.LinkedHashSet;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
/**
|
||||
* Default implementation of <code>DependencyTreeBuilder</code>. Customized wrapper for maven-dependency-tree to use
|
||||
|
@ -119,7 +122,6 @@ public class DefaultDependencyTreeBuilder
|
|||
|
||||
/**
|
||||
* TODO: can have other types, and this might eventually come through from the main request
|
||||
*
|
||||
*/
|
||||
@Inject
|
||||
private RepositorySessionFactory repositorySessionFactory;
|
||||
|
@ -131,12 +133,17 @@ public class DefaultDependencyTreeBuilder
|
|||
@Named( value = "repositoryPathTranslator#maven2" )
|
||||
private RepositoryPathTranslator pathTranslator;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Inject
|
||||
@Named( value = "archivaConfiguration#default" )
|
||||
private ArchivaConfiguration archivaConfiguration;
|
||||
private ProxyConnectorAdmin proxyConnectorAdmin;
|
||||
|
||||
@Inject
|
||||
private NetworkProxyAdmin networkProxyAdmin;
|
||||
|
||||
@Inject
|
||||
private RemoteRepositoryAdmin remoteRepositoryAdmin;
|
||||
|
||||
@Inject
|
||||
private ManagedRepositoryAdmin managedRepositoryAdmin;
|
||||
|
||||
@Inject
|
||||
private PlexusSisuBridge plexusSisuBridge;
|
||||
|
@ -148,9 +155,8 @@ public class DefaultDependencyTreeBuilder
|
|||
public void initialize()
|
||||
throws PlexusSisuBridgeException
|
||||
{
|
||||
factory = plexusSisuBridge.lookup( ArtifactFactory.class , "default" );
|
||||
collector = plexusSisuBridge.lookup( ArtifactCollector.class , "default" );
|
||||
|
||||
factory = plexusSisuBridge.lookup( ArtifactFactory.class, "default" );
|
||||
collector = plexusSisuBridge.lookup( ArtifactCollector.class, "default" );
|
||||
|
||||
DefaultModelBuilderFactory defaultModelBuilderFactory = new DefaultModelBuilderFactory();
|
||||
builder = defaultModelBuilderFactory.newInstance();
|
||||
|
@ -164,7 +170,15 @@ public class DefaultDependencyTreeBuilder
|
|||
new DependencyTreeResolutionListener( new Slf4JPlexusLogger( getClass() ) );
|
||||
|
||||
Artifact projectArtifact = factory.createProjectArtifact( groupId, artifactId, version );
|
||||
ManagedRepositoryConfiguration repository = findArtifactInRepositories( repositoryIds, projectArtifact );
|
||||
ManagedRepository repository = null;
|
||||
try
|
||||
{
|
||||
repository = findArtifactInRepositories( repositoryIds, projectArtifact );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
throw new DependencyTreeBuilderException( "Cannot build project dependency tree " + e.getMessage(), e );
|
||||
}
|
||||
|
||||
if ( repository == null )
|
||||
{
|
||||
|
@ -179,37 +193,31 @@ public class DefaultDependencyTreeBuilder
|
|||
// MRM-1411
|
||||
// TODO: this is a workaround for a lack of proxy capability in the resolvers - replace when it can all be
|
||||
// handled there. It doesn't cache anything locally!
|
||||
List< RemoteRepositoryConfiguration > remoteRepositories = new ArrayList<RemoteRepositoryConfiguration>();
|
||||
Map<String, ProxyInfo > networkProxies = new HashMap<String, ProxyInfo>();
|
||||
List<RemoteRepository> remoteRepositories = new ArrayList<RemoteRepository>();
|
||||
Map<String, NetworkProxy> networkProxies = new HashMap<String, NetworkProxy>();
|
||||
|
||||
Map<String, List< ProxyConnectorConfiguration >> proxyConnectorsMap = archivaConfiguration.getConfiguration().getProxyConnectorAsMap();
|
||||
List<ProxyConnectorConfiguration> proxyConnectors = proxyConnectorsMap.get( repository.getId() );
|
||||
if( proxyConnectors != null )
|
||||
Map<String, List<ProxyConnector>> proxyConnectorsMap = proxyConnectorAdmin.getProxyConnectorAsMap();
|
||||
List<ProxyConnector> proxyConnectors = proxyConnectorsMap.get( repository.getId() );
|
||||
if ( proxyConnectors != null )
|
||||
{
|
||||
for( ProxyConnectorConfiguration proxyConnector : proxyConnectors )
|
||||
for ( ProxyConnector proxyConnector : proxyConnectors )
|
||||
{
|
||||
remoteRepositories.add( archivaConfiguration.getConfiguration().findRemoteRepositoryById( proxyConnector.getTargetRepoId() ) );
|
||||
remoteRepositories.add(
|
||||
remoteRepositoryAdmin.getRemoteRepository( proxyConnector.getTargetRepoId() ) );
|
||||
|
||||
NetworkProxyConfiguration networkProxyConfig = archivaConfiguration.getConfiguration().getNetworkProxiesAsMap().get(
|
||||
proxyConnector.getProxyId() );
|
||||
NetworkProxy networkProxyConfig = networkProxyAdmin.getNetworkProxy( proxyConnector.getProxyId() );
|
||||
|
||||
if( networkProxyConfig != null )
|
||||
if ( networkProxyConfig != null )
|
||||
{
|
||||
ProxyInfo proxy = new ProxyInfo();
|
||||
proxy.setType( networkProxyConfig.getProtocol() );
|
||||
proxy.setHost( networkProxyConfig.getHost() );
|
||||
proxy.setPort( networkProxyConfig.getPort() );
|
||||
proxy.setUserName( networkProxyConfig.getUsername() );
|
||||
proxy.setPassword( networkProxyConfig.getPassword() );
|
||||
|
||||
// key/value: remote repo ID/proxy info
|
||||
networkProxies.put( proxyConnector.getTargetRepoId(), proxy );
|
||||
networkProxies.put( proxyConnector.getTargetRepoId(), networkProxyConfig );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Model model = buildProject( new RepositoryModelResolver( basedir, pathTranslator, wagonFactory, remoteRepositories,
|
||||
networkProxies, repository ), groupId, artifactId, version );
|
||||
Model model = buildProject(
|
||||
new RepositoryModelResolver( basedir, pathTranslator, wagonFactory, remoteRepositories, networkProxies,
|
||||
repository ), groupId, artifactId, version );
|
||||
|
||||
Map managedVersions = createManagedVersionMap( model );
|
||||
|
||||
|
@ -273,16 +281,20 @@ public class DefaultDependencyTreeBuilder
|
|||
{
|
||||
throw new DependencyTreeBuilderException( "Cannot build project dependency tree " + e.getMessage(), e );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
throw new DependencyTreeBuilderException( "Cannot build project dependency tree " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
private ManagedRepositoryConfiguration findArtifactInRepositories( List<String> repositoryIds, Artifact projectArtifact )
|
||||
private ManagedRepository findArtifactInRepositories( List<String> repositoryIds, Artifact projectArtifact )
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
for ( String repoId : repositoryIds )
|
||||
{
|
||||
ManagedRepositoryConfiguration repositoryConfiguration =
|
||||
archivaConfiguration.getConfiguration().findManagedRepositoryById( repoId );
|
||||
ManagedRepository managedRepository = managedRepositoryAdmin.getManagedRepository( repoId );
|
||||
|
||||
File repoDir = new File( repositoryConfiguration.getLocation() );
|
||||
File repoDir = new File( managedRepository.getLocation() );
|
||||
File file = pathTranslator.toFile( repoDir, projectArtifact.getGroupId(), projectArtifact.getArtifactId(),
|
||||
projectArtifact.getBaseVersion(),
|
||||
projectArtifact.getArtifactId() + "-" + projectArtifact.getVersion()
|
||||
|
@ -290,7 +302,7 @@ public class DefaultDependencyTreeBuilder
|
|||
|
||||
if ( file.exists() )
|
||||
{
|
||||
return repositoryConfiguration;
|
||||
return managedRepository;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -464,15 +476,23 @@ public class DefaultDependencyTreeBuilder
|
|||
factory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
|
||||
artifact.getScope() );
|
||||
|
||||
ManagedRepositoryConfiguration repository = findArtifactInRepositories( repositoryIds, pomArtifact );
|
||||
|
||||
ManagedRepository repository = null;
|
||||
try
|
||||
{
|
||||
repository = findArtifactInRepositories( repositoryIds, pomArtifact );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
throw new ArtifactMetadataRetrievalException( e.getMessage(), e, artifact );
|
||||
}
|
||||
Model project = null;
|
||||
if ( !Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) && repository != null )
|
||||
{
|
||||
File basedir = new File( repository.getLocation() );
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
File basedir = new File( repository.getLocation() );
|
||||
project =
|
||||
buildProject( new RepositoryModelResolver( basedir, pathTranslator ), artifact.getGroupId(),
|
||||
artifact.getArtifactId(), artifact.getVersion() );
|
||||
|
@ -485,6 +505,7 @@ public class DefaultDependencyTreeBuilder
|
|||
{
|
||||
throw new ArtifactMetadataRetrievalException( e.getMessage(), e, artifact );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ResolutionGroup result;
|
||||
|
@ -496,7 +517,8 @@ public class DefaultDependencyTreeBuilder
|
|||
// if the project is null, we encountered an invalid model (read: m1 POM)
|
||||
// we'll just return an empty resolution group.
|
||||
// or used the inherited scope (should that be passed to the buildFromRepository method above?)
|
||||
result = new ResolutionGroup( pomArtifact, Collections.<Artifact>emptySet(), Collections.<ArtifactRepository>emptyList() );
|
||||
result = new ResolutionGroup( pomArtifact, Collections.<Artifact>emptySet(),
|
||||
Collections.<ArtifactRepository>emptyList() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -560,4 +582,4 @@ public class DefaultDependencyTreeBuilder
|
|||
{
|
||||
return factory;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,8 +19,18 @@ package org.apache.archiva.metadata.repository.storage.maven2;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.archiva.admin.model.RepositoryAdminException;
|
||||
import org.apache.archiva.admin.model.beans.ManagedRepository;
|
||||
import org.apache.archiva.admin.model.beans.NetworkProxy;
|
||||
import org.apache.archiva.admin.model.beans.ProxyConnector;
|
||||
import org.apache.archiva.admin.model.beans.RemoteRepository;
|
||||
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
|
||||
import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
|
||||
import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
|
||||
import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
|
||||
import org.apache.archiva.checksum.ChecksumAlgorithm;
|
||||
import org.apache.archiva.checksum.ChecksummedFile;
|
||||
import org.apache.archiva.common.utils.VersionUtil;
|
||||
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
||||
import org.apache.archiva.metadata.model.ProjectMetadata;
|
||||
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
|
||||
|
@ -31,12 +41,6 @@ import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataI
|
|||
import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataNotFoundException;
|
||||
import org.apache.archiva.proxy.common.WagonFactory;
|
||||
import org.apache.archiva.reports.RepositoryProblemFacet;
|
||||
import org.apache.archiva.common.utils.VersionUtil;
|
||||
import org.apache.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.archiva.configuration.NetworkProxyConfiguration;
|
||||
import org.apache.archiva.configuration.ProxyConnectorConfiguration;
|
||||
import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
|
||||
import org.apache.archiva.xml.XMLException;
|
||||
import org.apache.maven.model.CiManagement;
|
||||
import org.apache.maven.model.Dependency;
|
||||
|
@ -52,11 +56,13 @@ import org.apache.maven.model.building.ModelBuilder;
|
|||
import org.apache.maven.model.building.ModelBuildingException;
|
||||
import org.apache.maven.model.building.ModelBuildingRequest;
|
||||
import org.apache.maven.model.building.ModelProblem;
|
||||
import org.apache.maven.wagon.proxy.ProxyInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FilenameFilter;
|
||||
|
@ -69,9 +75,6 @@ import java.util.Date;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
/**
|
||||
* Maven 2 repository format storage implementation. This class currently takes parameters to indicate the repository to
|
||||
|
@ -96,8 +99,16 @@ public class Maven2RepositoryStorage
|
|||
*
|
||||
*/
|
||||
@Inject
|
||||
@Named( value = "archivaConfiguration#default" )
|
||||
private ArchivaConfiguration archivaConfiguration;
|
||||
private RemoteRepositoryAdmin remoteRepositoryAdmin;
|
||||
|
||||
@Inject
|
||||
private ManagedRepositoryAdmin managedRepositoryAdmin;
|
||||
|
||||
@Inject
|
||||
private ProxyConnectorAdmin proxyConnectorAdmin;
|
||||
|
||||
@Inject
|
||||
private NetworkProxyAdmin networkProxyAdmin;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -129,10 +140,11 @@ public class Maven2RepositoryStorage
|
|||
|
||||
public ProjectVersionMetadata readProjectVersionMetadata( String repoId, String namespace, String projectId,
|
||||
String projectVersion )
|
||||
throws RepositoryStorageMetadataNotFoundException, RepositoryStorageMetadataInvalidException
|
||||
throws RepositoryStorageMetadataNotFoundException, RepositoryStorageMetadataInvalidException,
|
||||
RepositoryAdminException
|
||||
{
|
||||
ManagedRepositoryConfiguration repositoryConfiguration =
|
||||
archivaConfiguration.getConfiguration().findManagedRepositoryById( repoId );
|
||||
|
||||
ManagedRepository repositoryConfiguration = managedRepositoryAdmin.getManagedRepository( repoId );
|
||||
|
||||
String artifactVersion = projectVersion;
|
||||
|
||||
|
@ -175,36 +187,28 @@ public class Maven2RepositoryStorage
|
|||
|
||||
// TODO: this is a workaround until we can properly resolve using proxies as well - this doesn't cache
|
||||
// anything locally!
|
||||
List<RemoteRepositoryConfiguration> remoteRepositories = new ArrayList<RemoteRepositoryConfiguration>();
|
||||
Map<String, ProxyInfo> networkProxies = new HashMap<String, ProxyInfo>();
|
||||
List<RemoteRepository> remoteRepositories = new ArrayList<RemoteRepository>();
|
||||
Map<String, NetworkProxy> networkProxies = new HashMap<String, NetworkProxy>();
|
||||
|
||||
Map<String, List<ProxyConnectorConfiguration>> proxyConnectorsMap = archivaConfiguration.getConfiguration().getProxyConnectorAsMap();
|
||||
List<ProxyConnectorConfiguration> proxyConnectors = proxyConnectorsMap.get( repoId );
|
||||
if( proxyConnectors != null )
|
||||
Map<String, List<ProxyConnector>> proxyConnectorsMap = proxyConnectorAdmin.getProxyConnectorAsMap();
|
||||
List<ProxyConnector> proxyConnectors = proxyConnectorsMap.get( repoId );
|
||||
if ( proxyConnectors != null )
|
||||
{
|
||||
for( ProxyConnectorConfiguration proxyConnector : proxyConnectors )
|
||||
for ( ProxyConnector proxyConnector : proxyConnectors )
|
||||
{
|
||||
RemoteRepositoryConfiguration remoteRepoConfig = archivaConfiguration.getConfiguration().findRemoteRepositoryById(
|
||||
proxyConnector.getTargetRepoId() );
|
||||
RemoteRepository remoteRepoConfig =
|
||||
remoteRepositoryAdmin.getRemoteRepository( proxyConnector.getTargetRepoId() );
|
||||
|
||||
if( remoteRepoConfig != null )
|
||||
if ( remoteRepoConfig != null )
|
||||
{
|
||||
remoteRepositories.add( remoteRepoConfig );
|
||||
|
||||
NetworkProxyConfiguration networkProxyConfig = archivaConfiguration.getConfiguration().getNetworkProxiesAsMap().get(
|
||||
proxyConnector.getProxyId() );
|
||||
NetworkProxy networkProxyConfig = networkProxyAdmin.getNetworkProxy( proxyConnector.getProxyId() );
|
||||
|
||||
if( networkProxyConfig != null )
|
||||
if ( networkProxyConfig != null )
|
||||
{
|
||||
ProxyInfo proxy = new ProxyInfo();
|
||||
proxy.setType( networkProxyConfig.getProtocol() );
|
||||
proxy.setHost( networkProxyConfig.getHost() );
|
||||
proxy.setPort( networkProxyConfig.getPort() );
|
||||
proxy.setUserName( networkProxyConfig.getUsername() );
|
||||
proxy.setPassword( networkProxyConfig.getPassword() );
|
||||
|
||||
// key/value: remote repo ID/proxy info
|
||||
networkProxies.put( proxyConnector.getTargetRepoId(), proxy );
|
||||
networkProxies.put( proxyConnector.getTargetRepoId(), networkProxyConfig );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -215,8 +219,9 @@ public class Maven2RepositoryStorage
|
|||
req.setPomFile( file );
|
||||
|
||||
// MRM-1411
|
||||
req.setModelResolver( new RepositoryModelResolver( basedir, pathTranslator, wagonFactory, remoteRepositories,
|
||||
networkProxies, repositoryConfiguration ) );
|
||||
req.setModelResolver(
|
||||
new RepositoryModelResolver( basedir, pathTranslator, wagonFactory, remoteRepositories, networkProxies,
|
||||
repositoryConfiguration ) );
|
||||
req.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
|
||||
|
||||
Model model;
|
||||
|
@ -229,15 +234,15 @@ public class Maven2RepositoryStorage
|
|||
String msg = "The artifact's POM file '" + file + "' was invalid: " + e.getMessage();
|
||||
|
||||
List<ModelProblem> modelProblems = e.getProblems();
|
||||
for( ModelProblem problem : modelProblems )
|
||||
for ( ModelProblem problem : modelProblems )
|
||||
{
|
||||
// MRM-1411, related to MRM-1335
|
||||
// this means that the problem was that the parent wasn't resolved!
|
||||
if( problem.getException() instanceof FileNotFoundException && e.getModelId() != null &&
|
||||
if ( problem.getException() instanceof FileNotFoundException && e.getModelId() != null &&
|
||||
!e.getModelId().equals( problem.getModelId() ) )
|
||||
{
|
||||
log.warn( "The artifact's parent POM file '" + file + "' cannot be resolved. " +
|
||||
"Using defaults for project version metadata.." );
|
||||
"Using defaults for project version metadata.." );
|
||||
|
||||
ProjectVersionMetadata metadata = new ProjectVersionMetadata();
|
||||
metadata.setId( projectVersion );
|
||||
|
@ -248,7 +253,8 @@ public class Maven2RepositoryStorage
|
|||
facet.setPackaging( "jar" );
|
||||
metadata.addFacet( facet );
|
||||
|
||||
String errMsg = "Error in resolving artifact's parent POM file. " + problem.getException().getMessage();
|
||||
String errMsg =
|
||||
"Error in resolving artifact's parent POM file. " + problem.getException().getMessage();
|
||||
RepositoryProblemFacet repoProblemFacet = new RepositoryProblemFacet();
|
||||
repoProblemFacet.setRepositoryId( repoId );
|
||||
repoProblemFacet.setId( repoId );
|
||||
|
@ -257,9 +263,9 @@ public class Maven2RepositoryStorage
|
|||
repoProblemFacet.setProject( projectId );
|
||||
repoProblemFacet.setVersion( projectVersion );
|
||||
repoProblemFacet.setNamespace( namespace );
|
||||
|
||||
|
||||
metadata.addFacet( repoProblemFacet );
|
||||
|
||||
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
|
@ -318,6 +324,7 @@ public class Maven2RepositoryStorage
|
|||
metadata.addFacet( facet );
|
||||
|
||||
return metadata;
|
||||
|
||||
}
|
||||
|
||||
public void setWagonFactory( WagonFactory wagonFactory )
|
||||
|
@ -428,6 +435,7 @@ public class Maven2RepositoryStorage
|
|||
}
|
||||
|
||||
public Collection<String> listRootNamespaces( String repoId, Filter<String> filter )
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
File dir = getRepositoryBasedir( repoId );
|
||||
|
||||
|
@ -451,14 +459,15 @@ public class Maven2RepositoryStorage
|
|||
}
|
||||
|
||||
private File getRepositoryBasedir( String repoId )
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
ManagedRepositoryConfiguration repositoryConfiguration =
|
||||
archivaConfiguration.getConfiguration().findManagedRepositoryById( repoId );
|
||||
ManagedRepository repositoryConfiguration = managedRepositoryAdmin.getManagedRepository( repoId );
|
||||
|
||||
return new File( repositoryConfiguration.getLocation() );
|
||||
}
|
||||
|
||||
public Collection<String> listNamespaces( String repoId, String namespace, Filter<String> filter )
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace );
|
||||
|
||||
|
@ -480,6 +489,7 @@ public class Maven2RepositoryStorage
|
|||
}
|
||||
|
||||
public Collection<String> listProjects( String repoId, String namespace, Filter<String> filter )
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace );
|
||||
|
||||
|
@ -502,6 +512,7 @@ public class Maven2RepositoryStorage
|
|||
|
||||
public Collection<String> listProjectVersions( String repoId, String namespace, String projectId,
|
||||
Filter<String> filter )
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace, projectId );
|
||||
|
||||
|
@ -511,6 +522,7 @@ public class Maven2RepositoryStorage
|
|||
|
||||
public Collection<ArtifactMetadata> readArtifactsMetadata( String repoId, String namespace, String projectId,
|
||||
String projectVersion, Filter<String> filter )
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace, projectId, projectVersion );
|
||||
|
||||
|
@ -530,6 +542,7 @@ public class Maven2RepositoryStorage
|
|||
}
|
||||
|
||||
public ArtifactMetadata readArtifactMetadataFromPath( String repoId, String path )
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
ArtifactMetadata metadata = pathTranslator.getArtifactForPath( repoId, path );
|
||||
|
||||
|
|
|
@ -19,8 +19,10 @@ package org.apache.archiva.metadata.repository.storage.maven2;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.archiva.admin.model.beans.ManagedRepository;
|
||||
import org.apache.archiva.admin.model.beans.NetworkProxy;
|
||||
import org.apache.archiva.admin.model.beans.RemoteRepository;
|
||||
import org.apache.archiva.common.utils.VersionUtil;
|
||||
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
|
||||
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
|
||||
import org.apache.archiva.proxy.common.WagonFactory;
|
||||
|
@ -59,16 +61,16 @@ public class RepositoryModelResolver
|
|||
|
||||
private WagonFactory wagonFactory;
|
||||
|
||||
private List<RemoteRepositoryConfiguration> remoteRepositories;
|
||||
private List<RemoteRepository> remoteRepositories;
|
||||
|
||||
private ManagedRepositoryConfiguration targetRepository;
|
||||
private ManagedRepository targetRepository;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger( RepositoryModelResolver.class );
|
||||
|
||||
private static final String METADATA_FILENAME = "maven-metadata.xml";
|
||||
|
||||
// key/value: remote repo ID/network proxy
|
||||
Map<String, ProxyInfo> networkProxyMap;
|
||||
Map<String, NetworkProxy> networkProxyMap;
|
||||
|
||||
public RepositoryModelResolver( File basedir, RepositoryPathTranslator pathTranslator )
|
||||
{
|
||||
|
@ -78,9 +80,8 @@ public class RepositoryModelResolver
|
|||
}
|
||||
|
||||
public RepositoryModelResolver( File basedir, RepositoryPathTranslator pathTranslator, WagonFactory wagonFactory,
|
||||
List<RemoteRepositoryConfiguration> remoteRepositories,
|
||||
Map<String, ProxyInfo> networkProxiesMap,
|
||||
ManagedRepositoryConfiguration targetRepository )
|
||||
List<RemoteRepository> remoteRepositories,
|
||||
Map<String, NetworkProxy> networkProxiesMap, ManagedRepository targetRepository )
|
||||
{
|
||||
this( basedir, pathTranslator );
|
||||
|
||||
|
@ -103,7 +104,7 @@ public class RepositoryModelResolver
|
|||
|
||||
if ( !model.exists() )
|
||||
{
|
||||
for ( RemoteRepositoryConfiguration remoteRepository : remoteRepositories )
|
||||
for ( RemoteRepository remoteRepository : remoteRepositories )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -143,8 +144,8 @@ public class RepositoryModelResolver
|
|||
|
||||
// FIXME: we need to do some refactoring, we cannot re-use the proxy components of archiva-proxy in maven2-repository
|
||||
// because it's causing a cyclic dependency
|
||||
private boolean getModelFromProxy( RemoteRepositoryConfiguration remoteRepository, String groupId,
|
||||
String artifactId, String version, String filename )
|
||||
private boolean getModelFromProxy( RemoteRepository remoteRepository, String groupId, String artifactId,
|
||||
String version, String filename )
|
||||
throws AuthorizationException, TransferFailedException, ResourceDoesNotExistException, WagonFactoryException,
|
||||
XMLException
|
||||
{
|
||||
|
@ -162,7 +163,10 @@ public class RepositoryModelResolver
|
|||
try
|
||||
{
|
||||
String protocol = getProtocol( remoteRepository.getUrl() );
|
||||
final NetworkProxy networkProxy = this.networkProxyMap.get( remoteRepository.getId() );
|
||||
|
||||
wagon = ( networkProxy != null && networkProxy.isUseNtlm() ) ? wagonFactory.getWagon(
|
||||
"wagon#" + protocol + "-ntlm" ) : wagonFactory.getWagon( "wagon#" + protocol );
|
||||
wagon = wagonFactory.getWagon( "wagon#" + protocol );
|
||||
if ( wagon == null )
|
||||
{
|
||||
|
@ -261,15 +265,21 @@ public class RepositoryModelResolver
|
|||
* @param wagon the wagon instance to establish the connection on.
|
||||
* @return true if the connection was successful. false if not connected.
|
||||
*/
|
||||
private boolean connectToRepository( Wagon wagon, RemoteRepositoryConfiguration remoteRepository )
|
||||
private boolean connectToRepository( Wagon wagon, RemoteRepository remoteRepository )
|
||||
{
|
||||
boolean connected;
|
||||
|
||||
final ProxyInfo networkProxy;
|
||||
networkProxy = this.networkProxyMap.get( remoteRepository.getId() );
|
||||
|
||||
if ( networkProxy != null )
|
||||
final NetworkProxy proxyConnector = this.networkProxyMap.get( remoteRepository.getId() );
|
||||
ProxyInfo networkProxy = null;
|
||||
if ( proxyConnector != null )
|
||||
{
|
||||
networkProxy = new ProxyInfo();
|
||||
networkProxy.setType( proxyConnector.getProtocol() );
|
||||
networkProxy.setHost( proxyConnector.getHost() );
|
||||
networkProxy.setPort( proxyConnector.getPort() );
|
||||
networkProxy.setUserName( proxyConnector.getUsername() );
|
||||
networkProxy.setPassword( proxyConnector.getPassword() );
|
||||
|
||||
String msg = "Using network proxy " + networkProxy.getHost() + ":" + networkProxy.getPort()
|
||||
+ " to connect to remote repository " + remoteRepository.getUrl();
|
||||
if ( networkProxy.getNonProxyHosts() != null )
|
||||
|
@ -286,7 +296,7 @@ public class RepositoryModelResolver
|
|||
}
|
||||
|
||||
AuthenticationInfo authInfo = null;
|
||||
String username = remoteRepository.getUsername();
|
||||
String username = remoteRepository.getUserName();
|
||||
String password = remoteRepository.getPassword();
|
||||
|
||||
if ( StringUtils.isNotBlank( username ) && StringUtils.isNotBlank( password ) )
|
||||
|
@ -307,7 +317,14 @@ public class RepositoryModelResolver
|
|||
{
|
||||
org.apache.maven.wagon.repository.Repository wagonRepository =
|
||||
new org.apache.maven.wagon.repository.Repository( remoteRepository.getId(), remoteRepository.getUrl() );
|
||||
wagon.connect( wagonRepository, authInfo, networkProxy );
|
||||
if ( networkProxy != null )
|
||||
{
|
||||
wagon.connect( wagonRepository, authInfo, networkProxy );
|
||||
}
|
||||
else
|
||||
{
|
||||
wagon.connect( wagonRepository, authInfo );
|
||||
}
|
||||
connected = true;
|
||||
}
|
||||
catch ( ConnectionException e )
|
||||
|
@ -324,8 +341,8 @@ public class RepositoryModelResolver
|
|||
return connected;
|
||||
}
|
||||
|
||||
private File transferChecksum( Wagon wagon, RemoteRepositoryConfiguration remoteRepository, String remotePath,
|
||||
File resource, File tmpDirectory, String ext )
|
||||
private File transferChecksum( Wagon wagon, RemoteRepository remoteRepository, String remotePath, File resource,
|
||||
File tmpDirectory, String ext )
|
||||
throws AuthorizationException, TransferFailedException, ResourceDoesNotExistException
|
||||
{
|
||||
File destFile = new File( tmpDirectory, resource.getName() + ext );
|
||||
|
|
5
pom.xml
5
pom.xml
|
@ -1109,6 +1109,11 @@
|
|||
<artifactId>wagon-file</artifactId>
|
||||
<version>${wagon.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-http-lightweight</artifactId>
|
||||
<version>${wagon.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-http</artifactId>
|
||||
|
|
Loading…
Reference in New Issue