]> source.dussan.org Git - gitblit.git/commitdiff
Ensure a repository is only searched once
authorJames Moger <james.moger@gitblit.com>
Mon, 5 Oct 2015 12:04:10 +0000 (08:04 -0400)
committerJames Moger <james.moger@gitblit.com>
Mon, 5 Oct 2015 12:04:10 +0000 (08:04 -0400)
src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java

index ec8223183e5538bf24aac1c8bebe364c4b7e4a91..b2fd9037d98b44a94c43c36966cb0a98be35b5e6 100644 (file)
@@ -17,14 +17,16 @@ package com.gitblit.wicket.pages;
 \r
 import java.text.MessageFormat;\r
 import java.util.ArrayList;\r
+import java.util.LinkedHashSet;\r
 import java.util.List;\r
+import java.util.Set;\r
 \r
 import org.apache.wicket.Component;\r
 import org.apache.wicket.PageParameters;\r
 import org.apache.wicket.markup.html.basic.Label;\r
+import org.apache.wicket.markup.html.form.CheckBox;\r
 import org.apache.wicket.markup.html.form.ListMultipleChoice;\r
 import org.apache.wicket.markup.html.form.TextField;\r
-import org.apache.wicket.markup.html.form.CheckBox;\r
 import org.apache.wicket.markup.html.panel.Fragment;\r
 import org.apache.wicket.markup.repeater.Item;\r
 import org.apache.wicket.markup.repeater.data.DataView;\r
@@ -120,12 +122,13 @@ public class LuceneSearchPage extends RootPage {
                }\r
 \r
                // enforce user-accessible repository selections\r
-               ArrayList<String> searchRepositories = new ArrayList<String>();\r
+               Set<String> uniqueRepositories = new LinkedHashSet<String>();\r
                for (String selectedRepository : repositories) {\r
                        if (availableRepositories.contains(selectedRepository)) {\r
-                               searchRepositories.add(selectedRepository);\r
+                               uniqueRepositories.add(selectedRepository);\r
                        }\r
                }\r
+               ArrayList<String> searchRepositories = new ArrayList<String>(uniqueRepositories);\r
 \r
                // search form\r
                final Model<String> queryModel = new Model<String>(query);\r