use of org.apache.ignite.internal.configuration.rest.presentation.ConfigurationPresentation in project ignite-3 by apache.
the class ConfigurationHttpHandlers method handleUpdate.
/**
* Handle a configuration update request as json.
*
* @param req Rest request.
* @param res Rest response.
* @param presentation Configuration presentation.
*/
private static CompletableFuture<RestApiHttpResponse> handleUpdate(RestApiHttpRequest req, RestApiHttpResponse res, ConfigurationPresentation<String> presentation) {
String updateReq = req.request().content().toString(StandardCharsets.UTF_8);
return presentation.update(updateReq).thenApply(v -> res).exceptionally(e -> {
if (e instanceof CompletionException) {
e = e.getCause();
}
ErrorResult errRes;
if (e instanceof IllegalArgumentException) {
errRes = new ErrorResult("INVALID_CONFIG_FORMAT", e.getMessage());
} else if (e instanceof ConfigurationValidationException) {
errRes = new ErrorResult("VALIDATION_EXCEPTION", e.getMessage());
} else if (e instanceof IgniteException) {
errRes = new ErrorResult("APPLICATION_EXCEPTION", e.getMessage());
} else {
throw new CompletionException(e);
}
res.status(BAD_REQUEST);
res.json(Map.of("error", errRes));
return res;
});
}
Aggregations