Skip to content

Commit

Permalink
Merge branch 'devel' into fix/cb-5295/users-creation-flag
Browse files Browse the repository at this point in the history
  • Loading branch information
EvgeniaBzzz authored Sep 30, 2024
2 parents fa5fcd1 + c3c15bf commit b3c58ed
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,11 @@ public WebSession(
@NotNull WebAuthApplication application,
@NotNull Map<String, DBWSessionHandler> sessionHandlers
) throws DBException {
super(requestInfo.getId(), application);
this.lastAccessTime = this.createTime;
setLocale(CommonUtils.toString(requestInfo.getLocale(), this.locale));
this.sessionHandlers = sessionHandlers;
//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();
this(requestInfo.getId(),
CommonUtils.toString(requestInfo.getLocale()),
application,
sessionHandlers
);
updateSessionParameters(requestInfo);
}

Expand All @@ -151,7 +146,7 @@ protected WebSession(
super(id, application);
this.lastAccessTime = this.createTime;
this.sessionHandlers = sessionHandlers;
setLocale(locale);
setLocale(CommonUtils.toString(locale, this.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,
Expand Down Expand Up @@ -431,7 +426,7 @@ private boolean isDataSourceAccessible(DBPDataSourceContainer dataSource) {
}

@NotNull
private Set<String> readAccessibleConnectionIds() {
protected Set<String> readAccessibleConnectionIds() {
try {
return getSecurityController()
.getAllAvailableObjectsPermissions(SMObjectType.datasource)
Expand Down Expand Up @@ -493,7 +488,7 @@ private synchronized void refreshSessionAuth() {
}
}

private synchronized void refreshAccessibleConnectionIds() {
protected synchronized void refreshAccessibleConnectionIds() {
this.accessibleConnectionIds = readAccessibleConnectionIds();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package io.cloudbeaver.server;

import io.cloudbeaver.WebProjectImpl;
import io.cloudbeaver.model.app.WebApplication;
import io.cloudbeaver.utils.WebAppUtils;
import org.eclipse.core.runtime.Platform;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.Log;
Expand All @@ -28,8 +28,6 @@
import org.jkiss.dbeaver.model.impl.app.BaseWorkspaceImpl;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
Expand All @@ -48,17 +46,7 @@ public class WebGlobalWorkspace extends BaseWorkspaceImpl {
private WebGlobalProject globalProject;

public WebGlobalWorkspace(DBPPlatform platform) {
super(platform, Path.of(getWorkspaceURI()));
}

@NotNull
private static URI getWorkspaceURI() {
String workspacePath = Platform.getInstanceLocation().getURL().toString();
try {
return new URI(workspacePath);
} catch (URISyntaxException e) {
throw new IllegalStateException("Workspace path is invalid: " + workspacePath, e);
}
super(platform, ((WebApplication) platform.getApplication()).getWorkspaceDirectory());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@
import io.cloudbeaver.model.config.CBAppConfig;
import io.cloudbeaver.model.utils.ConfigurationUtils;
import io.cloudbeaver.server.CBApplication;
import io.cloudbeaver.utils.WebAppUtils;
import org.jkiss.dbeaver.model.connection.DBPDriver;

//TODO move to a separate CBApplication plugin
public class WebDatasourceAccessCheckHandler extends BaseDatasourceAccessCheckHandler {
@Override
protected boolean isDriverDisabled(DBPDriver driver) {
if (!WebAppUtils.getWebApplication().isMultiuser()) {
return false;
}
CBAppConfig config = CBApplication.getInstance().getAppConfiguration();
return !ConfigurationUtils.isDriverEnabled(
driver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ protected void startServer() {

Location instanceLoc = Platform.getInstanceLocation();
try {
if (!instanceLoc.isSet()) {
if (!instanceLoc.isSet()) { // always false?
URL wsLocationURL = new URL(
"file", //$NON-NLS-1$
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class CBPlatformActivator extends WebPlatformActivator {
protected void shutdownPlatform() {
try {
// Dispose core
if (DBWorkbench.getPlatform() instanceof CBPlatform cbPlatform) {
if (DBWorkbench.isPlatformStarted() && DBWorkbench.getPlatform() instanceof CBPlatform cbPlatform) {
cbPlatform.dispose();
}
} catch (Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import io.cloudbeaver.WebServiceUtils;
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;
Expand Down Expand Up @@ -63,6 +61,8 @@ public class GraphQLEndpoint extends HttpServlet {

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

private static final boolean DEBUG = true;

private static final String HEADER_ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin";
private static final String HEADER_ACCESS_CONTROL_ALLOW_HEADERS = "Access-Control-Allow-Headers";
private static final String HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials";
Expand Down Expand Up @@ -255,6 +255,8 @@ private void executeQuery(HttpServletRequest request, HttpServletResponse respon
// }
if (apiCall != null) {
log.debug("API > " + apiCall);
} else if (DEBUG) {
log.debug("API > " + query);
}
}
ExecutionInput executionInput = contextBuilder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package io.cloudbeaver.service.sql;

import io.cloudbeaver.model.session.WebSession;
import io.cloudbeaver.server.CBApplication;
import io.cloudbeaver.utils.WebAppUtils;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
Expand Down Expand Up @@ -58,7 +58,9 @@ class WebSQLQueryDataReceiver implements DBDDataReceiver {
this.contextInfo = contextInfo;
this.dataContainer = dataContainer;
this.dataFormat = dataFormat;
rowLimit = CBApplication.getInstance().getAppConfiguration().getResourceQuota(WebSQLConstants.QUOTA_PROP_ROW_LIMIT);
rowLimit = WebAppUtils.getWebApplication()
.getAppConfiguration()
.getResourceQuota(WebSQLConstants.QUOTA_PROP_ROW_LIMIT);
}

public WebSQLQueryResultSet getResultSet() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*/
package io.cloudbeaver.service.sql;

import io.cloudbeaver.model.config.CBAppConfig;
import io.cloudbeaver.model.app.WebAppConfiguration;
import io.cloudbeaver.model.session.WebSession;
import io.cloudbeaver.registry.WebServiceRegistry;
import io.cloudbeaver.server.CBApplication;
import io.cloudbeaver.utils.CBModelConstants;
import io.cloudbeaver.utils.WebAppUtils;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.data.*;
Expand Down Expand Up @@ -151,9 +151,11 @@ private static Object serializeContentValue(WebSession session, DBDContent value
if (ContentUtils.isTextContent(value)) {
String stringValue = ContentUtils.getContentStringValue(session.getProgressMonitor(), value);
int textPreviewMaxLength = CommonUtils.toInt(
CBApplication.getInstance().getAppConfiguration().getResourceQuota(
WebSQLConstants.QUOTA_PROP_TEXT_PREVIEW_MAX_LENGTH,
WebSQLConstants.TEXT_PREVIEW_MAX_LENGTH));
WebAppUtils.getWebApplication()
.getAppConfiguration()
.getResourceQuota(WebSQLConstants.QUOTA_PROP_TEXT_PREVIEW_MAX_LENGTH),
WebSQLConstants.TEXT_PREVIEW_MAX_LENGTH
);
if (stringValue != null && stringValue.length() > textPreviewMaxLength) {
stringValue = stringValue.substring(0, textPreviewMaxLength);
}
Expand All @@ -164,21 +166,20 @@ private static Object serializeContentValue(WebSession session, DBDContent value
if (binaryValue != null) {
byte[] previewValue = binaryValue;
// gets parameters from the configuration file
CBAppConfig config = CBApplication.getInstance().getAppConfiguration();
WebAppConfiguration config = WebAppUtils.getWebApplication().getAppConfiguration();
// the max length of the text preview
int textPreviewMaxLength = CommonUtils.toInt(
config.getResourceQuota(
WebSQLConstants.QUOTA_PROP_TEXT_PREVIEW_MAX_LENGTH,
WebSQLConstants.TEXT_PREVIEW_MAX_LENGTH));
WebSQLConstants.QUOTA_PROP_TEXT_PREVIEW_MAX_LENGTH), WebSQLConstants.TEXT_PREVIEW_MAX_LENGTH);
if (previewValue.length > textPreviewMaxLength) {
previewValue = Arrays.copyOf(previewValue, textPreviewMaxLength);
}
map.put(WebSQLConstants.ATTR_TEXT, GeneralUtils.convertToString(previewValue, 0, previewValue.length));
// the max length of the binary preview
int binaryPreviewMaxLength = CommonUtils.toInt(
config.getResourceQuota(
WebSQLConstants.QUOTA_PROP_BINARY_PREVIEW_MAX_LENGTH,
WebSQLConstants.BINARY_PREVIEW_MAX_LENGTH));
WebSQLConstants.QUOTA_PROP_BINARY_PREVIEW_MAX_LENGTH),
WebSQLConstants.BINARY_PREVIEW_MAX_LENGTH);
byte[] inlineValue = binaryValue;
if (inlineValue.length > binaryPreviewMaxLength) {
inlineValue = Arrays.copyOf(inlineValue, textPreviewMaxLength);
Expand Down Expand Up @@ -214,9 +215,11 @@ private static Object serializeGeometryValue(DBGeometry value) {
*/
public static Object serializeStringValue(Object value) {
int textPreviewMaxLength = CommonUtils.toInt(
CBApplication.getInstance().getAppConfiguration().getResourceQuota(
WebSQLConstants.QUOTA_PROP_TEXT_PREVIEW_MAX_LENGTH,
WebSQLConstants.TEXT_PREVIEW_MAX_LENGTH));
WebAppUtils.getWebApplication()
.getAppConfiguration()
.getResourceQuota(WebSQLConstants.QUOTA_PROP_TEXT_PREVIEW_MAX_LENGTH),
WebSQLConstants.TEXT_PREVIEW_MAX_LENGTH
);
String stringValue = value.toString();
if (stringValue.length() < textPreviewMaxLength) {
return value.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void migrateConfiguration(
smReverseProxyProviderConfiguration.setProvider(RPAuthProvider.AUTH_PROVIDER);
smReverseProxyProviderConfiguration.setDisplayName("Reverse Proxy");
smReverseProxyProviderConfiguration.setDescription(
"Automatically created provider after changing Reverse Proxy configuration way in 23.3.4 version"
"This provider was created automatically"
);
smReverseProxyProviderConfiguration .setIconURL("");
Map<String, Object> parameters = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ export class ServerConfigurationFormPart extends FormPart<IServerConfigurationFo
}
}

override get isChanged(): boolean {
if (this.loaded && this.administrationScreenService.isConfigurationMode) {
return true;
}

return super.isChanged;
}

protected override async saveChanges() {
if (!isObjectsEqual(this.state.navigatorConfig, this.initialState.navigatorConfig)) {
await this.defaultNavigatorSettingsResource.save(this.state.navigatorConfig);
Expand Down

0 comments on commit b3c58ed

Please sign in to comment.