use of io.confluent.ksql.services.SandboxedServiceContext in project ksql by confluentinc.
the class SchemaRegisterInjector method registerRawSchema.
private void registerRawSchema(final SchemaAndId schemaAndId, final String topic, final String statementText, final String subject, final Boolean isKey) {
final int id;
try {
id = SchemaRegistryUtil.registerSchema(serviceContext.getSchemaRegistryClient(), schemaAndId.rawSchema, topic, subject, isKey);
} catch (KsqlException e) {
throw new KsqlStatementException("Could not register schema for topic: " + e.getMessage(), statementText, e);
}
final boolean isSandbox = serviceContext instanceof SandboxedServiceContext;
// will return fixed id when register is called.
if (!isSandbox && id != schemaAndId.id) {
final String schemaIdPropStr = isKey ? CommonCreateConfigs.KEY_SCHEMA_ID : CommonCreateConfigs.VALUE_SCHEMA_ID;
throw new KsqlStatementException("Schema id registered is " + id + " which is different from provided " + schemaIdPropStr + " " + schemaAndId.id + "." + System.lineSeparator() + "Topic: " + topic + System.lineSeparator() + "Subject: " + subject + System.lineSeparator() + "Schema: " + schemaAndId.rawSchema, statementText);
}
}
Aggregations