use of org.codelibs.fess.app.web.api.ApiResult in project fess by codelibs.
the class ApiAdminGroupAction method put$setting.
// PUT /api/admin/group/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
validateApi(body, messages -> {
});
body.crudMode = CrudMode.CREATE;
final Group entity = getGroup(body).orElseGet(() -> {
throwValidationErrorApi(messages -> {
messages.addErrorsCrudFailedToCreateInstance(GLOBAL);
});
return null;
});
try {
groupService.store(entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
} catch (final Exception e) {
throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL, buildThrowableMessage(e)));
}
return asJson(new ApiResult.ApiUpdateResponse().id(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 ApiAdminKeymatchAction method put$setting.
// PUT /api/admin/keymatch/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
validateApi(body, messages -> {
});
body.crudMode = CrudMode.CREATE;
final KeyMatch keyMatch = getKeyMatch(body).map(entity -> {
try {
keyMatchService.store(entity);
} catch (final Exception e) {
throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL, buildThrowableMessage(e)));
}
return entity;
}).orElseGet(() -> {
throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateInstance(GLOBAL));
return null;
});
return asJson(new ApiUpdateResponse().id(keyMatch.getId()).created(true).status(Status.OK).result());
}
use of org.codelibs.fess.app.web.api.ApiResult in project fess by codelibs.
the class ApiAdminKeymatchAction method settings.
// ===================================================================================
// Search Execute
// ==============
// GET /api/admin/keymatch/settings
// POST /api/admin/keymatch/settings
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
validateApi(body, messages -> {
});
final KeyMatchPager pager = copyBeanToNewBean(body, KeyMatchPager.class);
final List<KeyMatch> list = keyMatchService.getKeyMatchList(pager);
return asJson(new ApiResult.ApiConfigsResponse<EditBody>().settings(list.stream().map(entity -> createEditBody(entity)).collect(Collectors.toList())).total(pager.getAllRecordCount()).status(ApiResult.Status.OK).result());
}
use of org.codelibs.fess.app.web.api.ApiResult in project fess by codelibs.
the class ApiAdminBadwordAction method post$upload.
// POST /api/admin/badword/upload
@Execute
public JsonResponse<ApiResult> post$upload(final UploadForm body) {
validateApi(body, messages -> {
});
new Thread(() -> {
try (Reader reader = new BufferedReader(new InputStreamReader(body.badWordFile.getInputStream(), getCsvEncoding()))) {
badWordService.importCsv(reader);
suggestHelper.storeAllBadWords();
} catch (final Exception e) {
throw new FessSystemException("Failed to import data.", e);
}
}).start();
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 ApiAdminDuplicatehostAction method settings.
// ===================================================================================
// Search Execute
// ==============
// GET /api/admin/duplicatehost/settings
// POST /api/admin/duplicatehost/settings
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
validateApi(body, messages -> {
});
final DuplicateHostPager pager = copyBeanToNewBean(body, DuplicateHostPager.class);
final List<DuplicateHost> list = duplicateHostService.getDuplicateHostList(pager);
return asJson(new ApiResult.ApiConfigsResponse<EditBody>().settings(list.stream().map(entity -> createEditBody(entity)).collect(Collectors.toList())).total(pager.getAllRecordCount()).status(ApiResult.Status.OK).result());
}
Aggregations