use of org.codelibs.fess.exception.ResultOffsetExceededException in project fess by codelibs.
the class ApiAdminSearchlistAction method docs.
// ===================================================================================
// Search Execute
// ==============
// GET /api/admin/searchlist/docs
// POST /api/admin/searchlist/docs
@Execute
public JsonResponse<ApiResult> docs(final SearchBody body) {
validateApi(body, messages -> {
});
if (StringUtil.isBlank(body.q)) {
// query matches on all documents.
body.q = Constants.MATCHES_ALL_QUERY;
}
final SearchRenderData renderData = new SearchRenderData();
body.initialize();
try {
searchHelper.search(body, renderData, getUserBean());
return asJson(new ApiDocsResponse().renderData(renderData).status(Status.OK).result());
} catch (final InvalidQueryException e) {
if (logger.isDebugEnabled()) {
logger.debug(e.getMessage(), e);
}
throwValidationErrorApi(e.getMessageCode());
} catch (final ResultOffsetExceededException e) {
if (logger.isDebugEnabled()) {
logger.debug(e.getMessage(), e);
}
throwValidationErrorApi(messages -> messages.addErrorsResultSizeExceeded(GLOBAL));
}
throwValidationErrorApi(messages -> messages.addErrorsInvalidQueryUnknown(GLOBAL));
// ignore
return null;
}
use of org.codelibs.fess.exception.ResultOffsetExceededException 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() && !form.hasConditionQuery()) {
// redirect to index page
form.q = null;
return redirectToRoot();
}
try {
buildFormParams(form);
form.lang = searchHelper.getLanguages(request, form);
final WebRenderData renderData = new WebRenderData();
searchHelper.search(form, renderData, getUserBean());
return asHtml(virtualHost(path_SearchJsp)).renderWith(data -> {
if (form.hasConditionQuery()) {
form.q = renderData.getSearchQuery();
}
renderData.register(data);
RenderDataUtil.register(data, "displayQuery", getDisplayQuery(form, labelTypeHelper.getLabelTypeItemList(SearchRequestType.SEARCH, request.getLocale() == null ? Locale.ROOT : request.getLocale())));
createPagingQuery(form);
final String[] relatedContents = relatedContentHelper.getRelatedContents(form.getQuery());
RenderDataUtil.register(data, "relatedContents", relatedContents);
final String[] relatedQueries = relatedQueryHelper.getRelatedQueries(form.getQuery());
if (relatedQueries.length > 0) {
RenderDataUtil.register(data, "relatedQueries", relatedQueries);
}
});
} 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