Skip to content

Commit

Permalink
CB-5574. Added new api for get manager, added flap in server configur… (
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisSinelnikov authored Jan 22, 2025
1 parent 8275326 commit cd7dcb4
Show file tree
Hide file tree
Showing 26 changed files with 789 additions and 333 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
* Copyright (C) 2010-2025 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.
Expand Down Expand Up @@ -44,6 +44,12 @@ public class WebPropertyInfo {
private DBPPropertySource propertySource;
private boolean showProtected;

private Object[] validValues;

private String[] supportedConfigurationTypes = new String[0];

private Object defaultValue;

public WebPropertyInfo(WebSession session, DBPPropertyDescriptor property, DBPPropertySource propertySource) {
this.session = session;
this.property = property;
Expand Down Expand Up @@ -123,7 +129,7 @@ public PropertyLength getLength() {

@Property
public Object getDefaultValue() throws DBException {
var defaultValue = property.getDefaultValue();
var defaultValue = property.getDefaultValue() == null ? this.defaultValue : property.getDefaultValue();
return defaultValue == null ? getValue() : defaultValue;
}

Expand Down Expand Up @@ -154,9 +160,9 @@ public Object[] getValidValues() {
}
return validValues;
}
return null;
return validValues;
}
return null;
return validValues;
}

@Property
Expand All @@ -172,7 +178,7 @@ public String[] getSupportedConfigurationTypes() {
.map(DBPDriverConfigurationType::toString)
.toArray(String[]::new);
}
return new String[0];
return supportedConfigurationTypes;
}

@Property
Expand Down Expand Up @@ -252,4 +258,20 @@ public List<String> getScopes() {
}
return null;
}

//TODO: delete after refactoring on front-end
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
//TODO: delete after refactoring on front-end
public void setValidValues(Object[] validValues) {
this.validValues = validValues;
}

