Cleanup of consumer dependencies

This commit is contained in:
Martin Stockhammer 2020-02-01 20:20:03 +01:00
parent 8fc6cdd37a
commit 92fbcf3dec
10 changed files with 95 additions and 161 deletions

View File

@ -136,11 +136,7 @@
<artifactId>log4j-jcl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.archiva.components.cache</groupId>
<artifactId>archiva-components-spring-cache-ehcache</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>

View File

@ -48,16 +48,6 @@
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-scheduler-indexing</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva.components.registry</groupId>
@ -68,70 +58,52 @@
<artifactId>archiva-components-spring-taskqueue</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
</exclusion>
</exclusions>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-common</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.indexer</groupId>
<artifactId>indexer-core</artifactId>
<classifier>shaded-lucene</classifier>
<exclusions>
<exclusion>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
</exclusion>
</exclusions>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-repository-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-repository-layer</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva.redback</groupId>
<artifactId>redback-rbac-model</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva.redback</groupId>
<artifactId>redback-rbac-role-manager</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-repository-admin-api</artifactId>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<!-- Test scope -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-test-utils</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-repository-admin-default</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http-lightweight</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-scheduler-repository</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.archiva.maven</groupId>
<artifactId>archiva-maven-repository</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-store-jcr</artifactId>
@ -143,18 +115,6 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.archiva.components.cache</groupId>
<artifactId>archiva-components-spring-cache-ehcache</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>

View File

@ -26,15 +26,12 @@ import org.apache.archiva.configuration.FileTypes;
import org.apache.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.archiva.consumers.ConsumerException;
import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.archiva.indexer.UnsupportedBaseContextException;
import org.apache.archiva.components.registry.Registry;
import org.apache.archiva.components.registry.RegistryListener;
import org.apache.archiva.components.taskqueue.TaskQueueException;
import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.RepositoryType;
import org.apache.archiva.scheduler.ArchivaTaskScheduler;
import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
import org.apache.maven.index.context.IndexingContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
@ -71,8 +68,6 @@ public class NexusIndexerConsumer
private ArchivaTaskScheduler<ArtifactIndexingTask> scheduler;
private IndexingContext indexingContext;
private List<String> includes = new ArrayList<>( 0 );
private ManagedRepository repository;
@ -106,18 +101,6 @@ public class NexusIndexerConsumer
this.repository = repository;
managedRepository = PathUtil.getPathFromUri( repository.getLocation() );
try
{
log.info( "Creating indexing context for repo : {}", repository.getId() );
if (repository.getType()== RepositoryType.MAVEN) {
indexingContext = repository.getIndexingContext().getBaseContext(IndexingContext.class);
} else {
indexingContext= null;
}
} catch (UnsupportedBaseContextException e) {
log.error("Bad repository type. Not nexus indexer compatible.");
throw new ConsumerException("Bad repository type "+repository.getType());
}
}
@Override
@ -259,20 +242,5 @@ public class NexusIndexerConsumer
}
private IndexingContext getIndexingContext()
throws ConsumerException
{
if ( this.indexingContext == null )
{
try
{
indexingContext = repository.getIndexingContext().getBaseContext(IndexingContext.class);
} catch (UnsupportedBaseContextException e) {
log.error("Bad repository type. Not nexus indexer compatible. "+repository.getType());
throw new ConsumerException("Bad repository type "+repository.getType());
}
}
return indexingContext;
}
}

View File

@ -54,12 +54,26 @@
<artifactId>metadata-repository-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-repository-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva.components.registry</groupId>
<artifactId>archiva-components-spring-registry-api</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -65,26 +65,18 @@
<dependency>
<groupId>org.apache.archiva.components.cache</groupId>
<artifactId>archiva-components-spring-cache-api</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Test scope -->
<!-- This runtime dependency is needed because the cache bean is
added to the spring context. -->
<dependency>
<groupId>org.apache.archiva.components.cache</groupId>
<artifactId>archiva-components-spring-cache-ehcache</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
<scope>runtime</scope>
</dependency>
<!-- Test scope -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>

View File

