diff --git a/client/src/com/mirth/connect/client/ui/alert/DefaultAlertEditPanel.java b/client/src/com/mirth/connect/client/ui/alert/DefaultAlertEditPanel.java index 0e4a34b81..33b524060 100644 --- a/client/src/com/mirth/connect/client/ui/alert/DefaultAlertEditPanel.java +++ b/client/src/com/mirth/connect/client/ui/alert/DefaultAlertEditPanel.java @@ -1,11 +1,6 @@ -/* - * Copyright (c) Mirth Corporation. All rights reserved. - * - * http://www.mirthcorp.com - * - * The software in this package is published under the terms of the MPL license a copy of which has - * been included with this distribution in the LICENSE.txt file. - */ +// SPDX-License-Identifier: MPL-2.0 +// SPDX-FileCopyrightText: Mirth Corporation +// SPDX-FileCopyrightText: 2025-2026 Open Integration Engine Contributors package com.mirth.connect.client.ui.alert; @@ -106,6 +101,7 @@ public void updateVariableList() { variables.add("alertName"); variables.add("serverId"); variables.add("serverName"); + variables.add("environmentName"); variables.add("globalMapVariable"); variables.add("date"); diff --git a/server/src/com/mirth/connect/server/alert/Alert.java b/server/src/com/mirth/connect/server/alert/Alert.java index f219fe4b2..8c61305b7 100644 --- a/server/src/com/mirth/connect/server/alert/Alert.java +++ b/server/src/com/mirth/connect/server/alert/Alert.java @@ -1,24 +1,27 @@ -/* - * Copyright (c) Mirth Corporation. All rights reserved. - * - * http://www.mirthcorp.com - * - * The software in this package is published under the terms of the MPL license a copy of which has - * been included with this distribution in the LICENSE.txt file. - */ +// SPDX-License-Identifier: MPL-2.0 +// SPDX-FileCopyrightText: Mirth Corporation +// SPDX-FileCopyrightText: 2025-2026 Open Integration Engine Contributors package com.mirth.connect.server.alert; +import static java.util.Map.entry; + import java.util.HashMap; +import java.util.Objects; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.velocity.tools.generic.DateTool; +import com.mirth.connect.client.core.ControllerException; +import com.mirth.connect.model.ServerSettings; import com.mirth.connect.model.alert.AlertModel; import com.mirth.connect.server.controllers.ConfigurationController; public class Alert { + private static final Logger logger = LogManager.getLogger(Alert.class); private AlertModel model; private Long enabledDateTime; @@ -56,12 +59,25 @@ public Map createContext() { context.put("alertId", model.getId()); context.put("alertName", model.getName()); context.put("serverId", ConfigurationController.getInstance().getServerId()); - context.put("serverName", ConfigurationController.getInstance().getServerName()); + context.putAll(getServerSettings()); context.put("date", new DateTool()); return context; } + private Map getServerSettings() { + try { + ServerSettings settings = ConfigurationController.getInstance().getServerSettings(); + // ensure an empty string as Velocity won't replace when given a null value + return Map.ofEntries(entry("serverName", Objects.toString(settings.getServerName(), "")), + entry("environmentName", Objects.toString(settings.getEnvironmentName(), ""))); + } catch (ControllerException e) { + logger.warn("Failed to retrieve server settings", e); + } + + return Map.of(); + } + public int getAlertedCount() { return alertedCount.get(); }