From 8a76b9964151f850885e4d784fa86358d0148199 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Mon, 24 Jul 2017 14:56:21 +1000 Subject: [PATCH] more progress on oak lucene shaded Signed-off-by: olivier lamy --- .../lucene/NexusIndexerConsumer.java | 12 +-- .../lucene/NexusIndexerConsumerTest.java | 8 +- .../indexer/merger/DefaultIndexMerger.java | 24 +++--- .../indexer/search/MavenRepositorySearch.java | 64 +++++---------- .../search/AbstractMavenRepositorySearch.java | 17 ++-- .../search/MavenRepositorySearchTest.java | 4 +- .../plexusbridge/MavenIndexerUtils.java | 77 ------------------- .../DefaultManagedRepositoryAdmin.java | 25 ------ .../DefaultDownloadRemoteIndexScheduler.java | 5 -- .../ArchivaIndexingTaskExecutorTest.java | 50 ++++++------ .../services/DefaultRepositoriesService.java | 6 +- .../META-INF/spring-context-test.xml | 2 + .../resources/spring-context-test-common.xml | 2 + .../resources/spring-context-with-jcr.xml | 2 + .../webdav/util/MavenIndexerCleaner.java | 14 +--- .../jcr/JcrRepositorySessionFactory.java | 2 +- .../src/test/resources/log4j2-test.xml | 9 +-- pom.xml | 6 ++ 18 files changed, 89 insertions(+), 240 deletions(-) delete mode 100644 archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/MavenIndexerUtils.java 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 c85a8fbea..69b9ba5b8 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 @@ -22,9 +22,6 @@ package org.apache.archiva.consumers.lucene; import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; -import org.apache.archiva.common.plexusbridge.MavenIndexerUtils; -import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; -import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.ConfigurationNames; import org.apache.archiva.configuration.FileTypes; @@ -32,13 +29,13 @@ import org.apache.archiva.consumers.AbstractMonitoredConsumer; import org.apache.archiva.consumers.ConsumerException; import org.apache.archiva.consumers.KnownRepositoryContentConsumer; import org.apache.archiva.redback.components.registry.Registry; +import org.apache.archiva.redback.components.registry.RegistryListener; +import org.apache.archiva.redback.components.taskqueue.TaskQueueException; import org.apache.archiva.scheduler.ArchivaTaskScheduler; import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask; import org.apache.maven.index.NexusIndexer; import org.apache.maven.index.context.IndexCreator; import org.apache.maven.index.context.IndexingContext; -import org.apache.archiva.redback.components.registry.RegistryListener; -import org.apache.archiva.redback.components.taskqueue.TaskQueueException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Scope; @@ -88,14 +85,13 @@ public class NexusIndexerConsumer public NexusIndexerConsumer( @Named( value = "archivaTaskScheduler#indexing" ) ArchivaTaskScheduler scheduler, @Named( value = "archivaConfiguration" ) ArchivaConfiguration configuration, FileTypes filetypes, - MavenIndexerUtils mavenIndexerUtils, - ManagedRepositoryAdmin managedRepositoryAdmin, NexusIndexer nexusIndexer ) + List indexCreators, ManagedRepositoryAdmin managedRepositoryAdmin, NexusIndexer nexusIndexer ) { this.configuration = configuration; this.filetypes = filetypes; this.scheduler = scheduler; this.nexusIndexer = nexusIndexer; - this.allIndexCreators = mavenIndexerUtils.getAllIndexCreators(); + this.allIndexCreators = indexCreators; this.managedRepositoryAdmin = managedRepositoryAdmin; } diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java index b5e688b88..91d0c107c 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java @@ -22,7 +22,6 @@ package org.apache.archiva.consumers.lucene; import junit.framework.TestCase; import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; -import org.apache.archiva.common.plexusbridge.MavenIndexerUtils; import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.FileTypes; import org.apache.archiva.redback.components.taskqueue.TaskQueueException; @@ -31,6 +30,7 @@ import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.apache.commons.io.FileUtils; import org.apache.maven.index.NexusIndexer; +import org.apache.maven.index.context.IndexCreator; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -99,7 +99,7 @@ public class NexusIndexerConsumerTest private NexusIndexer nexusIndexer; @Inject - private MavenIndexerUtils mavenIndexerUtils; + private List indexCreators; @Inject private ManagedRepositoryAdmin managedRepositoryAdmin; @@ -119,11 +119,11 @@ public class NexusIndexerConsumerTest FileTypes filetypes = applicationContext.getBean( FileTypes.class ); nexusIndexerConsumer = - new NexusIndexerConsumer( scheduler, configuration, filetypes, mavenIndexerUtils, + new NexusIndexerConsumer( scheduler, configuration, filetypes, indexCreators, managedRepositoryAdmin, nexusIndexer ); // initialize to set the file types to be processed - ( (NexusIndexerConsumer) nexusIndexerConsumer ).initialize(); + nexusIndexerConsumer.initialize(); repositoryConfig = new ManagedRepository(); repositoryConfig.setId( "test-repo" ); diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java index 663f0b63a..de9342c74 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java @@ -18,11 +18,10 @@ package org.apache.archiva.indexer.merger; * under the License. */ -import org.apache.archiva.common.plexusbridge.MavenIndexerUtils; -import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.time.StopWatch; import org.apache.maven.index.NexusIndexer; +import org.apache.maven.index.context.IndexCreator; import org.apache.maven.index.context.IndexingContext; import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException; import org.apache.maven.index.packer.IndexPacker; @@ -50,23 +49,22 @@ public class DefaultIndexMerger private Logger log = LoggerFactory.getLogger( getClass() ); - private MavenIndexerUtils mavenIndexerUtils; + private final NexusIndexer indexer; - private NexusIndexer indexer; + private final IndexPacker indexPacker; - private IndexPacker indexPacker; + private final List indexCreators; private List temporaryGroupIndexes = new CopyOnWriteArrayList<>(); - private List runningGroups = new CopyOnWriteArrayList(); + private List runningGroups = new CopyOnWriteArrayList<>(); @Inject - public DefaultIndexMerger( NexusIndexer nexusIndexer, IndexPacker indexPacker, MavenIndexerUtils mavenIndexerUtils ) - throws PlexusSisuBridgeException + public DefaultIndexMerger( NexusIndexer nexusIndexer, IndexPacker indexPacker, List indexCreators ) { this.indexer = nexusIndexer; - this.mavenIndexerUtils = mavenIndexerUtils; this.indexPacker = indexPacker; + this.indexCreators = indexCreators; } @Override @@ -96,7 +94,7 @@ public class DefaultIndexMerger File indexLocation = new File( mergedIndexDirectory, indexMergerRequest.getMergedIndexPath() ); IndexingContext indexingContext = indexer.addIndexingContext( tempRepoId, tempRepoId, mergedIndexDirectory, indexLocation, null, null, - mavenIndexerUtils.getAllIndexCreators() ); + indexCreators ); for ( String repoId : indexMergerRequest.getRepositoriesIds() ) { @@ -127,11 +125,7 @@ public class DefaultIndexMerger stopWatch.getTime() ); return indexingContext; } - catch ( IOException e ) - { - throw new IndexMergerException( e.getMessage(), e ); - } - catch ( UnsupportedExistingLuceneIndexException e ) + catch ( IOException | UnsupportedExistingLuceneIndexException e ) { throw new IndexMergerException( e.getMessage(), e ); } diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/MavenRepositorySearch.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/MavenRepositorySearch.java index 64db78594..827eda035 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/MavenRepositorySearch.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/MavenRepositorySearch.java @@ -24,11 +24,9 @@ import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.beans.ProxyConnector; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin; -import org.apache.archiva.common.plexusbridge.MavenIndexerUtils; import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.archiva.indexer.util.SearchUtil; import org.apache.commons.lang.StringUtils; - import org.apache.maven.index.ArtifactInfo; import org.apache.maven.index.FlatSearchRequest; import org.apache.maven.index.FlatSearchResponse; @@ -77,8 +75,6 @@ public class MavenRepositorySearch private ProxyConnectorAdmin proxyConnectorAdmin; - private MavenIndexerUtils mavenIndexerUtils; - protected MavenRepositorySearch() { // for test purpose @@ -86,14 +82,12 @@ public class MavenRepositorySearch @Inject public MavenRepositorySearch( NexusIndexer nexusIndexer, ManagedRepositoryAdmin managedRepositoryAdmin, - MavenIndexerUtils mavenIndexerUtils, ProxyConnectorAdmin proxyConnectorAdmin, - QueryCreator queryCreator) + ProxyConnectorAdmin proxyConnectorAdmin, QueryCreator queryCreator ) throws PlexusSisuBridgeException { this.indexer = nexusIndexer; this.queryCreator = queryCreator; this.managedRepositoryAdmin = managedRepositoryAdmin; - this.mavenIndexerUtils = mavenIndexerUtils; this.proxyConnectorAdmin = proxyConnectorAdmin; } @@ -162,11 +156,9 @@ public class MavenRepositorySearch BooleanQuery q = new BooleanQuery(); if ( StringUtils.isNotBlank( searchFields.getGroupId() ) ) { - q.add( indexer.constructQuery( MAVEN.GROUP_ID, searchFields.isExactSearch() - ? new SourcedSearchExpression( searchFields.getGroupId() ) - : new UserInputSearchExpression( searchFields.getGroupId() ) - ), BooleanClause.Occur.MUST - ); + q.add( indexer.constructQuery( MAVEN.GROUP_ID, searchFields.isExactSearch() ? new SourcedSearchExpression( + searchFields.getGroupId() ) : new UserInputSearchExpression( searchFields.getGroupId() ) ), + BooleanClause.Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getArtifactId() ) ) @@ -174,69 +166,64 @@ public class MavenRepositorySearch q.add( indexer.constructQuery( MAVEN.ARTIFACT_ID, searchFields.isExactSearch() ? new SourcedSearchExpression( searchFields.getArtifactId() ) - : new UserInputSearchExpression( searchFields.getArtifactId() ) - ), BooleanClause.Occur.MUST - ); + : new UserInputSearchExpression( searchFields.getArtifactId() ) ), + BooleanClause.Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getVersion() ) ) { q.add( indexer.constructQuery( MAVEN.VERSION, searchFields.isExactSearch() ? new SourcedSearchExpression( - searchFields.getVersion() ) : new SourcedSearchExpression( searchFields.getVersion() ) ), BooleanClause.Occur.MUST ); + searchFields.getVersion() ) : new SourcedSearchExpression( searchFields.getVersion() ) ), + BooleanClause.Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getPackaging() ) ) { q.add( indexer.constructQuery( MAVEN.PACKAGING, searchFields.isExactSearch() ? new SourcedSearchExpression( searchFields.getPackaging() ) : new UserInputSearchExpression( searchFields.getPackaging() ) ), - BooleanClause.Occur.MUST - ); + BooleanClause.Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getClassName() ) ) { q.add( indexer.constructQuery( MAVEN.CLASSNAMES, - new UserInputSearchExpression( searchFields.getClassName() ) ), BooleanClause.Occur.MUST ); + new UserInputSearchExpression( searchFields.getClassName() ) ), + BooleanClause.Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getBundleSymbolicName() ) ) { q.add( indexer.constructQuery( OSGI.SYMBOLIC_NAME, new UserInputSearchExpression( searchFields.getBundleSymbolicName() ) ), - BooleanClause.Occur.MUST - ); + BooleanClause.Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getBundleVersion() ) ) { q.add( indexer.constructQuery( OSGI.VERSION, new UserInputSearchExpression( searchFields.getBundleVersion() ) ), - BooleanClause.Occur.MUST - ); + BooleanClause.Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getBundleExportPackage() ) ) { q.add( indexer.constructQuery( OSGI.EXPORT_PACKAGE, new UserInputSearchExpression( searchFields.getBundleExportPackage() ) ), - Occur.MUST - ); + Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getBundleExportService() ) ) { q.add( indexer.constructQuery( OSGI.EXPORT_SERVICE, new UserInputSearchExpression( searchFields.getBundleExportService() ) ), - Occur.MUST - ); + Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getBundleImportPackage() ) ) { q.add( indexer.constructQuery( OSGI.IMPORT_PACKAGE, new UserInputSearchExpression( searchFields.getBundleImportPackage() ) ), - Occur.MUST - ); + Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getBundleName() ) ) @@ -249,24 +236,21 @@ public class MavenRepositorySearch { q.add( indexer.constructQuery( OSGI.IMPORT_PACKAGE, new UserInputSearchExpression( searchFields.getBundleImportPackage() ) ), - Occur.MUST - ); + Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getBundleRequireBundle() ) ) { q.add( indexer.constructQuery( OSGI.REQUIRE_BUNDLE, new UserInputSearchExpression( searchFields.getBundleRequireBundle() ) ), - Occur.MUST - ); + Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getClassifier() ) ) { q.add( indexer.constructQuery( MAVEN.CLASSIFIER, searchFields.isExactSearch() ? new SourcedSearchExpression( searchFields.getClassifier() ) : new UserInputSearchExpression( searchFields.getClassifier() ) ), - Occur.MUST - ); + Occur.MUST ); } else if ( searchFields.isExactSearch() ) { @@ -283,7 +267,8 @@ public class MavenRepositorySearch searchFields.getRepositories(), searchFields.isIncludePomArtifacts() ); } - private static class NullSearch implements SearchTyped, SearchExpression + private static class NullSearch + implements SearchTyped, SearchExpression { private static final NullSearch INSTANCE = new NullSearch(); @@ -476,13 +461,6 @@ public class MavenRepositorySearch } - - protected List getAllIndexCreators() - { - return mavenIndexerUtils.getAllIndexCreators(); - } - - private SearchResults convertToSearchResults( FlatSearchResponse response, SearchResultLimits limits, List artifactInfoFilters, List selectedRepos, boolean includePoms ) diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractMavenRepositorySearch.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractMavenRepositorySearch.java index cab896bdb..e3b96f043 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractMavenRepositorySearch.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractMavenRepositorySearch.java @@ -22,7 +22,6 @@ package org.apache.archiva.indexer.search; import junit.framework.TestCase; import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin; import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin; -import org.apache.archiva.common.plexusbridge.MavenIndexerUtils; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.common.utils.FileUtil; import org.apache.archiva.configuration.ArchivaConfiguration; @@ -37,8 +36,8 @@ import org.apache.maven.index.ArtifactScanningListener; import org.apache.maven.index.NexusIndexer; import org.apache.maven.index.QueryCreator; import org.apache.maven.index.ScanningResult; +import org.apache.maven.index.context.IndexCreator; import org.apache.maven.index.context.IndexingContext; -import org.apache.maven.index.shaded.lucene.index.IndexUpgrader; import org.easymock.EasyMock; import org.easymock.IMocksControl; import org.junit.After; @@ -85,7 +84,7 @@ public abstract class AbstractMavenRepositorySearch PlexusSisuBridge plexusSisuBridge; @Inject - MavenIndexerUtils mavenIndexerUtils; + List indexCreators; @Inject NexusIndexer nexusIndexer; @@ -106,7 +105,7 @@ public abstract class AbstractMavenRepositorySearch FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer" ) ); assertFalse( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer" ).exists() ); - archivaConfigControl = EasyMock.createControl( ); + archivaConfigControl = EasyMock.createControl(); archivaConfig = archivaConfigControl.createMock( ArchivaConfiguration.class ); @@ -116,12 +115,11 @@ public abstract class AbstractMavenRepositorySearch DefaultProxyConnectorAdmin defaultProxyConnectorAdmin = new DefaultProxyConnectorAdmin(); defaultProxyConnectorAdmin.setArchivaConfiguration( archivaConfig ); - search = new MavenRepositorySearch( nexusIndexer, defaultManagedRepositoryAdmin, mavenIndexerUtils, - defaultProxyConnectorAdmin, queryCreator ); + search = new MavenRepositorySearch( nexusIndexer, defaultManagedRepositoryAdmin, defaultProxyConnectorAdmin, + queryCreator ); - defaultManagedRepositoryAdmin.setMavenIndexerUtils( mavenIndexerUtils ); defaultManagedRepositoryAdmin.setIndexer( nexusIndexer ); - defaultManagedRepositoryAdmin.setIndexCreators( mavenIndexerUtils.getAllIndexCreators() ); + defaultManagedRepositoryAdmin.setIndexCreators( indexCreators ); config = new Configuration(); config.addManagedRepository( createRepositoryConfig( TEST_REPO_1 ) ); @@ -204,8 +202,7 @@ public abstract class AbstractMavenRepositorySearch context = nexusIndexer.addIndexingContext( repository, repository, repo, indexDirectory, repo.toURI().toURL().toExternalForm(), - indexDirectory.toURI().toURL().toString(), - search.getAllIndexCreators() ); + indexDirectory.toURI().toURL().toString(), indexCreators ); // minimize datas in memory // context.getIndexWriter().setMaxBufferedDocs( -1 ); diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchTest.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchTest.java index 8fb372850..77cddb8ee 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchTest.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchTest.java @@ -871,13 +871,13 @@ public class MavenRepositorySearchTest File indexDirectory = new File( repo, ".index" ); FileUtils.copyDirectoryStructure( new File( "src/test/repo-release" ), repo ); - IndexUpgrader.main( new String[]{indexDirectory.getAbsolutePath()} ); + IndexUpgrader.main( new String[]{ indexDirectory.getAbsolutePath() } ); createIndex( "repo-release", Collections.emptyList(), false ); nexusIndexer.addIndexingContext( REPO_RELEASE, REPO_RELEASE, repo, indexDirectory, repo.toURI().toURL().toExternalForm(), - indexDirectory.toURI().toURL().toString(), search.getAllIndexCreators() ); + indexDirectory.toURI().toURL().toString(), indexCreators ); SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES ); limits.setPageSize( 300 ); diff --git a/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/MavenIndexerUtils.java b/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/MavenIndexerUtils.java deleted file mode 100644 index 7f86da4ff..000000000 --- a/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/MavenIndexerUtils.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.apache.archiva.common.plexusbridge; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.index.context.IndexCreator; -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; -import java.util.List; -import java.util.Map; - -/** - * @author Olivier Lamy - * @since 1.4-M1 - */ -@Service( "mavenIndexerUtils" ) -public class MavenIndexerUtils -{ - - private Logger log = LoggerFactory.getLogger( getClass() ); - - private List allIndexCreators; - - private ApplicationContext applicationContext; - - @Inject - public MavenIndexerUtils(ApplicationContext applicationContext, Map indexers) - { - this.applicationContext = applicationContext; - } - - @PostConstruct - public void initialize() - { - allIndexCreators = new ArrayList<>( applicationContext.getBeansOfType( IndexCreator.class ).values()); - - if ( allIndexCreators == null || allIndexCreators.isEmpty() ) - { - throw new RuntimeException( "cannot initiliaze IndexCreators" ); - } - - log.debug( "allIndexCreators {}", allIndexCreators ); - } - - public List getAllIndexCreators() - { - return allIndexCreators; - } - - public void setAllIndexCreators( List allIndexCreators ) - { - this.allIndexCreators = allIndexCreators; - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java index ad90b4e82..7ba503cfb 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java @@ -23,9 +23,6 @@ import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; import org.apache.archiva.admin.repository.AbstractRepositoryAdmin; -import org.apache.archiva.common.plexusbridge.MavenIndexerUtils; -import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; -import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.archiva.configuration.ProxyConnectorConfiguration; @@ -95,9 +92,6 @@ public class DefaultManagedRepositoryAdmin @Inject private RepositoryStatisticsManager repositoryStatisticsManager; - @Inject - private MavenIndexerUtils mavenIndexerUtils; - @Inject protected RoleManager roleManager; @@ -116,15 +110,6 @@ public class DefaultManagedRepositoryAdmin public void initialize() throws RepositoryAdminException, RoleManagerException { -// try -// { -// indexCreators = mavenIndexerUtils.getAllIndexCreators(); -// indexer = plexusSisuBridge.lookup( NexusIndexer.class ); -// } -// catch ( PlexusSisuBridgeException e ) -// { -// throw new RepositoryAdminException( e.getMessage(), e ); -// } // initialize index context on start and check roles here for ( ManagedRepository managedRepository : getManagedRepositories() ) { @@ -817,16 +802,6 @@ public class DefaultManagedRepositoryAdmin this.repositoryTaskScheduler = repositoryTaskScheduler; } - public MavenIndexerUtils getMavenIndexerUtils() - { - return mavenIndexerUtils; - } - - public void setMavenIndexerUtils( MavenIndexerUtils mavenIndexerUtils ) - { - this.mavenIndexerUtils = mavenIndexerUtils; - } - public NexusIndexer getIndexer() { return indexer; diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java index a3930c6d5..b1f39558b 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java @@ -25,8 +25,6 @@ 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.ArchivaException; -import org.apache.archiva.common.plexusbridge.MavenIndexerUtils; -import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.ConfigurationEvent; @@ -83,9 +81,6 @@ public class DefaultDownloadRemoteIndexScheduler @Inject private NetworkProxyAdmin networkProxyAdmin; - @Inject - private MavenIndexerUtils mavenIndexerUtils; - @Inject private NexusIndexer nexusIndexer; diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java index 044ed87fd..b9ad48c68 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java @@ -22,14 +22,13 @@ package org.apache.archiva.scheduler.indexing; import junit.framework.TestCase; import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; -import org.apache.archiva.common.plexusbridge.MavenIndexerUtils; -import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.apache.maven.index.ArtifactInfo; import org.apache.maven.index.FlatSearchRequest; import org.apache.maven.index.FlatSearchResponse; import org.apache.maven.index.MAVEN; import org.apache.maven.index.NexusIndexer; +import org.apache.maven.index.context.IndexCreator; import org.apache.maven.index.context.IndexingContext; import org.apache.maven.index.expr.SourcedSearchExpression; import org.apache.maven.index.expr.StringSearchExpression; @@ -37,7 +36,9 @@ import org.apache.maven.index.shaded.lucene.search.BooleanClause; import org.apache.maven.index.shaded.lucene.search.BooleanQuery; import org.apache.maven.index.shaded.lucene.search.IndexSearcher; import org.apache.maven.index.shaded.lucene.search.TopDocs; +import org.apache.maven.index.updater.DefaultIndexUpdater; import org.apache.maven.index.updater.IndexUpdateRequest; +import org.apache.maven.index.updater.IndexUpdater; import org.assertj.core.api.Assertions; import org.junit.After; import org.junit.Before; @@ -46,19 +47,10 @@ import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import javax.inject.Inject; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; import java.io.File; import java.io.FilenameFilter; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.file.Files; -import java.nio.file.Paths; +import java.util.List; import java.util.Set; -import java.util.zip.GZIPInputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; /** * ArchivaIndexingTaskExecutorTest @@ -77,11 +69,14 @@ public class ArchivaIndexingTaskExecutorTest private NexusIndexer indexer; @Inject - MavenIndexerUtils mavenIndexerUtils; + List indexCreators; @Inject ManagedRepositoryAdmin managedRepositoryAdmin; + @Inject + private IndexUpdater indexUpdater; + @Before @Override public void setUp() @@ -153,12 +148,12 @@ public class ArchivaIndexingTaskExecutorTest if ( !indexer.getIndexingContexts().containsKey( repositoryConfig.getId() ) ) { - IndexingContext context = indexer.addIndexingContext( repositoryConfig.getId(), repositoryConfig.getId(), - new File( repositoryConfig.getLocation() ), - new File( repositoryConfig.getLocation(), - ".indexer" ), null, null, - mavenIndexerUtils.getAllIndexCreators() - ); + IndexingContext context = indexer.addIndexingContext( repositoryConfig.getId(), // + repositoryConfig.getId(), // + new File( repositoryConfig.getLocation() ), // + new File( repositoryConfig.getLocation(), ".indexer" ) + // + , null, null, indexCreators ); context.setSearchable( true ); } @@ -260,8 +255,7 @@ public class ArchivaIndexingTaskExecutorTest BooleanClause.Occur.SHOULD ); q.add( indexer.constructQuery( MAVEN.ARTIFACT_ID, new SourcedSearchExpression( "archiva-index-methods-jar-test" ) ), - BooleanClause.Occur.SHOULD - ); + BooleanClause.Occur.SHOULD ); assertTrue( new File( repositoryConfig.getLocation(), ".indexer" ).exists() ); assertFalse( new File( repositoryConfig.getLocation(), ".index" ).exists() ); @@ -317,17 +311,17 @@ public class ArchivaIndexingTaskExecutorTest // test packed index file creation //no more zip //Assertions.assertThat(new File( indexerDirectory, "nexus-maven-repository-index.zip" )).exists(); - Assertions.assertThat(new File( indexerDirectory, "nexus-maven-repository-index.properties" )).exists(); - Assertions.assertThat(new File( indexerDirectory, "nexus-maven-repository-index.gz" )).exists(); + Assertions.assertThat( new File( indexerDirectory, "nexus-maven-repository-index.properties" ) ).exists(); + Assertions.assertThat( new File( indexerDirectory, "nexus-maven-repository-index.gz" ) ).exists(); // unpack .zip index File destDir = new File( repositoryConfig.getLocation(), ".indexer/tmp" ); - unzipIndex( indexerDirectory.getPath(), destDir.getPath() ); + //unzipIndex( indexerDirectory.getPath(), destDir.getPath() ); - TrackingFetcher fetcher = new TrackingFetcher( remoteRepo ); - updateRequest = new IndexUpdateRequest( testContext, fetcher ); - updateRequest.setLocalIndexCacheDir( localCacheDir ); - updater.fetchAndUpdateIndex( updateRequest ); + DefaultIndexUpdater.FileFetcher fetcher = new DefaultIndexUpdater.FileFetcher( indexerDirectory ); + IndexUpdateRequest updateRequest = new IndexUpdateRequest( getIndexingContext(), fetcher ); + //updateRequest.setLocalIndexCacheDir( indexerDirectory ); + indexUpdater.fetchAndUpdateIndex( updateRequest ); BooleanQuery q = new BooleanQuery(); q.add( indexer.constructQuery( MAVEN.GROUP_ID, new StringSearchExpression( "org.apache.archiva" ) ), diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java index e0660c269..bbb7416ce 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java @@ -23,16 +23,15 @@ import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.admin.ArchivaAdministration; import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; -import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.archiva.checksum.ChecksumAlgorithm; import org.apache.archiva.checksum.ChecksummedFile; -import org.apache.archiva.common.plexusbridge.MavenIndexerUtils; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.common.utils.VersionComparator; import org.apache.archiva.common.utils.VersionUtil; import org.apache.archiva.maven2.metadata.MavenMetadataReader; import org.apache.archiva.maven2.model.Artifact; import org.apache.archiva.metadata.model.ArtifactMetadata; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.archiva.metadata.model.maven2.MavenArtifactFacet; import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataRepositoryException; @@ -125,9 +124,6 @@ public class DefaultRepositoriesService @Inject private PlexusSisuBridge plexusSisuBridge; - @Inject - private MavenIndexerUtils mavenIndexerUtils; - @Inject private SecuritySystem securitySystem; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/META-INF/spring-context-test.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/META-INF/spring-context-test.xml index 49c0748e1..830a3e6e3 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/META-INF/spring-context-test.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/META-INF/spring-context-test.xml @@ -75,6 +75,7 @@ + diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-test-common.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-test-common.xml index 3e8195d6a..d62446b45 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-test-common.xml +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-test-common.xml @@ -72,6 +72,7 @@ + diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-with-jcr.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-with-jcr.xml index 1e02fbcc7..6b72d332a 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-with-jcr.xml +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-with-jcr.xml @@ -28,6 +28,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd" default-lazy-init="true"> + diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/util/MavenIndexerCleaner.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/util/MavenIndexerCleaner.java index 079828fbe..cd59302e7 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/util/MavenIndexerCleaner.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/util/MavenIndexerCleaner.java @@ -18,23 +18,18 @@ package org.apache.archiva.webdav.util; * under the License. */ -import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; -import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.maven.index.NexusIndexer; import org.apache.maven.index.context.IndexingContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Service; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.context.support.WebApplicationContextUtils; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.inject.Inject; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; -import java.io.IOException; /** * @author Olivier Lamy @@ -46,15 +41,16 @@ public class MavenIndexerCleaner Logger log = LoggerFactory.getLogger( getClass() ); - private PlexusSisuBridge plexusSisuBridge; @Inject private ApplicationContext applicationContext; + @Inject + NexusIndexer nexusIndexer; + @PostConstruct public void startup() { - plexusSisuBridge = applicationContext.getBean( PlexusSisuBridge.class ); cleanupIndex(); } @@ -70,9 +66,6 @@ public class MavenIndexerCleaner { try { - WebApplicationContext wacu = - WebApplicationContextUtils.getRequiredWebApplicationContext( servletContextEvent.getServletContext() ); - plexusSisuBridge = wacu.getBean( PlexusSisuBridge.class ); cleanupIndex(); } @@ -103,7 +96,6 @@ public class MavenIndexerCleaner log.info( "cleanup IndexingContext" ); try { - NexusIndexer nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class ); for ( IndexingContext context : nexusIndexer.getIndexingContexts().values() ) { nexusIndexer.removeIndexingContext( context, true ); diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java index ed864639d..fa502798d 100644 --- a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java +++ b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java @@ -98,7 +98,7 @@ public class JcrRepositorySessionFactory throws Exception { - // skip initialisation if not cassandra + // skip initialisation if not jcr if ( !StringUtils.equals( repositorySessionFactoryBean.getId(), "jcr" ) ) { return; diff --git a/archiva-modules/plugins/metadata-store-jcr/src/test/resources/log4j2-test.xml b/archiva-modules/plugins/metadata-store-jcr/src/test/resources/log4j2-test.xml index 74dd0773f..50dab921b 100644 --- a/archiva-modules/plugins/metadata-store-jcr/src/test/resources/log4j2-test.xml +++ b/archiva-modules/plugins/metadata-store-jcr/src/test/resources/log4j2-test.xml @@ -19,7 +19,7 @@ --> - + @@ -31,11 +31,8 @@ - - - - - + + diff --git a/pom.xml b/pom.xml index 8d0e5424d..46a0022d5 100644 --- a/pom.xml +++ b/pom.xml @@ -291,6 +291,12 @@ org.apache.jackrabbit oak-jcr ${jcr-oak.version} + + + ch.qos.logback + logback-classic + + org.apache.jackrabbit -- 2.39.5