Skip to content
Merged
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
21 changes: 13 additions & 8 deletions client/src/com/mirth/connect/client/ui/FirstLoginDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

package com.mirth.connect.client.ui;

import static com.mirth.connect.client.core.BrandingConstants.CENTRAL_USER_REGISTRATION;
import static com.mirth.connect.client.core.BrandingConstants.MANDATORY_USER_REGISTRATION;

import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.Point;
Expand Down Expand Up @@ -47,10 +50,14 @@ public FirstLoginDialog(User currentUser) {
finishButton.setEnabled(false);

userEditPanel.setUser(this, currentUser);
userEditPanel.setRequiredFields(false, true);
if (currentUser.getId() == 1) {
registerCheckBox.setVisible(false);
}

final boolean isRegistrationMandatory = CENTRAL_USER_REGISTRATION && MANDATORY_USER_REGISTRATION && currentUser.getId() == 1;
registerCheckBox.setSelected(isRegistrationMandatory);
registerCheckBox.setEnabled(!isRegistrationMandatory);
registerCheckBox.setVisible(CENTRAL_USER_REGISTRATION);
registerCheckBoxActionPerformed(null);
userConsentCheckBox.setVisible(CENTRAL_USER_REGISTRATION);
contentTextPane.setVisible(CENTRAL_USER_REGISTRATION);

jLabel2.setForeground(UIConstants.HEADER_TITLE_TEXT_COLOR);
setModal(true);
Expand Down Expand Up @@ -151,7 +158,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
jScrollPane1.setViewportView(jTextPane1);

registerCheckBox.setBackground(new java.awt.Color(255, 255, 255));
registerCheckBox.setSelected(true);
registerCheckBox.setText(String.format("Register user with %s", BrandingConstants.COMPANY_NAME));
registerCheckBox.setToolTipText(String.format("<html>Register your user information with %s to help us<br>improve the product and provide better service.</html>", BrandingConstants.COMPANY_NAME));
registerCheckBox.addActionListener(new java.awt.event.ActionListener() {
Expand All @@ -161,7 +167,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
});

userConsentCheckBox.setBackground(new java.awt.Color(255, 255, 255));
userConsentCheckBox.setSelected(true);
userConsentCheckBox.setText(String.format("I consent to receive email updates and marketing messages from %s.", BrandingConstants.COMPANY_NAME));
userConsentCheckBox.setToolTipText("<html></html>");

Expand Down Expand Up @@ -273,7 +278,7 @@ private void finishButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
return;
}

if (registerCheckBox.isSelected()) {
if (registerCheckBox.isSelected() && CENTRAL_USER_REGISTRATION) {
parent.registerUser(user);
}

Expand Down Expand Up @@ -316,7 +321,7 @@ private void registerCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//
userConsentCheckBox.setSelected(false);
userConsentCheckBox.setEnabled(false);
}
userEditPanel.setRequiredFields(false, true);
userEditPanel.setRequiredFields(allRequired, true);
}//GEN-LAST:event_registerCheckBoxActionPerformed

public boolean getResult() {
Expand Down
20 changes: 19 additions & 1 deletion client/src/com/mirth/connect/client/ui/Frame.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

package com.mirth.connect.client.ui;

import static com.mirth.connect.client.core.BrandingConstants.CENTRAL_USER_REGISTRATION;
import static com.mirth.connect.client.core.BrandingConstants.CHECK_FOR_NOTIFICATIONS;
import static com.mirth.connect.client.core.BrandingConstants.SEND_USAGE_STATISTICS;

import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.awt.Color;
Expand Down Expand Up @@ -1250,7 +1254,9 @@ private void createOtherPane() {
otherPane.setTitle("Other");
otherPane.setName(TaskConstants.OTHER_KEY);
otherPane.setFocusable(false);
addTask(TaskConstants.OTHER_NOTIFICATIONS, UIConstants.VIEW_NOTIFICATIONS, String.format("View notifications from %s.", BrandingConstants.PRODUCT_NAME), "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/flag_orange.png")), otherPane, null);
if (CHECK_FOR_NOTIFICATIONS) {
addTask(TaskConstants.OTHER_NOTIFICATIONS, UIConstants.VIEW_NOTIFICATIONS, String.format("View notifications from %s.", BrandingConstants.PRODUCT_NAME), "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/flag_orange.png")), otherPane, null);
}
addTask(TaskConstants.OTHER_VIEW_USER_API, "View User API", String.format("View documentation for the %s User API.", BrandingConstants.PRODUCT_NAME), "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/page_white_text.png")), otherPane, null);
addTask(TaskConstants.OTHER_VIEW_CLIENT_API, "View Client API", String.format("View documentation for the %s Client API.", BrandingConstants.PRODUCT_NAME), "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/page_white_text.png")), otherPane, null);
addTask(TaskConstants.OTHER_HELP, "Help", String.format("View help for %s.", BrandingConstants.PRODUCT_NAME), "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/help.png")), otherPane, null);
Expand All @@ -1268,6 +1274,10 @@ public JXTaskPane getOtherPane() {
}

