Search in sources :

Example 1 with UploadForm

use of org.codelibs.fess.app.web.admin.dict.mapping.UploadForm 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 IOException e) {
        throwValidationErrorApi(messages -> messages.addErrorsFailedToUploadProtwordsFile(GLOBAL));
    }
    return asJson(new ApiResult.ApiResponse().status(ApiResult.Status.OK).result());
}
Also used : UploadForm(org.codelibs.fess.app.web.admin.dict.mapping.UploadForm) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) IOException(java.io.IOException) CharMappingPager(org.codelibs.fess.app.pager.CharMappingPager) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) CharMappingItem(org.codelibs.fess.dict.mapping.CharMappingItem) File(java.io.File) CharMappingFile(org.codelibs.fess.dict.mapping.CharMappingFile) StreamResponse(org.lastaflute.web.response.StreamResponse) CrudMode(org.codelibs.fess.app.web.CrudMode) CharMappingService(org.codelibs.fess.app.service.CharMappingService) AdminDictMappingAction.createCharMappingItem(org.codelibs.fess.app.web.admin.dict.mapping.AdminDictMappingAction.createCharMappingItem) Execute(org.lastaflute.web.Execute) InputStream(java.io.InputStream) ApiResult(org.codelibs.fess.app.web.api.ApiResult) InputStream(java.io.InputStream) IOException(java.io.IOException) CharMappingFile(org.codelibs.fess.dict.mapping.CharMappingFile) 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 CharMappingPager (org.codelibs.fess.app.pager.CharMappingPager)1 CharMappingService (org.codelibs.fess.app.service.CharMappingService)1 CrudMode (org.codelibs.fess.app.web.CrudMode)1 AdminDictMappingAction.createCharMappingItem (org.codelibs.fess.app.web.admin.dict.mapping.AdminDictMappingAction.createCharMappingItem)1 UploadForm (org.codelibs.fess.app.web.admin.dict.mapping.UploadForm)1 ApiResult (org.codelibs.fess.app.web.api.ApiResult)1 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)1 CharMappingFile (org.codelibs.fess.dict.mapping.CharMappingFile)1 CharMappingItem (org.codelibs.fess.dict.mapping.CharMappingItem)1 Execute (org.lastaflute.web.Execute)1 JsonResponse (org.lastaflute.web.response.JsonResponse)1 StreamResponse (org.lastaflute.web.response.StreamResponse)1