diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java index e36547142..267796f08 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java @@ -24,9 +24,9 @@ import org.apache.archiva.admin.model.managed.ManagedRepository; import org.apache.archiva.common.plexusbridge.MavenIndexerUtils; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; +import org.apache.commons.lang.StringUtils; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; -import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.index.ArtifactContext; import org.apache.maven.index.ArtifactContextProducer; import org.apache.maven.index.DefaultArtifactContextProducer; @@ -58,7 +58,6 @@ import java.util.List; * ArchivaIndexingTaskExecutor Executes all indexing tasks. Adding, updating and removing artifacts from the index are * 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" ) public class ArchivaIndexingTaskExecutor @@ -239,9 +238,11 @@ public class ArchivaIndexingTaskExecutor context.optimize(); - File managedRepository = new File( repository.getLocation() ); - final File indexLocation = new File( managedRepository, ".index" ); + String indexDirectory = repository.getIndexDirectory(); + final File indexLocation = StringUtils.isBlank( indexDirectory ) + ? new File( managedRepository, ".indexer" ) + : new File( indexDirectory ); IndexPackingRequest request = new IndexPackingRequest( context, indexLocation ); indexPacker.packIndex( request ); 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 86e164ab9..e3e347491 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 @@ -253,7 +253,7 @@ public class ArchivaIndexingTaskExecutorTest Occur.SHOULD ); assertTrue( new File( repositoryConfig.getLocation(), ".indexer" ).exists() ); - assertTrue( new File( repositoryConfig.getLocation(), ".index" ).exists() ); + assertFalse( new File( repositoryConfig.getLocation(), ".index" ).exists() ); flatSearchRequest = new FlatSearchRequest( q, getIndexingContext() ); @@ -286,11 +286,10 @@ public class ArchivaIndexingTaskExecutorTest indexingExecutor.executeTask( task ); assertTrue( new File( repositoryConfig.getLocation(), ".indexer" ).exists() ); - assertTrue( new File( repositoryConfig.getLocation(), ".index" ).exists() ); // unpack .zip index - File destDir = new File( repositoryConfig.getLocation(), ".index/tmp" ); - unzipIndex( new File( repositoryConfig.getLocation(), ".index" ).getPath(), destDir.getPath() ); + File destDir = new File( repositoryConfig.getLocation(), ".indexer/tmp" ); + unzipIndex( new File( repositoryConfig.getLocation(), ".indexer" ).getPath(), destDir.getPath() ); 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/pom.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml index bc7122715..908e8b66e 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml @@ -248,7 +248,6 @@ ${project.build.outputDirectory} ${basedir}/target/appserver-base - ${basedir}/target/ diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java index f04cd335e..0e9f5aaa2 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java @@ -23,7 +23,6 @@ import org.apache.archiva.rest.api.model.ManagedRepository; import org.apache.archiva.rest.api.model.SearchRequest; import org.apache.archiva.rest.api.services.ManagedRepositoriesService; import org.apache.archiva.rest.api.services.SearchService; -import org.apache.commons.io.FileUtils; import org.junit.Test; import java.io.File; @@ -146,7 +145,6 @@ public class SearchServiceTest assertTrue( " not 1 results for Bundle Symbolic Name org.apache.karaf.features.command but " + artifacts.size() + ":" + artifacts, artifacts.size() == 1 ); - log.info( "artifacts for commons-logging size {} search {}", artifacts.size(), artifacts ); deleteTestRepo( testRepoId, targetRepo ); } @@ -176,7 +174,34 @@ public class SearchServiceTest assertTrue( " not 2 results for Bundle Symbolic Name org.apache.karaf.features.core but " + artifacts.size() + ":" + artifacts, artifacts.size() == 2 ); - log.info( "artifacts for commons-logging size {} search {}", artifacts.size(), artifacts ); + + deleteTestRepo( testRepoId, targetRepo ); + } + + @Test + public void searchWithSearchRequestExportPackageOneVersion() + throws Exception + { + + String testRepoId = "test-repo"; + // force guest user creation if not exists + if ( getUserService( authorizationHeader ).getGuestUser() == null ) + { + assertNotNull( getUserService( authorizationHeader ).createGuestUser() ); + } + + File targetRepo = createAndIndexRepo( testRepoId ); + + SearchService searchService = getSearchService( authorizationHeader ); + + SearchRequest searchRequest = new SearchRequest(); + searchRequest.setBundleExportPackage( "org.apache.karaf.features.command.completers" ); + + List artifacts = searchService.searchArtifacts( searchRequest ); + + assertNotNull( artifacts ); + assertTrue( " not 1 results for Bundle ExportPackage org.apache.karaf.features.command.completers but " + + artifacts.size() + ":" + artifacts, artifacts.size() == 1 ); deleteTestRepo( testRepoId, targetRepo ); } @@ -188,19 +213,14 @@ public class SearchServiceTest { getManagedRepositoriesService( authorizationHeader ).deleteManagedRepository( testRepoId, true ); } - File targetRepo = new File( System.getProperty( "targetDir", "./target" ), "test-repo" ); - cleanupFiles( targetRepo ); - - File sourceRepo = new File( "src/test/repo-with-osgi" ); - - FileUtils.copyDirectory( sourceRepo, targetRepo ); + File targetRepo = new File( "src/test/repo-with-osgi" ); ManagedRepository managedRepository = new ManagedRepository(); managedRepository.setId( testRepoId ); managedRepository.setName( "test repo" ); managedRepository.setLocation( targetRepo.getPath() ); - managedRepository.setIndexDirectory( targetRepo.getPath() + "/index-" + Long.toString( new Date().getTime() ) ); + managedRepository.setIndexDirectory( "target/.index-" + Long.toString( new Date().getTime() ) ); ManagedRepositoriesService service = getManagedRepositoriesService( authorizationHeader ); service.addManagedRepository( managedRepository ); @@ -215,38 +235,11 @@ public class SearchServiceTest { if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( id ) != null ) { - getManagedRepositoriesService( authorizationHeader ).deleteManagedRepository( id, true ); + getManagedRepositoriesService( authorizationHeader ).deleteManagedRepository( id, false ); } - cleanupFiles( targetRepo ); } - private void cleanupFiles( File targetRepo ) - throws Exception - { - - File indexerDir = new File( targetRepo, ".indexer" ); - - if ( targetRepo.exists() ) - { - FileUtils.deleteDirectory( targetRepo ); - } - - if ( indexerDir.exists() ) - { - FileUtils.deleteDirectory( indexerDir ); - } - - File lockFile = new File( indexerDir, "write.lock" ); - if ( lockFile.exists() ) - { - FileUtils.forceDelete( lockFile ); - } - - assertFalse( targetRepo.exists() ); - assertFalse( indexerDir.exists() ); - assertFalse( lockFile.exists() ); - } }