use of io.confluent.ksql.api.server.NextHandlerOutput in project ksql by confluentinc.
the class StreamedQueryResource method handleStatement.
@SuppressWarnings("unchecked")
private EndpointResponse handleStatement(final KsqlSecurityContext securityContext, final KsqlRequest request, final PreparedStatement<?> statement, final CompletableFuture<Void> connectionClosedFuture, final Optional<Boolean> isInternalRequest, final MetricsCallbackHolder metricsCallbackHolder, final Context context) {
try {
authorizationValidator.ifPresent(validator -> validator.checkAuthorization(securityContext, ksqlEngine.getMetaStore(), statement.getStatement()));
final Map<String, Object> configProperties = request.getConfigOverrides();
denyListPropertyValidator.validateAll(configProperties);
if (statement.getStatement() instanceof Query) {
if (shouldMigrateToQueryStream(request.getConfigOverrides())) {
return EndpointResponse.ok(new NextHandlerOutput());
}
final QueryMetadataHolder queryMetadataHolder = queryExecutor.handleStatement(securityContext.getServiceContext(), request.getConfigOverrides(), request.getRequestProperties(), statement, isInternalRequest, metricsCallbackHolder, context, false);
return handleQuery((PreparedStatement<Query>) statement, connectionClosedFuture, queryMetadataHolder);
} else if (statement.getStatement() instanceof PrintTopic) {
return handlePrintTopic(securityContext.getServiceContext(), configProperties, (PreparedStatement<PrintTopic>) statement, connectionClosedFuture);
} else {
return Errors.badRequest(String.format("Statement type `%s' not supported for this resource", statement.getClass().getName()));
}
} catch (final TopicAuthorizationException e) {
return errorHandler.accessDeniedFromKafkaResponse(e);
} catch (final KsqlStatementException e) {
return Errors.badStatement(e.getRawMessage(), e.getSqlStatement());
} catch (final KsqlException e) {
return errorHandler.generateResponse(e, Errors.badRequest(e));
}
}
Aggregations