CB-1061 Server URL configuration parameter

This commit is contained in:
Serge Rider
2021-06-18 11:54:09 +03:00
parent 6283871ca2
commit 45c4d3e653
6 changed files with 26 additions and 3 deletions
@@ -90,6 +90,8 @@ type ServerConfig {
version: String!
workspaceId: ID!
serverURL: String!
anonymousAccessEnabled: Boolean
authenticationEnabled: Boolean @deprecated
supportsCustomConnections: Boolean
@@ -59,6 +59,11 @@ public class WebServerConfig {
return DBWorkbench.getPlatform().getWorkspace().getWorkspaceId();
}
@Property
public String getServerURL() {
return CommonUtils.notEmpty(application.getServerURL());
}
@Property
public boolean isAnonymousAccessEnabled() {
return application.getAppConfiguration().isAnonymousAccessEnabled();
@@ -533,6 +533,7 @@ public class CBApplication extends BaseApplicationImpl {
public synchronized void finishConfiguration(
@NotNull String newServerName,
@NotNull String newServerURL,
@NotNull String adminName,
@Nullable String adminPassword,
@NotNull List<WebAuthInfo> authInfoList,
@@ -549,7 +550,7 @@ public class CBApplication extends BaseApplicationImpl {
// Save runtime configuration
log.debug("Saving runtime configuration");
saveRuntimeConfig(newServerName, sessionExpireTime, appConfig);
saveRuntimeConfig(newServerName, newServerURL, sessionExpireTime, appConfig);
// Grant permissions to predefined connections
if (isConfigurationMode() && appConfig.isAnonymousAccessEnabled()) {
@@ -572,7 +573,7 @@ public class CBApplication extends BaseApplicationImpl {
}
public synchronized void flushConfiguration() throws DBException {
saveRuntimeConfig(serverName, maxSessionIdleTime, appConfiguration);
saveRuntimeConfig(serverName, serverURL, maxSessionIdleTime, appConfiguration);
}
@@ -594,7 +595,7 @@ public class CBApplication extends BaseApplicationImpl {
}
}
private void saveRuntimeConfig(String newServerName, long sessionExpireTime, CBAppConfig appConfig) throws DBException {
private void saveRuntimeConfig(String newServerName, String newServerURL, long sessionExpireTime, CBAppConfig appConfig) throws DBException {
File runtimeConfigFile = getRuntimeAppConfigFile();
try (Writer out = new OutputStreamWriter(new FileOutputStream(runtimeConfigFile), StandardCharsets.UTF_8)) {
@@ -611,6 +612,9 @@ public class CBApplication extends BaseApplicationImpl {
if (!CommonUtils.isEmpty(newServerName)) {
JSONUtils.field(json, CBConstants.PARAM_SERVER_NAME, newServerName);
}
if (!CommonUtils.isEmpty(newServerURL)) {
JSONUtils.field(json, CBConstants.PARAM_SERVER_URL, newServerURL);
}
if (sessionExpireTime > 0) {
JSONUtils.field(json, CBConstants.PARAM_SESSION_EXPIRE_PERIOD, sessionExpireTime);
}
@@ -50,6 +50,7 @@ type AdminPermissionInfo {
input ServerConfigInput {
serverName: String
serverURL: String
adminName: String
adminPassword: String
@@ -30,6 +30,7 @@ import java.util.Map;
public class AdminServerConfig {
private String serverName;
private String serverURL;
private String adminName;
private String adminPassword;
@@ -44,6 +45,7 @@ public class AdminServerConfig {
public AdminServerConfig(Map<String, Object> params) {
this.serverName = JSONUtils.getString(params, "serverName");
this.serverURL = JSONUtils.getString(params, "serverURL");
this.adminName = JSONUtils.getString(params, "adminName");
this.adminPassword = JSONUtils.getString(params, "adminPassword");
@@ -69,6 +71,14 @@ public class AdminServerConfig {
this.serverName = serverName;
}
public String getServerURL() {
return serverURL;
}
public void setServerURL(String serverURL) {
this.serverURL = serverURL;
}
public String getAdminName() {
return adminName;
}
@@ -419,6 +419,7 @@ public class WebServiceAdmin implements DBWServiceAdmin {
CBApplication.getInstance().finishConfiguration(
config.getServerName(),
config.getServerURL(),
adminName,
adminPassword,
authInfoList,