Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/devel' into CB-3861
Browse files Browse the repository at this point in the history
  • Loading branch information
teunlao committed Sep 22, 2023
2 parents 634eecd + 55ab736 commit 6ed0239
Show file tree
Hide file tree
Showing 91 changed files with 1,140 additions and 223 deletions.
22 changes: 13 additions & 9 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,32 @@
{
"type": "chrome",
"request": "launch",
"name": "Debug CE",
"name": "Chrome",
"url": "http://127.0.0.1:3100",
"webRoot": "${workspaceFolder}/webapp/packages/product-default"
"webRoot": "${workspaceFolder}/..",
"sourceMaps": true
},
{
"type": "java",
"name": "CloudBeaver CE",
"cwd": "${workspaceFolder}/../opt/cbce",
"request": "launch",
"mainClass": "org.eclipse.equinox.launcher.Main",
"classPaths": [
"${env:DBEAVER_DEVEL_ECLIPSE_PATH}/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar"
],
"windows": {
"type": "java",
"name": "CloudBeaver CE",
"request": "launch",
"mainClass": "org.eclipse.equinox.launcher.Main",
"classPaths": [
"${workspaceFolder}/../eclipse/eclipse/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar"
],
"args": [
"-product",
"io.cloudbeaver.product.ce.product",
"-configuration",
"file:${env:DBEAVER_DEVEL_ECLIPSE_WORKSPACE_PATH}/.metadata/.plugins/org.eclipse.pde.core/CloudbeaverServer.product/",
"file:${workspaceFolder}/../eclipse/workspace/.metadata/.plugins/org.eclipse.pde.core/CloudbeaverServer.product/",
"-dev",
"file:${env:DBEAVER_DEVEL_ECLIPSE_WORKSPACE_PATH}/.metadata/.plugins/org.eclipse.pde.core/CloudbeaverServer.product/dev.properties",
"file:${workspaceFolder}/../eclipse/workspace/.metadata/.plugins/org.eclipse.pde.core/CloudbeaverServer.product/dev.properties",
"-os",
"win32",
"-ws",
Expand All @@ -54,13 +55,16 @@
"name": "CloudBeaver CE",
"request": "launch",
"mainClass": "org.eclipse.equinox.launcher.Main",
"classPaths": [
"${workspaceFolder}/../eclipse/Eclipse.app/Contents/Eclipse/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar"
],
"args": [
"-product",
"io.cloudbeaver.product.ce.product",
"-configuration",
"file:${env:DBEAVER_DEVEL_ECLIPSE_WORKSPACE_PATH}/.metadata/.plugins/org.eclipse.pde.core/CloudbeaverServer.product/",
"file:${workspaceFolder}/../eclipse/workspace/.metadata/.plugins/org.eclipse.pde.core/CloudbeaverServer.product/",
"-dev",
"file:${env:DBEAVER_DEVEL_ECLIPSE_WORKSPACE_PATH}/.metadata/.plugins/org.eclipse.pde.core/CloudbeaverServer.product/dev.properties",
"file:${workspaceFolder}/../eclipse/workspace/.metadata/.plugins/org.eclipse.pde.core/CloudbeaverServer.product/dev.properties",
"-os",
"macosx",
"-ws",
Expand Down
4 changes: 2 additions & 2 deletions server/bundles/io.cloudbeaver.model/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Bundle-ManifestVersion: 2
Bundle-Vendor: DBeaver Corp
Bundle-Name: Cloudbeaver Web Model
Bundle-SymbolicName: io.cloudbeaver.model;singleton:=true
Bundle-Version: 1.0.36.qualifier
Bundle-Release-Date: 20230904
Bundle-Version: 1.0.37.qualifier
Bundle-Release-Date: 20230925
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Expand Down
2 changes: 1 addition & 1 deletion server/bundles/io.cloudbeaver.model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<relativePath>../</relativePath>
</parent>
<artifactId>io.cloudbeaver.model</artifactId>
<version>1.0.36-SNAPSHOT</version>
<version>1.0.37-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,25 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Set;

public class SMUtils {
public static boolean isAdmin(SMCredentialsProvider webSession) {
return webSession.hasPermission(DBWConstants.PERMISSION_ADMIN);
}

public static boolean isAdmin(@NotNull Set<String> permissions) {
return permissions.contains(DBWConstants.PERMISSION_ADMIN);
}

public static boolean isRMAdmin(SMCredentialsProvider webSession) {
return isAdmin(webSession) || webSession.hasPermission(RMConstants.PERMISSION_RM_ADMIN);
}

public static boolean isRMAdmin(@NotNull Set<String> permissions) {
return isAdmin(permissions) || permissions.contains(RMConstants.PERMISSION_RM_ADMIN);
}

public static boolean hasProjectPermission(
SMCredentialsProvider credentialsProvider,
RMProject project,
Expand Down
4 changes: 2 additions & 2 deletions server/bundles/io.cloudbeaver.product.ce/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Bundle-ManifestVersion: 2
Bundle-Vendor: DBeaver Corp
Bundle-Name: Cloudbeaver Community Product
Bundle-SymbolicName: io.cloudbeaver.product.ce;singleton:=true
Bundle-Version: 23.2.0.qualifier
Bundle-Release-Date: 20230904
Bundle-Version: 23.2.1.qualifier
Bundle-Release-Date: 20230925
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Expand Down
2 changes: 1 addition & 1 deletion server/bundles/io.cloudbeaver.product.ce/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<relativePath>../</relativePath>
</parent>
<artifactId>io.cloudbeaver.product.ce</artifactId>
<version>23.2.0-SNAPSHOT</version>
<version>23.2.1-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Base JDBC drivers
Bundle-SymbolicName: io.cloudbeaver.resources.drivers.base;singleton:=true
Bundle-Version: 1.0.81.qualifier
Bundle-Release-Date: 20230904
Bundle-Version: 1.0.82.qualifier
Bundle-Release-Date: 20230925
Bundle-Vendor: DBeaver Corp
Bundle-ActivationPolicy: lazy
Automatic-Module-Name: io.cloudbeaver.resources.drivers.base
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<relativePath>../</relativePath>
</parent>
<artifactId>io.cloudbeaver.resources.drivers.base</artifactId>
<version>1.0.81-SNAPSHOT</version>
<version>1.0.82-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
4 changes: 2 additions & 2 deletions server/bundles/io.cloudbeaver.server/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Bundle-ManifestVersion: 2
Bundle-Vendor: DBeaver Corp
Bundle-Name: Cloudbeaver Web Server
Bundle-SymbolicName: io.cloudbeaver.server;singleton:=true
Bundle-Version: 23.2.0.qualifier
Bundle-Release-Date: 20230904
Bundle-Version: 23.2.1.qualifier
Bundle-Release-Date: 20230925
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-ActivationPolicy: lazy
Bundle-Activator: io.cloudbeaver.server.CBPlatformActivator
Expand Down
2 changes: 1 addition & 1 deletion server/bundles/io.cloudbeaver.server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<relativePath>../</relativePath>
</parent>
<artifactId>io.cloudbeaver.server</artifactId>
<version>23.2.0-SNAPSHOT</version>
<version>23.2.1-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ enum CBServerEventId {
cb_rm_project_removed,

cb_object_permissions_updated,
cb_subject_permissions_updated
cb_subject_permissions_updated,

cb_database_output_log_updated
}

# Events sent by client
Expand All @@ -48,7 +50,8 @@ enum CBEventTopic {
cb_scripts,
cb_projects,
cb_object_permissions,
cb_subject_permissions
cb_subject_permissions,
cb_database_output_log
}

# Base server event interface
Expand Down Expand Up @@ -153,6 +156,22 @@ type CBProjectsActiveEvent implements CBClientEvent {
projectIds: [String!]! # list of active projects
}

# Database output log event
type CBDatabaseOutputLogEvent implements CBServerEvent {
id: CBServerEventId!
topicId: CBEventTopic
contextId: String!
messages: [WSOutputLogInfo!]!
eventTimestamp: Int!
}

# Define the type for WSOutputLogInfo
type WSOutputLogInfo {
severity: String
message: String
# Add more fields as needed
}

extend type Query {
emptyEvent: Boolean
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ extend type Mutation {
sql: String!,
resultId: ID,
filter: SQLDataFilter,
dataFormat: ResultDataFormat # requested data format. May be ignored by server
dataFormat: ResultDataFormat, # requested data format. May be ignored by server
readLogs: Boolean # added 23.2.1
): AsyncTaskInfo!

# Read data from table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,34 @@
package io.cloudbeaver.server.events;

import io.cloudbeaver.model.session.BaseWebSession;
import io.cloudbeaver.service.security.SMUtils;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.websocket.event.permissions.WSSubjectPermissionEvent;
import org.jkiss.utils.ArrayUtils;
import org.jkiss.utils.CommonUtils;

import java.util.HashSet;

public class WSSubjectPermissionUpdatedEventHandler extends WSDefaultEventHandler<WSSubjectPermissionEvent> {
private static final Log log = Log.getLog(WSSubjectPermissionUpdatedEventHandler.class);

@Override
protected void updateSessionData(@NotNull BaseWebSession activeUserSession, @NotNull WSSubjectPermissionEvent event) {
var oldUserPermissions = new HashSet<>(activeUserSession.getUserContext().getUserPermissions());
try {
activeUserSession.getUserContext().refreshSMSession();
} catch (DBException e) {
activeUserSession.addSessionError(e);
log.error("Error refreshing session", e);
}
activeUserSession.refreshUserData();
super.updateSessionData(activeUserSession, event);
var newUserPermissions = activeUserSession.getUserContext().getUserPermissions();
boolean shouldUpdateData = !(SMUtils.isRMAdmin(oldUserPermissions) && SMUtils.isRMAdmin(newUserPermissions));
if (shouldUpdateData) {
super.updateSessionData(activeUserSession, event);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2023 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.server.jobs;

import io.cloudbeaver.model.session.WebSession;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.exec.DBCException;
import org.jkiss.dbeaver.model.exec.DBCExecutionContext;
import org.jkiss.dbeaver.model.exec.DBCStatement;
import org.jkiss.dbeaver.model.exec.output.DBCOutputSeverity;
import org.jkiss.dbeaver.model.exec.output.DBCOutputWriter;
import org.jkiss.dbeaver.model.exec.output.DBCServerOutputReader;
import org.jkiss.dbeaver.model.runtime.AbstractJob;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.websocket.event.WSOutputLogInfo;
import org.jkiss.dbeaver.model.websocket.event.session.WSOutputDBLogEvent;
import org.jkiss.dbeaver.runtime.DBWorkbench;

import java.util.ArrayList;
import java.util.List;


public class SqlOutputLogReaderJob extends AbstractJob {

private static final Log log = Log.getLog(SqlOutputLogReaderJob.class);

@NotNull
private final WebSession webSession;
@NotNull
private final DBCExecutionContext dbcExecutionContext;
@NotNull
private final DBCStatement dbcStatement;
@NotNull
private final DBCServerOutputReader dbcServerOutputReader;
@NotNull
private final String contextInfoId;

public SqlOutputLogReaderJob(@NotNull WebSession webSession,
@NotNull DBCExecutionContext dbcExecutionContext,
@NotNull DBCStatement dbcStatement,
@NotNull DBCServerOutputReader dbcServerOutputReader,
@NotNull String contextInfoId) {
super("Sql log state job");
this.webSession = webSession;
this.dbcExecutionContext = dbcExecutionContext;
this.dbcStatement = dbcStatement;
this.dbcServerOutputReader = dbcServerOutputReader;
this.contextInfoId = contextInfoId;
}

@Override
protected IStatus run(DBRProgressMonitor monitor) {
if (!DBWorkbench.getPlatform().isShuttingDown()) {
try {
if (!dbcStatement.isStatementClosed()) {
dumpOutput(monitor);
schedule(100);
}
} catch (Exception e) {
log.debug("Failed to execute job " + e.getMessage(), e);
}
}
return Status.OK_STATUS;
}

private void dumpOutput(DBRProgressMonitor monitor) {
if (!monitor.isCanceled()) {
if (dbcServerOutputReader.isAsyncOutputReadSupported()) {
try {
if (!dbcStatement.isStatementClosed()) {
List<WSOutputLogInfo> messages = new ArrayList<>();
dbcServerOutputReader.readServerOutput(monitor, dbcExecutionContext, null, dbcStatement, new DBCOutputWriter() {
@Override
public void println(@Nullable DBCOutputSeverity severity, @Nullable String message) {
if (message != null && severity != null) {
messages.add(new WSOutputLogInfo(severity.getName(), message));
}
}

@Override
public void flush() {
messages.clear();
}
});
webSession.addSessionEvent(new WSOutputDBLogEvent(
contextInfoId,
messages,
System.currentTimeMillis()));
}
} catch (DBCException e) {
log.error(e);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ WebAsyncTaskInfo asyncExecuteQuery(
@NotNull String sql,
@Nullable String resultId,
@Nullable WebSQLDataFilter filter,
@Nullable WebDataFormat dataFormat) throws DBException;
@Nullable WebDataFormat dataFormat,
boolean readLogs,
@NotNull WebSession webSession) throws DBException;

@WebAction
WebAsyncTaskInfo asyncReadDataFromContainer(
Expand Down
Loading

0 comments on commit 6ed0239

Please sign in to comment.