Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dbeaver/dbeaver vscode#3 remove redundunt plugins #2891

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server/bundles/io.cloudbeaver.model/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Export-Package: io.cloudbeaver,
io.cloudbeaver.model,
io.cloudbeaver.model.app,
io.cloudbeaver.model.fs,
io.cloudbeaver.model.log,
io.cloudbeaver.model.rm,
io.cloudbeaver.model.rm.local,
io.cloudbeaver.model.rm.lock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.jkiss.code.NotNull;

/**
* Abstract class that contains methods for loading configuration with gson.
*/
public abstract class BaseServerConfigurationController<T extends WebServerConfiguration>
implements WebServerConfigurationController<T> {

@NotNull
public Gson getGson() {
return getGsonBuilder().create();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public abstract class BaseWebApplication extends BaseApplicationImpl implements
public static final String CLI_PARAM_WEB_CONFIG = "-web-config";
public static final String LOGBACK_FILE_NAME = "logback.xml";


private static final Log log = Log.getLog(BaseWebApplication.class);

private String instanceId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ public abstract class BaseWebSession extends AbstractSessionPersistent {
@NotNull
protected final WebUserContext userContext;
@NotNull
protected final WebAuthApplication application;
protected final WebApplication application;
protected volatile long lastAccessTime;

private final List<CBWebSessionEventHandler> sessionEventHandlers = new CopyOnWriteArrayList<>();
private WebSessionEventsFilter eventsFilter = new WebSessionEventsFilter();
private final WebSessionWorkspace workspace;

public BaseWebSession(@NotNull String id, @NotNull WebAuthApplication application) throws DBException {
public BaseWebSession(@NotNull String id, @NotNull WebApplication application) throws DBException {
this.id = id;
this.application = application;
this.createTime = System.currentTimeMillis();
Expand Down Expand Up @@ -232,6 +232,9 @@ public boolean isValid() {

@Property
public long getRemainingTime() {
return application.getMaxSessionIdleTime() + lastAccessTime - System.currentTimeMillis();
if (application instanceof WebAuthApplication authApplication) {
return authApplication.getMaxSessionIdleTime() + lastAccessTime - System.currentTimeMillis();
}
return Integer.MAX_VALUE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.cloudbeaver.model.WebAsyncTaskInfo;
import io.cloudbeaver.model.WebConnectionInfo;
import io.cloudbeaver.model.WebServerMessage;
import io.cloudbeaver.model.app.WebApplication;
import io.cloudbeaver.model.app.WebAuthApplication;
import io.cloudbeaver.model.user.WebUser;
import io.cloudbeaver.service.DBWSessionHandler;
Expand Down Expand Up @@ -88,6 +89,7 @@
* Web session.
* Is the main source of data in web application
*/
//TODO: split to authenticated and non authenticated context
public class WebSession extends BaseWebSession
implements SMSessionWithAuth, SMCredentialsProvider, DBACredentialsProvider, IAdaptable {

Expand Down Expand Up @@ -140,6 +142,24 @@ public WebSession(
updateSessionParameters(requestInfo);
}

protected WebSession(
@NotNull String id,
@Nullable String locale,
@NotNull WebApplication application,
@NotNull Map<String, DBWSessionHandler> sessionHandlers
) throws DBException {
super(id, application);
this.lastAccessTime = this.createTime;
this.sessionHandlers = sessionHandlers;
setLocale(locale);
//force authorization of anonymous session to avoid access error,
//because before authorization could be called by any request,
//but now 'updateInfo' is called only in special requests,
//and the order of requests is not guaranteed.
//look at CB-4747
refreshSessionAuth();
}

@Nullable
@Override
public SMSessionPrincipal getSessionPrincipal() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
* Web user context.
* Contains user state and services based on available permissions
*/
//TODO: split to authenticated and non authenticated context
public class WebUserContext implements SMCredentialsProvider {
private static final Log log = Log.getLog(WebUserContext.class);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
/*
* 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.server;

import io.cloudbeaver.DBWConstants;
import org.eclipse.core.runtime.Plugin;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.DBConstants;
import org.jkiss.dbeaver.model.app.DBACertificateStorage;
import org.jkiss.dbeaver.model.app.DBPWorkspace;
import org.jkiss.dbeaver.model.impl.app.DefaultCertificateStorage;
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.registry.BasePlatformImpl;
import org.jkiss.dbeaver.registry.DataSourceProviderRegistry;
import org.jkiss.dbeaver.runtime.SecurityProviderUtils;
import org.jkiss.dbeaver.runtime.qm.QMLogFileWriter;
import org.jkiss.dbeaver.runtime.qm.QMRegistryImpl;
import org.jkiss.dbeaver.utils.ContentUtils;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

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;

private QMRegistryImpl queryManager;
private QMLogFileWriter qmLogWriter;
private DBACertificateStorage certificateStorage;
private WebGlobalWorkspace workspace;

@Override
protected synchronized void initialize() {
// 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();
}

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

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

@NotNull
@Override
public DBPWorkspace getWorkspace() {
return workspace;
}

@NotNull

Check warning on line 93 in server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/server/BaseGQLPlatform.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/server/BaseGQLPlatform.java#L93

Missing a Javadoc comment.
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
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;
}
}

@NotNull
public QMRegistry getQueryManager() {
return queryManager;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
* Servlet service
*/
public interface DBWServiceBindingServlet<APPLICATION extends WebApplication> extends DBWServiceBinding {
default boolean isApplicable(WebApplication application) {

Check warning on line 26 in server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/service/DBWServiceBindingServlet.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/service/DBWServiceBindingServlet.java#L26

Missing a Javadoc comment.
return true;
}

void addServlets(APPLICATION application, DBWServletContext servletContext) throws DBException;
}
3 changes: 3 additions & 0 deletions server/bundles/io.cloudbeaver.server/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ Export-Package: io.cloudbeaver,
io.cloudbeaver.server.events,
io.cloudbeaver.server,
io.cloudbeaver.server.actions,
io.cloudbeaver.server.jetty,
io.cloudbeaver.server.graphql,
io.cloudbeaver.server.jobs,
io.cloudbeaver.server.servlets,
io.cloudbeaver.server.websockets,
io.cloudbeaver.service,
io.cloudbeaver.service.navigator,
io.cloudbeaver.service.session,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.cloudbeaver.auth.provisioning.SMProvisioner;
import io.cloudbeaver.registry.WebAuthProviderConfiguration;
import io.cloudbeaver.registry.WebAuthProviderDescriptor;
import io.cloudbeaver.server.CBAppConfig;
import io.cloudbeaver.server.CBApplication;
import io.cloudbeaver.server.CBPlatform;
import org.jkiss.dbeaver.Log;
Expand Down Expand Up @@ -64,7 +65,10 @@ public String getDescription() {
}

public boolean isDefaultProvider() {
return descriptor.getId().equals(CBPlatform.getInstance().getApplication().getAppConfiguration().getDefaultAuthProvider());
if (CBPlatform.getInstance().getApplication().getAppConfiguration() instanceof CBAppConfig cbAppConfig) {
return descriptor.getId().equals(cbAppConfig.getDefaultAuthProvider());
}
return false;
}

public boolean isConfigurable() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* 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.server;

import io.cloudbeaver.DBWebException;
import io.cloudbeaver.model.session.BaseWebSession;
import io.cloudbeaver.model.session.WebHeadlessSession;
import io.cloudbeaver.model.session.WebSession;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Session;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;

import java.util.Collection;

public interface AppWebSessionManager {

Check warning on line 33 in server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java#L33

Missing a Javadoc comment.
BaseWebSession closeSession(@NotNull HttpServletRequest request);

Check warning on line 34 in server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java#L34

Missing a Javadoc comment.

@NotNull

Check warning on line 36 in server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java#L36

Missing a Javadoc comment.
WebSession getWebSession(
@NotNull HttpServletRequest request,
@NotNull HttpServletResponse response
) throws DBWebException;

@NotNull

Check warning on line 42 in server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java#L42

Missing a Javadoc comment.
WebSession getWebSession(
@NotNull HttpServletRequest request,
@NotNull HttpServletResponse response,
boolean errorOnNoFound
) throws DBWebException;

@Nullable

Check warning on line 49 in server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java#L49

Missing a Javadoc comment.
BaseWebSession getSession(@NotNull String sessionId);

@Nullable

Check warning on line 52 in server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java#L52

Missing a Javadoc comment.
WebSession findWebSession(HttpServletRequest request);

WebSession findWebSession(HttpServletRequest request, boolean errorOnNoFound) throws DBWebException;

Check warning on line 55 in server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java#L55

Missing a Javadoc comment.

Collection<BaseWebSession> getAllActiveSessions();

Check warning on line 57 in server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java#L57

Missing a Javadoc comment.

WebSession getOrRestoreSession(Request httpRequest);

Check warning on line 59 in server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java#L59

Missing a Javadoc comment.

WebHeadlessSession getHeadlessSession(Request request, Session session, boolean create) throws DBException;

Check warning on line 61 in server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java#L61

Missing a Javadoc comment.

boolean touchSession(HttpServletRequest request, HttpServletResponse response) throws DBWebException;

Check warning on line 63 in server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java#L63

Missing a Javadoc comment.
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
/**
* This class controls all aspects of the application's execution
*/
public abstract class CBApplication<T extends CBServerConfig> extends BaseWebApplication implements WebAuthApplication {
public abstract class CBApplication<T extends CBServerConfig> extends
BaseWebApplication implements WebAuthApplication, GQLApplicationAdapter {

private static final Log log = Log.getLog(CBApplication.class);

Expand Down
Loading
Loading