Search in sources :

Example 1 with ApiDocsResponse

use of org.codelibs.fess.app.web.api.ApiResult.ApiDocsResponse in project fess by codelibs.

the class ApiAdminSearchlistAction method docs.

// ===================================================================================
//                                                                      Search Execute
//                                                                      ==============
// GET /api/admin/searchlist
// POST /api/admin/searchlist
@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 {
        searchService.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;
}
Also used : Constants(org.codelibs.fess.Constants) AdminSearchlistAction.validateUpdateFields(org.codelibs.fess.app.web.admin.searchlist.AdminSearchlistAction.validateUpdateFields) AdminSearchlistAction.getDoc(org.codelibs.fess.app.web.admin.searchlist.AdminSearchlistAction.getDoc) LoggerFactory(org.slf4j.LoggerFactory) ApiDeleteResponse(org.codelibs.fess.app.web.api.ApiResult.ApiDeleteResponse) ResultOffsetExceededException(org.codelibs.fess.exception.ResultOffsetExceededException) QueryBuilders(org.elasticsearch.index.query.QueryBuilders) ApiResult(org.codelibs.fess.app.web.api.ApiResult) Status(org.codelibs.fess.app.web.api.ApiResult.Status) CrudMode(org.codelibs.fess.app.web.CrudMode) Map(java.util.Map) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) SearchRenderData(org.codelibs.fess.entity.SearchRenderData) QueryBuilder(org.elasticsearch.index.query.QueryBuilder) AdminSearchlistAction.validateCreateFields(org.codelibs.fess.app.web.admin.searchlist.AdminSearchlistAction.validateCreateFields) Logger(org.slf4j.Logger) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) FessEsClient(org.codelibs.fess.es.client.FessEsClient) ApiDocResponse(org.codelibs.fess.app.web.api.ApiResult.ApiDocResponse) Resource(javax.annotation.Resource) StringUtil(org.codelibs.core.lang.StringUtil) JsonResponse(org.lastaflute.web.response.JsonResponse) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) SearchService(org.codelibs.fess.app.service.SearchService) ComponentUtil(org.codelibs.fess.util.ComponentUtil) ApiDocsResponse(org.codelibs.fess.app.web.api.ApiResult.ApiDocsResponse) Execute(org.lastaflute.web.Execute) InvalidQueryException(org.codelibs.fess.exception.InvalidQueryException) SearchRenderData(org.codelibs.fess.entity.SearchRenderData) ResultOffsetExceededException(org.codelibs.fess.exception.ResultOffsetExceededException) ApiDocsResponse(org.codelibs.fess.app.web.api.ApiResult.ApiDocsResponse) InvalidQueryException(org.codelibs.fess.exception.InvalidQueryException) Execute(org.lastaflute.web.Execute)

Aggregations

Map (java.util.Map)1 Resource (javax.annotation.Resource)1 StringUtil (org.codelibs.core.lang.StringUtil)1 Constants (org.codelibs.fess.Constants)1 SearchService (org.codelibs.fess.app.service.SearchService)1 CrudMode (org.codelibs.fess.app.web.CrudMode)1 AdminSearchlistAction.getDoc (org.codelibs.fess.app.web.admin.searchlist.AdminSearchlistAction.getDoc)1 AdminSearchlistAction.validateCreateFields (org.codelibs.fess.app.web.admin.searchlist.AdminSearchlistAction.validateCreateFields)1 AdminSearchlistAction.validateUpdateFields (org.codelibs.fess.app.web.admin.searchlist.AdminSearchlistAction.validateUpdateFields)1 ApiResult (org.codelibs.fess.app.web.api.ApiResult)1 ApiDeleteResponse (org.codelibs.fess.app.web.api.ApiResult.ApiDeleteResponse)1 ApiDocResponse (org.codelibs.fess.app.web.api.ApiResult.ApiDocResponse)1 ApiDocsResponse (org.codelibs.fess.app.web.api.ApiResult.ApiDocsResponse)1 ApiResponse (org.codelibs.fess.app.web.api.ApiResult.ApiResponse)1 ApiUpdateResponse (org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse)1 Status (org.codelibs.fess.app.web.api.ApiResult.Status)1 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)1 SearchRenderData (org.codelibs.fess.entity.SearchRenderData)1 FessEsClient (org.codelibs.fess.es.client.FessEsClient)1 InvalidQueryException (org.codelibs.fess.exception.InvalidQueryException)1