Search in sources :

Example 1 with SandboxedServiceContext

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);
    }
}
Also used : KsqlStatementException(io.confluent.ksql.util.KsqlStatementException) SandboxedServiceContext(io.confluent.ksql.services.SandboxedServiceContext) KsqlException(io.confluent.ksql.util.KsqlException)

Aggregations

SandboxedServiceContext (io.confluent.ksql.services.SandboxedServiceContext)1 KsqlException (io.confluent.ksql.util.KsqlException)1 KsqlStatementException (io.confluent.ksql.util.KsqlStatementException)1