@ -1280,9 +1280,14 @@ public class ArchivaRepositoryRegistry implements ConfigurationListener, EventHa
@Override
public Repository getRepositoryOfAsset( StorageAsset asset )
{
return getManagedRepositories( ).stream( ).filter( r -> r.getAsset( "" )
if (asset instanceof Repository) {
return (Repository)asset;
} else
{
return getRepositories( ).stream( ).filter( r -> r.getAsset( "" )
.getStorage( ).equals( asset.getStorage( ) ) ).findFirst( ).orElse( null );
}
}
@Override

View File

@ -33,11 +33,12 @@
</properties>
<dependencies>
<!--
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-repository-admin-api</artifactId>
</dependency>
-->
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-common</artifactId>
@ -46,6 +47,10 @@
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-repository-layer</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-proxy-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-proxy</artifactId>
@ -181,11 +186,17 @@
<artifactId>archiva-mock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.archiva.maven</groupId>
<artifactId>archiva-maven-repository</artifactId>
</dependency>
<!--
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-repository-admin-default</artifactId>
<scope>test</scope>
</dependency>
-->
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-test-utils</artifactId>

View File

@ -19,9 +19,6 @@ package org.apache.archiva.indexer.maven.search;
* under the License.
*/
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.ProxyConnector;
import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
import org.apache.archiva.indexer.UnsupportedBaseContextException;
import org.apache.archiva.indexer.search.ArtifactInfoFilter;
import org.apache.archiva.indexer.search.NoClassifierArtifactInfoFilter;
@ -33,6 +30,8 @@ import org.apache.archiva.indexer.search.SearchResultLimits;
import org.apache.archiva.indexer.search.SearchResults;
import org.apache.archiva.indexer.util.SearchUtil;
import org.apache.archiva.model.ArchivaArtifactModel;
import org.apache.archiva.proxy.ProxyRegistry;
import org.apache.archiva.proxy.model.ProxyConnector;
import org.apache.archiva.repository.RemoteRepository;
import org.apache.archiva.repository.Repository;
import org.apache.archiva.repository.RepositoryRegistry;
@ -82,9 +81,9 @@ public class MavenRepositorySearch
private QueryCreator queryCreator;
RepositoryRegistry repositoryRegistry;
private RepositoryRegistry repositoryRegistry;
private ProxyConnectorAdmin proxyConnectorAdmin;
private ProxyRegistry proxyRegistry;
protected MavenRepositorySearch()
{
@ -93,13 +92,12 @@ public class MavenRepositorySearch
@Inject
public MavenRepositorySearch( Indexer nexusIndexer, RepositoryRegistry repositoryRegistry,
ProxyConnectorAdmin proxyConnectorAdmin, QueryCreator queryCreator )
ProxyRegistry proxyRegistry, QueryCreator queryCreator )
{
this.indexer = nexusIndexer;
this.queryCreator = queryCreator;
this.repositoryRegistry = repositoryRegistry;
this.proxyConnectorAdmin = proxyConnectorAdmin;
this.proxyRegistry = proxyRegistry;
}
/**
@ -339,10 +337,6 @@ public class MavenRepositorySearch
{
throw new RepositorySearchException( e.getMessage(), e );
}
catch ( RepositoryAdminException e )
{
throw new RepositorySearchException( e.getMessage(), e );
}
}
@ -460,14 +454,7 @@ public class MavenRepositorySearch
Set<String> ids = new HashSet<>();
List<ProxyConnector> proxyConnectors = null;
try
{
proxyConnectors = proxyConnectorAdmin.getProxyConnectorAsMap().get( managedRepoId );
}
catch ( RepositoryAdminException e )
{
throw new RepositorySearchException( e.getMessage(), e );
}
proxyConnectors = proxyRegistry.getProxyConnectorAsMap( ).get( managedRepoId );
if ( proxyConnectors == null || proxyConnectors.isEmpty() )
{
@ -476,8 +463,8 @@ public class MavenRepositorySearch
for ( ProxyConnector proxyConnector : proxyConnectors )
{
String remoteId = "remote-" + proxyConnector.getTargetRepoId();
RemoteRepository repo = repositoryRegistry.getRemoteRepository(proxyConnector.getTargetRepoId());
String remoteId = "remote-" + proxyConnector.getTargetRepository().getId();
RemoteRepository repo = repositoryRegistry.getRemoteRepository(proxyConnector.getTargetRepository().getId());
if (repo.getType()==RepositoryType.MAVEN) {
try {
IndexingContext context = repo.getIndexingContext() != null ? repo.getIndexingContext().getBaseContext(IndexingContext.class) : null;
@ -523,7 +510,6 @@ public class MavenRepositorySearch
private SearchResults convertToSearchResults( FlatSearchResponse response, SearchResultLimits limits,
List<? extends ArtifactInfoFilter> artifactInfoFilters,
List<String> selectedRepos, boolean includePoms )
throws RepositoryAdminException
{
SearchResults results = new SearchResults();
Set<ArtifactInfo> artifactInfos = response.getResults();
@ -605,7 +591,6 @@ public class MavenRepositorySearch
* @return
*/
protected String getBaseUrl( ArtifactInfo artifactInfo, List<String> selectedRepos )
throws RepositoryAdminException
{
StringBuilder sb = new StringBuilder();
if ( StringUtils.startsWith( artifactInfo.getContext(), "remote-" ) )
@ -653,12 +638,10 @@ public class MavenRepositorySearch
* @param remoteRepo
* @param selectedRepos
* @return
* @throws RepositoryAdminException
*/
private String getManagedRepoId( String remoteRepo, List<String> selectedRepos )
throws RepositoryAdminException
{
Map<String, List<ProxyConnector>> proxyConnectorMap = proxyConnectorAdmin.getProxyConnectorAsMap();
Map<String, List<ProxyConnector>> proxyConnectorMap = proxyRegistry.getProxyConnectorAsMap();
if ( proxyConnectorMap == null || proxyConnectorMap.isEmpty() )
{
return null;
@ -671,9 +654,9 @@ public class MavenRepositorySearch
{
for ( ProxyConnector proxyConnector : entry.getValue() )
{
if ( StringUtils.equals( remoteRepo, proxyConnector.getTargetRepoId() ) )
if ( StringUtils.equals( remoteRepo, proxyConnector.getTargetRepository().getId() ) )
{
return proxyConnector.getSourceRepoId();
return proxyConnector.getSourceRepository().getId();
}
}
}
@ -686,9 +669,9 @@ public class MavenRepositorySearch
for ( ProxyConnector proxyConnector : entry.getValue() )
{
if ( StringUtils.equals( remoteRepo, proxyConnector.getTargetRepoId() ) )
if ( StringUtils.equals( remoteRepo, proxyConnector.getTargetRepository().getId() ) )
{
return proxyConnector.getSourceRepoId();
return proxyConnector.getSourceRepository().getId();
}
}

View File

@ -20,7 +20,6 @@ package org.apache.archiva.indexer.maven.search;
*/
import junit.framework.TestCase;
import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
import org.apache.archiva.common.utils.FileUtils;
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.Configuration;
@ -29,6 +28,7 @@ import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.archiva.indexer.ArchivaIndexingContext;
import org.apache.archiva.indexer.search.SearchResultHit;
import org.apache.archiva.indexer.search.SearchResults;
import org.apache.archiva.proxy.ProxyRegistry;
import org.apache.archiva.repository.base.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.Repository;
import org.apache.archiva.repository.features.IndexCreationFeature;
@ -92,6 +92,9 @@ public abstract class AbstractMavenRepositorySearch
@Inject
ArchivaRepositoryRegistry repositoryRegistry;
@Inject
ProxyRegistry proxyRegistry;
@Inject
private IndexerEngine indexerEngine;
@ -125,11 +128,9 @@ public abstract class AbstractMavenRepositorySearch
archivaConfig = archivaConfigControl.createMock( ArchivaConfiguration.class );
DefaultProxyConnectorAdmin defaultProxyConnectorAdmin = new DefaultProxyConnectorAdmin();
defaultProxyConnectorAdmin.setArchivaConfiguration( archivaConfig );
repositoryRegistry.setArchivaConfiguration( archivaConfig );
search = new MavenRepositorySearch( indexer, repositoryRegistry, defaultProxyConnectorAdmin,
search = new MavenRepositorySearch( indexer, repositoryRegistry, proxyRegistry,
queryCreator );
assertNotNull( repositoryRegistry );

View File

@ -21,6 +21,10 @@ archiva-modules
archiva-security-common
archiva-consumers
archiva-consumers-api
archiva-core-consumers
archiva-metadata-consumer
archiva-signature-consumer
archiva-lucene-consumer