From 6eb766e9d96a71fe8c6be5cd5caf6b83078f2c5f Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 17 Nov 2011 21:02:08 +0000 Subject: [PATCH] not return pom artifacts when searching artifacts git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1203364 13f79535-47bb-0310-9956-ffa450edef68 --- .../indexer/search/NexusRepositorySearch.java | 4 +++ .../rest/services/SearchServiceTest.java | 36 ++++++++++++++----- ...802_bug1234_v1_fixedAbugInTheStudioGui.txt | 2 ++ .../5.0.0/release-description-5.0.0.pom | 6 ++++ ...802_bug1234_v1_fixedAbugInTheStudioGui.zip | 0 .../5.0.0/studio-all-update-site-5.0.0.pom | 6 ++++ 6 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/repo-with-classifier-only/org/foo/release-description/5.0.0/release-description-5.0.0-Patch_20110802_bug1234_v1_fixedAbugInTheStudioGui.txt create mode 100644 archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/repo-with-classifier-only/org/foo/release-description/5.0.0/release-description-5.0.0.pom create mode 100644 archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/repo-with-classifier-only/org/foo/studio-all-update-site/5.0.0/studio-all-update-site-5.0.0-Patch_20110802_bug1234_v1_fixedAbugInTheStudioGui.zip create mode 100644 archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/repo-with-classifier-only/org/foo/studio-all-update-site/5.0.0/studio-all-update-site-5.0.0.pom diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java index 0ba4559bd..1f1b1c798 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java @@ -457,6 +457,10 @@ public class NexusRepositorySearch for ( ArtifactInfo artifactInfo : artifactInfos ) { + if ( StringUtils.equalsIgnoreCase( "pom", artifactInfo.fextension ) ) + { + continue; + } String id = SearchUtil.getHitId( artifactInfo.groupId, artifactInfo.artifactId, artifactInfo.classifier, artifactInfo.packaging ); Map hitsMap = results.getHitsMap(); 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 4b60ed0ae..088bf13d7 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 @@ -310,6 +310,34 @@ public class SearchServiceTest deleteTestRepo( testRepoId ); } + @Test + /** + * test we don't return 2 artifacts pom + zip one + */ + public void getSearchArtifactsWithOnlyClassifier() + throws Exception + { + + String testRepoId = "test-repo"; + // force guest user creation if not exists + if ( getUserService( authorizationHeader ).getGuestUser() == null ) + { + assertNotNull( getUserService( authorizationHeader ).createGuestUser() ); + } + + createAndIndexRepo( testRepoId, "src/test/repo-with-classifier-only" ); + + SearchService searchService = getSearchService( authorizationHeader ); + + SearchRequest searchRequest = + new SearchRequest( "org.foo", "studio-all-update-site", null, null, null, Arrays.asList( "test-repo" ) ); + + List artifacts = searchService.searchArtifacts( searchRequest ); + log.info( "artifacts:" + artifacts ); + assertEquals( 1, artifacts.size() ); + deleteTestRepo( testRepoId ); + } + private void createAndIndexRepo( String testRepoId, String repoPath ) throws Exception { @@ -317,13 +345,6 @@ public class SearchServiceTest { getManagedRepositoriesService( authorizationHeader ).deleteManagedRepository( testRepoId, false ); } - //File targetRepo = new File( "target/test-origin-repo" ); - //if ( targetRepo.exists() ) - //{ - // FileUtils.deleteDirectory( targetRepo ); - //} - //assertFalse( targetRepo.exists() ); - //FileUtils.copyDirectory( new File( "src/test/repo-with-osgi" ), targetRepo ); ManagedRepository managedRepository = new ManagedRepository(); managedRepository.setId( testRepoId ); @@ -340,7 +361,6 @@ public class SearchServiceTest getRepositoriesService( authorizationHeader ).scanRepositoryNow( testRepoId, true ); - //return targetRepo; } private void deleteTestRepo( String id ) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/repo-with-classifier-only/org/foo/release-description/5.0.0/release-description-5.0.0-Patch_20110802_bug1234_v1_fixedAbugInTheStudioGui.txt b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/repo-with-classifier-only/org/foo/release-description/5.0.0/release-description-5.0.0-Patch_20110802_bug1234_v1_fixedAbugInTheStudioGui.txt new file mode 100644 index 000000000..a907ec3f4 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/repo-with-classifier-only/org/foo/release-description/5.0.0/release-description-5.0.0-Patch_20110802_bug1234_v1_fixedAbugInTheStudioGui.txt @@ -0,0 +1,2 @@ +foo +bar \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/repo-with-classifier-only/org/foo/release-description/5.0.0/release-description-5.0.0.pom b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/repo-with-classifier-only/org/foo/release-description/5.0.0/release-description-5.0.0.pom new file mode 100644 index 000000000..ec96f650b --- /dev/null +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/repo-with-classifier-only/org/foo/release-description/5.0.0/release-description-5.0.0.pom @@ -0,0 +1,6 @@ + + 4.0.0 + org.foo + release-description + 5.0.0 + \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/repo-with-classifier-only/org/foo/studio-all-update-site/5.0.0/studio-all-update-site-5.0.0-Patch_20110802_bug1234_v1_fixedAbugInTheStudioGui.zip b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/repo-with-classifier-only/org/foo/studio-all-update-site/5.0.0/studio-all-update-site-5.0.0-Patch_20110802_bug1234_v1_fixedAbugInTheStudioGui.zip new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/repo-with-classifier-only/org/foo/studio-all-update-site/5.0.0/studio-all-update-site-5.0.0.pom b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/repo-with-classifier-only/org/foo/studio-all-update-site/5.0.0/studio-all-update-site-5.0.0.pom new file mode 100644 index 000000000..f523e78f3 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/repo-with-classifier-only/org/foo/studio-all-update-site/5.0.0/studio-all-update-site-5.0.0.pom @@ -0,0 +1,6 @@ + + 4.0.0 + org.foo + studio-all-update-site + 5.0.0 + \ No newline at end of file