diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/rm/local/LocalResourceController.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/rm/local/LocalResourceController.java index dacdc3ea4d..c447a48b77 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/rm/local/LocalResourceController.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/rm/local/LocalResourceController.java @@ -43,6 +43,8 @@ import org.jkiss.dbeaver.model.security.SMController; import org.jkiss.dbeaver.model.security.SMObjectType; import org.jkiss.dbeaver.model.sql.DBQuotaException; +import org.jkiss.dbeaver.model.websocket.event.WSErrorEvent; +import org.jkiss.dbeaver.model.websocket.event.WSEventType; import org.jkiss.dbeaver.registry.*; import org.jkiss.dbeaver.runtime.DBWorkbench; import org.jkiss.utils.ArrayUtils; @@ -959,12 +961,25 @@ protected T doProjectOperation(String projectId, RMFileOperation operatio protected T doFileReadOperation(String projectId, Path file, RMFileOperation operation) throws DBException { for (RMFileOperationHandler fileHandler : fileHandlers) { - try { - fileHandler.beforeFileRead(projectId, file); - } catch (Exception e) { - log.error("Error before file reading", e); +// try { +// fileHandler.beforeFileRead(projectId, file); +// } catch (Exception e) { + if (credentialsProvider.getActiveUserCredentials() != null) { + WebAppUtils.getWebApplication().getEventController().addEvent( + new WSErrorEvent( + WSEventType.SESSION_LOG_MESSAGE_ADDED, + credentialsProvider.getActiveUserCredentials().getSmSessionId(), + credentialsProvider.getActiveUserCredentials().getUserId(), + "123")); //e.getMessage())); + } else { + WebAppUtils.getWebApplication().getEventController().addEvent( + new WSErrorEvent( + WSEventType.SESSION_LOG_MESSAGE_ADDED, + "123")); //e.getMessage())); } } +// log.error("Error before file reading", e); +// } return operation.doOperation(); } diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/BaseWebSession.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/BaseWebSession.java index caf0f59f85..d96429c4e6 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/BaseWebSession.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/BaseWebSession.java @@ -16,6 +16,7 @@ */ package io.cloudbeaver.model.session; +import io.cloudbeaver.model.WebServerMessage; import io.cloudbeaver.model.app.WebApplication; import io.cloudbeaver.model.app.WebAuthApplication; import io.cloudbeaver.websocket.CBWebSessionEventHandler; @@ -201,6 +202,8 @@ public void removeSessionProject(@Nullable String projectId) throws DBException userContext.getAccessibleProjectIds().remove(projectId); } + public abstract void addSessionMessage(WebServerMessage message); + @Property public boolean isValid() { return getRemainingTime() > 0; diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/WebHeadlessSession.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/WebHeadlessSession.java index 9f8856507b..c71e55aa19 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/WebHeadlessSession.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/WebHeadlessSession.java @@ -16,6 +16,7 @@ */ package io.cloudbeaver.model.session; +import io.cloudbeaver.model.WebServerMessage; import io.cloudbeaver.model.app.WebAuthApplication; import org.jkiss.code.NotNull; import org.jkiss.dbeaver.DBException; @@ -37,6 +38,11 @@ public void addSessionError(Throwable exception) { } + @Override + public void addSessionMessage(WebServerMessage message) { + + } + @Override public SMSessionPrincipal getSessionPrincipal() { return null; diff --git a/server/bundles/io.cloudbeaver.server/plugin.xml b/server/bundles/io.cloudbeaver.server/plugin.xml index 71dcc26bb1..5275e98b99 100644 --- a/server/bundles/io.cloudbeaver.server/plugin.xml +++ b/server/bundles/io.cloudbeaver.server/plugin.xml @@ -70,6 +70,9 @@ + + + diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/events/EventHandlerLogSend.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/events/EventHandlerLogSend.java new file mode 100644 index 0000000000..b4a65626b1 --- /dev/null +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/events/EventHandlerLogSend.java @@ -0,0 +1,37 @@ +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2023 DBeaver Corp + * + * All Rights Reserved. + * + * NOTICE: All information contained herein is, and remains + * the property of DBeaver Corp and its suppliers, if any. + * The intellectual and technical concepts contained + * herein are proprietary to DBeaver Corp and its suppliers + * and may be covered by U.S. and Foreign Patents, + * patents in process, and are protected by trade secret or copyright law. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from DBeaver Corp. + */ +package io.cloudbeaver.server.events; + +import io.cloudbeaver.model.WebServerMessage; +import io.cloudbeaver.model.session.BaseWebSession; +import io.cloudbeaver.server.CBPlatform; +import org.jkiss.code.NotNull; +import org.jkiss.dbeaver.model.websocket.WSEventHandler; +import org.jkiss.dbeaver.model.websocket.event.WSErrorEvent; + +import java.util.Collection; + +public class EventHandlerLogSend extends WSDefaultEventHandler { + + protected void updateSessionData(@NotNull BaseWebSession activeUserSession, @NotNull WSErrorEvent event) { + activeUserSession.addSessionMessage(new WebServerMessage(WebServerMessage.MessageType.ERROR, event.getErrorMessage())); + } + + protected boolean isAcceptableInSession(@NotNull BaseWebSession activeUserSession, @NotNull WSErrorEvent event) { + return WSWebUtils.isSessionIdEquals(activeUserSession, event.getSessionId()); // skip events from current session + } +}