From: Maria Odea B. Ching Date: Wed, 4 Feb 2009 02:16:11 +0000 (+0000) Subject: [MRM-933] X-Git-Tag: archiva-1.2~151 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b8f16e0c718a4aeaa529ad54cbd2f623132a8a47;p=archiva.git [MRM-933] o set search result limits of the returned search results git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@740576 13f79535-47bb-0310-9956-ffa450edef68 --- 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 75ddecc11..f4646a96c 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 @@ -151,7 +151,9 @@ public class NexusRepositorySearch if( response == null || response.getTotalHits() == 0 ) { - return new SearchResults(); + SearchResults results = new SearchResults(); + results.setLimits( limits ); + return results; } return convertToSearchResults( response, limits ); @@ -272,6 +274,7 @@ public class NexusRepositorySearch } results.setTotalHits( results.getHitsMap().size() ); + results.setLimits( limits ); if( limits == null || limits.getSelectedPage() == SearchResultLimits.ALL_PAGES ) { @@ -279,13 +282,15 @@ public class NexusRepositorySearch } else { - return paginate( limits, results ); + return paginate( results ); } } - private SearchResults paginate( SearchResultLimits limits, SearchResults results ) + private SearchResults paginate( SearchResults results ) { - SearchResults paginated = new SearchResults(); + SearchResultLimits limits = results.getLimits(); + SearchResults paginated = new SearchResults(); + int fetchCount = limits.getPageSize(); int offset = ( limits.getSelectedPage() * limits.getPageSize() ); @@ -319,6 +324,7 @@ public class NexusRepositorySearch } } paginated.setTotalHits( results.getTotalHits() ); + paginated.setLimits( limits ); return paginated; } diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java index 94967ed81..1b55c8e10 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java @@ -203,6 +203,7 @@ public class NexusRepositorySearchTest assertNotNull( results ); assertEquals( 1, results.getHits().size() ); assertEquals( 2, results.getTotalHits() ); + assertEquals( limits, results.getLimits() ); archivaConfigControl.reset(); @@ -221,6 +222,7 @@ public class NexusRepositorySearchTest assertNotNull( results ); assertEquals( 1, results.getHits().size() ); assertEquals( 2, results.getTotalHits() ); + assertEquals( limits, results.getLimits() ); } public void testArtifactFoundInMultipleRepositories() diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java index 8d5911915..a4acd865d 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java @@ -193,9 +193,8 @@ public class SearchAction } SearchFields searchFields = new SearchFields( groupId, artifactId, version, null, className, selectedRepos ); - - - // TODO: add packaging in the list of fields for advanced search (UI) + + // TODO: add packaging in the list of fields for advanced search (UI)? try { results = getNexusSearch().search( getPrincipal(), searchFields, limits );