Search in sources :

Example 1 with SeunjeonItem

use of org.codelibs.fess.dict.seunjeon.SeunjeonItem in project fess by codelibs.

the class ApiAdminDictSeunjeonAction method post$setting.

// POST /api/admin/dict/seunjeon/setting/{dictId}
@Execute
public JsonResponse<ApiResult> post$setting(final String dictId, final EditBody body) {
    body.dictId = dictId;
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.EDIT;
    final SeunjeonItem entity = new AdminDictSeunjeonAction().createSeunjeonItem(body, () -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, String.valueOf(body.id)));
        return null;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, String.valueOf(body.id)));
        return null;
    });
    seunjeonService.store(body.dictId, entity);
    return asJson(new ApiResult.ApiUpdateResponse().id(String.valueOf(entity.getId())).created(false).status(ApiResult.Status.OK).result());
}
Also used : SeunjeonItem(org.codelibs.fess.dict.seunjeon.SeunjeonItem) SeunjeonItem(org.codelibs.fess.dict.seunjeon.SeunjeonItem) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) SeunjeonService(org.codelibs.fess.app.service.SeunjeonService) Resource(javax.annotation.Resource) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) File(java.io.File) UploadForm(org.codelibs.fess.app.web.admin.dict.seunjeon.UploadForm) StreamResponse(org.lastaflute.web.response.StreamResponse) CrudMode(org.codelibs.fess.app.web.CrudMode) SeunjeonFile(org.codelibs.fess.dict.seunjeon.SeunjeonFile) AdminDictSeunjeonAction(org.codelibs.fess.app.web.admin.dict.seunjeon.AdminDictSeunjeonAction) Execute(org.lastaflute.web.Execute) InputStream(java.io.InputStream) SeunjeonPager(org.codelibs.fess.app.pager.SeunjeonPager) ApiResult(org.codelibs.fess.app.web.api.ApiResult) AdminDictSeunjeonAction(org.codelibs.fess.app.web.admin.dict.seunjeon.AdminDictSeunjeonAction) Execute(org.lastaflute.web.Execute)

Example 2 with SeunjeonItem

use of org.codelibs.fess.dict.seunjeon.SeunjeonItem in project fess by codelibs.

the class ApiAdminDictSeunjeonAction method put$setting.

// PUT /api/admin/dict/seunjeon/setting/{dictId}
@Execute
public JsonResponse<ApiResult> put$setting(final String dictId, final CreateBody body) {
    body.dictId = dictId;
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.CREATE;
    final SeunjeonItem entity = new AdminDictSeunjeonAction().createSeunjeonItem(body, () -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateInstance(GLOBAL));
        return null;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateInstance(GLOBAL));
        return null;
    });
    seunjeonService.store(body.dictId, entity);
    return asJson(new ApiResult.ApiUpdateResponse().id(String.valueOf(entity.getId())).created(true).status(ApiResult.Status.OK).result());
}
Also used : SeunjeonItem(org.codelibs.fess.dict.seunjeon.SeunjeonItem) SeunjeonItem(org.codelibs.fess.dict.seunjeon.SeunjeonItem) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) SeunjeonService(org.codelibs.fess.app.service.SeunjeonService) Resource(javax.annotation.Resource) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) File(java.io.File) UploadForm(org.codelibs.fess.app.web.admin.dict.seunjeon.UploadForm) StreamResponse(org.lastaflute.web.response.StreamResponse) CrudMode(org.codelibs.fess.app.web.CrudMode) SeunjeonFile(org.codelibs.fess.dict.seunjeon.SeunjeonFile) AdminDictSeunjeonAction(org.codelibs.fess.app.web.admin.dict.seunjeon.AdminDictSeunjeonAction) Execute(org.lastaflute.web.Execute) InputStream(java.io.InputStream) SeunjeonPager(org.codelibs.fess.app.pager.SeunjeonPager) ApiResult(org.codelibs.fess.app.web.api.ApiResult) AdminDictSeunjeonAction(org.codelibs.fess.app.web.admin.dict.seunjeon.AdminDictSeunjeonAction) Execute(org.lastaflute.web.Execute)

Aggregations

File (java.io.File)2 InputStream (java.io.InputStream)2 Collectors (java.util.stream.Collectors)2 Resource (javax.annotation.Resource)2 SeunjeonPager (org.codelibs.fess.app.pager.SeunjeonPager)2 SeunjeonService (org.codelibs.fess.app.service.SeunjeonService)2 CrudMode (org.codelibs.fess.app.web.CrudMode)2 AdminDictSeunjeonAction (org.codelibs.fess.app.web.admin.dict.seunjeon.AdminDictSeunjeonAction)2 UploadForm (org.codelibs.fess.app.web.admin.dict.seunjeon.UploadForm)2 ApiResult (org.codelibs.fess.app.web.api.ApiResult)2 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)2 SeunjeonFile (org.codelibs.fess.dict.seunjeon.SeunjeonFile)2 SeunjeonItem (org.codelibs.fess.dict.seunjeon.SeunjeonItem)2 Execute (org.lastaflute.web.Execute)2 JsonResponse (org.lastaflute.web.response.JsonResponse)2 StreamResponse (org.lastaflute.web.response.StreamResponse)2