use of org.codelibs.fess.app.web.api.ApiResult in project fess by codelibs.
the class ApiAdminGroupAction method settings.
// GET /api/admin/group
// POST /api/admin/group
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
validateApi(body, messages -> {
});
final GroupPager pager = copyBeanToNewBean(body, GroupPager.class);
final List<Group> list = groupService.getGroupList(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 ApiAdminGroupAction method post$setting.
// POST /api/admin/group/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
validateApi(body, messages -> {
});
body.crudMode = CrudMode.EDIT;
final Group entity = getGroup(body).orElseGet(() -> {
throwValidationErrorApi(messages -> {
messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, body.id);
});
return null;
});
try {
groupService.store(entity);
} catch (final Exception e) {
throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, buildThrowableMessage(e)));
}
return asJson(new ApiResult.ApiUpdateResponse().id(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 ApiAdminGroupAction method delete$setting.
// DELETE /api/admin/group/setting/{id}
@Execute
public JsonResponse<ApiResult> delete$setting(final String id) {
final Group entity = groupService.getGroup(id).orElseGet(() -> {
throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id));
return null;
});
getUserBean().ifPresent(u -> {
if (u.getFessUser() instanceof User && entity.getName().equals(u.getUserId())) {
throwValidationErrorApi(messages -> messages.addErrorsCouldNotDeleteLoggedInUser(GLOBAL));
}
});
try {
groupService.delete(entity);
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
} catch (final Exception e) {
throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToDeleteCrudTable(GLOBAL, buildThrowableMessage(e)));
}
return asJson(new ApiResult.ApiUpdateResponse().id(id).created(false).status(ApiResult.Status.OK).result());
}
use of org.codelibs.fess.app.web.api.ApiResult in project fess by codelibs.
the class ApiAdminJoblogAction method logs.
// ===================================================================================
// Search Execute
// ==============
// GET /api/admin/joblog/logs
@Execute
public JsonResponse<ApiResult> logs(final SearchBody body) {
validateApi(body, messages -> {
});
final JobLogPager pager = copyBeanToNewBean(body, JobLogPager.class);
final List<JobLog> list = jobLogService.getJobLogList(pager);
return asJson(new ApiResult.ApiLogsResponse<EditBody>().logs(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 ApiAdminDictSeunjeonAction method get$settings.
// GET /api/admin/dict/seunjeon/settings/{dictId}
@Execute
public JsonResponse<ApiResult> get$settings(final String dictId, final SearchBody body) {
body.dictId = dictId;
validateApi(body, messages -> {
});
final SeunjeonPager pager = copyBeanToNewBean(body, SeunjeonPager.class);
return asJson(new ApiResult.ApiConfigsResponse<EditBody>().settings(seunjeonService.getSeunjeonList(body.dictId, pager).stream().map(protwordsItem -> createEditBody(protwordsItem, dictId)).collect(Collectors.toList())).status(ApiResult.Status.OK).result());
}
Aggregations