useWrappers = wrappers;
try {
RollerRequest rreq = RollerRequest.getRollerRequest(request);
setWebsiteSpecificSearch(checkForWebsite(request));
SearchOperation search =
new SearchOperation(RollerFactory.getRoller().getIndexManager());
search.setTerm(request.getParameter("q"));
setTerm(request.getParameter("q"));
WebsiteData website = null;
if (isWebsiteSpecificSearch()) {
website = rreq.getWebsite();
search.setWebsiteHandle(rreq.getWebsite().getHandle());
}
if (StringUtils.isNotEmpty(request.getParameter("c"))) {
search.setCategory(request.getParameter("c"));
}
// execute search
executeSearch(RollerFactory.getRoller(), search);
if (search.getResultsCount() == -1) {
// this means there has been a parsing (or IO) error
setErrorMessage(bundle.getString("error.searchProblem"));
} else {
// Convert the Hits into WeblogEntryData instances.
Hits hits = search.getResults();
setResults(convertHitsToEntries(rreq, website, hits));
setOffset((Integer)request.getAttribute("offset"));
setLimit((Integer)request.getAttribute("limit"));
if (request.getAttribute("categories") != null) {
Set cats = (Set)request.getAttribute("categories");
if (cats.size() > 0) {
setCategories(cats);
}
}
}
setHits(new Integer(search.getResultsCount()));
} catch (IOException ex) {
mLogger.error("ERROR: initializing search page model");
} catch (RollerException ex) {
mLogger.error("ERROR: initializing search page model");