use of org.codelibs.fess.app.web.api.ApiResult in project fess by codelibs.
the class ApiAdminDictKuromojiAction method post$setting.
// POST /api/admin/dict/kuromoji/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 KuromojiItem entity = createKuromojiItem(body).orElseGet(() -> {
throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, String.valueOf(body.id)));
return null;
});
kuromojiService.store(body.dictId, entity);
return asJson(new ApiResult.ApiUpdateResponse().id(String.valueOf(entity.getId())).created(false).status(ApiResult.Status.OK).result());
}
use of org.codelibs.fess.app.web.api.ApiResult in project fess by codelibs.
the class ApiAdminDictMappingAction method get$settings.
// GET /api/admin/dict/mapping/settings/{dictId}
@Execute
public JsonResponse<ApiResult> get$settings(final String dictId, final SearchBody body) {
body.dictId = dictId;
validateApi(body, messages -> {
});
final CharMappingPager pager = copyBeanToNewBean(body, CharMappingPager.class);
return asJson(new ApiResult.ApiConfigsResponse<EditBody>().settings(charMappingService.getCharMappingList(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 ApiAdminDictMappingAction method post$setting.
// POST /api/admin/dict/mapping/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 CharMappingItem entity = new AdminDictMappingAction().createCharMappingItem(body, () -> {
throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, String.valueOf(body.id)));
return null;
}).orElseGet(() -> {
throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, String.valueOf(body.id)));
return null;
});
charMappingService.store(body.dictId, entity);
return asJson(new ApiResult.ApiUpdateResponse().id(String.valueOf(entity.getId())).created(false).status(ApiResult.Status.OK).result());
}
Aggregations