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