use of org.springframework.cloud.stream.schema.SchemaNotFoundException in project spring-cloud-stream by spring-cloud.
the class ConfluentSchemaRegistryClient method fetch.
@Override
public String fetch(SchemaReference schemaReference) {
String path = String.format("/subjects/%s/versions/%d", schemaReference.getSubject(), schemaReference.getVersion());
HttpHeaders headers = new HttpHeaders();
headers.put("Accept", ACCEPT_HEADERS);
headers.add("Content-Type", "application/vnd.schemaregistry.v1+json");
HttpEntity<String> request = new HttpEntity<>("", headers);
try {
ResponseEntity<Map> response = this.template.exchange(this.endpoint + path, HttpMethod.GET, request, Map.class);
return (String) response.getBody().get("schema");
} catch (HttpStatusCodeException e) {
if (e.getStatusCode() == HttpStatus.NOT_FOUND) {
throw new SchemaNotFoundException(String.format("Could not find schema for reference: %s", schemaReference));
} else {
throw e;
}
}
}
use of org.springframework.cloud.stream.schema.SchemaNotFoundException in project spring-cloud-stream by spring-cloud.
the class ConfluentSchemaRegistryClient method fetch.
@Override
public String fetch(int id) {
String path = String.format("/schemas/ids/%d", id);
HttpHeaders headers = new HttpHeaders();
headers.put("Accept", ACCEPT_HEADERS);
headers.add("Content-Type", "application/vnd.schemaregistry.v1+json");
HttpEntity<String> request = new HttpEntity<>("", headers);
try {
ResponseEntity<Map> response = this.template.exchange(this.endpoint + path, HttpMethod.GET, request, Map.class);
return (String) response.getBody().get("schema");
} catch (HttpStatusCodeException e) {
if (e.getStatusCode() == HttpStatus.NOT_FOUND) {
throw new SchemaNotFoundException(String.format("Could not find schema with id: %s", id));
} else {
throw e;
}
}
}
Aggregations