use of org.infinispan.counter.configuration.CounterConfigurationSerializer in project infinispan by infinispan.
the class CounterResource method getConfig.
private CompletionStage<RestResponse> getConfig(RestRequest request) {
NettyRestResponse.Builder responseBuilder = new NettyRestResponse.Builder();
String counterName = request.variables().get("counterName");
return invocationHelper.getCounterManager().getConfigurationAsync(counterName).thenApply(cfg -> {
if (cfg == null)
return responseBuilder.status(NOT_FOUND).build();
AbstractCounterConfiguration parsedConfig = ConvertUtil.configToParsedConfig(counterName, cfg);
CounterConfigurationSerializer ccs = new CounterConfigurationSerializer();
StringBuilderWriter sw = new StringBuilderWriter();
try (ConfigurationWriter w = ConfigurationWriter.to(sw).withType(APPLICATION_JSON).build()) {
ccs.serializeConfiguration(w, parsedConfig);
}
return responseBuilder.entity(sw.toString()).contentType(APPLICATION_JSON).build();
});
}
Aggregations