Search in sources :

Example 1 with KuromojiItem

use of org.codelibs.fess.dict.kuromoji.KuromojiItem in project fess by codelibs.

the class ApiAdminDictKuromojiAction method put$setting.

// PUT /api/admin/dict/kuromoji/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 KuromojiItem entity = createKuromojiItem(this, body, () -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateInstance(GLOBAL));
        return null;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateInstance(GLOBAL));
        return null;
    });
    kuromojiService.store(body.dictId, entity);
    return asJson(new ApiResult.ApiUpdateResponse().id(String.valueOf(entity.getId())).created(true).status(ApiResult.Status.OK).result());
}
Also used : FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) IOException(java.io.IOException) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) File(java.io.File) KuromojiItem(org.codelibs.fess.dict.kuromoji.KuromojiItem) StreamResponse(org.lastaflute.web.response.StreamResponse) KuromojiPager(org.codelibs.fess.app.pager.KuromojiPager) CrudMode(org.codelibs.fess.app.web.CrudMode) KuromojiFile(org.codelibs.fess.dict.kuromoji.KuromojiFile) Execute(org.lastaflute.web.Execute) AdminDictKuromojiAction.createKuromojiItem(org.codelibs.fess.app.web.admin.dict.kuromoji.AdminDictKuromojiAction.createKuromojiItem) KuromojiService(org.codelibs.fess.app.service.KuromojiService) InputStream(java.io.InputStream) UploadForm(org.codelibs.fess.app.web.admin.dict.kuromoji.UploadForm) ApiResult(org.codelibs.fess.app.web.api.ApiResult) KuromojiItem(org.codelibs.fess.dict.kuromoji.KuromojiItem) AdminDictKuromojiAction.createKuromojiItem(org.codelibs.fess.app.web.admin.dict.kuromoji.AdminDictKuromojiAction.createKuromojiItem) Execute(org.lastaflute.web.Execute)

Example 2 with KuromojiItem

use of org.codelibs.fess.dict.kuromoji.KuromojiItem in project fess by codelibs.

the class ApiAdminDictKuromojiAction method post$setting.

// POST /api/admin/dict/kuromoji/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 KuromojiItem entity = createKuromojiItem(this, body, () -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, String.valueOf(body.id)));
        return null;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, String.valueOf(body.id)));
        return null;
    });
    kuromojiService.store(body.dictId, entity);
    return asJson(new ApiResult.ApiUpdateResponse().id(String.valueOf(entity.getId())).created(false).status(ApiResult.Status.OK).result());
}
Also used : FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) IOException(java.io.IOException) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) File(java.io.File) KuromojiItem(org.codelibs.fess.dict.kuromoji.KuromojiItem) StreamResponse(org.lastaflute.web.response.StreamResponse) KuromojiPager(org.codelibs.fess.app.pager.KuromojiPager) CrudMode(org.codelibs.fess.app.web.CrudMode) KuromojiFile(org.codelibs.fess.dict.kuromoji.KuromojiFile) Execute(org.lastaflute.web.Execute) AdminDictKuromojiAction.createKuromojiItem(org.codelibs.fess.app.web.admin.dict.kuromoji.AdminDictKuromojiAction.createKuromojiItem) KuromojiService(org.codelibs.fess.app.service.KuromojiService) InputStream(java.io.InputStream) UploadForm(org.codelibs.fess.app.web.admin.dict.kuromoji.UploadForm) ApiResult(org.codelibs.fess.app.web.api.ApiResult) KuromojiItem(org.codelibs.fess.dict.kuromoji.KuromojiItem) AdminDictKuromojiAction.createKuromojiItem(org.codelibs.fess.app.web.admin.dict.kuromoji.AdminDictKuromojiAction.createKuromojiItem) Execute(org.lastaflute.web.Execute)

Aggregations

File (java.io.File)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Collectors (java.util.stream.Collectors)2 Resource (javax.annotation.Resource)2 KuromojiPager (org.codelibs.fess.app.pager.KuromojiPager)2 KuromojiService (org.codelibs.fess.app.service.KuromojiService)2 CrudMode (org.codelibs.fess.app.web.CrudMode)2 AdminDictKuromojiAction.createKuromojiItem (org.codelibs.fess.app.web.admin.dict.kuromoji.AdminDictKuromojiAction.createKuromojiItem)2 UploadForm (org.codelibs.fess.app.web.admin.dict.kuromoji.UploadForm)2 ApiResult (org.codelibs.fess.app.web.api.ApiResult)2 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)2 KuromojiFile (org.codelibs.fess.dict.kuromoji.KuromojiFile)2 KuromojiItem (org.codelibs.fess.dict.kuromoji.KuromojiItem)2 Execute (org.lastaflute.web.Execute)2 JsonResponse (org.lastaflute.web.response.JsonResponse)2 StreamResponse (org.lastaflute.web.response.StreamResponse)2