mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
Merge pull request #1009 from dbeaver/fix/CB-2311-filter-global-connections
CB-2311 filter unaccessible connections
This commit is contained in:
+9
-1
@@ -27,6 +27,7 @@ import io.cloudbeaver.model.user.WebUser;
|
||||
import io.cloudbeaver.service.DBWSessionHandler;
|
||||
import io.cloudbeaver.service.sql.WebSQLConstants;
|
||||
import io.cloudbeaver.utils.CBModelConstants;
|
||||
import io.cloudbeaver.utils.WebAppUtils;
|
||||
import io.cloudbeaver.utils.WebDataSourceUtils;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
@@ -356,11 +357,18 @@ public class WebSession extends AbstractSessionPersistent implements SMSession,
|
||||
// Add all provided datasources to the session
|
||||
List<WebConnectionInfo> connList = new ArrayList<>();
|
||||
for (DBPProject project : accessibleProjects) {
|
||||
boolean isGlobalProject = WebAppUtils.isGlobalProject(project);
|
||||
DBPDataSourceRegistry registry = project.getDataSourceRegistry();
|
||||
|
||||
for (DBPDataSourceContainer ds : registry.getDataSources()) {
|
||||
WebConnectionInfo connectionInfo = new WebConnectionInfo(this, ds);
|
||||
connList.add(connectionInfo);
|
||||
if (isGlobalProject) {
|
||||
if (isDataSourceAccessible(ds)) {
|
||||
connList.add(connectionInfo);
|
||||
}
|
||||
} else {
|
||||
connList.add(connectionInfo);
|
||||
}
|
||||
}
|
||||
Throwable lastError = registry.getLastError();
|
||||
if (lastError != null) {
|
||||
|
||||
@@ -23,7 +23,9 @@ import org.jkiss.code.NotNull;
|
||||
import org.jkiss.code.Nullable;
|
||||
import org.jkiss.dbeaver.DBException;
|
||||
import org.jkiss.dbeaver.Log;
|
||||
import org.jkiss.dbeaver.model.app.DBPProject;
|
||||
import org.jkiss.dbeaver.model.auth.SMAuthenticationManager;
|
||||
import org.jkiss.dbeaver.model.rm.RMProject;
|
||||
import org.jkiss.dbeaver.runtime.DBWorkbench;
|
||||
import org.jkiss.utils.CommonUtils;
|
||||
|
||||
@@ -152,4 +154,13 @@ public class WebAppUtils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isGlobalProject(DBPProject project) {
|
||||
return project.getId().equals(getGlobalProjectId());
|
||||
}
|
||||
|
||||
public static String getGlobalProjectId() {
|
||||
String globalConfigurationName = getWebApplication().getDefaultProjectName();
|
||||
return RMProject.Type.GLOBAL.getPrefix() + "_" + globalConfigurationName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.cloudbeaver.model.WebNetworkHandlerConfigInput;
|
||||
import io.cloudbeaver.model.session.WebActionParameters;
|
||||
import io.cloudbeaver.model.session.WebSession;
|
||||
import io.cloudbeaver.server.CBApplication;
|
||||
import io.cloudbeaver.utils.WebAppUtils;
|
||||
import io.cloudbeaver.utils.WebCommonUtils;
|
||||
import org.jkiss.code.NotNull;
|
||||
import org.jkiss.code.Nullable;
|
||||
@@ -95,8 +96,7 @@ public class WebServiceUtils extends WebCommonUtils {
|
||||
}
|
||||
|
||||
public static DBPDataSourceRegistry getGlobalRegistry(WebSession session) {
|
||||
String globalConfigurationName = CBApplication.getInstance().getDefaultProjectName();
|
||||
return session.getProjectById(RMProject.Type.GLOBAL.getPrefix() + "_" + globalConfigurationName).getDataSourceRegistry();
|
||||
return session.getProjectById(WebAppUtils.getGlobalProjectId()).getDataSourceRegistry();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+5
@@ -130,6 +130,11 @@ public class WebServiceNavigator implements DBWServiceNavigator {
|
||||
if (container.isTemplate()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//TODO node should not contain unaccessible datasource
|
||||
if (session.findWebConnectionInfo(container.getId()) == null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
result.add(new WebNavigatorNodeInfo(session, node));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user