use of com.hortonworks.registries.common.catalog.CatalogResponse in project registry by hortonworks.
the class SchemaRegistryClient method handleSchemaIdVersionResponse.
private SchemaIdVersion handleSchemaIdVersionResponse(SchemaMetadataInfo schemaMetadataInfo, Response response) throws IncompatibleSchemaException, InvalidSchemaException {
int status = response.getStatus();
String msg = response.readEntity(String.class);
if (status == Response.Status.BAD_REQUEST.getStatusCode() || status == Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()) {
CatalogResponse catalogResponse = readCatalogResponse(msg);
if (CatalogResponse.ResponseMessage.INCOMPATIBLE_SCHEMA.getCode() == catalogResponse.getResponseCode()) {
throw new IncompatibleSchemaException(catalogResponse.getResponseMessage());
} else if (CatalogResponse.ResponseMessage.INVALID_SCHEMA.getCode() == catalogResponse.getResponseCode()) {
throw new InvalidSchemaException(catalogResponse.getResponseMessage());
} else {
throw new RuntimeException(catalogResponse.getResponseMessage());
}
}
Integer version = readEntity(msg, Integer.class);
SchemaVersionInfo schemaVersionInfo = doGetSchemaVersionInfo(new SchemaVersionKey(schemaMetadataInfo.getSchemaMetadata().getName(), version));
return new SchemaIdVersion(schemaMetadataInfo.getId(), version, schemaVersionInfo.getId());
}
use of com.hortonworks.registries.common.catalog.CatalogResponse in project registry by hortonworks.
the class SchemaRegistryClient method handleSchemaLifeCycleResponse.
private boolean handleSchemaLifeCycleResponse(Response response) throws SchemaNotFoundException, SchemaLifecycleException {
boolean result;
int status = response.getStatus();
if (status == Response.Status.OK.getStatusCode()) {
result = response.readEntity(Boolean.class);
} else if (status == Response.Status.NOT_FOUND.getStatusCode()) {
throw new SchemaNotFoundException(response.readEntity(String.class));
} else if (status == Response.Status.BAD_REQUEST.getStatusCode()) {
CatalogResponse catalogResponse = readCatalogResponse(response.readEntity(String.class));
if (catalogResponse.getResponseCode() == CatalogResponse.ResponseMessage.INCOMPATIBLE_SCHEMA.getCode()) {
throw new SchemaLifecycleException(new IncompatibleSchemaException(catalogResponse.getResponseMessage()));
}
throw new SchemaLifecycleException(catalogResponse.getResponseMessage());
} else {
throw new RuntimeException(response.readEntity(String.class));
}
return result;
}
Aggregations