Search in sources :

Example 31 with ApiResult

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

the class ApiAdminUserAction method settings.

// GET /api/admin/user
// POST /api/admin/user
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
    validateApi(body, messages -> {
    });
    final UserPager pager = copyBeanToNewBean(body, UserPager.class);
    final List<User> list = userService.getUserList(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 : AdminUserAction.getUser(org.codelibs.fess.app.web.admin.user.AdminUserAction.getUser) User(org.codelibs.fess.es.user.exentity.User) ApiResult(org.codelibs.fess.app.web.api.ApiResult) UserPager(org.codelibs.fess.app.pager.UserPager) Execute(org.lastaflute.web.Execute)

Example 32 with ApiResult

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

the class ApiAdminUserAction method post$setting.

// POST /api/admin/user/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.EDIT;
    final User entity = getUser(body).orElseGet(() -> {
        throwValidationErrorApi(messages -> {
            messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, body.id);
        });
        return null;
    });
    try {
        userService.store(entity);
    } catch (final Exception e) {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, buildThrowableMessage(e)));
    }
    return asJson(new ApiResult.ApiUpdateResponse().id(entity.getId()).created(false).status(ApiResult.Status.OK).result());
}
Also used : List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) UserPager(org.codelibs.fess.app.pager.UserPager) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) Execute(org.lastaflute.web.Execute) JsonResponse(org.lastaflute.web.response.JsonResponse) AdminUserAction.getUser(org.codelibs.fess.app.web.admin.user.AdminUserAction.getUser) UserService(org.codelibs.fess.app.service.UserService) User(org.codelibs.fess.es.user.exentity.User) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) AdminUserAction.getUser(org.codelibs.fess.app.web.admin.user.AdminUserAction.getUser) User(org.codelibs.fess.es.user.exentity.User) ApiResult(org.codelibs.fess.app.web.api.ApiResult) Execute(org.lastaflute.web.Execute)

Example 33 with ApiResult

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

the class ApiAdminUserAction method put$setting.

// PUT /api/admin/user/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.CREATE;
    final User entity = getUser(body).orElseGet(() -> {
        throwValidationErrorApi(messages -> {
            messages.addErrorsCrudFailedToCreateInstance(GLOBAL);
        });
        return null;
    });
    try {
        userService.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 : List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) UserPager(org.codelibs.fess.app.pager.UserPager) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) Execute(org.lastaflute.web.Execute) JsonResponse(org.lastaflute.web.response.JsonResponse) AdminUserAction.getUser(org.codelibs.fess.app.web.admin.user.AdminUserAction.getUser) UserService(org.codelibs.fess.app.service.UserService) User(org.codelibs.fess.es.user.exentity.User) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) AdminUserAction.getUser(org.codelibs.fess.app.web.admin.user.AdminUserAction.getUser) User(org.codelibs.fess.es.user.exentity.User) ApiResult(org.codelibs.fess.app.web.api.ApiResult) Execute(org.lastaflute.web.Execute)

Example 34 with ApiResult

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

the class ApiAdminWebauthAction method post$setting.

// POST /api/admin/webauth/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.EDIT;
    final WebAuthentication webAuth = getWebAuthentication(body).map(entity -> {
        try {
            webAuthService.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(webAuth.getId()).created(false).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) Execute(org.lastaflute.web.Execute)

Example 35 with ApiResult

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

the class ApiAdminWebconfigAction method post$setting.

// POST /api/admin/webconfig/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.EDIT;
    final WebConfig webConfig = getWebConfig(body).map(entity -> {
        try {
            webConfigService.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(webConfig.getId()).created(false).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)

Aggregations

ApiResult (org.codelibs.fess.app.web.api.ApiResult)88 Execute (org.lastaflute.web.Execute)88 Resource (javax.annotation.Resource)65 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)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 BufferedReader (java.io.BufferedReader)7 InputStreamReader (java.io.InputStreamReader)7