Search in sources :

Example 36 with Execute

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

the class ApiAdminBadwordAction method put$setting.

// PUT /api/admin/badword/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.CREATE;
    final BadWord entity = getBadWord(body).orElseGet(() -> {
        throwValidationErrorApi(messages -> {
            messages.addErrorsCrudFailedToCreateInstance(GLOBAL);
        });
        return null;
    });
    try {
        badWordService.store(entity);
        suggestHelper.addBadWord(entity.getSuggestWord());
    } 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 : BadWordService(org.codelibs.fess.app.service.BadWordService) FessSystemException(org.codelibs.fess.exception.FessSystemException) UploadForm(org.codelibs.fess.app.web.admin.badword.UploadForm) ApiResult(org.codelibs.fess.app.web.api.ApiResult) StreamResponse(org.lastaflute.web.response.StreamResponse) CrudMode(org.codelibs.fess.app.web.CrudMode) BadWord(org.codelibs.fess.es.config.exentity.BadWord) AdminBadwordAction.getBadWord(org.codelibs.fess.app.web.admin.badword.AdminBadwordAction.getBadWord) OutputStreamWriter(java.io.OutputStreamWriter) Path(java.nio.file.Path) Files(java.nio.file.Files) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) BufferedWriter(java.io.BufferedWriter) Resource(javax.annotation.Resource) Reader(java.io.Reader) JsonResponse(org.lastaflute.web.response.JsonResponse) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) List(java.util.List) Writer(java.io.Writer) Execute(org.lastaflute.web.Execute) BufferedReader(java.io.BufferedReader) BadWordPager(org.codelibs.fess.app.pager.BadWordPager) SuggestHelper(org.codelibs.fess.helper.SuggestHelper) InputStream(java.io.InputStream) ApiResult(org.codelibs.fess.app.web.api.ApiResult) BadWord(org.codelibs.fess.es.config.exentity.BadWord) AdminBadwordAction.getBadWord(org.codelibs.fess.app.web.admin.badword.AdminBadwordAction.getBadWord) FessSystemException(org.codelibs.fess.exception.FessSystemException) Execute(org.lastaflute.web.Execute)

Example 37 with Execute

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

the class ApiAdminBadwordAction 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 BadWord entity = getBadWord(body).orElseGet(() -> {
        throwValidationErrorApi(messages -> {
            messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, body.id);
        });
        return null;
    });
    try {
        badWordService.store(entity);
        suggestHelper.storeAllBadWords();
    } 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 : BadWordService(org.codelibs.fess.app.service.BadWordService) FessSystemException(org.codelibs.fess.exception.FessSystemException) UploadForm(org.codelibs.fess.app.web.admin.badword.UploadForm) ApiResult(org.codelibs.fess.app.web.api.ApiResult) StreamResponse(org.lastaflute.web.response.StreamResponse) CrudMode(org.codelibs.fess.app.web.CrudMode) BadWord(org.codelibs.fess.es.config.exentity.BadWord) AdminBadwordAction.getBadWord(org.codelibs.fess.app.web.admin.badword.AdminBadwordAction.getBadWord) OutputStreamWriter(java.io.OutputStreamWriter) Path(java.nio.file.Path) Files(java.nio.file.Files) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) BufferedWriter(java.io.BufferedWriter) Resource(javax.annotation.Resource) Reader(java.io.Reader) JsonResponse(org.lastaflute.web.response.JsonResponse) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) List(java.util.List) Writer(java.io.Writer) Execute(org.lastaflute.web.Execute) BufferedReader(java.io.BufferedReader) BadWordPager(org.codelibs.fess.app.pager.BadWordPager) SuggestHelper(org.codelibs.fess.helper.SuggestHelper) InputStream(java.io.InputStream) ApiResult(org.codelibs.fess.app.web.api.ApiResult) BadWord(org.codelibs.fess.es.config.exentity.BadWord) AdminBadwordAction.getBadWord(org.codelibs.fess.app.web.admin.badword.AdminBadwordAction.getBadWord) FessSystemException(org.codelibs.fess.exception.FessSystemException) Execute(org.lastaflute.web.Execute)

Example 38 with Execute

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

the class ApiAdminBoostdocAction method settings.

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

Example 39 with Execute

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

the class ApiAdminRoleAction method settings.

// GET /api/admin/role
// POST /api/admin/role
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
    validateApi(body, messages -> {
    });
    final RolePager pager = copyBeanToNewBean(body, RolePager.class);
    final List<Role> list = roleService.getRoleList(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 : RolePager(org.codelibs.fess.app.pager.RolePager) Role(org.codelibs.fess.es.user.exentity.Role) AdminRoleAction.getRole(org.codelibs.fess.app.web.admin.role.AdminRoleAction.getRole) ApiResult(org.codelibs.fess.app.web.api.ApiResult) Execute(org.lastaflute.web.Execute)

Example 40 with Execute

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

the class ApiAdminSchedulerAction method settings.

// GET /api/admin/scheduler
// POST /api/admin/scheduler
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
    validateApi(body, messages -> {
    });
    final SchedulerPager pager = copyBeanToNewBean(body, SchedulerPager.class);
    final List<ScheduledJob> list = scheduledJobService.getScheduledJobList(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 : ApiResult(org.codelibs.fess.app.web.api.ApiResult) AdminSchedulerAction.getScheduledJob(org.codelibs.fess.app.web.admin.scheduler.AdminSchedulerAction.getScheduledJob) ScheduledJob(org.codelibs.fess.es.config.exentity.ScheduledJob) SchedulerPager(org.codelibs.fess.app.pager.SchedulerPager) 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