From 302186acd1307d56ffa7fa082a7f47e0241a3dbf Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Sun, 24 May 2009 07:20:59 +0000 Subject: [PATCH] [MRM-1167] o fix xmlrpc search service git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@778106 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-xmlrpc-client/pom.xml | 4 +- .../xmlrpc/services/SearchServiceImpl.java | 58 +++++++++++-------- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml index 7c14c38fc..eb8aa0519 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml @@ -63,10 +63,10 @@ org.apache.archiva.web.xmlrpc.client.SampleClient - http://127.0.0.1:9091/xmlrpc + http://127.0.0.1:8080/archiva/xmlrpc admin ${password} 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 b0654dfbb..9cd26bd18 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 @@ -40,6 +40,8 @@ import org.apache.maven.archiva.database.browsing.RepositoryBrowsing; import org.apache.maven.archiva.database.constraints.ArtifactsByChecksumConstraint; import org.apache.maven.archiva.model.ArchivaArtifact; import org.apache.maven.archiva.model.ArchivaProjectModel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * SearchServiceImpl @@ -49,6 +51,8 @@ import org.apache.maven.archiva.model.ArchivaProjectModel; public class SearchServiceImpl implements SearchService { + private Logger log = LoggerFactory.getLogger( SearchServiceImpl.class ); + private RepositorySearch search; private XmlRpcUserRepositories xmlRpcUserRepositories; @@ -89,35 +93,43 @@ public class SearchServiceImpl SearchResults results = null; results = search.search( "", observableRepos, queryString, limits, null ); - + List hits = results.getHits(); + for( SearchResultHit hit : hits ) { ArtifactDAO artifactDAO = archivaDAO.getArtifactDAO(); - try + + List versions = hit.getVersions(); + if( versions != null ) { - ArchivaArtifact pomArtifact = artifactDAO.getArtifact( - hit.getGroupId(), hit.getArtifactId(), hit.getVersion(), "", "pom", hit.getRepositoryId() ); - - if( pomArtifact != null ) - { - Artifact artifact = new Artifact( pomArtifact.getModel().getRepositoryId(), pomArtifact.getGroupId(), pomArtifact.getArtifactId(), pomArtifact.getVersion(), - pomArtifact.getType() ); - //pomArtifact.getType(), pomArtifact.getModel().getWhenGathered() ); - artifacts.add( artifact ); + for( String version : versions ) + { + for( String repo : observableRepos ) + { + try + { + ArchivaArtifact pomArtifact = artifactDAO.getArtifact( + hit.getGroupId(), hit.getArtifactId(), version, null, "pom", repo ); + if( pomArtifact != null ) + { + Artifact artifact = new Artifact( pomArtifact.getModel().getRepositoryId(), pomArtifact.getGroupId(), pomArtifact.getArtifactId(), pomArtifact.getVersion(), + pomArtifact.getType() ); + //pomArtifact.getType(), pomArtifact.getModel().getWhenGathered() ); + artifacts.add( artifact ); + break; + } + } + catch( ObjectNotFoundException e ) + { + log.debug( "Unable to find pom artifact : " + e.getMessage() ); + } + catch( ArchivaDatabaseException e ) + { + log.debug( "Error occurred while getting pom artifact from database : " + e.getMessage() ); + } + } } - else - { - continue; - } - } - catch ( ObjectNotFoundException e ) - { - continue; - } - catch ( ArchivaDatabaseException e ) - { - continue; } }