//TODO: delete after refactoring on front-end
public void setSupportedConfigurationTypes(String[] supportedConfigurationTypes) {
this.supportedConfigurationTypes = supportedConfigurationTypes;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public abstract class BaseWebAppConfiguration implements ServletAppConfiguration
protected final Map<String, Object> plugins;
protected String defaultUserTeam = DEFAULT_APP_ANONYMOUS_TEAM_NAME;
protected boolean resourceManagerEnabled;
protected boolean secretManagerEnabled;
protected boolean showReadOnlyConnectionInfo;
protected String[] enabledFeatures;
protected String[] disabledBetaFeatures;
Expand All @@ -42,6 +43,7 @@ public BaseWebAppConfiguration() {
this.enabledFeatures = null;
this.disabledBetaFeatures = new String[0];
this.showReadOnlyConnectionInfo = false;
this.secretManagerEnabled = false;
}

public BaseWebAppConfiguration(BaseWebAppConfiguration src) {
Expand All @@ -51,6 +53,7 @@ public BaseWebAppConfiguration(BaseWebAppConfiguration src) {
this.enabledFeatures = src.enabledFeatures;
this.disabledBetaFeatures = src.disabledBetaFeatures;
this.showReadOnlyConnectionInfo = src.showReadOnlyConnectionInfo;
this.secretManagerEnabled = src.secretManagerEnabled;
}

@Override
Expand Down Expand Up @@ -84,6 +87,11 @@ public boolean isResourceManagerEnabled() {
return resourceManagerEnabled;
}

@Override
public boolean isSecretManagerEnabled() {
return secretManagerEnabled;
}

@Override
public boolean isFeatureEnabled(String id) {
return ArrayUtils.contains(getEnabledFeatures(), id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public interface ServletAppConfiguration {

boolean isResourceManagerEnabled();

boolean isSecretManagerEnabled();

boolean isFeaturesEnabled(String[] requiredFeatures);

boolean isFeatureEnabled(String id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ public void setResourceManagerEnabled(boolean resourceManagerEnabled) {
this.resourceManagerEnabled = resourceManagerEnabled;
}

public void setSecretManagerEnabled(boolean secretManagerEnabled) {
this.secretManagerEnabled = secretManagerEnabled;
}

public boolean isSupportsCustomConnections() {
return supportsCustomConnections;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
* Copyright (C) 2010-2025 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.
Expand Down Expand Up @@ -114,13 +114,22 @@ protected BaseWebProjectImpl getWebProject(String projectId, boolean refresh) th
if (project == null || refresh) {
SessionContextImpl sessionContext = new SessionContextImpl(null);
RMProject rmProject = makeProjectFromId(projectId, false);
project = new InternalWebProjectImpl(sessionContext, rmProject, getProjectPath(projectId));
project = createWebProjectImpl(projectId, sessionContext, rmProject);
projectRegistries.put(projectId, project);
}
return project;
}
}

@NotNull
protected InternalWebProjectImpl createWebProjectImpl(
String projectId,
SessionContextImpl sessionContext,
RMProject rmProject
) throws DBException {
return new InternalWebProjectImpl(sessionContext, rmProject, getProjectPath(projectId));
}

@NotNull
@Override
public RMProject[] listAccessibleProjects() throws DBException {
Expand Down Expand Up @@ -946,16 +955,19 @@ public String ping() {
return "pong (RM)";
}

public static final class Builder {
private final SMCredentialsProvider credentialsProvider;
private final Supplier<SMController> smController;
private final DBPWorkspace workspace;
public static class Builder {
protected final SMCredentialsProvider credentialsProvider;
protected final Supplier<SMController> smController;
protected final DBPWorkspace workspace;

private Path rootPath;
private Path userProjectsPath;
private Path sharedProjectsPath;
protected Path rootPath;
protected Path userProjectsPath;
protected Path sharedProjectsPath;

private Builder(DBPWorkspace workspace, SMCredentialsProvider credentialsProvider, Supplier<SMController> smControllerSupplier) {
protected Builder(
DBPWorkspace workspace, SMCredentialsProvider credentialsProvider,
Supplier<SMController> smControllerSupplier
) {
this.workspace = workspace;
this.credentialsProvider = credentialsProvider;
this.smController = smControllerSupplier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class CBConstants {
public static final String PARAM_STATIC_CONTENT = "staticContent";
public static final String PARAM_RESOURCE_QUOTAS = "resourceQuotas";
public static final String PARAM_RESOURCE_MANAGER_ENABLED = "resourceManagerEnabled";
public static final String PARAM_SECRET_MANAGER_ENABLED = "secretManagerEnabled";
public static final String PARAM_SHOW_READ_ONLY_CONN_INFO = "showReadOnlyConnectionInfo";
public static final String PARAM_CONN_GRANT_ANON_ACCESS = "grantConnectionsAccessToAnonymousTeam";
public static final String PARAM_AUTH_PROVIDERS = "authConfiguration";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Export-Package: io.cloudbeaver,
io.cloudbeaver.model.config,
io.cloudbeaver.server,
io.cloudbeaver.service,
io.cloudbeaver.service.core,
io.cloudbeaver.service.session
Import-Package: org.slf4j
Automatic-Module-Name: io.cloudbeaver.server.ce
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import io.cloudbeaver.registry.WebDriverRegistry;
import io.cloudbeaver.registry.WebServiceRegistry;
import io.cloudbeaver.server.jetty.CBJettyServer;
import io.cloudbeaver.service.ConnectionController;
import io.cloudbeaver.service.ConnectionControllerCE;
import io.cloudbeaver.service.DBWServiceInitializer;
import io.cloudbeaver.service.DBWServiceServerConfigurator;
import io.cloudbeaver.service.session.CBSessionManager;
Expand Down Expand Up @@ -773,4 +775,9 @@ public Map<String, String> getInitActions() {
public WebServerConfig getWebServerConfig() {
return new CBWebServerConfig(this);
}

@Override
public ConnectionController getConnectionController() {
return new ConnectionControllerCE();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,11 @@ protected Map<String, Object> collectConfigurationProperties(
appConfigProperties,
CBConstants.PARAM_RESOURCE_MANAGER_ENABLED,
appConfig.isResourceManagerEnabled());
copyConfigValue(
oldAppConfig,
appConfigProperties,
CBConstants.PARAM_SECRET_MANAGER_ENABLED,
appConfig.isSecretManagerEnabled());
copyConfigValue(
oldAppConfig,
appConfigProperties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ type ServerConfig {
supportsCustomConnections: Boolean!
resourceManagerEnabled: Boolean!

secretManagerEnabled: Boolean! @since(version: "24.3.2")

publicCredentialsSaveEnabled: Boolean!
adminCredentialsSaveEnabled: Boolean!

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
* Copyright (C) 2010-2025 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.
Expand Down Expand Up @@ -39,6 +39,8 @@
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Stream;

/**
* Web driver configuration
Expand Down Expand Up @@ -255,9 +257,19 @@ public WebPropertyInfo[] getMainProperties() {

@Property
public WebPropertyInfo[] getProviderProperties() {
return Arrays.stream(driver.getProviderPropertyDescriptors())
WebPropertyInfo[] additionalWebProperty = Optional.of(WebAppUtils.getWebApplication())
.filter(app -> app.getAppConfiguration().isSecretManagerEnabled())
.map(app -> app.getConnectionController().getExternalInfo(webSession))
.orElse(new WebPropertyInfo[0]);

WebPropertyInfo[] providerProperties = Arrays.stream(driver.getProviderPropertyDescriptors())
.map(p -> new WebPropertyInfo(webSession, p, null))
.toArray(WebPropertyInfo[]::new);

return Stream.concat(
Arrays.stream(additionalWebProperty),
Arrays.stream(providerProperties)
).toArray(WebPropertyInfo[]::new);
}

@Property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ public boolean isResourceManagerEnabled() {
return application.getAppConfiguration().isResourceManagerEnabled();
}

@Property
public boolean isSecretManagerEnabled() {
return application.getAppConfiguration().isSecretManagerEnabled();
}

@Property
public String[] getEnabledFeatures() {
return application.getAppConfiguration().getEnabledFeatures();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.cloudbeaver.model.app.WebAppConfiguration;
import io.cloudbeaver.model.app.WebServerConfiguration;
import io.cloudbeaver.registry.WebDriverRegistry;
import io.cloudbeaver.service.ConnectionController;
import org.jkiss.code.NotNull;

import java.net.InetAddress;
Expand Down Expand Up @@ -52,4 +53,6 @@ public interface WebApplication extends ServletApplication {

WebServerConfig getWebServerConfig();

ConnectionController getConnectionController();

}
Loading

0 comments on commit cd7dcb4

Please sign in to comment.