Skip to content

Commit

Permalink
Merge branch 'devel' into CB-5757-unit-tests-for-core-utils-and-core-…
Browse files Browse the repository at this point in the history
…blocks
  • Loading branch information
sergeyteleshev authored Oct 15, 2024
2 parents f62360f + 94ea41c commit bb4dfd7
Show file tree
Hide file tree
Showing 164 changed files with 4,380 additions and 3,900 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ server/test/io.cloudbeaver.test.platform/workspace/.data/
.classpath
.settings/

## Eclipse PDE
*.product.launch

workspace-dev-ce/
deploy/cloudbeaver
server/**/target
Expand Down
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
"label": "Build CE",
"type": "shell",
"windows": {
"command": "./build-sqlite.bat"
"command": "./build.bat"
},
"osx": {
"command": "./build-sqlite.sh"
"command": "./build.sh"
},
"options": {
"cwd": "${workspaceFolder}/deploy"
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ You can see a live demo of CloudBeaver here: https://demo.cloudbeaver.io

## Changelog

### 24.2.2. 2024-10-07
- Schemas were added to the SQL autocompletion for PostgreSQL, H2, and SQL Server;
- CloudBeaver can now correctly display negative dates for MySQL database;
- A search option was added for preferences in the Administration part;
- Keyboard navigation has been enhanced. You can now use the arrow keys to move through navigator tree elements and the tab key to switch between editors tabs;
- Sample SQLite database was removed.

### 24.2.1. 2024-09-23
- Chinese localization has been improved (thanks to [cashlifei](https://github.com/cashlifei));
- Environment variables configuration has been improved - now you can configure more variables on the initial stage of the Docker setup;
Expand Down
7 changes: 4 additions & 3 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ currently being supported with security updates.
| ------- | --------- |
| 22.x | yes |
| 23.x | yes |
| 24.x | yes |

## Reporting a Vulnerability

Please report (suspected) security vulnerabilities to devops@dbeaver.com.
You will receive a response from us within 48 hours.
If the issue is confirmed, we will release a patch as soon as possible depending on complexity but historically within a few days.
Please report (suspected) security vulnerabilities to devops@dbeaver.com.
You will receive a response from us within 48 hours.
If the issue is confirmed, we will release a patch as soon as possible, depending on complexity, but historically, within a few days.
24 changes: 2 additions & 22 deletions config/GlobalConfiguration/.dbeaver/data-sources.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
{
"folders": {},
"connections": {
"postgresql-template-1": {
"provider": "postgresql",
"driver": "postgres-jdbc",
"name": "PostgreSQL (Template)",
"save-password": false,
"show-system-objects": false,
"read-only": true,
"template": true,
"configuration": {
"host": "localhost",
"port": "5432",
"database": "postgres",
"url": "jdbc:postgresql://localhost:5432/postgres",
"type": "dev",
"provider-properties": {
"@dbeaver-show-non-default-db@": "false"
}
}
}
}
"folders": {},
"connections": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.jkiss.dbeaver.model.rm.RMController;
import org.jkiss.dbeaver.model.rm.RMControllerProvider;
import org.jkiss.dbeaver.model.rm.RMProject;
import org.jkiss.dbeaver.model.rm.RMUtils;
import org.jkiss.utils.CommonUtils;
import org.jkiss.utils.Pair;

Expand All @@ -44,11 +43,12 @@ public BaseWebProjectImpl(
@NotNull DBPWorkspace workspace,
@NotNull RMController resourceController,
@NotNull SMSessionContext sessionContext,
@NotNull RMProject project
@NotNull RMProject project,
@NotNull Path path
) {
super(workspace, sessionContext);
this.resourceController = resourceController;
this.path = RMUtils.getProjectPath(project);
this.path = path;
this.project = project;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.cloudbeaver.model.session.WebHeadlessSession;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.model.rm.RMProject;
import org.jkiss.dbeaver.model.rm.RMUtils;

public class WebHeadlessSessionProjectImpl extends WebProjectImpl {
public WebHeadlessSessionProjectImpl(
Expand All @@ -30,7 +31,8 @@ public WebHeadlessSessionProjectImpl(
session.getUserContext().getRmController(),
session.getSessionContext(),
project,
session.getUserContext().getPreferenceStore()
session.getUserContext().getPreferenceStore(),
RMUtils.getProjectPath(project)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,22 @@
import org.jkiss.dbeaver.registry.rm.DataSourceRegistryRM;
import org.jkiss.dbeaver.runtime.DBWorkbench;

import java.nio.file.Path;

public abstract class WebProjectImpl extends BaseWebProjectImpl {
private static final Log log = Log.getLog(WebProjectImpl.class);
@NotNull
protected final DBPPreferenceStore preferenceStore;

public WebProjectImpl(
@NotNull DBPWorkspace workspace,
@NotNull RMController resourceController,
@NotNull SMSessionContext sessionContext,
@NotNull RMProject project,
@NotNull DBPPreferenceStore preferenceStore
@NotNull DBPPreferenceStore preferenceStore,
@NotNull Path path
) {
super(workspace, resourceController, sessionContext, project);
super(workspace, resourceController, sessionContext, project, path);
this.preferenceStore = preferenceStore;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
import org.jkiss.dbeaver.model.app.DBPDataSourceRegistryCache;
import org.jkiss.dbeaver.model.navigator.DBNModel;
import org.jkiss.dbeaver.model.rm.RMProject;
import org.jkiss.dbeaver.model.rm.RMUtils;
import org.jkiss.dbeaver.model.websocket.event.WSEventType;
import org.jkiss.dbeaver.registry.DataSourceDescriptor;
import org.jkiss.dbeaver.runtime.jobs.DisconnectJob;

import java.nio.file.Path;
import java.util.*;
import java.util.stream.Collectors;

Expand All @@ -49,7 +51,24 @@ public WebSessionProjectImpl(
webSession.getRmController(),
webSession.getSessionContext(),
project,
webSession.getUserPreferenceStore()
webSession.getUserPreferenceStore(),
RMUtils.getProjectPath(project)
);
this.webSession = webSession;
}

public WebSessionProjectImpl(
@NotNull WebSession webSession,
@NotNull RMProject project,
@NotNull Path path
) {
super(
webSession.getWorkspace(),
webSession.getRmController(),
webSession.getSessionContext(),
project,
webSession.getUserPreferenceStore(),
path
);
this.webSession = webSession;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,86 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.registry.fs.FileSystemProviderRegistry;
import org.jkiss.utils.IOUtils;

import java.net.URI;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;

/**
* Abstract class that contains methods for loading configuration with gson.
*/
public abstract class BaseServerConfigurationController<T extends WebServerConfiguration>
implements WebServerConfigurationController<T> {
private static final Log log = Log.getLog(BaseServerConfigurationController.class);
@NotNull
private final Path homeDirectory;

protected Path workspacePath;

protected BaseServerConfigurationController(@NotNull Path homeDirectory) {
this.homeDirectory = homeDirectory;
//default workspaceLocation
this.workspacePath = homeDirectory.resolve("workspace");
}

@NotNull
public Gson getGson() {
return getGsonBuilder().create();
}

@NotNull
protected abstract GsonBuilder getGsonBuilder();

public abstract T getServerConfiguration();


@NotNull
protected synchronized void initWorkspacePath() throws DBException {
if (workspacePath != null && !IOUtils.isFileFromDefaultFS(workspacePath)) {
log.warn("Workspace directory already initialized: " + workspacePath);
}
String workspaceLocation = getWorkspaceLocation();
URI workspaceUri = URI.create(workspaceLocation);
if (workspaceUri.getScheme() == null) {
// default filesystem
this.workspacePath = getHomeDirectory().resolve(workspaceLocation);
} else {
var externalFsProvider =
FileSystemProviderRegistry.getInstance().getFileSystemProviderBySchema(workspaceUri.getScheme());
if (externalFsProvider == null) {
throw new DBException("File system not found for scheme: " + workspaceUri.getScheme());
}
ClassLoader fsClassloader = externalFsProvider.getInstance().getClass().getClassLoader();
try (FileSystem externalFileSystem = FileSystems.newFileSystem(workspaceUri,
System.getenv(),
fsClassloader);) {
this.workspacePath = externalFileSystem.provider().getPath(workspaceUri);
} catch (Exception e) {
throw new DBException("Failed to initialize workspace path: " + workspaceUri, e);
}
}
log.info("Workspace path initialized: " + workspacePath);
}

@NotNull
protected abstract String getWorkspaceLocation();

@NotNull
protected Path getHomeDirectory() {
return homeDirectory;
}

@NotNull
@Override
public Path getWorkspacePath() {
if (workspacePath == null) {
throw new RuntimeException("Workspace path not initialized");
}
return workspacePath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ public String getWorkspaceIdProperty() throws DBException {
return BaseWorkspaceImpl.readWorkspaceIdProperty();
}

@Override
public Path getWorkspaceDirectory() {
return getServerConfigurationController().getWorkspacePath();
}


public String getApplicationId() {
try {
return getApplicationInstanceId();
Expand All @@ -252,4 +258,12 @@ public WSEventController getEventController() {
public boolean isEnvironmentVariablesAccessible() {
return false;
}

protected void closeResource(String name, Runnable closeFunction) {
try {
closeFunction.run();
} catch (Exception e) {
log.error("Failed close " + name, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package io.cloudbeaver.model.app;

import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;

import java.util.Map;

Expand All @@ -28,6 +29,7 @@ public interface WebAppConfiguration {

boolean isAnonymousAccessEnabled();

@Nullable
<T> T getResourceQuota(String quotaId);

String getDefaultUserTeam();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
*/
package io.cloudbeaver.model.app;

import io.cloudbeaver.server.WebServerPreferenceStore;
import org.jkiss.code.NotNull;

import java.util.Map;

/**
* Web server configuration.
* Contains only server configuration properties.
Expand All @@ -27,4 +32,12 @@ default String getRootURI() {
return "";
}

/**
* @return the setting values that will be used in {@link WebServerPreferenceStore}
*/
@NotNull
default Map<String, Object> getProductSettings() {
return Map.of();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ default Map<String, Object> getOriginalConfigurationProperties() {
return Map.of();
}

@NotNull
Path getWorkspacePath();

@NotNull
Gson getGson();

void validateFinalServerConfiguration() throws DBException;
}
Loading

0 comments on commit bb4dfd7

Please sign in to comment.