public void updateNotificationTaskName(int notifications) {
if (!CHECK_FOR_NOTIFICATIONS) {
return;
}

String taskName = UIConstants.VIEW_NOTIFICATIONS;
if (notifications > 0) {
taskName += " (" + notifications + ")";
Expand Down Expand Up @@ -1949,6 +1959,10 @@ public User getCurrentUser(Component parentComponent, boolean alertOnFailure) {
}

public void registerUser(final User user) {
if (!CENTRAL_USER_REGISTRATION) {
return;
}

final String workingId = startWorking("Registering user...");

SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
Expand All @@ -1972,6 +1986,10 @@ public void done() {
}

public void sendUsageStatistics() {
if (!SEND_USAGE_STATISTICS) {
return;
}

UpdateSettings updateSettings = null;
try {
updateSettings = mirthClient.getUpdateSettings();
Expand Down
5 changes: 4 additions & 1 deletion client/src/com/mirth/connect/client/ui/LoginPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

package com.mirth.connect.client.ui;

import static com.mirth.connect.client.core.BrandingConstants.CHECK_FOR_NOTIFICATIONS;

import java.awt.Color;
import java.awt.Cursor;
import java.util.Collections;
Expand Down Expand Up @@ -609,7 +611,8 @@ private boolean handleSuccess(LoginStatus loginStatus) throws ClientException {

// Check for new notifications from update server if enabled
String checkForNotifications = userPreferences.getProperty("checkForNotifications");
if (checkForNotifications == null || BooleanUtils.toBoolean(checkForNotifications)) {
if (CHECK_FOR_NOTIFICATIONS
&& (checkForNotifications == null || BooleanUtils.toBoolean(checkForNotifications))) {
Set<Integer> archivedNotifications = new HashSet<Integer>();
String archivedNotificationString = userPreferences.getProperty("archivedNotifications");
if (archivedNotificationString != null) {
Expand Down
14 changes: 10 additions & 4 deletions client/src/com/mirth/connect/client/ui/SettingsPanelServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

package com.mirth.connect.client.ui;

import static com.mirth.connect.client.core.BrandingConstants.SEND_USAGE_STATISTICS;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.Font;
Expand Down Expand Up @@ -81,8 +83,12 @@ public SettingsPanelServer(String tabName) {
addTask(TaskConstants.SETTINGS_SERVER_RESTORE, "Restore Config", "Restore your server configuration from a server configuration XML file. This will remove and restore your channels, alerts, code templates, server properties, global scripts, and plugin properties.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/report_go.png")));
addTask(TaskConstants.SETTINGS_CLEAR_ALL_STATS, "Clear All Statistics", "Reset the current and lifetime statistics for all channels.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/chart_bar_delete.png")));

provideUsageStatsMoreInfoLabel.setToolTipText(BrandingConstants.PRIVACY_TOOLTIP);
provideUsageStatsMoreInfoLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
if (!SEND_USAGE_STATISTICS) {
provideUsageStatsLabel.setVisible(false);
provideUsageStatsYesRadio.setVisible(false);
provideUsageStatsNoRadio.setVisible((false));
provideUsageStatsMoreInfoLabel.setVisible(false);
}
queueBufferSizeField.setDocument(new MirthFieldConstraints(8, false, false, true));
smtpTimeoutField.setDocument(new MirthFieldConstraints(0, false, false, false));
administratorAutoLogoutIntervalField.setDocument(new MirthFieldConstraints(2, false, false, true));
Expand Down Expand Up @@ -728,8 +734,8 @@ public void actionPerformed(ActionEvent evt) {
provideUsageStatsButtonGroup.add(provideUsageStatsNoRadio);

provideUsageStatsMoreInfoLabel = new JLabel("<html><font color=blue><u>More Info</u></font></html>");
provideUsageStatsMoreInfoLabel.setEnabled(false);
provideUsageStatsMoreInfoLabel.setVisible(false);
provideUsageStatsMoreInfoLabel.setToolTipText(BrandingConstants.PRIVACY_TOOLTIP);
provideUsageStatsMoreInfoLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
provideUsageStatsMoreInfoLabel.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
provideUsageStatsMoreInfoLabelMouseClicked(evt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@ public class BrandingConstants {
public static final String CLIENT_CONNECTION_HEADER = "openintegrationengine-client";

public static final String SERVER_CERTIFICATE_CN = "oie-engine";

public static final String CONNECT_SERVER_URL = "https://connect.openintegrationengine.org";
public static final String NOTIFICATIONS_URL = "https://api.github.com/repos/openintegrationengine/engine/releases";

public static final boolean CENTRAL_USER_REGISTRATION = false;
public static final boolean MANDATORY_USER_REGISTRATION = false;
public static final boolean CHECK_FOR_NOTIFICATIONS = true;
public static final boolean SEND_USAGE_STATISTICS = false;
}
22 changes: 20 additions & 2 deletions server/src/com/mirth/connect/client/core/ConnectServiceUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,27 @@
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import com.github.zafarkhaja.semver.Version;

import com.mirth.connect.model.User;
import com.mirth.connect.model.converters.ObjectXMLSerializer;
import com.mirth.connect.model.notification.Notification;
import com.mirth.connect.util.MirthSSLUtil;

public class ConnectServiceUtil {
private final static String URL_CONNECT_SERVER = "https://connect.mirthcorp.com";
private final static String URL_CONNECT_SERVER = BrandingConstants.CONNECT_SERVER_URL;
private final static String URL_REGISTRATION_SERVLET = "/RegistrationServlet";
private final static String URL_USAGE_SERVLET = "/UsageStatisticsServlet";
private static String URL_NOTIFICATIONS = "https://api.github.com/repos/openintegrationengine/engine/releases";
private static String URL_NOTIFICATIONS = BrandingConstants.NOTIFICATIONS_URL;
private final static int TIMEOUT = 10000;
public final static Integer MILLIS_PER_DAY = 86400000;

public static void registerUser(String serverId, String mirthVersion, User user, String[] protocols, String[] cipherSuites) throws ClientException {
if (!BrandingConstants.CENTRAL_USER_REGISTRATION) {
throw new UnsupportedOperationException("User Registration is disabled");
}

CloseableHttpClient httpClient = null;
CloseableHttpResponse httpResponse = null;
NameValuePair[] params = { new BasicNameValuePair("serverId", serverId),
Expand Down Expand Up @@ -107,6 +113,10 @@ public static void registerUser(String serverId, String mirthVersion, User user,
* @throws Exception should anything fail dealing with the web request and the handling of its response
*/
public static List<Notification> getNotifications(String serverId, String mirthVersion, Map<String, String> extensionVersions, String[] protocols, String[] cipherSuites) throws Exception {
if (!BrandingConstants.CHECK_FOR_NOTIFICATIONS) {
throw new UnsupportedOperationException("Checking for Notifications is disabled.");
}

List<Notification> validNotifications = Collections.emptyList();
Optional<Version> parsedMirthVersion = Version.tryParse(mirthVersion);
if (!parsedMirthVersion.isPresent()) {
Expand Down Expand Up @@ -208,6 +218,10 @@ protected static Notification toNotification(JsonNode node) {
}

public static int getNotificationCount(String serverId, String mirthVersion, Map<String, String> extensionVersions, Set<Integer> archivedNotifications, String[] protocols, String[] cipherSuites) {
if (!BrandingConstants.CHECK_FOR_NOTIFICATIONS) {
throw new UnsupportedOperationException("Checking for Notifications is disabled.");
}

Long notificationCount = 0L;
try {
notificationCount = getNotifications(serverId, mirthVersion, extensionVersions, protocols, cipherSuites)
Expand All @@ -222,6 +236,10 @@ public static int getNotificationCount(String serverId, String mirthVersion, Map
}

public static boolean sendStatistics(String serverId, String mirthVersion, boolean server, String data, String[] protocols, String[] cipherSuites) {
if (!BrandingConstants.SEND_USAGE_STATISTICS) {
throw new UnsupportedOperationException("Sending Usage Statistics is disabled.");
}

if (data == null) {
return false;
}
Expand Down
6 changes: 4 additions & 2 deletions server/src/com/mirth/connect/server/Mirth.java
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,10 @@ public void startup() {
printSplashScreen();

// schedule usage statistics to be sent at startup and every 24 hours
Timer timer = new Timer();
timer.schedule(new UsageSenderTask(), 0, ConnectServiceUtil.MILLIS_PER_DAY);
if (BrandingConstants.SEND_USAGE_STATISTICS) {
Timer timer = new Timer();
timer.schedule(new UsageSenderTask(), 0, ConnectServiceUtil.MILLIS_PER_DAY);
}
}

/**
Expand Down