Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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");

Expand Down
34 changes: 25 additions & 9 deletions server/src/com/mirth/connect/server/alert/Alert.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -56,12 +59,25 @@ public Map<String, Object> 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<String, Object> 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();
}
Expand Down
Loading