]> source.dussan.org Git - archiva.git/commitdiff
[MRM-933]
authorMaria Odea B. Ching <oching@apache.org>
Wed, 4 Feb 2009 02:16:11 +0000 (02:16 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Wed, 4 Feb 2009 02:16:11 +0000 (02:16 +0000)
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

archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java

index 75ddecc1115952d4fe3772b020fc54206aff201a..f4646a96cad89c493e6cf3748a6bee16ed09908c 100644 (file)
@@ -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;
     }
index 94967ed813fde499988bf47d02de0ddd937c67ff..1b55c8e10eaace4290a90ae996c9dae5ad1ff19d 100644 (file)
@@ -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()
index 8d591191544430201bbcb24b088d8bc49d94dd09..a4acd865de84408fdbc8b360edc762a5f6bb6207 100644 (file)
@@ -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 );