mirror of
https://github.com/apache/archiva.git
synced 2025-02-20 17:04:57 +00:00
more progress on new maven indexer version
Signed-off-by: olivier lamy <olamy@apache.org>
This commit is contained in:
parent
7480b7ffe2
commit
003d5794a8
@ -23,13 +23,14 @@
|
||||
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.configuration.ArchivaConfiguration;
|
||||
import org.apache.archiva.configuration.FileTypes;
|
||||
import org.apache.archiva.redback.components.taskqueue.TaskQueueException;
|
||||
import org.apache.archiva.scheduler.ArchivaTaskScheduler;
|
||||
import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
|
||||
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.archiva.redback.components.taskqueue.TaskQueueException;
|
||||
import org.apache.maven.index.NexusIndexer;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@ -45,7 +46,6 @@
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* NexusIndexerConsumerTest
|
||||
@ -58,7 +58,7 @@ public class NexusIndexerConsumerTest
|
||||
private final class ArchivaTaskSchedulerStub
|
||||
implements ArchivaTaskScheduler<ArtifactIndexingTask>
|
||||
{
|
||||
Set<File> indexed = new HashSet<File>();
|
||||
Set<File> indexed = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public void queueTask( ArtifactIndexingTask task )
|
||||
@ -96,7 +96,7 @@ public void queueTask( ArtifactIndexingTask task )
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Inject
|
||||
private PlexusSisuBridge plexusSisuBridge;
|
||||
private NexusIndexer nexusIndexer;
|
||||
|
||||
@Inject
|
||||
private MavenIndexerUtils mavenIndexerUtils;
|
||||
@ -119,8 +119,8 @@ public void setUp()
|
||||
FileTypes filetypes = applicationContext.getBean( FileTypes.class );
|
||||
|
||||
nexusIndexerConsumer =
|
||||
new NexusIndexerConsumer( scheduler, configuration, filetypes, plexusSisuBridge, mavenIndexerUtils,
|
||||
managedRepositoryAdmin );
|
||||
new NexusIndexerConsumer( scheduler, configuration, filetypes, mavenIndexerUtils,
|
||||
managedRepositoryAdmin, nexusIndexer );
|
||||
|
||||
// initialize to set the file types to be processed
|
||||
( (NexusIndexerConsumer) nexusIndexerConsumer ).initialize();
|
||||
|
@ -22,6 +22,7 @@
|
||||
import org.apache.archiva.common.utils.FileUtil;
|
||||
import org.apache.archiva.indexer.util.SearchUtil;
|
||||
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
|
||||
import org.apache.maven.index.shaded.lucene.index.IndexUpgrader;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
import org.easymock.EasyMock;
|
||||
import org.junit.Test;
|
||||
@ -29,10 +30,7 @@
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -40,8 +38,8 @@
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RunWith(ArchivaSpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" })
|
||||
@RunWith( ArchivaSpringJUnit4ClassRunner.class )
|
||||
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
|
||||
public class MavenRepositorySearchTest
|
||||
extends AbstractMavenRepositorySearch
|
||||
{
|
||||
@ -290,13 +288,13 @@ public void testQuickSearchWithPagination()
|
||||
|
||||
archivaConfigControl.replay();
|
||||
|
||||
SearchResults results = search.search( "user", selectedRepos, "org", limits, Collections.<String>emptyList() );
|
||||
SearchResults results = search.search( "user", selectedRepos, "org", limits, Collections.emptyList() );
|
||||
|
||||
archivaConfigControl.verify();
|
||||
|
||||
assertNotNull( results );
|
||||
assertEquals( 1, results.getHits().size() );
|
||||
assertEquals( "total hits not 8 for page1 " + results, 8, results.getTotalHits() );
|
||||
assertEquals( "total hits not 9 for page1 " + results, 9, results.getTotalHits() );
|
||||
assertEquals( "returned hits not 1 for page1 " + results, 1, results.getReturnedHitsCount() );
|
||||
assertEquals( limits, results.getLimits() );
|
||||
|
||||
@ -317,7 +315,7 @@ public void testQuickSearchWithPagination()
|
||||
assertNotNull( results );
|
||||
|
||||
assertEquals( "hits not 1", 1, results.getHits().size() );
|
||||
assertEquals( "total hits not 8 for page 2 " + results, 8, results.getTotalHits() );
|
||||
assertEquals( "total hits not 9 for page 2 " + results, 9, results.getTotalHits() );
|
||||
assertEquals( "returned hits not 1 for page2 " + results, 1, results.getReturnedHitsCount() );
|
||||
assertEquals( limits, results.getLimits() );
|
||||
}
|
||||
@ -873,7 +871,9 @@ public void nolimitedResult()
|
||||
File indexDirectory = new File( repo, ".index" );
|
||||
FileUtils.copyDirectoryStructure( new File( "src/test/repo-release" ), repo );
|
||||
|
||||
createIndex( "repo-release", Collections.<File>emptyList(), false );
|
||||
IndexUpgrader.main( new String[]{indexDirectory.getAbsolutePath()} );
|
||||
|
||||
createIndex( "repo-release", Collections.emptyList(), false );
|
||||
|
||||
nexusIndexer.addIndexingContext( REPO_RELEASE, REPO_RELEASE, repo, indexDirectory,
|
||||
repo.toURI().toURL().toExternalForm(),
|
||||
@ -886,8 +886,9 @@ public void nolimitedResult()
|
||||
|
||||
archivaConfigControl.replay();
|
||||
|
||||
SearchResults searchResults = search.search( null, Arrays.asList( REPO_RELEASE ), "org.example", limits,
|
||||
Collections.<String>emptyList() );
|
||||
SearchResults searchResults = search.search( null, Arrays.asList( REPO_RELEASE ), //
|
||||
"org.example", limits, //
|
||||
Collections.emptyList() );
|
||||
|
||||
log.info( "results: {}", searchResults.getHits().size() );
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
@ -1,5 +0,0 @@
|
||||
༚
|
||||
䑅千剉偔佒ć䥄塉乆伐ŵā洐ũခ朁šā瘁ݧ牯異䥤<EFBFBD>
|
||||
慲瑩晡捴䥤ć癥牳楯渁Űāţ<EFBFBD>
|
||||
捬慳獮慭敳ē䉵湤汥ⵓ祭扯汩捎慭攁โ畮摬攭噥牳楯渁ๅ硰潲琭偡捫慧攁ๅ硰潲琭卥牶楣攁ୂ畮摬攭乡浥Ď䥭灯牴ⵐ慣歡来Ď剥煵楲攭䉵湤汥<EFBFBD>
|
||||
牯潴䝲潵灳Ď牯潴䝲潵灳䱩獴ဉ慬汇牯異猁ൡ汬䝲潵灳䱩獴<EFBFBD>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -51,7 +51,7 @@
|
||||
* all performed by this executor. Add and update artifact in index tasks are added in the indexing task queue by the
|
||||
* NexusIndexerConsumer while remove artifact from index tasks are added by the LuceneCleanupRemoveIndexedConsumer.
|
||||
*/
|
||||
@Service ( "taskExecutor#indexing" )
|
||||
@Service( "taskExecutor#indexing" )
|
||||
public class ArchivaIndexingTaskExecutor
|
||||
implements TaskExecutor
|
||||
{
|
||||
@ -112,9 +112,10 @@ public void executeTask( Task task )
|
||||
{
|
||||
try
|
||||
{
|
||||
log.debug( "Creating indexing context on resource: {}", ( indexingTask.getResourceFile() == null
|
||||
? "none"
|
||||
: indexingTask.getResourceFile().getPath() ) );
|
||||
log.debug( "Creating indexing context on resource: {}", //
|
||||
( indexingTask.getResourceFile() == null
|
||||
? "none"
|
||||
: indexingTask.getResourceFile().getPath() ) );
|
||||
context = managedRepositoryAdmin.createIndexContext( repository );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
@ -233,8 +234,10 @@ private void finishIndexingTask( ArtifactIndexingTask indexingTask, ManagedRepos
|
||||
{
|
||||
|
||||
IndexPackingRequest request = new IndexPackingRequest( context, //
|
||||
context.acquireIndexSearcher().getIndexReader(), //
|
||||
context.acquireIndexSearcher().getIndexReader(),
|
||||
//
|
||||
context.getIndexDirectoryFile() );
|
||||
|
||||
indexPacker.packIndex( request );
|
||||
context.updateTimestamp( true );
|
||||
|
||||
|
@ -20,8 +20,8 @@
|
||||
*/
|
||||
|
||||
import org.apache.archiva.admin.model.beans.ManagedRepository;
|
||||
import org.apache.maven.index.context.IndexingContext;
|
||||
import org.apache.archiva.redback.components.taskqueue.Task;
|
||||
import org.apache.maven.index.context.IndexingContext;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@ -79,8 +79,14 @@ public boolean isExecuteOnEntireRepo()
|
||||
}
|
||||
|
||||
public void setExecuteOnEntireRepo( boolean executeOnEntireRepo )
|
||||
{
|
||||
this.executeOnEntireRepo( executeOnEntireRepo );
|
||||
}
|
||||
|
||||
public ArtifactIndexingTask executeOnEntireRepo( boolean executeOnEntireRepo )
|
||||
{
|
||||
this.executeOnEntireRepo = executeOnEntireRepo;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,7 +57,7 @@
|
||||
* @author Olivier Lamy
|
||||
* @since 1.4-M1
|
||||
*/
|
||||
@Service ("downloadRemoteIndexScheduler#default")
|
||||
@Service( "downloadRemoteIndexScheduler#default" )
|
||||
public class DefaultDownloadRemoteIndexScheduler
|
||||
implements ConfigurationListener, DownloadRemoteIndexScheduler
|
||||
{
|
||||
@ -65,7 +65,7 @@ public class DefaultDownloadRemoteIndexScheduler
|
||||
private Logger log = LoggerFactory.getLogger( getClass() );
|
||||
|
||||
@Inject
|
||||
@Named (value = "taskScheduler#indexDownloadRemote")
|
||||
@Named( value = "taskScheduler#indexDownloadRemote" )
|
||||
private TaskScheduler taskScheduler;
|
||||
|
||||
@Inject
|
||||
@ -83,16 +83,16 @@ public class DefaultDownloadRemoteIndexScheduler
|
||||
@Inject
|
||||
private NetworkProxyAdmin networkProxyAdmin;
|
||||
|
||||
@Inject
|
||||
private PlexusSisuBridge plexusSisuBridge;
|
||||
|
||||
@Inject
|
||||
private MavenIndexerUtils mavenIndexerUtils;
|
||||
|
||||
@Inject
|
||||
private NexusIndexer nexusIndexer;
|
||||
|
||||
@Inject
|
||||
private IndexUpdater indexUpdater;
|
||||
|
||||
@Inject
|
||||
private IndexPacker indexPacker;
|
||||
|
||||
// store ids about currently running remote download : updated in DownloadRemoteIndexTask
|
||||
@ -106,12 +106,6 @@ public void startup()
|
||||
archivaConfiguration.addListener( this );
|
||||
// TODO add indexContexts even if null
|
||||
|
||||
nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
|
||||
|
||||
indexUpdater = plexusSisuBridge.lookup( IndexUpdater.class );
|
||||
|
||||
this.indexPacker = plexusSisuBridge.lookup( IndexPacker.class );
|
||||
|
||||
for ( RemoteRepository remoteRepository : remoteRepositoryAdmin.getRemoteRepositories() )
|
||||
{
|
||||
String contextKey = "remote-" + remoteRepository.getId();
|
||||
@ -180,11 +174,14 @@ public void scheduleDownloadRemote( String repositoryId, boolean now, boolean fu
|
||||
}
|
||||
}
|
||||
|
||||
DownloadRemoteIndexTaskRequest downloadRemoteIndexTaskRequest =
|
||||
new DownloadRemoteIndexTaskRequest().setRemoteRepository( remoteRepository ).setNetworkProxy(
|
||||
networkProxy ).setFullDownload( fullDownload ).setWagonFactory(
|
||||
wagonFactory ).setRemoteRepositoryAdmin( remoteRepositoryAdmin ).setIndexUpdater(
|
||||
indexUpdater ).setIndexPacker( this.indexPacker );
|
||||
DownloadRemoteIndexTaskRequest downloadRemoteIndexTaskRequest = new DownloadRemoteIndexTaskRequest() //
|
||||
.setRemoteRepository( remoteRepository ) //
|
||||
.setNetworkProxy( networkProxy ) //
|
||||
.setFullDownload( fullDownload ) //
|
||||
.setWagonFactory( wagonFactory ) //
|
||||
.setRemoteRepositoryAdmin( remoteRepositoryAdmin ) //
|
||||
.setIndexUpdater( indexUpdater ) //
|
||||
.setIndexPacker( this.indexPacker );
|
||||
|
||||
if ( now )
|
||||
{
|
||||
|
@ -0,0 +1,47 @@
|
||||
package org.apache.archiva.scheduler.indexing;
|
||||
|
||||
/*
|
||||
* 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.IndexingContext;
|
||||
import org.apache.maven.index.shaded.lucene.store.Directory;
|
||||
import org.apache.maven.index.updater.IndexUpdateSideEffect;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Not doing much but required at least one implementation
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
@Service
|
||||
public class DefaultIndexUpdateSideEffect
|
||||
implements IndexUpdateSideEffect
|
||||
{
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger( DefaultIndexUpdateSideEffect.class );
|
||||
|
||||
@Override
|
||||
public void updateIndex( Directory directory, IndexingContext indexingContext, boolean b )
|
||||
{
|
||||
LOGGER.info( "updating index: {} with directory: {}", //
|
||||
indexingContext.getId(), //
|
||||
directory.toString() );
|
||||
}
|
||||
}
|
@ -196,32 +196,7 @@ public void run()
|
||||
indexingContext.updateTimestamp( true );
|
||||
|
||||
}
|
||||
catch ( MalformedURLException e )
|
||||
{
|
||||
log.error( e.getMessage(), e );
|
||||
throw new RuntimeException( e.getMessage(), e );
|
||||
}
|
||||
catch ( WagonFactoryException e )
|
||||
{
|
||||
log.error( e.getMessage(), e );
|
||||
throw new RuntimeException( e.getMessage(), e );
|
||||
}
|
||||
catch ( ConnectionException e )
|
||||
{
|
||||
log.error( e.getMessage(), e );
|
||||
throw new RuntimeException( e.getMessage(), e );
|
||||
}
|
||||
catch ( AuthenticationException e )
|
||||
{
|
||||
log.error( e.getMessage(), e );
|
||||
throw new RuntimeException( e.getMessage(), e );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
log.error( e.getMessage(), e );
|
||||
throw new RuntimeException( e.getMessage(), e );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
catch ( Exception e )
|
||||
{
|
||||
log.error( e.getMessage(), e );
|
||||
throw new RuntimeException( e.getMessage(), e );
|
||||
|
@ -25,10 +25,6 @@
|
||||
import org.apache.archiva.common.plexusbridge.MavenIndexerUtils;
|
||||
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
|
||||
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
|
||||
import org.apache.lucene.search.BooleanClause.Occur;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.TopDocs;
|
||||
import org.apache.maven.index.ArtifactInfo;
|
||||
import org.apache.maven.index.FlatSearchRequest;
|
||||
import org.apache.maven.index.FlatSearchResponse;
|
||||
@ -37,6 +33,12 @@
|
||||
import org.apache.maven.index.context.IndexingContext;
|
||||
import org.apache.maven.index.expr.SourcedSearchExpression;
|
||||
import org.apache.maven.index.expr.StringSearchExpression;
|
||||
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.IndexUpdateRequest;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@ -54,6 +56,7 @@
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Set;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
@ -70,10 +73,8 @@ public class ArchivaIndexingTaskExecutorTest
|
||||
|
||||
private ManagedRepository repositoryConfig;
|
||||
|
||||
private NexusIndexer indexer;
|
||||
|
||||
@Inject
|
||||
PlexusSisuBridge plexusSisuBridge;
|
||||
private NexusIndexer indexer;
|
||||
|
||||
@Inject
|
||||
MavenIndexerUtils mavenIndexerUtils;
|
||||
@ -98,8 +99,6 @@ public void setUp()
|
||||
repositoryConfig.setSnapshots( false );
|
||||
repositoryConfig.setReleases( true );
|
||||
|
||||
indexer = plexusSisuBridge.lookup( NexusIndexer.class );
|
||||
|
||||
managedRepositoryAdmin.createIndexContext( repositoryConfig );
|
||||
}
|
||||
|
||||
@ -147,10 +146,10 @@ public void testAddArtifactToIndex()
|
||||
|
||||
BooleanQuery q = new BooleanQuery();
|
||||
q.add( indexer.constructQuery( MAVEN.GROUP_ID, new StringSearchExpression( "org.apache.archiva" ) ),
|
||||
Occur.SHOULD );
|
||||
BooleanClause.Occur.SHOULD );
|
||||
q.add(
|
||||
indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ),
|
||||
Occur.SHOULD );
|
||||
BooleanClause.Occur.SHOULD );
|
||||
|
||||
if ( !indexer.getIndexingContexts().containsKey( repositoryConfig.getId() ) )
|
||||
{
|
||||
@ -173,9 +172,9 @@ public void testAddArtifactToIndex()
|
||||
Set<ArtifactInfo> results = response.getResults();
|
||||
|
||||
ArtifactInfo artifactInfo = results.iterator().next();
|
||||
assertEquals( "org.apache.archiva", artifactInfo.groupId );
|
||||
assertEquals( "archiva-index-methods-jar-test", artifactInfo.artifactId );
|
||||
assertEquals( "test-repo", artifactInfo.repository );
|
||||
assertEquals( "org.apache.archiva", artifactInfo.getGroupId() );
|
||||
assertEquals( "archiva-index-methods-jar-test", artifactInfo.getArtifactId() );
|
||||
assertEquals( "test-repo", artifactInfo.getRepository() );
|
||||
|
||||
}
|
||||
|
||||
@ -195,10 +194,10 @@ public void testUpdateArtifactInIndex()
|
||||
|
||||
BooleanQuery q = new BooleanQuery();
|
||||
q.add( indexer.constructQuery( MAVEN.GROUP_ID, new StringSearchExpression( "org.apache.archiva" ) ),
|
||||
Occur.SHOULD );
|
||||
BooleanClause.Occur.SHOULD );
|
||||
q.add(
|
||||
indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ),
|
||||
Occur.SHOULD );
|
||||
BooleanClause.Occur.SHOULD );
|
||||
|
||||
IndexingContext ctx = indexer.getIndexingContexts().get( repositoryConfig.getId() );
|
||||
|
||||
@ -231,7 +230,7 @@ public void testRemoveArtifactFromIndex()
|
||||
|
||||
BooleanQuery q = new BooleanQuery();
|
||||
q.add( indexer.constructQuery( MAVEN.GROUP_ID, new SourcedSearchExpression( "org.apache.archiva" ) ),
|
||||
Occur.SHOULD );
|
||||
BooleanClause.Occur.SHOULD );
|
||||
//q.add(
|
||||
// indexer.constructQuery( MAVEN.ARTIFACT_ID, new SourcedSearchExpression( "archiva-index-methods-jar-test" ) ),
|
||||
// Occur.SHOULD );
|
||||
@ -258,9 +257,10 @@ public void testRemoveArtifactFromIndex()
|
||||
|
||||
q = new BooleanQuery();
|
||||
q.add( indexer.constructQuery( MAVEN.GROUP_ID, new SourcedSearchExpression( "org.apache.archiva" ) ),
|
||||
Occur.SHOULD );
|
||||
BooleanClause.Occur.SHOULD );
|
||||
q.add( indexer.constructQuery( MAVEN.ARTIFACT_ID,
|
||||
new SourcedSearchExpression( "archiva-index-methods-jar-test" ) ), Occur.SHOULD
|
||||
new SourcedSearchExpression( "archiva-index-methods-jar-test" ) ),
|
||||
BooleanClause.Occur.SHOULD
|
||||
);
|
||||
|
||||
assertTrue( new File( repositoryConfig.getLocation(), ".indexer" ).exists() );
|
||||
@ -315,20 +315,26 @@ public boolean accept( File file, String s )
|
||||
assertTrue( indexerDirectory.exists() );
|
||||
|
||||
// test packed index file creation
|
||||
assertTrue( new File( indexerDirectory, "nexus-maven-repository-index.zip" ).exists() );
|
||||
assertTrue( new File( indexerDirectory, "nexus-maven-repository-index.properties" ).exists() );
|
||||
assertTrue( new File( indexerDirectory, "nexus-maven-repository-index.gz" ).exists() );
|
||||
//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();
|
||||
|
||||
// unpack .zip index
|
||||
File destDir = new File( repositoryConfig.getLocation(), ".indexer/tmp" );
|
||||
unzipIndex( indexerDirectory.getPath(), destDir.getPath() );
|
||||
|
||||
TrackingFetcher fetcher = new TrackingFetcher( remoteRepo );
|
||||
updateRequest = new IndexUpdateRequest( testContext, fetcher );
|
||||
updateRequest.setLocalIndexCacheDir( localCacheDir );
|
||||
updater.fetchAndUpdateIndex( updateRequest );
|
||||
|
||||
BooleanQuery q = new BooleanQuery();
|
||||
q.add( indexer.constructQuery( MAVEN.GROUP_ID, new StringSearchExpression( "org.apache.archiva" ) ),
|
||||
Occur.SHOULD );
|
||||
BooleanClause.Occur.SHOULD );
|
||||
q.add(
|
||||
indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ),
|
||||
Occur.SHOULD );
|
||||
BooleanClause.Occur.SHOULD );
|
||||
|
||||
FlatSearchRequest request = new FlatSearchRequest( q, getIndexingContext() );
|
||||
FlatSearchResponse response = indexer.searchFlat( request );
|
||||
@ -336,42 +342,11 @@ public boolean accept( File file, String s )
|
||||
Set<ArtifactInfo> results = response.getResults();
|
||||
|
||||
ArtifactInfo artifactInfo = results.iterator().next();
|
||||
assertEquals( "org.apache.archiva", artifactInfo.groupId );
|
||||
assertEquals( "archiva-index-methods-jar-test", artifactInfo.artifactId );
|
||||
assertEquals( "test-repo", artifactInfo.repository );
|
||||
assertEquals( "org.apache.archiva", artifactInfo.getGroupId() );
|
||||
assertEquals( "archiva-index-methods-jar-test", artifactInfo.getArtifactId() );
|
||||
assertEquals( "test-repo", artifactInfo.getRepository() );
|
||||
|
||||
assertEquals( 1, response.getTotalHits() );
|
||||
}
|
||||
|
||||
private void unzipIndex( String indexDir, String destDir )
|
||||
throws IOException
|
||||
{
|
||||
final int buff = 2048;
|
||||
|
||||
Files.createDirectories( Paths.get( destDir ) );
|
||||
|
||||
try (InputStream fin = Files.newInputStream( Paths.get( indexDir, "nexus-maven-repository-index.zip" ) ))
|
||||
{
|
||||
ZipInputStream in = new ZipInputStream( new BufferedInputStream( fin ) );
|
||||
ZipEntry entry;
|
||||
|
||||
while ( ( entry = in.getNextEntry() ) != null )
|
||||
{
|
||||
int count;
|
||||
byte data[] = new byte[buff];
|
||||
try (OutputStream fout = Files.newOutputStream( Paths.get( destDir, entry.getName() ) ))
|
||||
{
|
||||
try (BufferedOutputStream out = new BufferedOutputStream( fout, buff ))
|
||||
{
|
||||
|
||||
while ( ( count = in.read( data, 0, buff ) ) != -1 )
|
||||
{
|
||||
out.write( data, 0, count );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,13 +23,13 @@
|
||||
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
|
||||
import org.apache.archiva.common.utils.FileUtil;
|
||||
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
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.expr.StringSearchExpression;
|
||||
import org.apache.maven.index.shaded.lucene.search.BooleanClause;
|
||||
import org.apache.maven.index.shaded.lucene.search.BooleanQuery;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
@ -75,8 +75,6 @@ public class DownloadRemoteIndexTaskTest
|
||||
DefaultDownloadRemoteIndexScheduler downloadRemoteIndexScheduler;
|
||||
|
||||
@Inject
|
||||
PlexusSisuBridge plexusSisuBridge;
|
||||
|
||||
NexusIndexer nexusIndexer;
|
||||
|
||||
@Before
|
||||
@ -90,7 +88,6 @@ public void initialize()
|
||||
this.server.start();
|
||||
this.port = serverConnector.getLocalPort();
|
||||
log.info( "start server on port {}", this.port );
|
||||
nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
|
||||
}
|
||||
|
||||
protected void createContext( Server server, File repositoryDirectory )
|
||||
|
@ -53,8 +53,6 @@ public class ArchivaStartup
|
||||
|
||||
private DefaultRepositoryArchivaTaskScheduler repositoryTaskScheduler;
|
||||
|
||||
private PlexusSisuBridge plexusSisuBridge;
|
||||
|
||||
private NexusIndexer nexusIndexer;
|
||||
|
||||
@Override
|
||||
@ -74,16 +72,8 @@ public void contextInitialized( ServletContextEvent contextEvent )
|
||||
|
||||
tqeIndexing = wac.getBean( "taskQueueExecutor#indexing", ThreadedTaskQueueExecutor.class );
|
||||
|
||||
plexusSisuBridge = wac.getBean( PlexusSisuBridge.class );
|
||||
nexusIndexer = wac.getBean( NexusIndexer.class );
|
||||
|
||||
try
|
||||
{
|
||||
nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
|
||||
}
|
||||
catch ( PlexusSisuBridgeException e )
|
||||
{
|
||||
throw new RuntimeException( "Unable to get NexusIndexer: " + e.getMessage(), e );
|
||||
}
|
||||
try
|
||||
{
|
||||
securitySync.startup();
|
||||
|
@ -102,6 +102,10 @@
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jackrabbit</groupId>
|
||||
<artifactId>jackrabbit-webdav</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
|
@ -277,7 +277,7 @@
|
||||
<executions>
|
||||
<execution>
|
||||
<id>test-repository</id>
|
||||
<phase>generate-test-resources</phase>
|
||||
<phase>process-test-classes</phase>
|
||||
<goals>
|
||||
<goal>unpack-dependencies</goal>
|
||||
</goals>
|
||||
|
@ -28,9 +28,6 @@
|
||||
<artifactId>metadata-store-jcr</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<name>Archiva Core Plugins :: JCR Storage for Metadata</name>
|
||||
<properties>
|
||||
<jcr-oak.version>1.7.2</jcr-oak.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
@ -65,12 +62,10 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.jackrabbit</groupId>
|
||||
<artifactId>oak-jcr</artifactId>
|
||||
<version>${jcr-oak.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jackrabbit</groupId>
|
||||
<artifactId>oak-segment-tar</artifactId>
|
||||
<version>${jcr-oak.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jackrabbit</groupId>
|
||||
@ -124,6 +119,7 @@
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.lucene</groupId>
|
||||
<artifactId>lucene-core</artifactId>
|
||||
@ -169,6 +165,7 @@
|
||||
<artifactId>lucene-analyzers-common</artifactId>
|
||||
<version>${lucene.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<testResources>
|
||||
|
@ -36,6 +36,8 @@
|
||||
import javax.inject.Inject;
|
||||
import javax.jcr.Repository;
|
||||
import javax.jcr.RepositoryException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -54,7 +56,6 @@ public class JcrRepositorySessionFactory
|
||||
|
||||
private Map<String, MetadataFacetFactory> metadataFacetFactories;
|
||||
|
||||
@Inject
|
||||
private Repository repository;
|
||||
|
||||
// Lazy evaluation to avoid problems with circular dependencies during initialization
|
||||
@ -123,6 +124,11 @@ public void initialize()
|
||||
JcrMetadataRepository metadataRepository = null;
|
||||
try
|
||||
{
|
||||
RepositoryFactory factory = new RepositoryFactory();
|
||||
// FIXME this need to be configurable
|
||||
Path directoryPath = Paths.get(System.getProperty( "appserver.base" ), "data/jcr");
|
||||
factory.setRepositoryPath( directoryPath );
|
||||
repository = factory.createRepository();
|
||||
metadataRepository = new JcrMetadataRepository( metadataFacetFactories, repository );
|
||||
JcrMetadataRepository.initialize( metadataRepository.getJcrSession() );
|
||||
}
|
||||
|
@ -19,8 +19,8 @@
|
||||
-->
|
||||
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
|
||||
</beans>
|
34
pom.xml
34
pom.xml
@ -77,7 +77,9 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<surefire.redirectTestOutputToFile>true</surefire.redirectTestOutputToFile>
|
||||
<lucene.version>4.10.4</lucene.version>
|
||||
<jackrabbit.version>2.14.1</jackrabbit.version>
|
||||
|
||||
<jcr-oak.version>1.7.2</jcr-oak.version>
|
||||
<jackrabbit.version>2.15.4</jackrabbit.version>
|
||||
|
||||
<cxf.version>3.0.3</cxf.version>
|
||||
<derbyVersion>10.13.1.1</derbyVersion>
|
||||
@ -285,6 +287,36 @@
|
||||
<artifactId>archiva-indexer</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jackrabbit</groupId>
|
||||
<artifactId>oak-jcr</artifactId>
|
||||
<version>${jcr-oak.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jackrabbit</groupId>
|
||||
<artifactId>oak-segment-tar</artifactId>
|
||||
<version>${jcr-oak.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jackrabbit</groupId>
|
||||
<artifactId>oak-lucene</artifactId>
|
||||
<version>${jcr-oak.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.lucene</groupId>
|
||||
<artifactId>lucene-misc</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.lucene</groupId>
|
||||
<artifactId>lucene-facet</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jackrabbit</groupId>
|
||||
<artifactId>jackrabbit-webdav</artifactId>
|
||||
<version>${jackrabbit.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.indexer</groupId>
|
||||
<artifactId>indexer-reader</artifactId>
|
||||
|
Loading…
x
Reference in New Issue
Block a user