Search in sources :

Example 91 with Execute

use of org.lastaflute.web.Execute in project fess by codelibs.

the class ApiAdminFailureurlAction method delete$all.

// DELETE /api/admin/failureurl/all
@Execute
public JsonResponse<ApiResult> delete$all() {
    try {
        failureUrlService.deleteAll(failureUrlPager);
        failureUrlPager.clear();
        saveInfo(messages -> messages.addSuccessFailureUrlDeleteAll(GLOBAL));
    } catch (final Exception e) {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToDeleteCrudTable(GLOBAL, buildThrowableMessage(e)));
    }
    return asJson(new ApiResponse().status(Status.OK).result());
}
Also used : ProcessHelper(org.codelibs.fess.helper.ProcessHelper) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) ApiLogResponse(org.codelibs.fess.app.web.api.ApiResult.ApiLogResponse) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) Execute(org.lastaflute.web.Execute) FailureUrlPager(org.codelibs.fess.app.pager.FailureUrlPager) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) FailureUrlService(org.codelibs.fess.app.service.FailureUrlService) FailureUrl(org.codelibs.fess.es.config.exentity.FailureUrl) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) Execute(org.lastaflute.web.Execute)

Example 92 with Execute

use of org.lastaflute.web.Execute in project fess by codelibs.

the class ApiAdminFileauthAction method settings.

// ===================================================================================
//                                                                      Search Execute
//                                                                      ==============
// GET /api/admin/fileauth/settings
// POST /api/admin/fileauth/settings
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
    validateApi(body, messages -> {
    });
    final FileAuthPager pager = copyBeanToNewBean(body, FileAuthPager.class);
    final List<FileAuthentication> list = fileAuthService.getFileAuthenticationList(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 : FileAuthPager(org.codelibs.fess.app.pager.FileAuthPager) ApiResult(org.codelibs.fess.app.web.api.ApiResult) 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 93 with Execute

use of org.lastaflute.web.Execute in project fess by codelibs.

the class ApiAdminFileauthAction method post$setting.

// POST /api/admin/fileauth/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.EDIT;
    final FileAuthentication fileAuth = getFileAuthentication(body).map(entity -> {
        try {
            fileAuthService.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(fileAuth.getId()).created(false).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) 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 94 with Execute

use of org.lastaflute.web.Execute in project fess by codelibs.

the class ApiAdminFileconfigAction method settings.

// ===================================================================================
//                                                                      Search Execute
//                                                                      ==============
// GET /api/admin/fileconfig/settings
// POST /api/admin/fileconfig/settings
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
    validateApi(body, messages -> {
    });
    final FileConfigPager pager = copyBeanToNewBean(body, FileConfigPager.class);
    final List<FileConfig> list = fileConfigService.getFileConfigList(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 : AdminFileconfigAction.getFileConfig(org.codelibs.fess.app.web.admin.fileconfig.AdminFileconfigAction.getFileConfig) FileConfig(org.codelibs.fess.es.config.exentity.FileConfig) ApiResult(org.codelibs.fess.app.web.api.ApiResult) FileConfigPager(org.codelibs.fess.app.pager.FileConfigPager) Execute(org.lastaflute.web.Execute)

Example 95 with Execute

use of org.lastaflute.web.Execute in project fess by codelibs.

the class ApiAdminFileconfigAction method post$setting.

// POST /api/admin/fileconfig/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.EDIT;
    final FileConfig fileConfig = getFileConfig(body).map(entity -> {
        try {
            fileConfigService.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(fileConfig.getId()).created(false).status(Status.OK).result());
}
Also used : FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) AdminFileconfigAction.getFileConfig(org.codelibs.fess.app.web.admin.fileconfig.AdminFileconfigAction.getFileConfig) 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) FileConfigPager(org.codelibs.fess.app.pager.FileConfigPager) 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) FileConfig(org.codelibs.fess.es.config.exentity.FileConfig) AdminFileconfigAction.getFileConfig(org.codelibs.fess.app.web.admin.fileconfig.AdminFileconfigAction.getFileConfig) FileConfig(org.codelibs.fess.es.config.exentity.FileConfig) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) Execute(org.lastaflute.web.Execute)

Aggregations

Execute (org.lastaflute.web.Execute)125 ApiResult (org.codelibs.fess.app.web.api.ApiResult)94 Resource (javax.annotation.Resource)83 CrudMode (org.codelibs.fess.app.web.CrudMode)77 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)71 JsonResponse (org.lastaflute.web.response.JsonResponse)71 Collectors (java.util.stream.Collectors)70 List (java.util.List)51 InputStream (java.io.InputStream)39 File (java.io.File)35 StreamResponse (org.lastaflute.web.response.StreamResponse)34 ApiResponse (org.codelibs.fess.app.web.api.ApiResult.ApiResponse)32 Status (org.codelibs.fess.app.web.api.ApiResult.Status)31 Constants (org.codelibs.fess.Constants)26 ApiUpdateResponse (org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse)26 StringUtil (org.codelibs.core.lang.StringUtil)24 ComponentUtil (org.codelibs.fess.util.ComponentUtil)23 ApiConfigResponse (org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse)22 HtmlResponse (org.lastaflute.web.response.HtmlResponse)20 FessAdminAction (org.codelibs.fess.app.web.base.FessAdminAction)14