From 92fbcf3decb633f85aaa738345995f79a9b50462 Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Sat, 1 Feb 2020 20:20:03 +0100 Subject: [PATCH] Cleanup of consumer dependencies --- .../archiva-configuration/pom.xml | 6 +- .../archiva-lucene-consumers/pom.xml | 100 ++++++------------ .../lucene/NexusIndexerConsumer.java | 32 ------ .../archiva-metadata-consumer/pom.xml | 18 +++- .../archiva-base/archiva-policies/pom.xml | 20 ++-- .../base/ArchivaRepositoryRegistry.java | 9 +- .../archiva-maven-indexer/pom.xml | 13 ++- .../maven/search/MavenRepositorySearch.java | 45 +++----- .../search/AbstractMavenRepositorySearch.java | 9 +- status-dep.txt | 4 + 10 files changed, 95 insertions(+), 161 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-configuration/pom.xml b/archiva-modules/archiva-base/archiva-configuration/pom.xml index 1275ca1e0..5fc0b780c 100644 --- a/archiva-modules/archiva-base/archiva-configuration/pom.xml +++ b/archiva-modules/archiva-base/archiva-configuration/pom.xml @@ -136,11 +136,7 @@ log4j-jcl test - - org.apache.archiva.components.cache - archiva-components-spring-cache-ehcache - test - + diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml index 893033486..24a726ddf 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml @@ -48,16 +48,6 @@ org.apache.archiva archiva-scheduler-indexing - - - commons-logging - commons-logging-api - - - - - org.slf4j - slf4j-api org.apache.archiva.components.registry @@ -68,70 +58,52 @@ archiva-components-spring-taskqueue - commons-io - commons-io - - - org.apache.lucene - lucene-queryparser - - - org.apache.lucene - lucene-analyzers-common - - + org.apache.archiva + archiva-common - org.apache.maven.indexer - indexer-core - shaded-lucene - - - org.apache.lucene - lucene-queryparser - - - org.apache.lucene - lucene-analyzers-common - - + org.apache.archiva + archiva-repository-api + + org.apache.archiva + archiva-repository-layer + + + org.apache.archiva.redback + redback-rbac-model + + + org.apache.archiva.redback + redback-rbac-role-manager + + javax.inject javax.inject - org.apache.archiva - archiva-repository-admin-api + javax.annotation + javax.annotation-api + + + + org.springframework + spring-context + + org.springframework + spring-test + test + org.apache.archiva archiva-test-utils - ${project.version} - test - - - org.apache.archiva - archiva-repository-admin-default - test - - - org.apache.maven.wagon - wagon-http-lightweight - provided - - - org.apache.archiva - archiva-scheduler-repository - test - - - org.apache.archiva.maven - archiva-maven-repository test + org.apache.archiva metadata-store-jcr @@ -143,18 +115,6 @@ test - - org.ow2.asm - asm - test - - - - org.apache.archiva.components.cache - archiva-components-spring-cache-ehcache - test - - diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java index 89c3a9758..e03557ebf 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java @@ -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 scheduler; - private IndexingContext indexingContext; - private List 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; - } } diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml index 3662968df..c8c11fd9c 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml @@ -54,12 +54,26 @@ metadata-repository-api - org.slf4j - slf4j-api + org.apache.archiva + archiva-repository-api org.apache.archiva.components.registry archiva-components-spring-registry-api + + + javax.inject + javax.inject + + + javax.annotation + javax.annotation-api + + + + org.springframework + spring-context + diff --git a/archiva-modules/archiva-base/archiva-policies/pom.xml b/archiva-modules/archiva-base/archiva-policies/pom.xml index 449033581..edeeb89eb 100644 --- a/archiva-modules/archiva-base/archiva-policies/pom.xml +++ b/archiva-modules/archiva-base/archiva-policies/pom.xml @@ -65,26 +65,18 @@ org.apache.archiva.components.cache archiva-components-spring-cache-api - - - commons-logging - commons-logging - - - + org.apache.archiva.components.cache archiva-components-spring-cache-ehcache - - - commons-logging - commons-logging - - - test + runtime + + + org.springframework spring-context diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/base/ArchivaRepositoryRegistry.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/base/ArchivaRepositoryRegistry.java index 1c10a2a49..4bd19998c 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/base/ArchivaRepositoryRegistry.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/base/ArchivaRepositoryRegistry.java @@ -1280,8 +1280,13 @@ public class ArchivaRepositoryRegistry implements ConfigurationListener, EventHa @Override public Repository getRepositoryOfAsset( StorageAsset asset ) { - return getManagedRepositories( ).stream( ).filter( r -> r.getAsset( "" ) - .getStorage( ).equals( asset.getStorage( ) ) ).findFirst( ).orElse( null ); + if (asset instanceof Repository) { + return (Repository)asset; + } else + { + return getRepositories( ).stream( ).filter( r -> r.getAsset( "" ) + .getStorage( ).equals( asset.getStorage( ) ) ).findFirst( ).orElse( null ); + } } diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/pom.xml b/archiva-modules/archiva-maven/archiva-maven-indexer/pom.xml index 449806933..11b0471b5 100644 --- a/archiva-modules/archiva-maven/archiva-maven-indexer/pom.xml +++ b/archiva-modules/archiva-maven/archiva-maven-indexer/pom.xml @@ -33,11 +33,12 @@ - + org.apache.archiva archiva-common @@ -46,6 +47,10 @@ org.apache.archiva archiva-repository-layer + + org.apache.archiva + archiva-proxy-api + org.apache.archiva archiva-proxy @@ -181,11 +186,17 @@ archiva-mock test + + org.apache.archiva.maven + archiva-maven-repository + + org.apache.archiva archiva-test-utils diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/maven/search/MavenRepositorySearch.java b/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/maven/search/MavenRepositorySearch.java index 9c76451ab..ff594757c 100644 --- a/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/maven/search/MavenRepositorySearch.java +++ b/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/maven/search/MavenRepositorySearch.java @@ -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 ids = new HashSet<>(); List 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 artifactInfoFilters, List selectedRepos, boolean includePoms ) - throws RepositoryAdminException { SearchResults results = new SearchResults(); Set artifactInfos = response.getResults(); @@ -605,7 +591,6 @@ public class MavenRepositorySearch * @return */ protected String getBaseUrl( ArtifactInfo artifactInfo, List 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 selectedRepos ) - throws RepositoryAdminException { - Map> proxyConnectorMap = proxyConnectorAdmin.getProxyConnectorAsMap(); + Map> 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(); } } diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/java/org/apache/archiva/indexer/maven/search/AbstractMavenRepositorySearch.java b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/java/org/apache/archiva/indexer/maven/search/AbstractMavenRepositorySearch.java index 542681e42..b94e6b8e5 100644 --- a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/java/org/apache/archiva/indexer/maven/search/AbstractMavenRepositorySearch.java +++ b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/java/org/apache/archiva/indexer/maven/search/AbstractMavenRepositorySearch.java @@ -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 ); diff --git a/status-dep.txt b/status-dep.txt index 57e5042d2..259da5cb6 100644 --- a/status-dep.txt +++ b/status-dep.txt @@ -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