From fddbe8c029a67523dc6a4008ebe4365f287ab9fe Mon Sep 17 00:00:00 2001 From: Julian Pufler Date: Tue, 14 Nov 2023 12:09:30 +0100 Subject: [PATCH] remove model and send string only --- .../versionplugin/client/VersionPlugin.java | 35 +++++++------------ pom.xml | 10 ++++-- .../versionplugin/server/VersionPlugin.java | 2 -- .../server/servlet/VersionServlet.java | 5 ++- .../interfaces/VersionServletInterface.java | 9 ++--- .../shared/models/VersionModel.java | 29 --------------- 6 files changed, 25 insertions(+), 65 deletions(-) delete mode 100644 shared/src/main/java/com/dedalus/versionplugin/shared/models/VersionModel.java diff --git a/client/src/main/java/com/dedalus/versionplugin/client/VersionPlugin.java b/client/src/main/java/com/dedalus/versionplugin/client/VersionPlugin.java index 75456dc..760adf3 100644 --- a/client/src/main/java/com/dedalus/versionplugin/client/VersionPlugin.java +++ b/client/src/main/java/com/dedalus/versionplugin/client/VersionPlugin.java @@ -23,24 +23,18 @@ import com.mirth.connect.client.ui.PlatformUI; import com.dedalus.versionplugin.shared.Constants; import com.dedalus.versionplugin.shared.interfaces.VersionServletInterface; -import com.dedalus.versionplugin.shared.models.VersionModel; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; @MirthClientClass public class VersionPlugin extends ClientPlugin { protected Frame frame = PlatformUI.MIRTH_FRAME; - private static final Logger logger = LogManager.getLogger(VersionPlugin.class); - private static final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); - private static VersionModel versionData; + private static String versionData; public VersionPlugin(String name) { super(name); @@ -53,29 +47,25 @@ public String getPluginPointName() { @Override public void start() { - System.out.println("[" + Constants.POINT_NAME + "] Starting..."); - try { VersionServletInterface servlet = frame.mirthClient.getServlet(VersionServletInterface.class); versionData = servlet.getVersionData(); } catch (Exception e) { - versionData = new VersionModel("N/A"); + frame.alertThrowable(frame, e); + versionData = "N/A"; } - System.out.println("[" + Constants.POINT_NAME + "] Retrieved version " + versionData.getVersion()); + System.out.println("[" + Constants.POINT_NAME + "] Retrieved version " + versionData); Runnable updateTask = () -> { - if (frame.statusBar != null) { - String currentServerText = frame.statusBar.getServerText(); - if (currentServerText.indexOf(versionData.getVersion()) == -1) { - System.out.println("[" + Constants.POINT_NAME + "] Updating StatusBar ServerText"); - frame.statusBar - .setServerText( - currentServerText + " | Communication Platform Version: " - + versionData.getVersion()); - } - } else { - System.out.println("[" + Constants.POINT_NAME + "] StatusBar is null"); + if (frame.statusBar == null) + return; + + String currentServerText = frame.statusBar.getServerText(); + if (currentServerText.indexOf(versionData) == -1) { + frame.statusBar + .setServerText(currentServerText + " | Communication Platform Version: " + versionData); + } }; @@ -85,7 +75,6 @@ public void start() { @Override public void stop() { - System.out.println("[" + Constants.POINT_NAME + "] Stopping..."); executor.shutdownNow(); } diff --git a/pom.xml b/pom.xml index d05f70d..8376b3c 100644 --- a/pom.xml +++ b/pom.xml @@ -37,7 +37,7 @@ 1.8 UTF-8 - 4.4.0 + 4.4.1 4.5 3.3.0 @@ -57,7 +57,7 @@ Julian Pufler ${project.version} This plugin is used to display the communication platform version in the GUI - 4.4.0,4.3.0,4.2.0,4.1.1,4.1.0 + 4.4.1,4.4.0,4.3.0,4.2.0,4.1.1,4.1.0 versionplugin-${project.version} @@ -100,6 +100,12 @@ ${log4j.version} provided + + + org.swinglabs.swingx + swingx-core + 1.6.5-1 + diff --git a/server/src/main/java/com/dedalus/versionplugin/server/VersionPlugin.java b/server/src/main/java/com/dedalus/versionplugin/server/VersionPlugin.java index fe466ac..5404f31 100644 --- a/server/src/main/java/com/dedalus/versionplugin/server/VersionPlugin.java +++ b/server/src/main/java/com/dedalus/versionplugin/server/VersionPlugin.java @@ -18,9 +18,7 @@ package com.dedalus.versionplugin.server; import com.kaurpalang.mirth.annotationsplugin.annotation.MirthServerClass; -import com.dedalus.versionplugin.shared.interfaces.VersionServletInterface; import com.dedalus.versionplugin.shared.Constants; -import com.mirth.connect.client.core.api.util.OperationUtil; import com.mirth.connect.model.ExtensionPermission; import com.mirth.connect.plugins.ServicePlugin; import java.util.HashMap; diff --git a/server/src/main/java/com/dedalus/versionplugin/server/servlet/VersionServlet.java b/server/src/main/java/com/dedalus/versionplugin/server/servlet/VersionServlet.java index 06034d8..7271c5a 100644 --- a/server/src/main/java/com/dedalus/versionplugin/server/servlet/VersionServlet.java +++ b/server/src/main/java/com/dedalus/versionplugin/server/servlet/VersionServlet.java @@ -21,7 +21,6 @@ import com.kaurpalang.mirth.annotationsplugin.type.ApiProviderType; import com.dedalus.versionplugin.shared.Constants; import com.dedalus.versionplugin.shared.interfaces.VersionServletInterface; -import com.dedalus.versionplugin.shared.models.VersionModel; import com.mirth.connect.server.api.MirthServlet; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Context; @@ -35,8 +34,8 @@ public VersionServlet(@Context HttpServletRequest request, @Context SecurityCont } @Override - public VersionModel getVersionData() { + public String getVersionData() { String version = System.getenv("COMPLATFORM_VERSION"); - return new VersionModel(version); + return version; } } \ No newline at end of file diff --git a/shared/src/main/java/com/dedalus/versionplugin/shared/interfaces/VersionServletInterface.java b/shared/src/main/java/com/dedalus/versionplugin/shared/interfaces/VersionServletInterface.java index 3e6156e..ac7af98 100644 --- a/shared/src/main/java/com/dedalus/versionplugin/shared/interfaces/VersionServletInterface.java +++ b/shared/src/main/java/com/dedalus/versionplugin/shared/interfaces/VersionServletInterface.java @@ -19,12 +19,9 @@ import com.kaurpalang.mirth.annotationsplugin.annotation.MirthApiProvider; import com.kaurpalang.mirth.annotationsplugin.type.ApiProviderType; -import com.dedalus.versionplugin.shared.models.VersionModel; import com.mirth.connect.client.core.ClientException; import com.mirth.connect.client.core.api.BaseServletInterface; import com.mirth.connect.client.core.api.MirthOperation; -import com.mirth.connect.client.core.api.Param; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -44,9 +41,9 @@ public interface VersionServletInterface extends BaseServletInterface { @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @ApiResponse(responseCode = "200", description = "Returns current CommunicationPlatform version data from ENV", content = { - @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = VersionModel.class)), - @Content(mediaType = MediaType.APPLICATION_XML, schema = @Schema(implementation = VersionModel.class)) + @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = String.class)), + @Content(mediaType = MediaType.APPLICATION_XML, schema = @Schema(implementation = String.class)) }) @MirthOperation(name = "getVersionData", display = "Get current CommunicationPlatform version data from ENV") - VersionModel getVersionData() throws ClientException; + String getVersionData() throws ClientException; } \ No newline at end of file diff --git a/shared/src/main/java/com/dedalus/versionplugin/shared/models/VersionModel.java b/shared/src/main/java/com/dedalus/versionplugin/shared/models/VersionModel.java deleted file mode 100644 index c6303f8..0000000 --- a/shared/src/main/java/com/dedalus/versionplugin/shared/models/VersionModel.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2021 Kaur Palang - * Copyright 2023 Julian Pufler - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.dedalus.versionplugin.shared.models; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; - -@AllArgsConstructor -public class VersionModel { - @Getter - @Setter - private String version; -} \ No newline at end of file