Search in sources :

Example 31 with JsonResponse

use of org.lastaflute.web.response.JsonResponse in project fess by codelibs.

the class ApiAdminPathmapAction method delete$setting.

// DELETE /api/admin/pathmap/setting/{id}
@Execute
public JsonResponse<ApiResult> delete$setting(final String id) {
    final PathMapping entity = pathMappingService.getPathMapping(id).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id));
        return null;
    });
    try {
        pathMappingService.delete(entity);
        saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
    } catch (final Exception e) {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToDeleteCrudTable(GLOBAL, buildThrowableMessage(e)));
    }
    return asJson(new ApiResult.ApiUpdateResponse().id(id).created(false).status(ApiResult.Status.OK).result());
}
Also used : PathMapPager(org.codelibs.fess.app.pager.PathMapPager) PathMapping(org.codelibs.fess.es.config.exentity.PathMapping) Constants(org.codelibs.fess.Constants) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) Execute(org.lastaflute.web.Execute) AdminPathmapAction.getPathMapping(org.codelibs.fess.app.web.admin.pathmap.AdminPathmapAction.getPathMapping) PathMappingService(org.codelibs.fess.app.service.PathMappingService) ApiResult(org.codelibs.fess.app.web.api.ApiResult) PathMapping(org.codelibs.fess.es.config.exentity.PathMapping) AdminPathmapAction.getPathMapping(org.codelibs.fess.app.web.admin.pathmap.AdminPathmapAction.getPathMapping) Execute(org.lastaflute.web.Execute)

Example 32 with JsonResponse

use of org.lastaflute.web.response.JsonResponse in project fess by codelibs.

the class ApiAdminWebconfigAction method put$setting.

// PUT /api/admin/webconfig/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.CREATE;
    final WebConfig webConfig = getWebConfig(body).map(entity -> {
        try {
            webConfigService.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(webConfig.getId()).created(true).status(Status.OK).result());
}
Also used : AdminWebconfigAction.getWebConfig(org.codelibs.fess.app.web.admin.webconfig.AdminWebconfigAction.getWebConfig) 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) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) WebConfigPager(org.codelibs.fess.app.pager.WebConfigPager) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) WebConfig(org.codelibs.fess.es.config.exentity.WebConfig) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) AdminWebconfigAction.getWebConfig(org.codelibs.fess.app.web.admin.webconfig.AdminWebconfigAction.getWebConfig) WebConfig(org.codelibs.fess.es.config.exentity.WebConfig) Execute(org.lastaflute.web.Execute)

Example 33 with JsonResponse

use of org.lastaflute.web.response.JsonResponse in project fess by codelibs.

the class ApiAdminPathmapAction method put$setting.

// PUT /api/admin/pathmap/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.CREATE;
    final PathMapping entity = getPathMapping(body).orElseGet(() -> {
        throwValidationErrorApi(messages -> {
            messages.addErrorsCrudFailedToCreateInstance(GLOBAL);
        });
        return null;
    });
    try {
        pathMappingService.store(entity);
        saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
    } catch (final Exception e) {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL, buildThrowableMessage(e)));
    }
    return asJson(new ApiResult.ApiUpdateResponse().id(entity.getId()).created(true).status(ApiResult.Status.OK).result());
}
Also used : PathMapPager(org.codelibs.fess.app.pager.PathMapPager) PathMapping(org.codelibs.fess.es.config.exentity.PathMapping) Constants(org.codelibs.fess.Constants) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) Execute(org.lastaflute.web.Execute) AdminPathmapAction.getPathMapping(org.codelibs.fess.app.web.admin.pathmap.AdminPathmapAction.getPathMapping) PathMappingService(org.codelibs.fess.app.service.PathMappingService) ApiResult(org.codelibs.fess.app.web.api.ApiResult) PathMapping(org.codelibs.fess.es.config.exentity.PathMapping) AdminPathmapAction.getPathMapping(org.codelibs.fess.app.web.admin.pathmap.AdminPathmapAction.getPathMapping) Execute(org.lastaflute.web.Execute)

Example 34 with JsonResponse

use of org.lastaflute.web.response.JsonResponse 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)

Example 35 with JsonResponse

use of org.lastaflute.web.response.JsonResponse in project fess by codelibs.

the class ApiAdminRoleAction method put$setting.

// PUT /api/admin/role/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.CREATE;
    final Role entity = getRole(body).orElseGet(() -> {
        throwValidationErrorApi(messages -> {
            messages.addErrorsCrudFailedToCreateInstance(GLOBAL);
        });
        return null;
    });
    try {
        roleService.store(entity);
    } catch (final Exception e) {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL, buildThrowableMessage(e)));
    }
    return asJson(new ApiResult.ApiUpdateResponse().id(entity.getId()).created(true).status(ApiResult.Status.OK).result());
}
Also used : Role(org.codelibs.fess.es.user.exentity.Role) AdminRoleAction.getRole(org.codelibs.fess.app.web.admin.role.AdminRoleAction.getRole) Role(org.codelibs.fess.es.user.exentity.Role) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) RolePager(org.codelibs.fess.app.pager.RolePager) Resource(javax.annotation.Resource) Execute(org.lastaflute.web.Execute) JsonResponse(org.lastaflute.web.response.JsonResponse) AdminRoleAction.getRole(org.codelibs.fess.app.web.admin.role.AdminRoleAction.getRole) Collectors(java.util.stream.Collectors) RoleService(org.codelibs.fess.app.service.RoleService) ApiResult(org.codelibs.fess.app.web.api.ApiResult) ApiResult(org.codelibs.fess.app.web.api.ApiResult) Execute(org.lastaflute.web.Execute)

Aggregations

Resource (javax.annotation.Resource)65 ApiResult (org.codelibs.fess.app.web.api.ApiResult)65 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)65 Execute (org.lastaflute.web.Execute)65 JsonResponse (org.lastaflute.web.response.JsonResponse)65 CrudMode (org.codelibs.fess.app.web.CrudMode)63 Collectors (java.util.stream.Collectors)61 List (java.util.List)43 ApiResponse (org.codelibs.fess.app.web.api.ApiResult.ApiResponse)31 Status (org.codelibs.fess.app.web.api.ApiResult.Status)31 ApiUpdateResponse (org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse)26 InputStream (java.io.InputStream)23 StreamResponse (org.lastaflute.web.response.StreamResponse)23 ApiConfigResponse (org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse)22 File (java.io.File)18 Constants (org.codelibs.fess.Constants)12 StringUtil (org.codelibs.core.lang.StringUtil)9 ComponentUtil (org.codelibs.fess.util.ComponentUtil)9 WebConfigService (org.codelibs.fess.app.service.WebConfigService)6 ApiErrorResponse (org.codelibs.fess.app.web.api.ApiResult.ApiErrorResponse)6