Skip to content

Commit

Permalink
CB-5440. Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisSinelnikov committed Dec 5, 2024
2 parents b527fdd + 0b5af36 commit 2ae4f04
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.Strictness;
import io.cloudbeaver.auth.provider.local.LocalAuthProviderConstants;
import io.cloudbeaver.model.app.WebApplication;
import io.cloudbeaver.model.app.ServletApplication;
import io.cloudbeaver.model.config.WebDatabaseConfig;
import io.cloudbeaver.registry.WebAuthProviderDescriptor;
import io.cloudbeaver.registry.WebAuthProviderRegistry;
import io.cloudbeaver.utils.WebAppUtils;
import io.cloudbeaver.utils.ServletAppUtils;
import org.apache.commons.dbcp2.*;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
Expand Down Expand Up @@ -66,7 +67,7 @@ public class CBDatabase extends InternalDB {
public static final String SCHEMA_UPDATE_SQL_PATH = "db/cb_schema_update_";

private static final int LEGACY_SCHEMA_VERSION = 1;
private static final int CURRENT_SCHEMA_VERSION = 21;
private static final int CURRENT_SCHEMA_VERSION = 22;

private static final String DEFAULT_DB_USER_NAME = "cb-data";
private static final String DEFAULT_DB_PWD_FILE = ".database-credentials.dat";
Expand All @@ -76,14 +77,14 @@ public class CBDatabase extends InternalDB {
private static final String MAC_ADDRESS = "macAddress";
private static final String HOST_NAME = "hostName";

private final WebApplication application;
private final ServletApplication application;
private final WebDatabaseConfig databaseConfiguration;
private transient volatile Connection exclusiveConnection;

private String instanceId;
private SMAdminController adminSecurityController;

public CBDatabase(WebApplication application, WebDatabaseConfig databaseConfiguration) {
public CBDatabase(ServletApplication application, WebDatabaseConfig databaseConfiguration) {
super(databaseConfiguration, application);
this.application = application;
this.databaseConfiguration = databaseConfiguration;
Expand Down Expand Up @@ -252,10 +253,12 @@ CBDatabaseInitialData getInitialData() throws DBException {
return null;
}

initialDataPath = WebAppUtils.getRelativePath(
initialDataPath = ServletAppUtils.getRelativePath(
databaseConfiguration.getInitialDataConfiguration(), application.getHomeDirectory());
try (Reader reader = new InputStreamReader(new FileInputStream(initialDataPath), StandardCharsets.UTF_8)) {
Gson gson = new GsonBuilder().setLenient().create();
Gson gson = new GsonBuilder()
.setStrictness(Strictness.LENIENT)
.create();
return gson.fromJson(reader, CBDatabaseInitialData.class);
} catch (Exception e) {
throw new DBException("Error loading initial data configuration", e);
Expand Down Expand Up @@ -479,7 +482,7 @@ private void checkInstanceRecord(Connection connection) throws SQLException, IOE
}

public static boolean isDefaultH2Configuration(WebDatabaseConfig databaseConfiguration) {
var workspace = WebAppUtils.getWebApplication().getWorkspaceDirectory();
var workspace = ServletAppUtils.getServletApplication().getWorkspaceDirectory();
var v1Path = workspace.resolve(".data").resolve(V1_DB_NAME);
var v2Path = workspace.resolve(".data").resolve(V2_DB_NAME);
var v1DefaultUrl = "jdbc:h2:" + v1Path;
Expand All @@ -492,7 +495,7 @@ protected WebDatabaseConfig getDatabaseConfiguration() {
return databaseConfiguration;
}

protected WebApplication getApplication() {
protected ServletApplication getApplication() {
return application;
}

Expand Down

0 comments on commit 2ae4f04

Please sign in to comment.