Skip to content

Commit 9c1fbba

Browse files
committed
improve logging
Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
1 parent 4f2039a commit 9c1fbba

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

xmla/bridge/src/main/java/org/eclipse/daanse/olap/xmla/bridge/execute/OlapExecuteService.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,11 @@
177177
import org.eclipse.daanse.xmla.model.record.mddataset.RowSetR;
178178
import org.eclipse.daanse.xmla.model.record.mddataset.RowSetRowR;
179179
import org.eclipse.daanse.xmla.model.record.xmla_empty.EmptyresultR;
180+
import org.slf4j.Logger;
180181

181182
public class OlapExecuteService implements ExecuteService {
182183

184+
private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(OlapExecuteService.class);
183185
private static final String MDX_CUBE_0_NOT_FOUND = "MDX cube ''{0}'' not found";
184186
public static final String SESSION_ID = "sessionId";
185187
public static final String CODE3238658121 = "3238658121";
@@ -247,14 +249,19 @@ public ClearCacheResponse clearCache(ClearCacheRequest clearCacheRequest, Reques
247249
public StatementResponse statement(StatementRequest statementRequest, RequestMetaData metaData,
248250
UserRolePrincipal userRolePrincipal) {
249251

252+
String statement = statementRequest.command().statement();
253+
if (statement == null || statement.isBlank()) {
254+
LOGGER.warn("Empty statement received");
255+
return new StatementResponseR(null, null);
256+
}
257+
250258
Optional<String> oCatalog = statementRequest.properties().catalog();
259+
251260
if (oCatalog.isPresent()) {
252261
String catalogName = oCatalog.get();
253262
Optional<Context<?>> oContext = contextsListSupplyer.getContexts().stream()
254263
.filter(ctx -> catalogName.equals(ctx.getName())).findAny();
255264
Context context = oContext.get();
256-
String statement = statementRequest.command().statement();
257-
if (statement != null && statement.length() > 0) {
258265
Locale locale = getLocale(statementRequest.properties());
259266
Connection connection = context.getConnection(new ConnectionProps(RoleUtils.getRoles(contextsListSupplyer, r -> userRolePrincipal.hasRole(r)), locale));
260267
QueryComponent queryComponent = connection.parseStatement(statement);
@@ -278,11 +285,11 @@ public StatementResponse statement(StatementRequest statementRequest, RequestMet
278285
} else if (queryComponent instanceof SqlQuery sqlQuery) {
279286
return executeSqlQuery(sqlQuery);
280287
}
281-
}
288+
282289
} else {
283-
String statement = statementRequest.command().statement();
284-
if (statement != null && statement.length() > 0 && contextsListSupplyer.getContexts() != null
285-
&& !contextsListSupplyer.getContexts().isEmpty()) {
290+
if (contextsListSupplyer.getContexts() != null && !contextsListSupplyer.getContexts().isEmpty()) {
291+
//TODO: aggregate word from all statements?
292+
//or do we have a default context?
286293
Connection connection = contextsListSupplyer.getContexts().get(0).getConnection(new ConnectionProps(RoleUtils.getRoles(contextsListSupplyer, r -> userRolePrincipal.hasRole(r))));
287294
QueryComponent queryComponent = connection.parseStatement(statement);
288295
if (queryComponent instanceof DmvQuery dmvQuery) {
@@ -321,10 +328,10 @@ public StatementResponse statement(StatementRequest statementRequest, RequestMet
321328

322329
}
323330
// here
324-
}
325331
}
326-
332+
}
327333
return new StatementResponseR(null, null);
334+
328335
}
329336

330337
private Locale getLocale(Properties properties) {

0 commit comments

Comments
 (0)