From 6d669fa7785f1a5443be4c26499123c49aea6142 Mon Sep 17 00:00:00 2001 From: ShadelessFox Date: Thu, 7 Mar 2024 19:47:33 +0100 Subject: [PATCH] dbeaver/pro#2589 Project reference fix --- .../server/jobs/WebDataSourceMonitorJob.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/jobs/WebDataSourceMonitorJob.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/jobs/WebDataSourceMonitorJob.java index a3a5d650dd..fadbf4e873 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/jobs/WebDataSourceMonitorJob.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/jobs/WebDataSourceMonitorJob.java @@ -20,9 +20,11 @@ import io.cloudbeaver.model.session.WebSession; import io.cloudbeaver.server.CBApplication; import io.cloudbeaver.server.CBPlatform; +import org.jkiss.code.NotNull; import org.jkiss.dbeaver.model.DBPDataSource; import org.jkiss.dbeaver.model.DBPDataSourceContainer; import org.jkiss.dbeaver.model.app.DBPPlatform; +import org.jkiss.dbeaver.model.app.DBPProject; import org.jkiss.dbeaver.model.auth.SMSession; import org.jkiss.dbeaver.model.websocket.event.WSEventType; import org.jkiss.dbeaver.model.websocket.event.datasource.WSDataSourceEvent; @@ -46,22 +48,23 @@ public WebDataSourceMonitorJob(DBPPlatform platform) { protected void doJob() { Collection allSessions = CBPlatform.getInstance().getSessionManager().getAllActiveSessions(); allSessions.parallelStream().forEach(s -> { - checkDataSourceAliveInWorkspace(s.getWorkspace(), s::getLastAccessTimeMillis); + checkDataSourceAliveInWorkspace(s.getWorkspace(), s.getLastAccessTimeMillis()); }); } @Override - public void showNotification(DBPDataSource dataSource, DBPDataSourceContainer dsDescriptor, SMSession smSession) { - if (smSession instanceof WebSession webSession) { - webSession.addSessionEvent( //TODO: Add new event for disconnect datasource - WSDataSourceEvent.update( - webSession.getSessionId(), - webSession.getUserId(), - dsDescriptor.getProject().getId(), - List.of(dsDescriptor.getId()), - WSDataSourceProperty.CONFIGURATION) - ); + protected void showNotification(@NotNull DBPDataSource dataSource) { + final DBPProject project = dataSource.getContainer().getProject(); + if (project.getWorkspaceSession() instanceof WebSession webSession) { + // TODO: Add new event for disconnect datasource + webSession.addSessionEvent(WSDataSourceEvent.update( + webSession.getSessionId(), + webSession.getUserId(), + project.getId(), + List.of(dataSource.getContainer().getId()), + WSDataSourceProperty.CONFIGURATION + )); } } }