mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-10-16 14:50:15 +08:00
dbeaver/pro#9266 Refactor workspace path init and change (#4409)
Co-authored-by: mr-anton-t <42037741+mr-anton-t@users.noreply.github.com>
This commit is contained in:
co-authored by
mr-anton-t
parent
eb5f89dae3
commit
7d21186158
+2
-13
@@ -89,12 +89,6 @@ public abstract class BaseServletApplication extends BaseApplicationImpl impleme
|
||||
return new SharedFileLockManager(getApplicationInstanceId());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Path getDefaultWorkingFolder() {
|
||||
return getServerConfigurationController().getWorkspacePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHeadlessMode() {
|
||||
return true;
|
||||
@@ -218,6 +212,8 @@ public abstract class BaseServletApplication extends BaseApplicationImpl impleme
|
||||
@Override
|
||||
public Object start(IApplicationContext context) {
|
||||
initializeApplicationServices();
|
||||
setWorkspacePath(getServerConfigurationController().getWorkspacePath());
|
||||
|
||||
try {
|
||||
startServer();
|
||||
} catch (Exception e) {
|
||||
@@ -254,13 +250,6 @@ public abstract class BaseServletApplication extends BaseApplicationImpl impleme
|
||||
return BaseWorkspaceImpl.readWorkspaceIdProperty();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Path getWorkspaceDirectory() {
|
||||
return getServerConfigurationController().getWorkspacePath();
|
||||
}
|
||||
|
||||
|
||||
public String getApplicationId() {
|
||||
try {
|
||||
return getApplicationInstanceId();
|
||||
|
||||
+1
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* DBeaver - Universal Database Manager
|
||||
* Copyright (C) 2010-2024 DBeaver Corp and others
|
||||
* Copyright (C) 2010-2026 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.
|
||||
@@ -53,9 +53,6 @@ public interface ServletApplication extends DBPApplication {
|
||||
@NotNull
|
||||
Path getDataDirectory(boolean create);
|
||||
|
||||
@NotNull
|
||||
Path getWorkspaceDirectory();
|
||||
|
||||
@NotNull
|
||||
Path getHomeDirectory();
|
||||
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class ServerGlobalWorkspace extends BaseWorkspaceImpl {
|
||||
@NotNull DBPPlatform platform,
|
||||
@NotNull ServletApplication application
|
||||
) {
|
||||
super(platform, application.getWorkspaceDirectory());
|
||||
super(platform, application.getWorkspacePath());
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -228,11 +228,11 @@ public abstract class CBApplication<T extends CBServerConfig>
|
||||
Location instanceLoc = Platform.getInstanceLocation();
|
||||
try {
|
||||
if (!instanceLoc.isSet()) { // always false?
|
||||
URL wsLocationURL = getWorkspaceDirectory().toUri().toURL();
|
||||
URL wsLocationURL = getWorkspacePath().toUri().toURL();
|
||||
instanceLoc.set(wsLocationURL, true);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Error setting workspace location to " + getWorkspaceDirectory().toAbsolutePath(), e);
|
||||
log.error("Error setting workspace location to " + getWorkspacePath().toAbsolutePath(), e);
|
||||
return;
|
||||
}
|
||||
this.systemInformationCollector = createSystemInformationCollector();
|
||||
@@ -443,7 +443,7 @@ public abstract class CBApplication<T extends CBServerConfig>
|
||||
|
||||
@NotNull
|
||||
public Path getDataDirectory(boolean create) {
|
||||
Path dataDir = getWorkspaceDirectory().resolve(CBConstants.RUNTIME_DATA_DIR_NAME);
|
||||
Path dataDir = getWorkspacePath().resolve(CBConstants.RUNTIME_DATA_DIR_NAME);
|
||||
if (create && !Files.exists(dataDir)) {
|
||||
try {
|
||||
Files.createDirectories(dataDir);
|
||||
|
||||
+1
-1
@@ -502,7 +502,7 @@ public class CBDatabase extends InternalDB<WebDatabaseConfig> {
|
||||
}
|
||||
|
||||
public static boolean isDefaultH2Configuration(WebDatabaseConfig databaseConfiguration) {
|
||||
var workspace = ServletAppUtils.getServletApplication().getWorkspaceDirectory();
|
||||
var workspace = ServletAppUtils.getServletApplication().getWorkspacePath();
|
||||
var v1Path = workspace.resolve(".data").resolve(V1_DB_NAME);
|
||||
var v2Path = workspace.resolve(".data").resolve(V2_DB_NAME);
|
||||
var v1DefaultUrl = "jdbc:h2:" + v1Path;
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ public class ConnectionsTest extends CloudbeaverMockTest {
|
||||
System.out.println("APP:: " + GeneralUtils.getProductTitle());
|
||||
//CBPlatform.setApplication(testApp);
|
||||
|
||||
Path defaultWorkingFolder = DBWorkbench.getPlatform().getApplication().getDefaultWorkingFolder();
|
||||
Path defaultWorkingFolder = DBWorkbench.getPlatform().getApplication().getWorkspacePath();
|
||||
System.out.println("DBeaver application: " + defaultWorkingFolder);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user