Search in sources :

Example 1 with UploadForm

use of org.codelibs.fess.app.web.admin.dict.kuromoji.UploadForm in project fess by codelibs.

the class ApiAdminDictKuromojiAction method post$upload.

// POST /api/admin/dict/kuromoji/upload/{dictId}
@Execute
public JsonResponse<ApiResult> post$upload(final String dictId, final UploadForm form) {
    form.dictId = dictId;
    validateApi(form, messages -> {
    });
    final KuromojiFile file = kuromojiService.getKuromojiFile(form.dictId).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsFailedToUploadProtwordsFile(GLOBAL));
        return null;
    });
    try (InputStream inputStream = form.kuromojiFile.getInputStream()) {
        file.update(inputStream);
    } catch (final IOException e) {
        throwValidationErrorApi(messages -> messages.addErrorsFailedToUploadProtwordsFile(GLOBAL));
    }
    return asJson(new ApiResult.ApiResponse().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) KuromojiFile(org.codelibs.fess.dict.kuromoji.KuromojiFile) InputStream(java.io.InputStream) IOException(java.io.IOException) Execute(org.lastaflute.web.Execute)

Aggregations

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