Skip to content

Commit

Permalink
dbeaver-vscode#3 resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-skoblikov committed Sep 17, 2024
1 parent 0a12157 commit b8348ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
*/
package io.cloudbeaver.server;

import org.eclipse.core.resources.ResourcesPlugin;
import io.cloudbeaver.DBWConstants;
import org.eclipse.core.runtime.Plugin;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.DBConstants;
import org.jkiss.dbeaver.model.app.DBACertificateStorage;
Expand All @@ -28,7 +27,6 @@
import org.jkiss.dbeaver.model.qm.QMRegistry;
import org.jkiss.dbeaver.model.qm.QMUtils;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.registry.BasePlatformImpl;
import org.jkiss.dbeaver.registry.DataSourceProviderRegistry;
import org.jkiss.dbeaver.runtime.SecurityProviderUtils;
Expand All @@ -40,8 +38,8 @@
import java.nio.file.Files;
import java.nio.file.Path;

public abstract class BaseWebPlatform extends BasePlatformImpl {
private static final Log log = Log.getLog(BaseWebPlatform.class);
public abstract class BaseGQLPlatform extends BasePlatformImpl {
private static final Log log = Log.getLog(BaseGQLPlatform.class);
public static final String WORK_DATA_FOLDER_NAME = ".work-data";

private Path tempFolder;
Expand All @@ -57,7 +55,7 @@ protected synchronized void initialize() {
SecurityProviderUtils.registerSecurityProvider();

// Register properties adapter
this.workspace = new WebGlobalWorkspace(this, ResourcesPlugin.getWorkspace());
this.workspace = new WebGlobalWorkspace(this);
this.workspace.initializeProjects();
QMUtils.initApplication(this);

Expand Down Expand Up @@ -97,7 +95,7 @@ public Path getTempFolder(@NotNull DBRProgressMonitor monitor, @NotNull String n
if (tempFolder == null) {
// Make temp folder
monitor.subTask("Create temp folder");
tempFolder = workspace.getAbsolutePath().resolve(WORK_DATA_FOLDER_NAME);
tempFolder = workspace.getAbsolutePath().resolve(DBWConstants.WORK_DATA_FOLDER_NAME);
}
if (!Files.exists(tempFolder)) {
try {
Expand Down Expand Up @@ -131,14 +129,6 @@ public synchronized void dispose() {
}
DataSourceProviderRegistry.dispose();

if (workspace != null) {
try {
workspace.save(new VoidProgressMonitor());
} catch (DBException ex) {
log.error("Can't save workspace", ex); //$NON-NLS-1$
}
}

// Remove temp folder
if (tempFolder != null) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package io.cloudbeaver.server;

import io.cloudbeaver.DBWConstants;
import io.cloudbeaver.auth.NoAuthCredentialsProvider;
import io.cloudbeaver.model.app.AppWebSessionManager;
import io.cloudbeaver.model.app.GQLApplicationAdapter;
Expand All @@ -37,7 +36,6 @@
import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore;
import org.jkiss.dbeaver.model.runtime.AbstractJob;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.registry.BasePlatformImpl;
import org.jkiss.dbeaver.registry.DataSourceProviderRegistry;
import org.jkiss.dbeaver.runtime.DBWorkbench;
import org.jkiss.utils.IOUtils;
Expand All @@ -51,7 +49,7 @@
/**
* CBPlatform
*/
public class CBPlatform extends BaseWebPlatform {
public class CBPlatform extends BaseGQLPlatform {

// The plug-in ID
public static final String PLUGIN_ID = "io.cloudbeaver.server"; //$NON-NLS-1$
Expand Down Expand Up @@ -82,21 +80,6 @@ protected synchronized void initialize() {
long startTime = System.currentTimeMillis();
log.info("Initialize web platform...: ");
this.preferenceStore = new CBPreferenceStore(this, WebPlatformActivator.getInstance().getPreferences());
// Register BC security provider
SecurityProviderUtils.registerSecurityProvider();

// Register properties adapter
this.workspace = new WebGlobalWorkspace(this);
this.workspace.initializeProjects();

QMUtils.initApplication(this);
this.queryManager = new QMRegistryImpl();

this.qmLogWriter = new QMLogFileWriter();
this.queryManager.registerMetaListener(qmLogWriter);

this.certificateStorage = new DefaultCertificateStorage(
WebPlatformActivator.getInstance().getStateLocation().toFile().toPath().resolve(DBConstants.CERTIFICATE_STORAGE_FOLDER));
super.initialize();
refreshApplicableDrivers();

Expand Down Expand Up @@ -136,26 +119,6 @@ public synchronized void dispose() {

super.dispose();

if (this.qmLogWriter != null) {
this.queryManager.unregisterMetaListener(qmLogWriter);
this.qmLogWriter.dispose();
this.qmLogWriter = null;
}
if (this.queryManager != null) {
this.queryManager.dispose();
//queryManager = null;
}
DataSourceProviderRegistry.dispose();

// Remove temp folder
if (tempFolder != null) {

if (!ContentUtils.deleteFileRecursive(tempFolder.toFile())) {
log.warn("Can't delete temp folder '" + tempFolder.toAbsolutePath() + "'");
}
tempFolder = null;
}

CBPlatform.application = null;
System.gc();
log.debug("Shutdown completed in " + (System.currentTimeMillis() - startTime) + "ms");
Expand All @@ -178,42 +141,6 @@ public DBPPreferenceStore getPreferenceStore() {
return preferenceStore;
}

@NotNull
@Override
public DBACertificateStorage getCertificateStorage() {
return certificateStorage;
}

@NotNull
public Path getTempFolder(@NotNull DBRProgressMonitor monitor, @NotNull String name) {
if (tempFolder == null) {
// Make temp folder
monitor.subTask("Create temp folder");
tempFolder = workspace.getAbsolutePath().resolve(DBWConstants.WORK_DATA_FOLDER_NAME);
}
if (!Files.exists(tempFolder)) {
try {
Files.createDirectories(tempFolder);
} catch (IOException e) {
log.error("Can't create temp directory " + tempFolder, e);
}
}
Path folder = tempFolder.resolve(name);
if (!Files.exists(folder)) {
try {
Files.createDirectories(folder);
} catch (IOException e) {
log.error("Error creating temp folder '" + folder.toAbsolutePath() + "'", e);
}
}
return folder;
}

@Override
protected Plugin getProductPlugin() {
return WebPlatformActivator.getInstance();
}

@Override
public boolean isShuttingDown() {
return false;
Expand Down

0 comments on commit b8348ff

Please sign in to comment.