use of org.codelibs.fess.app.web.base.SearchForm in project fess by codelibs.
the class SearchAction method doSearch.
protected HtmlResponse doSearch(final SearchForm form) {
validate(form, messages -> {
}, () -> asHtml(virtualHost(path_SearchJsp)));
if (isLoginRequired()) {
return redirectToLogin();
}
if (viewHelper.isUseSession()) {
final HttpSession session = request.getSession(false);
if (session != null) {
final Object resultsPerPage = session.getAttribute(Constants.RESULTS_PER_PAGE);
if (resultsPerPage instanceof Integer) {
form.num = (Integer) resultsPerPage;
}
}
}
if (StringUtil.isBlank(form.q) && form.fields.isEmpty()) {
// redirect to index page
form.q = null;
return redirectToRoot();
}
try {
buildFormParams(form);
form.lang = searchService.getLanguages(request, form);
request.setAttribute(Constants.REQUEST_LANGUAGES, form.lang);
request.setAttribute(Constants.REQUEST_QUERIES, form.q);
final WebRenderData renderData = new WebRenderData();
searchService.search(form, renderData, getUserBean());
return asHtml(virtualHost(path_SearchJsp)).renderWith(data -> {
renderData.register(data);
if (favoriteSupport || thumbnailSupport) {
final String queryId = renderData.getQueryId();
final List<Map<String, Object>> documentItems = renderData.getDocumentItems();
userInfoHelper.storeQueryId(queryId, documentItems);
if (thumbnailSupport) {
thumbnailManager.storeRequest(queryId, documentItems);
}
}
RenderDataUtil.register(data, "displayQuery", getDisplayQuery(form, labelTypeHelper.getLabelTypeItemList(SearchRequestType.SEARCH)));
createPagingQuery(form);
});
} catch (final InvalidQueryException e) {
if (logger.isDebugEnabled()) {
logger.debug(e.getMessage(), e);
}
saveError(e.getMessageCode());
return redirectToRoot();
} catch (final ResultOffsetExceededException e) {
if (logger.isDebugEnabled()) {
logger.debug(e.getMessage(), e);
}
saveError(messages -> {
messages.addErrorsResultSizeExceeded(GLOBAL);
});
return redirectToRoot();
}
}
Aggregations