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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations