Search in sources :

Example 6 with ApiResult

use of org.codelibs.fess.app.web.api.ApiResult in project fess by codelibs.

the class ApiAdminDictMappingAction method put$setting.

// PUT /api/admin/dict/mapping/setting/{dictId}
@Execute
public JsonResponse<ApiResult> put$setting(final String dictId, final CreateBody body) {
    body.dictId = dictId;
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.CREATE;
    final CharMappingItem entity = new AdminDictMappingAction().createCharMappingItem(body, () -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateInstance(GLOBAL));
        return null;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateInstance(GLOBAL));
        return null;
    });
    charMappingService.store(body.dictId, entity);
    return asJson(new ApiResult.ApiUpdateResponse().id(String.valueOf(entity.getId())).created(true).status(ApiResult.Status.OK).result());
}
Also used : CharMappingItem(org.codelibs.fess.dict.mapping.CharMappingItem) UploadForm(org.codelibs.fess.app.web.admin.dict.mapping.UploadForm) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) 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(org.codelibs.fess.app.web.admin.dict.mapping.AdminDictMappingAction) Execute(org.lastaflute.web.Execute) InputStream(java.io.InputStream) ApiResult(org.codelibs.fess.app.web.api.ApiResult) AdminDictMappingAction(org.codelibs.fess.app.web.admin.dict.mapping.AdminDictMappingAction) Execute(org.lastaflute.web.Execute)

Example 7 with ApiResult

use of org.codelibs.fess.app.web.api.ApiResult 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());
}
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) 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(org.codelibs.fess.app.web.admin.dict.mapping.AdminDictMappingAction) Execute(org.lastaflute.web.Execute) InputStream(java.io.InputStream) ApiResult(org.codelibs.fess.app.web.api.ApiResult) InputStream(java.io.InputStream) CharMappingFile(org.codelibs.fess.dict.mapping.CharMappingFile) Execute(org.lastaflute.web.Execute)

Example 8 with ApiResult

use of org.codelibs.fess.app.web.api.ApiResult in project fess by codelibs.

the class ApiAdminDictProtwordsAction method put$setting.

// PUT /api/admin/dict/protwords/setting/{dictId}
@Execute
public JsonResponse<ApiResult> put$setting(final String dictId, final CreateBody body) {
    body.dictId = dictId;
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.CREATE;
    final ProtwordsItem entity = createProtwordsItem(body, () -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateInstance(GLOBAL));
        return null;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateInstance(GLOBAL));
        return null;
    });
    protwordsService.store(body.dictId, entity);
    return asJson(new ApiResult.ApiUpdateResponse().id(String.valueOf(entity.getId())).created(true).status(ApiResult.Status.OK).result());
}
Also used : AdminDictProtwordsAction.createProtwordsItem(org.codelibs.fess.app.web.admin.dict.protwords.AdminDictProtwordsAction.createProtwordsItem) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) ProtwordsPager(org.codelibs.fess.app.pager.ProtwordsPager) Resource(javax.annotation.Resource) UploadForm(org.codelibs.fess.app.web.admin.dict.protwords.UploadForm) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) File(java.io.File) StreamResponse(org.lastaflute.web.response.StreamResponse) CrudMode(org.codelibs.fess.app.web.CrudMode) ProtwordsItem(org.codelibs.fess.dict.protwords.ProtwordsItem) ProtwordsService(org.codelibs.fess.app.service.ProtwordsService) Execute(org.lastaflute.web.Execute) ProtwordsFile(org.codelibs.fess.dict.protwords.ProtwordsFile) InputStream(java.io.InputStream) ApiResult(org.codelibs.fess.app.web.api.ApiResult) AdminDictProtwordsAction.createProtwordsItem(org.codelibs.fess.app.web.admin.dict.protwords.AdminDictProtwordsAction.createProtwordsItem) ProtwordsItem(org.codelibs.fess.dict.protwords.ProtwordsItem) Execute(org.lastaflute.web.Execute)

Example 9 with ApiResult

use of org.codelibs.fess.app.web.api.ApiResult in project fess by codelibs.

the class ApiAdminDictProtwordsAction method get$settings.

