Skip to content

Commit

Permalink
Merge branch 'devel' into CB-6059-npe-on-attempt-to-use-uppercase-for…
Browse files Browse the repository at this point in the history
…-team-id-field
  • Loading branch information
dariamarutkina authored Dec 24, 2024
2 parents f9c0b4f + 398f9b7 commit 701ac30
Show file tree
Hide file tree
Showing 62 changed files with 1,169 additions and 495 deletions.
8 changes: 8 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@
"options": {
"cwd": "${workspaceFolder}/webapp"
}
},
{
"label": "Add Custom Plugin",
"type": "shell",
"command": "yarn run add-plugin",
"options": {
"cwd": "${workspaceFolder}/webapp/packages"
}
}
],
"inputs": [
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ You can see a live demo of CloudBeaver here: https://demo.cloudbeaver.io
[Database access instructions](https://github.com/dbeaver/cloudbeaver/wiki/Demo-Server)

## Changelog

### 24.3.1. 2024-12-23
- Added an ability to reconnect for all editors if a connection has been lost;
- Added an option to replace line break characters on any custom value when exporting to CSV;
- Added an ability to create connections in the Navigation tree not only on the initial level but in folders and sub-folders directly;
- Updated list of available shortcuts for MacOS.

### 24.3.0. 2024-12-02
### Changes since 24.2.0:
- General:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,41 @@
*/
package io.cloudbeaver.model;

import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.model.runtime.AbstractJob;

/**
* Web connection info
* Web async task info
*/
public class WebAsyncTaskInfo {

private String id;
private String name;
private boolean running;
@NotNull
private final String id;
@NotNull
private final String name;
private boolean running = false;
private Object result;
private Object extendedResult;
private String status;
private Throwable jobError;

private AbstractJob job;

public WebAsyncTaskInfo(String id, String name) {
public WebAsyncTaskInfo(@NotNull String id, @NotNull String name) {
this.id = id;
this.name = name;
}

@NotNull
public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

@NotNull
public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public boolean isRunning() {
return running;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,33 @@
package io.cloudbeaver.model.session;

import jakarta.servlet.http.HttpServletRequest;
import org.jkiss.code.Nullable;

public class WebHttpRequestInfo {
public static final String USER_AGENT = "User-Agent";

@Nullable
private final String id;
@Nullable
private final Object locale;
@Nullable
private final String lastRemoteAddress;
@Nullable
private final String lastRemoteUserAgent;

public WebHttpRequestInfo(HttpServletRequest request) {
this.id = request.getSession().getId();
this.id = request.getSession() == null ? null : request.getSession().getId();
this.locale = request.getAttribute("locale");
this.lastRemoteAddress = request.getRemoteAddr();
this.lastRemoteUserAgent = request.getHeader("User-Agent");
this.lastRemoteUserAgent = request.getHeader(USER_AGENT);
}

public WebHttpRequestInfo(String id, Object locale, String lastRemoteAddress, String lastRemoteUserAgent) {
public WebHttpRequestInfo(
@Nullable String id,
@Nullable Object locale,
@Nullable String lastRemoteAddress,
@Nullable String lastRemoteUserAgent
) {
this.id = id;
this.locale = locale;
this.lastRemoteAddress = lastRemoteAddress;
Expand All @@ -43,14 +54,17 @@ public String getId() {
return id;
}

@Nullable
public Object getLocale() {
return locale;
}

@Nullable
public String getLastRemoteAddress() {
return lastRemoteAddress;
}

@Nullable
public String getLastRemoteUserAgent() {
return lastRemoteUserAgent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
import io.cloudbeaver.model.WebServerMessage;
import io.cloudbeaver.model.app.ServletApplication;
import io.cloudbeaver.model.app.ServletAuthApplication;
import io.cloudbeaver.model.session.monitor.TaskProgressMonitor;
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.WebDataSourceUtils;
import io.cloudbeaver.utils.WebEventUtils;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
Expand All @@ -57,7 +59,6 @@
import org.jkiss.dbeaver.model.runtime.AbstractJob;
import org.jkiss.dbeaver.model.runtime.BaseProgressMonitor;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.ProxyProgressMonitor;
import org.jkiss.dbeaver.model.security.SMAdminController;
import org.jkiss.dbeaver.model.security.SMConstants;
import org.jkiss.dbeaver.model.security.SMController;
Expand Down Expand Up @@ -511,7 +512,7 @@ public DBRProgressMonitor getProgressMonitor() {
///////////////////////////////////////////////////////
// Async model

public WebAsyncTaskInfo getAsyncTask(String taskId, String taskName, boolean create) {
public WebAsyncTaskInfo getAsyncTask(@NotNull String taskId, @NotNull String taskName, boolean create) {
synchronized (asyncTasks) {
WebAsyncTaskInfo taskInfo = asyncTasks.get(taskId);
if (taskInfo == null && create) {
Expand All @@ -528,7 +529,6 @@ public WebAsyncTaskInfo asyncTaskStatus(String taskId, boolean removeOnFinish) t
if (taskInfo == null) {
throw new DBWebException("Task '" + taskId + "' not found");
}
taskInfo.setRunning(taskInfo.getJob() != null && !taskInfo.getJob().isFinished());
if (removeOnFinish && !taskInfo.isRunning()) {
asyncTasks.remove(taskId);
}
Expand All @@ -551,7 +551,7 @@ public boolean asyncTaskCancel(String taskId) throws DBWebException {
return true;
}

public WebAsyncTaskInfo createAndRunAsyncTask(String taskName, WebAsyncTaskProcessor<?> runnable) {
public WebAsyncTaskInfo createAndRunAsyncTask(@NotNull String taskName, @NotNull WebAsyncTaskProcessor<?> runnable) {
int taskId = TASK_ID.incrementAndGet();
WebAsyncTaskInfo asyncTask = getAsyncTask(String.valueOf(taskId), taskName, true);

Expand All @@ -560,7 +560,8 @@ public WebAsyncTaskInfo createAndRunAsyncTask(String taskName, WebAsyncTaskProce
protected IStatus run(DBRProgressMonitor monitor) {
int curTaskCount = taskCount.incrementAndGet();

TaskProgressMonitor taskMonitor = new TaskProgressMonitor(monitor, asyncTask);
DBRProgressMonitor taskMonitor = new TaskProgressMonitor(monitor, WebSession.this, asyncTask);

try {
Number queryLimit = application.getAppConfiguration().getResourceQuota(WebSQLConstants.QUOTA_PROP_QUERY_LIMIT);
if (queryLimit != null && curTaskCount > queryLimit.intValue()) {
Expand All @@ -572,14 +573,15 @@ protected IStatus run(DBRProgressMonitor monitor) {
asyncTask.setResult(runnable.getResult());
asyncTask.setExtendedResult(runnable.getExtendedResults());
asyncTask.setStatus("Finished");
asyncTask.setRunning(false);
} catch (InvocationTargetException e) {
addSessionError(e.getTargetException());
asyncTask.setJobError(e.getTargetException());
} catch (Exception e) {
asyncTask.setJobError(e);
} finally {
taskCount.decrementAndGet();
asyncTask.setRunning(false);
WebEventUtils.sendAsyncTaskEvent(WebSession.this, asyncTask);
}
return Status.OK_STATUS;
}
Expand Down Expand Up @@ -989,27 +991,6 @@ public void subTask(String name) {
}
}

private static class TaskProgressMonitor extends ProxyProgressMonitor {

private final WebAsyncTaskInfo asyncTask;

public TaskProgressMonitor(DBRProgressMonitor original, WebAsyncTaskInfo asyncTask) {
super(original);
this.asyncTask = asyncTask;
}

@Override
public void beginTask(String name, int totalWork) {
super.beginTask(name, totalWork);
asyncTask.setStatus(name);
}

@Override
public void subTask(String name) {
super.subTask(name);
asyncTask.setStatus(name);
}
}

private record PersistentAttribute(Object value) {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 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.model.session.monitor;

import io.cloudbeaver.model.WebAsyncTaskInfo;
import io.cloudbeaver.model.session.WebSession;
import io.cloudbeaver.utils.WebEventUtils;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.ProxyProgressMonitor;

/**
* Task progress monitor.
* Used by async GQL requests.
*/
public class TaskProgressMonitor extends ProxyProgressMonitor {

@NotNull
private final WebAsyncTaskInfo asyncTask;
private final WebSession webSession;

public TaskProgressMonitor(DBRProgressMonitor original, @NotNull WebSession webSession, @NotNull WebAsyncTaskInfo asyncTask) {
super(original);
this.webSession = webSession;
this.asyncTask = asyncTask;
}

@Override
public void beginTask(String name, int totalWork) {
super.beginTask(name, totalWork);
asyncTask.setStatus(name);
WebEventUtils.sendAsyncTaskEvent(webSession, asyncTask);
}

@Override
public void subTask(String name) {
super.subTask(name);
asyncTask.setStatus(name);
WebEventUtils.sendAsyncTaskEvent(webSession, asyncTask);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
*/
package io.cloudbeaver.utils;

import io.cloudbeaver.model.WebAsyncTaskInfo;
import io.cloudbeaver.model.session.WebSession;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.model.app.DBPProject;
import org.jkiss.dbeaver.model.websocket.WSConstants;
import org.jkiss.dbeaver.model.websocket.event.WSEvent;
Expand All @@ -25,6 +27,7 @@
import org.jkiss.dbeaver.model.websocket.event.datasource.WSDatasourceFolderEvent;
import org.jkiss.dbeaver.model.websocket.event.resource.WSResourceProperty;
import org.jkiss.dbeaver.model.websocket.event.resource.WSResourceUpdatedEvent;
import org.jkiss.dbeaver.model.websocket.event.session.WSSessionTaskInfoEvent;

import java.util.List;

Expand Down Expand Up @@ -182,4 +185,14 @@ public static void addRmResourceUpdatedEvent(
ServletAppUtils.getServletApplication().getEventController().addEvent(event);
}

public static void sendAsyncTaskEvent(@NotNull WebSession webSession, @NotNull WebAsyncTaskInfo taskInfo) {
webSession.addSessionEvent(
new WSSessionTaskInfoEvent(
taskInfo.getId(),
taskInfo.getStatus(),
taskInfo.isRunning()
)
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.cloudbeaver.server.jobs.SessionStateJob;
import io.cloudbeaver.server.jobs.WebDataSourceMonitorJob;
import io.cloudbeaver.server.jobs.WebSessionMonitorJob;
import io.cloudbeaver.service.session.CBSessionManager;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.jkiss.code.NotNull;
Expand Down Expand Up @@ -84,6 +83,7 @@ protected synchronized void initialize() {
}

protected void scheduleServerJobs() {
super.scheduleServerJobs();
new WebSessionMonitorJob(this, application.getSessionManager())
.scheduleMonitor();

Expand Down
Loading

0 comments on commit 701ac30

Please sign in to comment.