[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
This commit is contained in:
Maria Odea B. Ching 2009-02-03 09:28:37 +00:00
parent 5e02d4b9da
commit 61859a5535
3 changed files with 27 additions and 66 deletions

View File

@ -39,15 +39,11 @@
</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 -->

View 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 )
{

View 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();