Пример #1
0
 /**
  * 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#errorMsg} as well as {@link
  * SearchHelper#redirect} 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() {
   SearchHelper sh = new SearchHelper();
   sh.dataRoot = getDataRoot(); // throws Exception if none-existent
   List<SortOrder> sortOrders = getSortOrder();
   sh.order = sortOrders.isEmpty() ? SortOrder.RELEVANCY : sortOrders.get(0);
   if (getRequestedProjects().isEmpty() && getEnv().hasProjects()) {
     sh.errorMsg = "You must select a project!";
     return sh;
   }
   sh.builder = getQueryBuilder();
   if (sh.builder.getSize() == 0) {
     // Entry page show the map
     sh.redirect = req.getContextPath() + '/';
     return sh;
   }
   sh.start = getSearchStart();
   sh.maxItems = getSearchMaxItems();
   sh.contextPath = req.getContextPath();
   // jel: this should be IMHO a config param since not only core dependend
   sh.parallel = Runtime.getRuntime().availableProcessors() > 1;
   sh.isCrossRefSearch = getPrefix() == Prefix.SEARCH_R;
   sh.compressed = env.isCompressXref();
   sh.desc = getEftarReader();
   sh.sourceRoot = new File(getSourceRootPath());
   sh.lastEditedDisplayMode = isLastEditedDisplayMode();
   return sh;
 }