use of org.codelibs.fess.app.web.api.ApiResult.ApiErrorResponse in project fess by codelibs.
the class ApiAdminFileauthAction method put$setting.
// PUT /api/admin/fileauth/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
validateApi(body, messages -> {
});
if (!isValidFileConfigId(body.fileConfigId)) {
return asJson(new ApiErrorResponse().message("invalid fileConfigId").status(Status.BAD_REQUEST).result());
}
body.crudMode = CrudMode.CREATE;
final FileAuthentication fileAuth = getFileAuthentication(body).map(entity -> {
try {
fileAuthService.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(fileAuth.getId()).created(true).status(Status.OK).result());
}
use of org.codelibs.fess.app.web.api.ApiResult.ApiErrorResponse in project fess by codelibs.
the class ApiAdminWebauthAction method put$setting.
// PUT /api/admin/webauth/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 WebAuthentication webAuth = getWebAuthentication(body).map(entity -> {
try {
webAuthService.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(webAuth.getId()).created(true).status(Status.OK).result());
}
use of org.codelibs.fess.app.web.api.ApiResult.ApiErrorResponse 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