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