use of org.codelibs.fess.dict.mapping.CharMappingFile in project fess by codelibs.
the class ApiAdminDictMappingAction method post$upload.
// POST /api/admin/dict/mapping/upload/{dictId}
@Execute
public JsonResponse<ApiResult> post$upload(final String dictId, final UploadForm form) {
form.dictId = dictId;
validateApi(form, messages -> {
});
final CharMappingFile file = charMappingService.getCharMappingFile(form.dictId).orElseGet(() -> {
throwValidationErrorApi(messages -> messages.addErrorsFailedToUploadProtwordsFile(GLOBAL));
return null;
});
try (InputStream inputStream = form.charMappingFile.getInputStream()) {
file.update(inputStream);
} catch (final Throwable e) {
e.printStackTrace();
throwValidationErrorApi(messages -> messages.addErrorsFailedToUploadProtwordsFile(GLOBAL));
}
return asJson(new ApiResult.ApiResponse().status(ApiResult.Status.OK).result());
}
Aggregations