in server/src/main/java/org/apache/cassandra/sidecar/handlers/validations/ValidateTableExistenceHandler.java [66:111]
protected void handleInternal(RoutingContext context,
HttpServerRequest httpRequest,
@NotNull String host,
SocketAddress remoteAddress,
QualifiedTableName input)
{
if (input.keyspace() == null)
{
// no need to validate
context.next();
return;
}
getKeyspaceMetadata(host, input.keyspace())
.onFailure(context::fail) // fail the request with the internal server error thrown from getKeyspaceMetadata
.onSuccess(keyspaceMetadata -> {
if (keyspaceMetadata == null)
{
context.fail(wrapHttpException(HttpResponseStatus.NOT_FOUND,
"Keyspace " + input.keyspace() + " was not found"));
return;
}
RoutingContextUtils.put(context, RoutingContextUtils.SC_KEYSPACE_METADATA, keyspaceMetadata);
String table = input.tableName();
if (table == null)
{
context.next();
return;
}
TableMetadata tableMetadata = keyspaceMetadata.getTable(table);
if (tableMetadata == null)
{
String errMsg = "Table " + input.tableName() + " was not found for keyspace " + input.keyspace();
context.fail(wrapHttpException(HttpResponseStatus.NOT_FOUND, errMsg));
}
else
{
RoutingContextUtils.put(context, RoutingContextUtils.SC_TABLE_METADATA, tableMetadata);
// keyspace / [table] exists
context.next();
}
});
}