use of org.lastaflute.web.Execute in project fess by codelibs.
the class ApiAdminBadwordAction method put$setting.
// PUT /api/admin/badword/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
validateApi(body, messages -> {
});
body.crudMode = CrudMode.CREATE;
final BadWord entity = getBadWord(body).orElseGet(() -> {
throwValidationErrorApi(messages -> {
messages.addErrorsCrudFailedToCreateInstance(GLOBAL);
});
return null;
});
try {
badWordService.store(entity);
suggestHelper.addBadWord(entity.getSuggestWord());
} 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.lastaflute.web.Execute in project fess by codelibs.
the class ApiAdminBadwordAction method post$setting.
// POST /api/admin/user/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
validateApi(body, messages -> {
});
body.crudMode = CrudMode.EDIT;
final BadWord entity = getBadWord(body).orElseGet(() -> {
throwValidationErrorApi(messages -> {
messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, body.id);
});
return null;
});
try {
badWordService.store(entity);
suggestHelper.storeAllBadWords();
} 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.lastaflute.web.Execute in project fess by codelibs.
the class ApiAdminBoostdocAction method settings.
// ===================================================================================
// Search Execute
// ==============
// GET /api/admin/boostdoc
// POST /api/admin/boostdoc
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
validateApi(body, messages -> {
});
final BoostDocPager pager = copyBeanToNewBean(body, BoostDocPager.class);
final List<BoostDocumentRule> list = boostDocumentRuleService.getBoostDocumentRuleList(pager);
return asJson(new ApiConfigsResponse<EditBody>().settings(list.stream().map(entity -> createEditBody(entity)).collect(Collectors.toList())).total(pager.getAllRecordCount()).status(Status.OK).result());
}
use of org.lastaflute.web.Execute in project fess by codelibs.
the class ApiAdminRoleAction method settings.
// GET /api/admin/role
// POST /api/admin/role
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
validateApi(body, messages -> {
});
final RolePager pager = copyBeanToNewBean(body, RolePager.class);
final List<Role> list = roleService.getRoleList(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.lastaflute.web.Execute in project fess by codelibs.
the class ApiAdminSchedulerAction method settings.
// GET /api/admin/scheduler
// POST /api/admin/scheduler
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
validateApi(body, messages -> {
});
final SchedulerPager pager = copyBeanToNewBean(body, SchedulerPager.class);
final List<ScheduledJob> list = scheduledJobService.getScheduledJobList(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