use of org.codelibs.fess.es.config.exentity.RequestHeader in project fess by codelibs.
the class ApiAdminReqheaderAction method post$setting.
// POST /api/admin/reqheader/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
validateApi(body, messages -> {
});
body.crudMode = CrudMode.EDIT;
final RequestHeader reqHeader = getRequestHeader(body).map(entity -> {
try {
reqHeaderService.store(entity);
} catch (final Exception e) {
throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, buildThrowableMessage(e)));
}
return entity;
}).orElseGet(() -> {
throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, body.id));
return null;
});
return asJson(new ApiUpdateResponse().id(reqHeader.getId()).created(false).status(Status.OK).result());
}
use of org.codelibs.fess.es.config.exentity.RequestHeader in project fess by codelibs.
the class ApiAdminReqheaderAction method settings.
// ===================================================================================
// Search Execute
// ==============
// GET /api/admin/reqheader/settings
// POST /api/admin/reqheader/settings
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
validateApi(body, messages -> {
});
final ReqHeaderPager pager = copyBeanToNewBean(body, ReqHeaderPager.class);
final List<RequestHeader> list = reqHeaderService.getRequestHeaderList(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.es.config.exentity.RequestHeader in project fess by codelibs.
the class ApiAdminReqheaderAction method put$setting.
// PUT /api/admin/reqheader/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
validateApi(body, messages -> {
});
if (!isValidWebConfigId(body.webConfigId)) {
return asJson(new ApiErrorResponse().message("invalid webConfigId").status(Status.BAD_REQUEST).result());
}
body.crudMode = CrudMode.CREATE;
final RequestHeader reqHeader = getRequestHeader(body).map(entity -> {
try {
reqHeaderService.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(reqHeader.getId()).created(true).status(Status.OK).result());
}
Aggregations