]> source.dussan.org Git - archiva.git/commitdiff
[MRM-749]
authorMaria Odea B. Ching <oching@apache.org>
Tue, 3 Feb 2009 09:28:37 +0000 (09:28 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Tue, 3 Feb 2009 09:28:37 +0000 (09:28 +0000)
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

archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImpl.java
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java

index 58c3b69b794f6635f44119420b24593017a03b4a..f640639d88375e0e9ccaf8708ea80f5cd48e0049 100644 (file)
   </bean> 
   
   <!-- Web Services : Search Service -->
-  <bean name="searchService" lazy-init="true" scope="singleton" class="org.apache.archiva.web.xmlrpc.services.SearchServiceImpl">
-    <!--  
-    <constructor-arg ref="archivaConfiguration"/>
-    <constructor-arg ref="repositoryContentFactory"/>
-     -->
-    <constructor-arg ref="xmlRpcUserRepositories"/>    
-    <constructor-arg ref="crossRepositorySearch"/>
+  <bean name="searchService" lazy-init="true" scope="singleton" class="org.apache.archiva.web.xmlrpc.services.SearchServiceImpl">    
+    <constructor-arg ref="xmlRpcUserRepositories"/>   
     <constructor-arg ref="archivaDAO#jdo"/>
     <constructor-arg ref="repositoryBrowsing"/>
+    <constructor-arg ref="nexusSearch"/>
   </bean>
   
   <!-- Web Services : Administration Service -->
index 914d2732c49347facfbfc1855650a9a4457e6a4b..fc9c24f9a1e797885399941ae2b8b668f2e7671b 100644 (file)
@@ -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<SearchResultHit> hits = results.getHits();
         for( SearchResultHit hit : hits )
         {   
index 2db1b931ce709aff092e16664e655718d46efcaa..5f1d937b3e7c1bcfc83b7aa710b6014f912a933d 100644 (file)
@@ -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<Artifact> 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<Artifact> artifacts = searchService.quickSearch( "archiva" );
         
         userReposControl.verify();
-        crossRepoSearchControl.verify();  
+        searchControl.verify();
         archivaDAOControl.verify();
         artifactDAOControl.verify();