Search in sources :

Example 1 with ApiErrorResponse

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

the class ApiAdminFileauthAction method put$setting.

// PUT /api/admin/fileauth/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
    validateApi(body, messages -> {
    });
    if (!isValidFileConfigId(body.fileConfigId)) {
        return asJson(new ApiErrorResponse().message("invalid fileConfigId").status(Status.BAD_REQUEST).result());
    }
    body.crudMode = CrudMode.CREATE;
    final FileAuthentication fileAuth = getFileAuthentication(body).map(entity -> {
        try {
            fileAuthService.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(fileAuth.getId()).created(true).status(Status.OK).result());
}
Also used : FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) AdminFileauthAction.getFileAuthentication(org.codelibs.fess.app.web.admin.fileauth.AdminFileauthAction.getFileAuthentication) Resource(javax.annotation.Resource) FileAuthenticationService(org.codelibs.fess.app.service.FileAuthenticationService) 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) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) FileConfigService(org.codelibs.fess.app.service.FileConfigService) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) ApiErrorResponse(org.codelibs.fess.app.web.api.ApiResult.ApiErrorResponse) FileAuthPager(org.codelibs.fess.app.pager.FileAuthPager) FileAuthentication(org.codelibs.fess.es.config.exentity.FileAuthentication) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) ApiErrorResponse(org.codelibs.fess.app.web.api.ApiResult.ApiErrorResponse) AdminFileauthAction.getFileAuthentication(org.codelibs.fess.app.web.admin.fileauth.AdminFileauthAction.getFileAuthentication) FileAuthentication(org.codelibs.fess.es.config.exentity.FileAuthentication) Execute(org.lastaflute.web.Execute)

Example 2 with ApiErrorResponse

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

the class ApiAdminWebauthAction method put$setting.

// PUT /api/admin/webauth/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 WebAuthentication webAuth = getWebAuthentication(body).map(entity -> {
        try {
            webAuthService.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(webAuth.getId()).created(true).status(Status.OK).result());
}
Also used : WebAuthentication(org.codelibs.fess.es.config.exentity.WebAuthentication) WebAuthPager(org.codelibs.fess.app.pager.WebAuthPager) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) WebAuthenticationService(org.codelibs.fess.app.service.WebAuthenticationService) 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) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) AdminWebauthAction.getWebAuthentication(org.codelibs.fess.app.web.admin.webauth.AdminWebauthAction.getWebAuthentication) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) ApiErrorResponse(org.codelibs.fess.app.web.api.ApiResult.ApiErrorResponse) WebAuthentication(org.codelibs.fess.es.config.exentity.WebAuthentication) AdminWebauthAction.getWebAuthentication(org.codelibs.fess.app.web.admin.webauth.AdminWebauthAction.getWebAuthentication) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) ApiErrorResponse(org.codelibs.fess.app.web.api.ApiResult.ApiErrorResponse) Execute(org.lastaflute.web.Execute)

Example 3 with ApiErrorResponse

use of org.codelibs.fess.app.web.api.ApiResult.ApiErrorResponse 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

List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Resource (javax.annotation.Resource)3 CrudMode (org.codelibs.fess.app.web.CrudMode)3 ApiResult (org.codelibs.fess.app.web.api.ApiResult)3 ApiConfigResponse (org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse)3 ApiErrorResponse (org.codelibs.fess.app.web.api.ApiResult.ApiErrorResponse)3 ApiResponse (org.codelibs.fess.app.web.api.ApiResult.ApiResponse)3 ApiUpdateResponse (org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse)3 Status (org.codelibs.fess.app.web.api.ApiResult.Status)3 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)3 Execute (org.lastaflute.web.Execute)3 JsonResponse (org.lastaflute.web.response.JsonResponse)3 WebConfigService (org.codelibs.fess.app.service.WebConfigService)2 FileAuthPager (org.codelibs.fess.app.pager.FileAuthPager)1 ReqHeaderPager (org.codelibs.fess.app.pager.ReqHeaderPager)1 WebAuthPager (org.codelibs.fess.app.pager.WebAuthPager)1 FileAuthenticationService (org.codelibs.fess.app.service.FileAuthenticationService)1 FileConfigService (org.codelibs.fess.app.service.FileConfigService)1 RequestHeaderService (org.codelibs.fess.app.service.RequestHeaderService)1