diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebServerMessage.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebServerMessage.java index 6dc4bfa762..74c8b52def 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebServerMessage.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebServerMessage.java @@ -17,26 +17,17 @@ package io.cloudbeaver.model; import io.cloudbeaver.utils.CBModelConstants; +import org.jkiss.dbeaver.model.websocket.event.MessageType; import java.io.PrintWriter; import java.io.StringWriter; import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZoneId; /** * Web server message */ public class WebServerMessage { - - public enum MessageType { - DEBUG, - INFO, - WARNING, - ERROR - } - private final MessageType type; private final Instant time; private final String message; 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 9d076f065d..fa1135ad1b 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,8 +43,9 @@ 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.MessageType; import org.jkiss.dbeaver.model.websocket.event.WSEventType; +import org.jkiss.dbeaver.model.websocket.event.WSSessionLogUpdatedEvent; import org.jkiss.dbeaver.registry.*; import org.jkiss.dbeaver.runtime.DBWorkbench; import org.jkiss.utils.ArrayUtils; @@ -966,15 +967,11 @@ protected T doFileReadOperation(String projectId, Path file, RMFileOperation } catch (Exception e) { if (credentialsProvider.getActiveUserCredentials() != null) { WebAppUtils.getWebApplication().getEventController().addEvent( - new WSErrorEvent( - WSEventType.SESSION_LOG_MESSAGE_ADDED, + new WSSessionLogUpdatedEvent( + WSEventType.SESSION_LOG_UPDATED, credentialsProvider.getActiveUserCredentials().getSmSessionId(), credentialsProvider.getActiveUserCredentials().getUserId(), - e.getMessage())); - } else { - WebAppUtils.getWebApplication().getEventController().addEvent( - new WSErrorEvent( - WSEventType.SESSION_LOG_MESSAGE_ADDED, + MessageType.ERROR, e.getMessage())); } log.error("Error before file reading", e); diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/WebSession.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/WebSession.java index 740c3eea6d..35e5827198 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/WebSession.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/WebSession.java @@ -68,6 +68,7 @@ import org.jkiss.dbeaver.model.security.SMObjectType; import org.jkiss.dbeaver.model.security.user.SMObjectPermissions; import org.jkiss.dbeaver.model.sql.DBQuotaException; +import org.jkiss.dbeaver.model.websocket.event.MessageType; import org.jkiss.dbeaver.model.websocket.event.WSEventType; import org.jkiss.dbeaver.model.websocket.event.WSSessionLogUpdatedEvent; import org.jkiss.dbeaver.registry.DataSourceDescriptor; @@ -726,15 +727,20 @@ public void addSessionMessage(WebServerMessage message) { synchronized (sessionMessages) { sessionMessages.add(message); } - addSessionEvent(new WSSessionLogUpdatedEvent()); + addSessionEvent(new WSSessionLogUpdatedEvent( + WSEventType.SESSION_LOG_UPDATED, + this.userContext.getSmSessionId(), + this.userContext.getUserId(), + MessageType.ERROR, + message.getMessage())); } public void addInfoMessage(String message) { - addSessionMessage(new WebServerMessage(WebServerMessage.MessageType.INFO, message)); + addSessionMessage(new WebServerMessage(MessageType.INFO, message)); } public void addWarningMessage(String message) { - addSessionMessage(new WebServerMessage(WebServerMessage.MessageType.WARNING, message)); + addSessionMessage(new WebServerMessage(MessageType.WARNING, message)); } public List readLog(Integer maxEntries, Boolean clearLog) { diff --git a/server/bundles/io.cloudbeaver.server/plugin.xml b/server/bundles/io.cloudbeaver.server/plugin.xml index aa182e3596..eb75b6ef1d 100644 --- a/server/bundles/io.cloudbeaver.server/plugin.xml +++ b/server/bundles/io.cloudbeaver.server/plugin.xml @@ -70,7 +70,7 @@ - + diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/events/WSEventLogSendHandler.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/events/WSLogEventHandler.java similarity index 76% rename from server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/events/WSEventLogSendHandler.java rename to server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/events/WSLogEventHandler.java index 0b90a32548..cef7816000 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/events/WSEventLogSendHandler.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/events/WSLogEventHandler.java @@ -19,15 +19,15 @@ import io.cloudbeaver.model.WebServerMessage; import io.cloudbeaver.model.session.BaseWebSession; import org.jkiss.code.NotNull; -import org.jkiss.dbeaver.model.websocket.event.WSErrorEvent; +import org.jkiss.dbeaver.model.websocket.event.WSSessionLogUpdatedEvent; -public class WSEventLogSendHandler extends WSDefaultEventHandler { +public class WSLogEventHandler extends WSDefaultEventHandler { - protected void updateSessionData(@NotNull BaseWebSession activeUserSession, @NotNull WSErrorEvent event) { - activeUserSession.addSessionMessage(new WebServerMessage(WebServerMessage.MessageType.ERROR, event.getErrorMessage())); + protected void updateSessionData(@NotNull BaseWebSession activeUserSession, @NotNull WSSessionLogUpdatedEvent event) { + activeUserSession.addSessionMessage(new WebServerMessage(event.getMessageType(), event.getMessage())); } - protected boolean isAcceptableInSession(@NotNull BaseWebSession activeUserSession, @NotNull WSErrorEvent event) { + protected boolean isAcceptableInSession(@NotNull BaseWebSession activeUserSession, @NotNull WSSessionLogUpdatedEvent event) { return WSWebUtils.isSessionIdEquals(activeUserSession, event.getSessionId()); } }