From 6552f3fdfeb3603b36090ca78e92bb8d217af977 Mon Sep 17 00:00:00 2001 From: serge-rider Date: Tue, 22 Oct 2024 17:34:37 +0200 Subject: [PATCH] CB-5732 Navigator filters fix for optional nodes --- .../service/navigator/WebNavigatorNodeInfo.java | 10 ++++++++-- .../service/navigator/impl/WebServiceNavigator.java | 10 +++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/navigator/WebNavigatorNodeInfo.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/navigator/WebNavigatorNodeInfo.java index 511b0743f6..feec305045 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/navigator/WebNavigatorNodeInfo.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/navigator/WebNavigatorNodeInfo.java @@ -324,8 +324,14 @@ public DBSObjectFilter getFilter() throws DBWebException { if (!(node instanceof DBNDatabaseNode dbNode)) { throw new DBWebException("Invalid navigator node type: " + node.getClass().getName()); } - DBSObjectFilter filter = dbNode.getNodeFilter(dbNode.getItemsMeta(), true); - return filter == null || filter.isEmpty() || !filter.isEnabled() ? null : filter; + try { + DBSObjectFilter filter = dbNode.getNodeFilter( + DBNUtils.getValidItemsMeta(session.getProgressMonitor(), dbNode), + true); + return filter == null || filter.isEmpty() || !filter.isEnabled() ? null : filter; + } catch (DBException e) { + throw new DBWebException(e); + } } @Override diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/navigator/impl/WebServiceNavigator.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/navigator/impl/WebServiceNavigator.java index 67efb63def..c22861f44c 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/navigator/impl/WebServiceNavigator.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/navigator/impl/WebServiceNavigator.java @@ -19,7 +19,6 @@ import io.cloudbeaver.BaseWebProjectImpl; import io.cloudbeaver.DBWebException; -import io.cloudbeaver.WebProjectImpl; import io.cloudbeaver.WebServiceUtils; import io.cloudbeaver.model.WebCommandContext; import io.cloudbeaver.model.WebConnectionInfo; @@ -43,6 +42,8 @@ import org.jkiss.dbeaver.model.exec.DBCExecutionContext; import org.jkiss.dbeaver.model.exec.DBCExecutionContextDefaults; import org.jkiss.dbeaver.model.navigator.*; +import org.jkiss.dbeaver.model.navigator.meta.DBXTreeItem; +import org.jkiss.dbeaver.model.rm.RMControllerProvider; import org.jkiss.dbeaver.model.rm.RMProject; import org.jkiss.dbeaver.model.rm.RMProjectPermission; import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor; @@ -229,8 +230,11 @@ public boolean setNavigatorNodeFilter( } filter.setEnabled(true); if (node instanceof DBNDatabaseNode dbNode) { - dbNode.setNodeFilter(dbNode.getItemsMeta(), filter, true); - if (hasNodeEditPermission(webSession, node, ((WebProjectImpl) node.getOwnerProject()).getRMProject())) { + DBXTreeItem itemsMeta = DBNUtils.getValidItemsMeta(webSession.getProgressMonitor(), dbNode); + dbNode.setNodeFilter(itemsMeta, filter, true); + if (node.getOwnerProject() instanceof RMControllerProvider rmControllerProvider && + hasNodeEditPermission(webSession, node, rmControllerProvider.getRMProject()) + ) { // Save settings dbNode.getDataSourceContainer().persistConfiguration(); }