return name();\r
}\r
}\r
+\r
+ /**\r
+ * Enumeration of the search types.\r
+ */\r
+ public static enum SearchType {\r
+ AUTHOR, COMMITTER, COMMIT;\r
+ \r
+ public static SearchType forName(String name) {\r
+ for (SearchType type : values()) {\r
+ if (type.name().equalsIgnoreCase(name)) {\r
+ return type;\r
+ }\r
+ }\r
+ return COMMIT;\r
+ }\r
+ \r
+ @Override\r
+ public String toString() {\r
+ return name().toLowerCase();\r
+ }\r
+ }\r
}\r
import com.gitblit.models.SyndicatedEntryModel;\r
import com.gitblit.utils.HttpUtils;\r
import com.gitblit.utils.JGitUtils;\r
-import com.gitblit.utils.JGitUtils.SearchType;\r
import com.gitblit.utils.StringUtils;\r
import com.gitblit.utils.SyndicationUtils;\r
\r
String objectId = request.getParameter("h");\r
String l = request.getParameter("l");\r
String searchString = request.getParameter("s");\r
- SearchType searchType = SearchType.COMMIT;\r
+ Constants.SearchType searchType = Constants.SearchType.COMMIT;\r
if (!StringUtils.isEmpty(request.getParameter("st"))) {\r
- SearchType type = SearchType.forName(request.getParameter("st"));\r
+ Constants.SearchType type = Constants.SearchType.forName(request.getParameter("st"));\r
if (type != null) {\r
searchType = type;\r
}\r
return list;\r
}\r
\r
- /**\r
- * Enumeration of the search types.\r
- */\r
- public static enum SearchType {\r
- AUTHOR, COMMITTER, COMMIT;\r
-\r
- public static SearchType forName(String name) {\r
- for (SearchType type : values()) {\r
- if (type.name().equalsIgnoreCase(name)) {\r
- return type;\r
- }\r
- }\r
- return COMMIT;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return name().toLowerCase();\r
- }\r
- }\r
-\r
/**\r
* Search the commit history for a case-insensitive match to the value.\r
* Search results require a specified SearchType of AUTHOR, COMMITTER, or\r
* @return matching list of commits\r
*/\r
public static List<RevCommit> searchRevlogs(Repository repository, String objectId,\r
- String value, final SearchType type, int offset, int maxCount) {\r
+ String value, final com.gitblit.Constants.SearchType type, int offset, int maxCount) {\r
final String lcValue = value.toLowerCase();\r
List<RevCommit> list = new ArrayList<RevCommit>();\r
if (maxCount == 0) {\r
import java.net.URLConnection;\r
import java.text.MessageFormat;\r
import java.util.ArrayList;\r
-import java.util.Arrays;\r
import java.util.List;\r
\r
import com.gitblit.Constants;\r
import com.gitblit.GitBlitException;\r
import com.gitblit.models.SyndicatedEntryModel;\r
-import com.gitblit.utils.JGitUtils.SearchType;\r
import com.sun.syndication.feed.synd.SyndCategory;\r
import com.sun.syndication.feed.synd.SyndCategoryImpl;\r
import com.sun.syndication.feed.synd.SyndContent;\r
* @throws {@link IOException}\r
*/\r
public static List<SyndicatedEntryModel> readSearchFeed(String url, String repository,\r
- String branch, String fragment, SearchType searchType, int numberOfEntries,\r
+ String branch, String fragment, Constants.SearchType searchType, int numberOfEntries,\r
String username, char[] password) throws IOException {\r
// determine parameters\r
List<String> parameters = new ArrayList<String>();\r
import org.wicketstuff.googlecharts.AbstractChartData;\r
import org.wicketstuff.googlecharts.IChartData;\r
\r
+import com.gitblit.Constants;\r
import com.gitblit.Constants.FederationPullStatus;\r
import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
import com.gitblit.models.FederationModel;\r
import com.gitblit.models.Metric;\r
import com.gitblit.utils.HttpUtils;\r
-import com.gitblit.utils.JGitUtils.SearchType;\r
import com.gitblit.utils.StringUtils;\r
import com.gitblit.utils.TimeUtils;\r
\r
}\r
\r
public static PageParameters newSearchParameter(String repositoryName, String commitId,\r
- String search, SearchType type) {\r
+ String search, Constants.SearchType type) {\r
if (StringUtils.isEmpty(commitId)) {\r
return new PageParameters("r=" + repositoryName + ",s=" + search + ",st=" + type.name());\r
}\r
}\r
\r
public static PageParameters newSearchParameter(String repositoryName, String commitId,\r
- String search, SearchType type, int pageNumber) {\r
+ String search, Constants.SearchType type, int pageNumber) {\r
if (StringUtils.isEmpty(commitId)) {\r
return new PageParameters("r=" + repositoryName + ",s=" + search + ",st=" + type.name()\r
+ ",page=" + pageNumber);\r
import org.eclipse.jgit.lib.Repository;\r
import org.eclipse.jgit.revwalk.RevCommit;\r
\r
+import com.gitblit.Constants;\r
import com.gitblit.DownloadZipServlet;\r
import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
import com.gitblit.models.GitNote;\r
import com.gitblit.models.PathModel.PathChangeModel;\r
import com.gitblit.utils.JGitUtils;\r
-import com.gitblit.utils.JGitUtils.SearchType;\r
import com.gitblit.wicket.WicketUtils;\r
import com.gitblit.wicket.panels.CommitHeaderPanel;\r
import com.gitblit.wicket.panels.CommitLegendPanel;\r
addRefs(r, c);\r
\r
// author\r
- add(createPersonPanel("commitAuthor", c.getAuthorIdent(), SearchType.AUTHOR));\r
+ add(createPersonPanel("commitAuthor", c.getAuthorIdent(), Constants.SearchType.AUTHOR));\r
add(WicketUtils.createTimestampLabel("commitAuthorDate", c.getAuthorIdent().getWhen(),\r
getTimeZone()));\r
\r
// committer\r
- add(createPersonPanel("commitCommitter", c.getCommitterIdent(), SearchType.COMMITTER));\r
+ add(createPersonPanel("commitCommitter", c.getCommitterIdent(), Constants.SearchType.COMMITTER));\r
add(WicketUtils.createTimestampLabel("commitCommitterDate",\r
c.getCommitterIdent().getWhen(), getTimeZone()));\r
\r
GitNote entry = item.getModelObject();\r
item.add(new RefsPanel("refName", repositoryName, Arrays.asList(entry.notesRef)));\r
item.add(createPersonPanel("authorName", entry.notesRef.getAuthorIdent(),\r
- SearchType.AUTHOR));\r
+ Constants.SearchType.AUTHOR));\r
item.add(WicketUtils.createTimestampLabel("authorDate", entry.notesRef\r
.getAuthorIdent().getWhen(), getTimeZone()));\r
item.add(new Label("noteContent", GitBlit.self().processCommitMessage(\r
import org.eclipse.jgit.lib.Repository;\r
import org.eclipse.jgit.revwalk.RevCommit;\r
\r
+import com.gitblit.Constants;\r
import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
import com.gitblit.SyndicationServlet;\r
import com.gitblit.models.RepositoryModel;\r
import com.gitblit.utils.JGitUtils;\r
-import com.gitblit.utils.JGitUtils.SearchType;\r
import com.gitblit.utils.StringUtils;\r
import com.gitblit.utils.TicgitUtils;\r
import com.gitblit.wicket.GitBlitWebSession;\r
protected abstract String getPageName();\r
\r
protected Component createPersonPanel(String wicketId, PersonIdent identity,\r
- SearchType searchType) {\r
+ Constants.SearchType searchType) {\r
String name = identity == null ? "" : identity.getName();\r
String address = identity == null ? "" : identity.getEmailAddress();\r
boolean showEmail = GitBlit.getBoolean(Keys.web.showEmailAddresses, false);\r
}\r
}\r
\r
- protected void setPersonSearchTooltip(Component component, String value, SearchType searchType) {\r
- if (searchType.equals(SearchType.AUTHOR)) {\r
+ protected void setPersonSearchTooltip(Component component, String value, Constants.SearchType searchType) {\r
+ if (searchType.equals(Constants.SearchType.AUTHOR)) {\r
WicketUtils.setHtmlTooltip(component, getString("gb.searchForAuthor") + " " + value);\r
- } else if (searchType.equals(SearchType.COMMITTER)) {\r
+ } else if (searchType.equals(Constants.SearchType.COMMITTER)) {\r
WicketUtils.setHtmlTooltip(component, getString("gb.searchForCommitter") + " " + value);\r
}\r
}\r
\r
private final IModel<String> searchBoxModel = new Model<String>("");\r
\r
- private final IModel<SearchType> searchTypeModel = new Model<SearchType>(SearchType.COMMIT);\r
+ private final IModel<Constants.SearchType> searchTypeModel = new Model<Constants.SearchType>(Constants.SearchType.COMMIT);\r
\r
public SearchForm(String id, String repositoryName) {\r
super(id);\r
this.repositoryName = repositoryName;\r
- DropDownChoice<SearchType> searchType = new DropDownChoice<SearchType>("searchType",\r
- Arrays.asList(SearchType.values()));\r
+ DropDownChoice<Constants.SearchType> searchType = new DropDownChoice<Constants.SearchType>("searchType",\r
+ Arrays.asList(Constants.SearchType.values()));\r
searchType.setModel(searchTypeModel);\r
add(searchType.setVisible(GitBlit.getBoolean(Keys.web.showSearchTypeSelection, false)));\r
TextField<String> searchBox = new TextField<String>("searchBox", searchBoxModel);\r
\r
@Override\r
public void onSubmit() {\r
- SearchType searchType = searchTypeModel.getObject();\r
+ Constants.SearchType searchType = searchTypeModel.getObject();\r
String searchString = searchBoxModel.getObject();\r
if (searchString == null) {\r
// FIXME IE intermittently has no searchString. Wicket bug?\r
return;\r
}\r
- for (SearchType type : SearchType.values()) {\r
+ for (Constants.SearchType type : Constants.SearchType.values()) {\r
if (searchString.toLowerCase().startsWith(type.name().toLowerCase() + ":")) {\r
searchType = type;\r
searchString = searchString.substring(type.name().toLowerCase().length() + 1)\r
import org.apache.wicket.PageParameters;\r
import org.apache.wicket.markup.html.link.BookmarkablePageLink;\r
\r
-import com.gitblit.utils.JGitUtils.SearchType;\r
+import com.gitblit.Constants;\r
import com.gitblit.wicket.WicketUtils;\r
import com.gitblit.wicket.panels.SearchPanel;\r
\r
\r
String value = WicketUtils.getSearchString(params);\r
String type = WicketUtils.getSearchType(params);\r
- SearchType searchType = SearchType.forName(type);\r
+ Constants.SearchType searchType = Constants.SearchType.forName(type);\r
\r
int pageNumber = WicketUtils.getPage(params);\r
int prevPage = Math.max(0, pageNumber - 1);\r
\r
import com.gitblit.models.RefModel;\r
import com.gitblit.utils.JGitUtils;\r
-import com.gitblit.utils.JGitUtils.SearchType;\r
import com.gitblit.wicket.WicketUtils;\r
import com.gitblit.wicket.panels.LinkPanel;\r
import com.gitblit.wicket.panels.RefsPanel;\r
linkClass, linkParameters));\r
add(new Label("taggedObjectType", getString(typeKey)));\r
\r
- add(createPersonPanel("tagger", tagRef.getAuthorIdent(), SearchType.AUTHOR));\r
+ add(createPersonPanel("tagger", tagRef.getAuthorIdent(), com.gitblit.Constants.SearchType.AUTHOR));\r
Date when = new Date(0);\r
if (tagRef.getAuthorIdent() != null) {\r
when = tagRef.getAuthorIdent().getWhen();\r
import org.apache.wicket.markup.html.panel.Panel;\r
import org.apache.wicket.model.Model;\r
\r
+import com.gitblit.Constants;\r
import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
-import com.gitblit.utils.JGitUtils.SearchType;\r
import com.gitblit.wicket.GitBlitWebSession;\r
import com.gitblit.wicket.WicketUtils;\r
\r
.getTimezone() : TimeZone.getDefault();\r
}\r
\r
- protected void setPersonSearchTooltip(Component component, String value, SearchType searchType) {\r
- if (searchType.equals(SearchType.AUTHOR)) {\r
+ protected void setPersonSearchTooltip(Component component, String value, Constants.SearchType searchType) {\r
+ if (searchType.equals(Constants.SearchType.AUTHOR)) {\r
WicketUtils.setHtmlTooltip(component, getString("gb.searchForAuthor") + " " + value);\r
- } else if (searchType.equals(SearchType.COMMITTER)) {\r
+ } else if (searchType.equals(Constants.SearchType.COMMITTER)) {\r
WicketUtils.setHtmlTooltip(component, getString("gb.searchForCommitter") + " " + value);\r
}\r
}\r
import org.apache.wicket.model.StringResourceModel;\r
import org.eclipse.jgit.lib.Repository;\r
\r
+import com.gitblit.Constants;\r
import com.gitblit.SyndicationServlet;\r
import com.gitblit.models.RefModel;\r
import com.gitblit.models.RepositoryModel;\r
import com.gitblit.utils.JGitUtils;\r
-import com.gitblit.utils.JGitUtils.SearchType;\r
import com.gitblit.utils.StringUtils;\r
import com.gitblit.wicket.WicketUtils;\r
import com.gitblit.wicket.pages.BranchesPage;\r
String author = entry.getAuthorIdent().getName();\r
LinkPanel authorLink = new LinkPanel("branchAuthor", "list", author,\r
SearchPage.class, WicketUtils.newSearchParameter(model.name,\r
- entry.getName(), author, SearchType.AUTHOR));\r
- setPersonSearchTooltip(authorLink, author, SearchType.AUTHOR);\r
+ entry.getName(), author, Constants.SearchType.AUTHOR));\r
+ setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR);\r
item.add(authorLink);\r
\r
// short message\r
import org.eclipse.jgit.lib.Repository;\r
import org.eclipse.jgit.revwalk.RevCommit;\r
\r
+import com.gitblit.Constants;\r
import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
import com.gitblit.models.PathModel;\r
import com.gitblit.models.PathModel.PathChangeModel;\r
import com.gitblit.models.RefModel;\r
import com.gitblit.utils.JGitUtils;\r
-import com.gitblit.utils.JGitUtils.SearchType;\r
import com.gitblit.utils.StringUtils;\r
import com.gitblit.wicket.WicketUtils;\r
import com.gitblit.wicket.pages.BlobDiffPage;\r
String author = entry.getAuthorIdent().getName();\r
LinkPanel authorLink = new LinkPanel("commitAuthor", "list", author,\r
SearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId,\r
- author, SearchType.AUTHOR));\r
- setPersonSearchTooltip(authorLink, author, SearchType.AUTHOR);\r
+ author, Constants.SearchType.AUTHOR));\r
+ setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR);\r
item.add(authorLink);\r
\r
// merge icon\r
import org.eclipse.jgit.lib.Repository;\r
import org.eclipse.jgit.revwalk.RevCommit;\r
\r
+import com.gitblit.Constants;\r
import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
import com.gitblit.models.RefModel;\r
import com.gitblit.utils.JGitUtils;\r
-import com.gitblit.utils.JGitUtils.SearchType;\r
import com.gitblit.utils.StringUtils;\r
import com.gitblit.wicket.WicketUtils;\r
import com.gitblit.wicket.pages.CommitDiffPage;\r
String author = entry.getAuthorIdent().getName();\r
LinkPanel authorLink = new LinkPanel("commitAuthor", "list", author,\r
SearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId,\r
- author, SearchType.AUTHOR));\r
- setPersonSearchTooltip(authorLink, author, SearchType.AUTHOR);\r
+ author, Constants.SearchType.AUTHOR));\r
+ setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR);\r
item.add(authorLink);\r
\r
// merge icon\r
import org.eclipse.jgit.lib.Repository;\r
import org.eclipse.jgit.revwalk.RevCommit;\r
\r
+import com.gitblit.Constants;\r
import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
import com.gitblit.models.RefModel;\r
import com.gitblit.utils.JGitUtils;\r
-import com.gitblit.utils.JGitUtils.SearchType;\r
import com.gitblit.utils.StringUtils;\r
import com.gitblit.wicket.WicketUtils;\r
import com.gitblit.wicket.pages.CommitDiffPage;\r
private boolean hasMore;\r
\r
public SearchPanel(String wicketId, final String repositoryName, final String objectId,\r
- final String value, SearchType searchType, Repository r, int limit, int pageOffset) {\r
+ final String value, Constants.SearchType searchType, Repository r, int limit, int pageOffset) {\r
super(wicketId);\r
boolean pageResults = limit <= 0;\r
int itemsPerPage = GitBlit.getInteger(Keys.web.itemsPerPage, 50);\r
String author = entry.getAuthorIdent().getName();\r
LinkPanel authorLink = new LinkPanel("commitAuthor", "list", author,\r
SearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId,\r
- author, SearchType.AUTHOR));\r
- setPersonSearchTooltip(authorLink, author, SearchType.AUTHOR);\r
+ author, Constants.SearchType.AUTHOR));\r
+ setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR);\r
item.add(authorLink);\r
\r
// merge icon\r
import com.gitblit.models.PathModel.PathChangeModel;\r
import com.gitblit.models.RefModel;\r
import com.gitblit.utils.JGitUtils;\r
-import com.gitblit.utils.JGitUtils.SearchType;\r
import com.gitblit.utils.StringUtils;\r
\r
public class JGitUtilsTest extends TestCase {\r
}\r
\r
public void testSearchTypes() throws Exception {\r
- assertTrue(SearchType.forName("commit").equals(SearchType.COMMIT));\r
- assertTrue(SearchType.forName("committer").equals(SearchType.COMMITTER));\r
- assertTrue(SearchType.forName("author").equals(SearchType.AUTHOR));\r
- assertTrue(SearchType.forName("unknown").equals(SearchType.COMMIT));\r
-\r
- assertTrue(SearchType.COMMIT.toString().equals("commit"));\r
- assertTrue(SearchType.COMMITTER.toString().equals("committer"));\r
- assertTrue(SearchType.AUTHOR.toString().equals("author"));\r
+ assertTrue(com.gitblit.Constants.SearchType.forName("commit").equals(com.gitblit.Constants.SearchType.COMMIT));\r
+ assertTrue(com.gitblit.Constants.SearchType.forName("committer").equals(com.gitblit.Constants.SearchType.COMMITTER));\r
+ assertTrue(com.gitblit.Constants.SearchType.forName("author").equals(com.gitblit.Constants.SearchType.AUTHOR));\r
+ assertTrue(com.gitblit.Constants.SearchType.forName("unknown").equals(com.gitblit.Constants.SearchType.COMMIT));\r
+\r
+ assertTrue(com.gitblit.Constants.SearchType.COMMIT.toString().equals("commit"));\r
+ assertTrue(com.gitblit.Constants.SearchType.COMMITTER.toString().equals("committer"));\r
+ assertTrue(com.gitblit.Constants.SearchType.AUTHOR.toString().equals("author"));\r
}\r
\r
public void testSearchRevlogs() throws Exception {\r
- assertTrue(JGitUtils.searchRevlogs(null, null, "java", SearchType.COMMIT, 0, 0).size() == 0);\r
- List<RevCommit> results = JGitUtils.searchRevlogs(null, null, "java", SearchType.COMMIT, 0,\r
+ assertTrue(JGitUtils.searchRevlogs(null, null, "java", com.gitblit.Constants.SearchType.COMMIT, 0, 0).size() == 0);\r
+ List<RevCommit> results = JGitUtils.searchRevlogs(null, null, "java", com.gitblit.Constants.SearchType.COMMIT, 0,\r
3);\r
assertTrue(results.size() == 0);\r
\r
// test commit message search\r
Repository repository = GitBlitSuite.getHelloworldRepository();\r
- results = JGitUtils.searchRevlogs(repository, null, "java", SearchType.COMMIT, 0, 3);\r
+ results = JGitUtils.searchRevlogs(repository, null, "java", com.gitblit.Constants.SearchType.COMMIT, 0, 3);\r
assertTrue(results.size() == 3);\r
\r
// test author search\r
- results = JGitUtils.searchRevlogs(repository, null, "timothy", SearchType.AUTHOR, 0, -1);\r
+ results = JGitUtils.searchRevlogs(repository, null, "timothy", com.gitblit.Constants.SearchType.AUTHOR, 0, -1);\r
assertTrue(results.size() == 1);\r
\r
// test committer search\r
- results = JGitUtils.searchRevlogs(repository, null, "mike", SearchType.COMMITTER, 0, 10);\r
+ results = JGitUtils.searchRevlogs(repository, null, "mike", com.gitblit.Constants.SearchType.COMMITTER, 0, 10);\r
assertTrue(results.size() == 10);\r
\r
// test paging and offset\r
- RevCommit commit = JGitUtils.searchRevlogs(repository, null, "mike", SearchType.COMMITTER,\r
+ RevCommit commit = JGitUtils.searchRevlogs(repository, null, "mike", com.gitblit.Constants.SearchType.COMMITTER,\r
9, 1).get(0);\r
assertTrue(results.get(9).equals(commit));\r
\r