<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>
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;
}
{
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 );
* 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 )
<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>
\ No newline at end of file
*/
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;
@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" )
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() )
+ 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 );
+ ", 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 ) )
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( "/" ) )
{
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 );
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;
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() );
<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>
* 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;
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;
* 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" )
{
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() )
}
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 )
* 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;
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;
}
* 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;
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;
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;
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
/**
* TODO: can have other types, and this might eventually come through from the main request
- *
*/
@Inject
private RepositorySessionFactory repositorySessionFactory;
@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;
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();
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 )
{
// 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 );
{
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()
if ( file.exists() )
{
- return repositoryConfiguration;
+ return managedRepository;
}
}
return null;
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() );
{
throw new ArtifactMetadataRetrievalException( e.getMessage(), e, artifact );
}
+
}
ResolutionGroup result;
// 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
{
{
return factory;
}
-}
+}
\ No newline at end of file
* 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;
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;
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;
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
*
*/
@Inject
- @Named( value = "archivaConfiguration#default" )
- private ArchivaConfiguration archivaConfiguration;
+ private RemoteRepositoryAdmin remoteRepositoryAdmin;
+
+ @Inject
+ private ManagedRepositoryAdmin managedRepositoryAdmin;
+
+ @Inject
+ private ProxyConnectorAdmin proxyConnectorAdmin;
+
+ @Inject
+ private NetworkProxyAdmin networkProxyAdmin;
/**
*
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;
// 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 );
}
}
}
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;
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 );
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 );
repoProblemFacet.setProject( projectId );
repoProblemFacet.setVersion( projectVersion );
repoProblemFacet.setNamespace( namespace );
-
+
metadata.addFacet( repoProblemFacet );
-
+
return metadata;
}
}
metadata.addFacet( facet );
return metadata;
+
}
public void setWagonFactory( WagonFactory wagonFactory )
}
public Collection<String> listRootNamespaces( String repoId, Filter<String> filter )
+ throws RepositoryAdminException
{
File dir = getRepositoryBasedir( repoId );
}
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 );
}
public Collection<String> listProjects( String repoId, String namespace, Filter<String> filter )
+ throws RepositoryAdminException
{
File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace );
public Collection<String> listProjectVersions( String repoId, String namespace, String projectId,
Filter<String> filter )
+ throws RepositoryAdminException
{
File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace, projectId );
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 );
}
public ArtifactMetadata readArtifactMetadataFromPath( String repoId, String path )
+ throws RepositoryAdminException
{
ArtifactMetadata metadata = pathTranslator.getArtifactForPath( repoId, path );
* 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;
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 )
{
}
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 );
if ( !model.exists() )
{
- for ( RemoteRepositoryConfiguration remoteRepository : remoteRepositories )
+ for ( RemoteRepository remoteRepository : remoteRepositories )
{
try
{
// 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
{
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 )
{
* @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 )
}
AuthenticationInfo authInfo = null;
- String username = remoteRepository.getUsername();
+ String username = remoteRepository.getUserName();
String password = remoteRepository.getPassword();
if ( StringUtils.isNotBlank( username ) && StringUtils.isNotBlank( password ) )
{
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 )
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 );
<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>