use of org.codelibs.fess.dict.kuromoji.KuromojiFile 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());
}
Aggregations