Skip to content

Commit

Permalink
dbeaver-vscode#3 endpoint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-skoblikov committed Sep 5, 2024
1 parent 605b6df commit 2788f4d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

//FIXME: this interface should not exist,
// the logic of platforms and applications should be separated from each other
public interface CBApplicationAdapter extends WebApplication {
public interface GQLApplicationAdapter extends WebApplication {

Check warning on line 28 in server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/GQLApplicationAdapter.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/GQLApplicationAdapter.java#L28

Missing a Javadoc comment.
AppWebSessionManager getSessionManager();

Check warning on line 29 in server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/GQLApplicationAdapter.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/GQLApplicationAdapter.java#L29

Missing a Javadoc comment.

WebDriverRegistry getDriverRegistry();

Check warning on line 31 in server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/GQLApplicationAdapter.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/GQLApplicationAdapter.java#L31

Missing a Javadoc comment.
Expand All @@ -34,4 +34,10 @@ public interface CBApplicationAdapter extends WebApplication {
Map<String, Object> getProductConfiguration();

List<InetAddress> getLocalInetAddresses();

Check warning on line 36 in server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/GQLApplicationAdapter.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/GQLApplicationAdapter.java#L36

Missing a Javadoc comment.

Map<String, String> getInitActions();

Check warning on line 38 in server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/GQLApplicationAdapter.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/GQLApplicationAdapter.java#L38

Missing a Javadoc comment.

boolean isLicenseValid();

Check warning on line 40 in server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/GQLApplicationAdapter.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/GQLApplicationAdapter.java#L40

Missing a Javadoc comment.

String getLicenseStatus();

Check warning on line 42 in server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/GQLApplicationAdapter.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/GQLApplicationAdapter.java#L42

Missing a Javadoc comment.
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import io.cloudbeaver.WebServiceUtils;
import io.cloudbeaver.auth.NoAuthCredentialsProvider;
import io.cloudbeaver.model.app.BaseWebApplication;
import io.cloudbeaver.model.app.CBApplicationAdapter;
import io.cloudbeaver.model.app.GQLApplicationAdapter;
import io.cloudbeaver.model.app.WebAuthApplication;
import io.cloudbeaver.model.app.WebAuthConfiguration;
import io.cloudbeaver.registry.WebDriverRegistry;
Expand Down Expand Up @@ -76,7 +76,7 @@
* This class controls all aspects of the application's execution
*/
public abstract class CBApplication<T extends CBServerConfig> extends
BaseWebApplication implements WebAuthApplication, CBApplicationAdapter {
BaseWebApplication implements WebAuthApplication, GQLApplicationAdapter {

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

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

import io.cloudbeaver.auth.NoAuthCredentialsProvider;
import io.cloudbeaver.model.app.AppWebSessionManager;
import io.cloudbeaver.model.app.CBApplicationAdapter;
import io.cloudbeaver.model.app.GQLApplicationAdapter;
import io.cloudbeaver.server.jobs.SessionStateJob;
import io.cloudbeaver.server.jobs.WebDataSourceMonitorJob;
import io.cloudbeaver.server.jobs.WebSessionMonitorJob;
Expand Down Expand Up @@ -60,7 +60,7 @@ public class CBPlatform extends BaseWebPlatform {


@Nullable
private static CBApplicationAdapter application = null;
private static GQLApplicationAdapter application = null;

private CBPreferenceStore preferenceStore;
protected final List<DBPDriver> applicableDrivers = new ArrayList<>();
Expand All @@ -72,7 +72,7 @@ public static CBPlatform getInstance() {
protected CBPlatform() {
}

public static void setApplication(@NotNull CBApplicationAdapter application) {
public static void setApplication(@NotNull GQLApplicationAdapter application) {
CBPlatform.application = application;
}

Expand Down Expand Up @@ -128,7 +128,7 @@ public synchronized void dispose() {

@NotNull
@Override
public CBApplicationAdapter getApplication() {
public GQLApplicationAdapter getApplication() {
return application;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
import io.cloudbeaver.model.session.WebSession;
import io.cloudbeaver.registry.WebServiceRegistry;
import io.cloudbeaver.server.CBApplication;
import io.cloudbeaver.server.CBPlatform;
import io.cloudbeaver.server.HttpConstants;
import io.cloudbeaver.service.DBWBindingContext;
import io.cloudbeaver.service.DBWServiceBindingGraphQL;
import io.cloudbeaver.service.WebServiceBindingBase;
import io.cloudbeaver.utils.WebAppUtils;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -122,7 +124,7 @@ protected void doOptions(HttpServletRequest request, HttpServletResponse respons
}

private void setDevelHeaders(HttpServletRequest request, HttpServletResponse response) {
if (CBApplication.getInstance().isDevelMode()) {
if (WebAppUtils.getWebApplication().getServerConfiguration().isDevelMode()) {
// response.setHeader(HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, "*");
// response.setHeader(HEADER_ACCESS_CONTROL_ALLOW_HEADERS, "*");
// response.setHeader(HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS, "*");
Expand Down Expand Up @@ -209,7 +211,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
if (path == null) {
path = request.getServletPath();
}
boolean develMode = CBApplication.getInstance().isDevelMode();
boolean develMode = WebAppUtils.getWebApplication().getServerConfiguration().isDevelMode();

if (path.contentEquals("/schema.json") && develMode) {
executeQuery(request, response, GraphQLConstants.SCHEMA_READ_QUERY, null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.google.gson.stream.JsonWriter;
import io.cloudbeaver.server.CBApplication;
import io.cloudbeaver.server.CBConstants;
import io.cloudbeaver.server.CBPlatform;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -46,7 +47,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
infoMap.put("health", "ok");
infoMap.put("product.name", GeneralUtils.getProductName());
infoMap.put("product.version", GeneralUtils.getProductVersion().toString());
CBApplication.getInstance().getStatusInfo(infoMap);
CBPlatform.getInstance().getApplication().getStatusInfo(infoMap);
try (JsonWriter writer = new JsonWriter(response.getWriter())) {
JSONUtils.serializeMap(writer, infoMap);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.cloudbeaver.server.CBPlatform;
import io.cloudbeaver.server.graphql.GraphQLEndpoint;
import io.cloudbeaver.service.security.SMUtils;
import io.cloudbeaver.utils.WebAppUtils;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jkiss.code.NotNull;
Expand Down Expand Up @@ -250,7 +251,7 @@ private void checkServicePermissions(Method method, WebActionSet actionSet) thro
}

private void checkActionPermissions(@NotNull Method method, @NotNull WebAction webAction) throws DBWebException {
CBApplication<?> application = CBApplication.getInstance();
var application = CBPlatform.getInstance().getApplication();
if (application.isInitializationMode() && webAction.initializationRequired()) {
String message = "Server initialization in progress: "
+ String.join(",", application.getInitActions().values()) + ".\nDo not restart the server.";
Expand Down

0 comments on commit 2788f4d

Please sign in to comment.