From: Maria Odea B. Ching Date: Tue, 3 Feb 2009 09:28:37 +0000 (+0000) Subject: [MRM-749] X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=61859a5535ceb80f974b674396ce8a84d217917b;p=archiva.git [MRM-749] o use nexus search impl in xmlrpc search service git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-nexus-indexer@740257 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml index 58c3b69b7..f640639d8 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml @@ -39,15 +39,11 @@ - - - - + + + diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImpl.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImpl.java index 914d2732c..fc9c24f9a 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImpl.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImpl.java @@ -23,7 +23,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import org.apache.archiva.indexer.util.SearchUtil; +import org.apache.archiva.indexer.search.RepositorySearch; import org.apache.archiva.web.xmlrpc.api.SearchService; import org.apache.archiva.web.xmlrpc.api.beans.Artifact; import org.apache.archiva.web.xmlrpc.api.beans.Dependency; @@ -34,7 +34,6 @@ import org.apache.maven.archiva.database.ObjectNotFoundException; import org.apache.maven.archiva.database.browsing.BrowsingResults; import org.apache.maven.archiva.database.browsing.RepositoryBrowsing; import org.apache.maven.archiva.database.constraints.ArtifactsByChecksumConstraint; -import org.apache.maven.archiva.indexer.search.CrossRepositorySearch; import org.apache.maven.archiva.indexer.search.SearchResultHit; import org.apache.maven.archiva.indexer.search.SearchResultLimits; import org.apache.maven.archiva.indexer.search.SearchResults; @@ -49,8 +48,7 @@ import org.apache.maven.archiva.model.ArchivaProjectModel; public class SearchServiceImpl implements SearchService { - - private CrossRepositorySearch crossRepoSearch; + private RepositorySearch search; private XmlRpcUserRepositories xmlRpcUserRepositories; @@ -58,13 +56,13 @@ public class SearchServiceImpl private RepositoryBrowsing repoBrowsing; - public SearchServiceImpl( XmlRpcUserRepositories xmlRpcUserRepositories, CrossRepositorySearch crossRepoSearch, - ArchivaDAO archivaDAO, RepositoryBrowsing repoBrowsing ) + public SearchServiceImpl( XmlRpcUserRepositories xmlRpcUserRepositories, ArchivaDAO archivaDAO, + RepositoryBrowsing repoBrowsing, RepositorySearch search ) { this.xmlRpcUserRepositories = xmlRpcUserRepositories; - this.crossRepoSearch = crossRepoSearch; this.archivaDAO = archivaDAO; this.repoBrowsing = repoBrowsing; + this.search = search; } /* @@ -89,15 +87,8 @@ public class SearchServiceImpl SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES ); SearchResults results = null; - if( SearchUtil.isBytecodeSearch( queryString ) ) - { - results = crossRepoSearch.searchForBytecode( "", observableRepos, SearchUtil.removeBytecodeKeyword( queryString ), limits ); - } - else - { - results = crossRepoSearch.searchForTerm( "", observableRepos, queryString, limits ); - } - + results = search.search( "", observableRepos, queryString, limits, null ); + List hits = results.getHits(); for( SearchResultHit hit : hits ) { diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java index 2db1b931c..5f1d937b3 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java @@ -20,20 +20,15 @@ package org.apache.archiva.web.xmlrpc.services; */ -import java.io.File; import java.util.ArrayList; import java.util.Date; import java.util.List; +import org.apache.archiva.indexer.search.RepositorySearch; import org.apache.archiva.web.xmlrpc.api.SearchService; import org.apache.archiva.web.xmlrpc.api.beans.Artifact; import org.apache.archiva.web.xmlrpc.api.beans.Dependency; -import org.apache.archiva.web.xmlrpc.security.XmlRpcAuthenticator; import org.apache.archiva.web.xmlrpc.security.XmlRpcUserRepositories; -import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.configuration.Configuration; -import org.apache.maven.archiva.configuration.FileTypes; -import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.database.ArchivaDAO; import org.apache.maven.archiva.database.ArtifactDAO; import org.apache.maven.archiva.database.ObjectNotFoundException; @@ -41,33 +36,14 @@ import org.apache.maven.archiva.database.browsing.BrowsingResults; import org.apache.maven.archiva.database.browsing.RepositoryBrowsing; import org.apache.maven.archiva.database.constraints.ArtifactsByChecksumConstraint; import org.apache.maven.archiva.indexer.filecontent.FileContentRecord; -import org.apache.maven.archiva.indexer.lucene.LuceneRepositoryContentRecord; -import org.apache.maven.archiva.indexer.search.CrossRepositorySearch; import org.apache.maven.archiva.indexer.search.SearchResultLimits; import org.apache.maven.archiva.indexer.search.SearchResults; import org.apache.maven.archiva.model.ArchivaArtifact; -import org.apache.maven.archiva.model.ArchivaArtifactModel; import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.ArtifactReference; -import org.apache.maven.archiva.repository.ManagedRepositoryContent; -import org.apache.maven.archiva.repository.RepositoryContentFactory; -import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent; -import org.apache.maven.archiva.repository.content.PathParser; -import org.apache.maven.archiva.security.ArchivaRoleConstants; -import org.apache.xmlrpc.XmlRpcRequest; -import org.apache.xmlrpc.common.XmlRpcHttpRequestConfigImpl; -import org.codehaus.plexus.redback.role.RoleManager; -import org.codehaus.plexus.redback.system.SecuritySystem; -import org.codehaus.plexus.redback.users.User; -import org.codehaus.plexus.redback.users.UserManager; -import org.codehaus.plexus.redback.users.UserNotFoundException; import org.codehaus.plexus.spring.PlexusInSpringTestCase; -import org.easymock.ArgumentsMatcher; import org.easymock.MockControl; import org.easymock.classextension.MockClassControl; -import sun.security.action.GetLongAction; - /** * SearchServiceImplTest * @@ -82,10 +58,10 @@ public class SearchServiceImplTest private XmlRpcUserRepositories userRepos; - private MockControl crossRepoSearchControl; - - private CrossRepositorySearch crossRepoSearch; + private MockControl searchControl; + private RepositorySearch search; + private MockControl archivaDAOControl; private ArchivaDAO archivaDAO; @@ -103,17 +79,17 @@ public class SearchServiceImplTest { userReposControl = MockClassControl.createControl( XmlRpcUserRepositories.class ); userRepos = ( XmlRpcUserRepositories ) userReposControl.getMock(); - - crossRepoSearchControl = MockControl.createControl( CrossRepositorySearch.class ); - crossRepoSearch = ( CrossRepositorySearch ) crossRepoSearchControl.getMock(); - + archivaDAOControl = MockControl.createControl( ArchivaDAO.class ); archivaDAO = ( ArchivaDAO ) archivaDAOControl.getMock(); repoBrowsingControl = MockControl.createControl( RepositoryBrowsing.class ); repoBrowsing = ( RepositoryBrowsing ) repoBrowsingControl.getMock(); - searchService = new SearchServiceImpl( userRepos, crossRepoSearch, archivaDAO, repoBrowsing ); + searchControl = MockControl.createControl( RepositorySearch.class ); + search = ( RepositorySearch ) searchControl.getMock(); + + searchService = new SearchServiceImpl( userRepos, archivaDAO, repoBrowsing, search ); artifactDAOControl = MockControl.createControl( ArtifactDAO.class ); artifactDAO = ( ArtifactDAO ) artifactDAOControl.getMock(); @@ -158,21 +134,20 @@ public class SearchServiceImplTest SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES ); - crossRepoSearchControl.expectAndDefaultReturn( - crossRepoSearch.searchForBytecode( "", observableRepoIds, "MyClassName", limits ), results ); - + searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "MyClassName", limits, null ), results ); + archivaDAOControl.expectAndReturn( archivaDAO.getArtifactDAO(), artifactDAO ); artifactDAOControl.expectAndReturn( artifactDAO.getArtifact( "org.apache.archiva", "archiva-test", "1.0", "", "pom" ), artifact ); userReposControl.replay(); - crossRepoSearchControl.replay(); + searchControl.replay(); archivaDAOControl.replay(); artifactDAOControl.replay(); List artifacts = searchService.quickSearch( "bytecode:MyClassName" ); userReposControl.verify(); - crossRepoSearchControl.verify(); + searchControl.verify(); archivaDAOControl.verify(); artifactDAOControl.verify(); @@ -203,21 +178,20 @@ public class SearchServiceImplTest SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES ); - crossRepoSearchControl.expectAndDefaultReturn( - crossRepoSearch.searchForTerm( "", observableRepoIds, "archiva", limits ), results ); - + searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ), results ); + archivaDAOControl.expectAndReturn( archivaDAO.getArtifactDAO(), artifactDAO ); artifactDAOControl.expectAndReturn( artifactDAO.getArtifact( "org.apache.archiva", "archiva-test", "1.0", "", "pom" ), artifact ); userReposControl.replay(); - crossRepoSearchControl.replay(); + searchControl.replay(); archivaDAOControl.replay(); artifactDAOControl.replay(); List artifacts = searchService.quickSearch( "archiva" ); userReposControl.verify(); - crossRepoSearchControl.verify(); + searchControl.verify(); archivaDAOControl.verify(); artifactDAOControl.verify();