Search in sources :

Example 1 with RequestHeader

use of org.codelibs.fess.es.config.exentity.RequestHeader in project fess by codelibs.

the class ApiAdminReqheaderAction method post$setting.

// POST /api/admin/reqheader/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.EDIT;
    final RequestHeader reqHeader = getRequestHeader(body).map(entity -> {
        try {
            reqHeaderService.store(entity);
        } catch (final Exception e) {
            throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, buildThrowableMessage(e)));
        }
        return entity;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, body.id));
        return null;
    });
    return asJson(new ApiUpdateResponse().id(reqHeader.getId()).created(false).status(Status.OK).result());
}
Also used : RequestHeaderService(org.codelibs.fess.app.service.RequestHeaderService) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) WebConfigService(org.codelibs.fess.app.service.WebConfigService) Resource(javax.annotation.Resource) ApiConfigResponse(org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) ReqHeaderPager(org.codelibs.fess.app.pager.ReqHeaderPager) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) AdminReqheaderAction.getRequestHeader(org.codelibs.fess.app.web.admin.reqheader.AdminReqheaderAction.getRequestHeader) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) RequestHeader(org.codelibs.fess.es.config.exentity.RequestHeader) ApiErrorResponse(org.codelibs.fess.app.web.api.ApiResult.ApiErrorResponse) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) AdminReqheaderAction.getRequestHeader(org.codelibs.fess.app.web.admin.reqheader.AdminReqheaderAction.getRequestHeader) RequestHeader(org.codelibs.fess.es.config.exentity.RequestHeader) Execute(org.lastaflute.web.Execute)

Example 2 with RequestHeader

use of org.codelibs.fess.es.config.exentity.RequestHeader in project fess by codelibs.

the class ApiAdminReqheaderAction method settings.

// ===================================================================================
//                                                                      Search Execute
//                                                                      ==============
// GET /api/admin/reqheader/settings
// POST /api/admin/reqheader/settings
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
    validateApi(body, messages -> {
    });
    final ReqHeaderPager pager = copyBeanToNewBean(body, ReqHeaderPager.class);
    final List<RequestHeader> list = reqHeaderService.getRequestHeaderList(pager);
    return asJson(new ApiResult.ApiConfigsResponse<EditBody>().settings(list.stream().map(entity -> createEditBody(entity)).collect(Collectors.toList())).total(pager.getAllRecordCount()).status(ApiResult.Status.OK).result());
}
Also used : ReqHeaderPager(org.codelibs.fess.app.pager.ReqHeaderPager) ApiResult(org.codelibs.fess.app.web.api.ApiResult) AdminReqheaderAction.getRequestHeader(org.codelibs.fess.app.web.admin.reqheader.AdminReqheaderAction.getRequestHeader) RequestHeader(org.codelibs.fess.es.config.exentity.RequestHeader) Execute(org.lastaflute.web.Execute)

Example 3 with RequestHeader

use of org.codelibs.fess.es.config.exentity.RequestHeader in project fess by codelibs.

the class ApiAdminReqheaderAction method put$setting.

// PUT /api/admin/reqheader/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
    validateApi(body, messages -> {
    });
    if (!isValidWebConfigId(body.webConfigId)) {
        return asJson(new ApiErrorResponse().message("invalid webConfigId").status(Status.BAD_REQUEST).result());
    }
    body.crudMode = CrudMode.CREATE;
    final RequestHeader reqHeader = getRequestHeader(body).map(entity -> {
        try {
            reqHeaderService.store(entity);
        } catch (final Exception e) {
            throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL, buildThrowableMessage(e)));
        }
        return entity;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateInstance(GLOBAL));
        return null;
    });
    return asJson(new ApiUpdateResponse().id(reqHeader.getId()).created(true).status(Status.OK).result());
}
Also used : RequestHeaderService(org.codelibs.fess.app.service.RequestHeaderService) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) WebConfigService(org.codelibs.fess.app.service.WebConfigService) Resource(javax.annotation.Resource) ApiConfigResponse(org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) ReqHeaderPager(org.codelibs.fess.app.pager.ReqHeaderPager) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) AdminReqheaderAction.getRequestHeader(org.codelibs.fess.app.web.admin.reqheader.AdminReqheaderAction.getRequestHeader) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) RequestHeader(org.codelibs.fess.es.config.exentity.RequestHeader) ApiErrorResponse(org.codelibs.fess.app.web.api.ApiResult.ApiErrorResponse) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) ApiErrorResponse(org.codelibs.fess.app.web.api.ApiResult.ApiErrorResponse) AdminReqheaderAction.getRequestHeader(org.codelibs.fess.app.web.admin.reqheader.AdminReqheaderAction.getRequestHeader) RequestHeader(org.codelibs.fess.es.config.exentity.RequestHeader) Execute(org.lastaflute.web.Execute)

Aggregations

ReqHeaderPager (org.codelibs.fess.app.pager.ReqHeaderPager)3 AdminReqheaderAction.getRequestHeader (org.codelibs.fess.app.web.admin.reqheader.AdminReqheaderAction.getRequestHeader)3 ApiResult (org.codelibs.fess.app.web.api.ApiResult)3 RequestHeader (org.codelibs.fess.es.config.exentity.RequestHeader)3 Execute (org.lastaflute.web.Execute)3 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Resource (javax.annotation.Resource)2 RequestHeaderService (org.codelibs.fess.app.service.RequestHeaderService)2 WebConfigService (org.codelibs.fess.app.service.WebConfigService)2 CrudMode (org.codelibs.fess.app.web.CrudMode)2 ApiConfigResponse (org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse)2 ApiErrorResponse (org.codelibs.fess.app.web.api.ApiResult.ApiErrorResponse)2 ApiResponse (org.codelibs.fess.app.web.api.ApiResult.ApiResponse)2 ApiUpdateResponse (org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse)2 Status (org.codelibs.fess.app.web.api.ApiResult.Status)2 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)2 JsonResponse (org.lastaflute.web.response.JsonResponse)2