use of org.opengrok.indexer.web.SortOrder in project OpenGrok by OpenGrok.
the class PageConfig method prepareSearch.
/**
* Prepare a search helper with all required information, ready to execute
* the query implied by the related request parameters and cookies.
* <p>
* NOTE: One should check the {@link SearchHelper#getErrorMsg()} as well as
* {@link SearchHelper#getRedirect()} and take the appropriate action before
* executing the prepared query or continue processing.
* <p>
* This method stops populating fields as soon as an error occurs.
*
* @return a search helper.
*/
public SearchHelper prepareSearch() {
List<SortOrder> sortOrders = getSortOrder();
SearchHelper sh = prepareInternalSearch(sortOrders.isEmpty() ? SortOrder.RELEVANCY : sortOrders.get(0));
if (getRequestedProjects().isEmpty() && getEnv().hasProjects()) {
sh.setErrorMsg("You must select a project!");
return sh;
}
if (sh.getBuilder().getSize() == 0) {
// Entry page show the map
sh.setRedirect(req.getContextPath() + '/');
return sh;
}
return sh;
}
use of org.opengrok.indexer.web.SortOrder in project OpenGrok by OpenGrok.
the class PageConfig method getSortOrder.
/**
* Get sort orders from the request parameter {@code sort} and if this list
* would be empty from the cookie {@code OpenGrokSorting}.
*
* @return a possible empty list which contains the sort order values in the
* same order supplied by the request parameter or cookie(s).
*/
public List<SortOrder> getSortOrder() {
List<SortOrder> sort = new ArrayList<>();
List<String> vals = getParameterValues(QueryParameters.SORT_PARAM);
for (String s : vals) {
SortOrder so = SortOrder.get(s);
if (so != null) {
sort.add(so);
}
}
if (sort.isEmpty()) {
vals = getCookieVals("OpenGrokSorting");
for (String s : vals) {
SortOrder so = SortOrder.get(s);
if (so != null) {
sort.add(so);
}
}
}
return sort;
}
Aggregations