use of io.confluent.rest.exceptions.RestException in project schema-registry by confluentinc.
the class KafkaSchemaRegistry method forwardRegisterRequestToLeader.
private int forwardRegisterRequestToLeader(String subject, Schema schema, boolean normalize, Map<String, String> headerProperties) throws SchemaRegistryRequestForwardingException {
final UrlList baseUrl = leaderRestService.getBaseUrls();
RegisterSchemaRequest registerSchemaRequest = new RegisterSchemaRequest();
registerSchemaRequest.setSchema(schema.getSchema());
registerSchemaRequest.setSchemaType(schema.getSchemaType());
registerSchemaRequest.setReferences(schema.getReferences());
registerSchemaRequest.setVersion(schema.getVersion());
registerSchemaRequest.setId(schema.getId());
log.debug(String.format("Forwarding registering schema request %s to %s", registerSchemaRequest, baseUrl));
try {
int id = leaderRestService.registerSchema(headerProperties, registerSchemaRequest, subject, normalize);
return id;
} catch (IOException e) {
throw new SchemaRegistryRequestForwardingException(String.format("Unexpected error while forwarding the registering schema request %s to %s", registerSchemaRequest, baseUrl), e);
} catch (RestClientException e) {
throw new RestException(e.getMessage(), e.getStatus(), e.getErrorCode(), e);
}
}
use of io.confluent.rest.exceptions.RestException in project schema-registry by confluentinc.
the class KafkaSchemaRegistry method forwardDeleteSchemaVersionRequestToLeader.
private void forwardDeleteSchemaVersionRequestToLeader(Map<String, String> headerProperties, String subject, Integer version, boolean permanentDelete) throws SchemaRegistryRequestForwardingException {
UrlList baseUrl = leaderRestService.getBaseUrls();
log.debug(String.format("Forwarding deleteSchemaVersion schema version request %s-%s to %s", subject, version, baseUrl));
try {
leaderRestService.deleteSchemaVersion(headerProperties, subject, String.valueOf(version), permanentDelete);
} catch (IOException e) {
throw new SchemaRegistryRequestForwardingException(String.format("Unexpected error while forwarding deleteSchemaVersion schema version " + "request %s-%s to %s", subject, version, baseUrl), e);
} catch (RestClientException e) {
throw new RestException(e.getMessage(), e.getStatus(), e.getErrorCode(), e);
}
}
use of io.confluent.rest.exceptions.RestException in project schema-registry by confluentinc.
the class KafkaSchemaRegistry method forwardDeleteSubjectRequestToLeader.
private List<Integer> forwardDeleteSubjectRequestToLeader(Map<String, String> requestProperties, String subject, boolean permanentDelete) throws SchemaRegistryRequestForwardingException {
UrlList baseUrl = leaderRestService.getBaseUrls();
log.debug(String.format("Forwarding delete subject request for %s to %s", subject, baseUrl));
try {
return leaderRestService.deleteSubject(requestProperties, subject, permanentDelete);
} catch (IOException e) {
throw new SchemaRegistryRequestForwardingException(String.format("Unexpected error while forwarding delete subject " + "request %s to %s", subject, baseUrl), e);
} catch (RestClientException e) {
throw new RestException(e.getMessage(), e.getStatus(), e.getErrorCode(), e);
}
}
use of io.confluent.rest.exceptions.RestException in project schema-registry by confluentinc.
the class KafkaSchemaRegistry method forwardSetModeRequestToLeader.
private void forwardSetModeRequestToLeader(String subject, Mode mode, boolean force, Map<String, String> headerProperties) throws SchemaRegistryRequestForwardingException {
UrlList baseUrl = leaderRestService.getBaseUrls();
ModeUpdateRequest modeUpdateRequest = new ModeUpdateRequest();
modeUpdateRequest.setMode(mode.name());
log.debug(String.format("Forwarding update mode request %s to %s", modeUpdateRequest, baseUrl));
try {
leaderRestService.setMode(headerProperties, modeUpdateRequest, subject, force);
} catch (IOException e) {
throw new SchemaRegistryRequestForwardingException(String.format("Unexpected error while forwarding the update mode request %s to %s", modeUpdateRequest, baseUrl), e);
} catch (RestClientException e) {
throw new RestException(e.getMessage(), e.getStatus(), e.getErrorCode(), e);
}
}
use of io.confluent.rest.exceptions.RestException in project schema-registry by confluentinc.
the class KafkaSchemaRegistry method forwardDeleteSubjectModeRequestToLeader.
private void forwardDeleteSubjectModeRequestToLeader(String subject, Map<String, String> headerProperties) throws SchemaRegistryRequestForwardingException {
UrlList baseUrl = leaderRestService.getBaseUrls();
log.debug(String.format("Forwarding delete subject mode request %s to %s", subject, baseUrl));
try {
leaderRestService.deleteSubjectMode(headerProperties, subject);
} catch (IOException e) {
throw new SchemaRegistryRequestForwardingException(String.format("Unexpected error while forwarding delete subject mode" + "request %s to %s", subject, baseUrl), e);
} catch (RestClientException e) {
throw new RestException(e.getMessage(), e.getStatus(), e.getErrorCode(), e);
}
}
Aggregations