Replace websocket with RestAPI#110
Conversation
|
Test Version (with Mitigation) is already up and running on https://webeditor.t-hueller.de |
There was a problem hiding this comment.
Pull request overview
This PR replaces the frontend↔backend WebSocket protocol with a simple HTTP REST API and refactors the backend server code accordingly (Jetty + servlets + service classes).
Changes:
- Removed the WebSocket client/server implementation and wiring on both frontend and backend.
- Added a REST-based
DfdApiClienton the frontend and new/api/*servlets/services on the backend. - Refactored the loading indicator delay behavior from JS timeout-based logic to CSS-based delay.
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/webEditor/src/webSocket/webSocket.ts | Removes the old WebSocket client implementation. |
| frontend/webEditor/src/webSocket/di.config.ts | Removes DI bindings for the WebSocket client. |
| frontend/webEditor/src/startUpAgent/webSocketConnect.ts | Removes startup logic that forced WebSocket initialization. |
| frontend/webEditor/src/startUpAgent/di.config.ts | Stops registering the WebSocket startup agent. |
| frontend/webEditor/src/serialize/saveFile.ts | Updates loading indicator API usage (hideIndicator). |
| frontend/webEditor/src/serialize/saveDfdAndDdFile.ts | Switches “save DD” backend call from WebSocket to REST client. |
| frontend/webEditor/src/serialize/loadPalladioFile.ts | Switches PCM loading call to REST client. |
| frontend/webEditor/src/serialize/loadJson.ts | Updates loading indicator usage and adds alert on error; makes postLoadActions public. |
| frontend/webEditor/src/serialize/loadDfdAndDdFile.ts | Switches DFD+DD loading call to REST client. |
| frontend/webEditor/src/serialize/analyze.ts | Switches analyze call to REST client. |
| frontend/webEditor/src/loadingIndicator/loadingIndicator.ts | Refactors indicator show/hide logic to class-based CSS toggling. |
| frontend/webEditor/src/loadingIndicator/loadingIndicator.css | Implements CSS-based delayed visibility for the loading overlay. |
| frontend/webEditor/src/index.ts | Loads the new REST client DI module instead of the WebSocket module. |
| frontend/webEditor/src/dfdApiClient/di.config.ts | Adds DI module for the new REST client. |
| frontend/webEditor/src/dfdApiClient/dfdApiClient.ts | Adds REST client that POSTs to /api/{action} and parses responses. |
| frontend/webEditor/.gitignore | Adds .vs/ and fixes formatting. |
| backend/.../websocket/WebSocketServerUtils.java | Removes WebSocket server bootstrap. |
| backend/.../websocket/WebSocketServerHandler.java | Removes WebSocket message handler implementation. |
| backend/.../services/Util.java | Adds shared JSON/constraint/temp-file helpers for the REST services. |
| backend/.../services/SaveDDService.java | Adds service for converting WebEditor JSON to DFD+DD file content. |
| backend/.../services/LoadPCMService.java | Adds service for parsing PCM uploads and converting to WebEditor JSON. |
| backend/.../services/LoadDDService.java | Adds service for parsing DFD+DD uploads and converting to WebEditor JSON. |
| backend/.../services/AnalyzeService.java | Adds service for analyzing/annotating WebEditor JSON. |
| backend/.../server/ApiServer.java | Adds Jetty server that exposes REST endpoints via servlets. |
| backend/.../Main.java | Switches the CLI entrypoint to start the REST API server. |
| backend/.../Application.java | Switches the Equinox application entrypoint to start the REST API server. |
| backend/.../api/Servlet.java | Adds common servlet base class for reading request bodies and writing text responses. |
| backend/.../api/SaveDDServlet.java | Adds /api/saveDD endpoint. |
| backend/.../api/LoadPCMServlet.java | Adds /api/loadPCM endpoint. |
| backend/.../api/LoadDDServlet.java | Adds /api/loadDD endpoint. |
| backend/.../api/AnalyzeServlet.java | Adds /api/analyze endpoint. |
| backend/.../analysis/Converter.java | Removes the old “Converter” utility that mixed multiple responsibilities. |
Comments suppressed due to low confidence (1)
backend/analysisBackendServer/bundles/org.dataflowanalysis.standalone/src/org/dataflowanalysis/standalone/server/ApiServer.java:27
ApiServer.start()callsserver.join(), so it blocks the calling thread. InApplication.start(), this means the code below (Scanner loop / exit handling) is never reached. Consider starting Jetty on a separate thread, or returning theServerinstance and letting the caller decide whether tojoin().
public static void start() throws Exception {
Server server = new Server(new InetSocketAddress("localhost", 3000));
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
context.setContextPath("/");
context.addServlet(AnalyzeServlet.class, "/api/analyze");
context.addServlet(LoadDDServlet.class, "/api/loadDD");
context.addServlet(LoadPCMServlet.class, "/api/loadPCM");
context.addServlet(SaveDDServlet.class, "/api/saveDD");
server.setHandler(context);
server.start();
server.join();
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| */ | ||
| private WebEditorDfd convertDFD(File dfd, File dd){ | ||
| var converter = new DFD2WebConverter(); | ||
| ResourceSet rs = new ResourceSetImpl(); |
| String filename = fileSection.substring(0, firstColon); | ||
| String fileContent = fileSection.substring(firstColon + 1); | ||
|
|
||
| File file = Util.createAndWriteTempFile(filename, fileContent); |
There was a problem hiding this comment.
Could this cause problems if multiple people tried to call the default.diagram at the same time?
| proxy: { | ||
| "/api": { | ||
| target: "https://websocket.dataflowanalysis.org", | ||
| //target: "http://localhost:3000", |
Replaced the websocket with a simple RestAPI
Also refactored the backend in the process
DONT MERGE YET
I need to adjust the backend Server nginx first