// GET /api/admin/dict/protwords/settings/{dictId}
@Execute
public JsonResponse<ApiResult> get$settings(final String dictId, final SearchBody body) {
    body.dictId = dictId;
    validateApi(body, messages -> {
    });
    final ProtwordsPager pager = copyBeanToNewBean(body, ProtwordsPager.class);
    return asJson(new ApiResult.ApiConfigsResponse<EditBody>().settings(protwordsService.getProtwordsList(body.dictId, pager).stream().map(protwordsItem -> createEditBody(protwordsItem, dictId)).collect(Collectors.toList())).status(ApiResult.Status.OK).result());
}
Also used : AdminDictProtwordsAction.createProtwordsItem(org.codelibs.fess.app.web.admin.dict.protwords.AdminDictProtwordsAction.createProtwordsItem) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) ProtwordsPager(org.codelibs.fess.app.pager.ProtwordsPager) Resource(javax.annotation.Resource) UploadForm(org.codelibs.fess.app.web.admin.dict.protwords.UploadForm) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) File(java.io.File) StreamResponse(org.lastaflute.web.response.StreamResponse) CrudMode(org.codelibs.fess.app.web.CrudMode) ProtwordsItem(org.codelibs.fess.dict.protwords.ProtwordsItem) ProtwordsService(org.codelibs.fess.app.service.ProtwordsService) Execute(org.lastaflute.web.Execute) ProtwordsFile(org.codelibs.fess.dict.protwords.ProtwordsFile) InputStream(java.io.InputStream) ProtwordsPager(org.codelibs.fess.app.pager.ProtwordsPager) Execute(org.lastaflute.web.Execute)

Example 10 with ApiResult

use of org.codelibs.fess.app.web.api.ApiResult in project fess by codelibs.

the class ApiAdminDictSeunjeonAction method post$setting.

// POST /api/admin/dict/seunjeon/setting/{dictId}
@Execute
public JsonResponse<ApiResult> post$setting(final String dictId, final EditBody body) {
    body.dictId = dictId;
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.EDIT;
    final SeunjeonItem entity = new AdminDictSeunjeonAction().createSeunjeonItem(body, () -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, String.valueOf(body.id)));
        return null;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, String.valueOf(body.id)));
        return null;
    });
    seunjeonService.store(body.dictId, entity);
    return asJson(new ApiResult.ApiUpdateResponse().id(String.valueOf(entity.getId())).created(false).status(ApiResult.Status.OK).result());
}
Also used : SeunjeonItem(org.codelibs.fess.dict.seunjeon.SeunjeonItem) SeunjeonItem(org.codelibs.fess.dict.seunjeon.SeunjeonItem) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) SeunjeonService(org.codelibs.fess.app.service.SeunjeonService) Resource(javax.annotation.Resource) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) File(java.io.File) UploadForm(org.codelibs.fess.app.web.admin.dict.seunjeon.UploadForm) StreamResponse(org.lastaflute.web.response.StreamResponse) CrudMode(org.codelibs.fess.app.web.CrudMode) SeunjeonFile(org.codelibs.fess.dict.seunjeon.SeunjeonFile) AdminDictSeunjeonAction(org.codelibs.fess.app.web.admin.dict.seunjeon.AdminDictSeunjeonAction) Execute(org.lastaflute.web.Execute) InputStream(java.io.InputStream) SeunjeonPager(org.codelibs.fess.app.pager.SeunjeonPager) ApiResult(org.codelibs.fess.app.web.api.ApiResult) AdminDictSeunjeonAction(org.codelibs.fess.app.web.admin.dict.seunjeon.AdminDictSeunjeonAction) Execute(org.lastaflute.web.Execute)

Aggregations

ApiResult (org.codelibs.fess.app.web.api.ApiResult)88 Execute (org.lastaflute.web.Execute)88 Resource (javax.annotation.Resource)65 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)65 JsonResponse (org.lastaflute.web.response.JsonResponse)65 CrudMode (org.codelibs.fess.app.web.CrudMode)63 Collectors (java.util.stream.Collectors)61 List (java.util.List)43 ApiResponse (org.codelibs.fess.app.web.api.ApiResult.ApiResponse)31 Status (org.codelibs.fess.app.web.api.ApiResult.Status)31 ApiUpdateResponse (org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse)26 InputStream (java.io.InputStream)23 StreamResponse (org.lastaflute.web.response.StreamResponse)23 ApiConfigResponse (org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse)22 File (java.io.File)18 Constants (org.codelibs.fess.Constants)12 StringUtil (org.codelibs.core.lang.StringUtil)9 ComponentUtil (org.codelibs.fess.util.ComponentUtil)9 BufferedReader (java.io.BufferedReader)7 InputStreamReader (java.io.InputStreamReader)7