Skip to content

Commit 8fb0b06

Browse files
mgaffigantonygermano
authored and
kayyagari
committed
Allow telemetry options to be enabled/disabled via BrandingConstants
Adds the following settings to BrandingConstants in client-core: - CENTRAL_USER_REGISTRATION - When false, disables the sending of user demographic information and hides the registration and marketing consent boxes from the first time login screen. - MANDATORY_USER_REGISTRATION - used in conjunction with CENTRAL_USER_REGISTRATION. When this is setting is true and the user id is 1, then the user will not be able to unselect the registration checkbox. - CHECK_FOR_NOTIFICATIONS - When false, allows for notification fetching from the client to be disabled. The notification menu task is also removed. - SEND_USAGE_STATISTICS - When false, allows for sending of usage statistics to be disabled. Also hides the setting which allows users to opt-in or opt-out of sending statistics. With the restoration of the registration checkbox when the appropriate settings are enabled, the adjustment of which fields are required on the user profile has also been restored. Co-authored-by: Tony Germano <tony@germano.name> Signed-off-by: Mitch Gaffigan <mitch.gaffigan@comcast.net> Signed-off-by: Tony Germano <tony@germano.name> Issue: #5
1 parent 96934fc commit 8fb0b06

File tree

7 files changed

+78
-18
lines changed

7 files changed

+78
-18
lines changed

client/src/com/mirth/connect/client/ui/FirstLoginDialog.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
package com.mirth.connect.client.ui;
1111

12+
import static com.mirth.connect.client.core.BrandingConstants.CENTRAL_USER_REGISTRATION;
13+
import static com.mirth.connect.client.core.BrandingConstants.MANDATORY_USER_REGISTRATION;
14+
1215
import java.awt.Desktop;
1316
import java.awt.Dimension;
1417
import java.awt.Point;
@@ -47,10 +50,14 @@ public FirstLoginDialog(User currentUser) {
4750
finishButton.setEnabled(false);
4851

4952
userEditPanel.setUser(this, currentUser);
50-
userEditPanel.setRequiredFields(false, true);
51-
if (currentUser.getId() == 1) {
52-
registerCheckBox.setVisible(false);
53-
}
53+
54+
final boolean isRegistrationMandatory = CENTRAL_USER_REGISTRATION && MANDATORY_USER_REGISTRATION && currentUser.getId() == 1;
55+
registerCheckBox.setSelected(isRegistrationMandatory);
56+
registerCheckBox.setEnabled(!isRegistrationMandatory);
57+
registerCheckBox.setVisible(CENTRAL_USER_REGISTRATION);
58+
registerCheckBoxActionPerformed(null);
59+
userConsentCheckBox.setVisible(CENTRAL_USER_REGISTRATION);
60+
contentTextPane.setVisible(CENTRAL_USER_REGISTRATION);
5461

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

153160
registerCheckBox.setBackground(new java.awt.Color(255, 255, 255));
154-
registerCheckBox.setSelected(true);
155161
registerCheckBox.setText(String.format("Register user with %s", BrandingConstants.COMPANY_NAME));
156162
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));
157163
registerCheckBox.addActionListener(new java.awt.event.ActionListener() {
@@ -161,7 +167,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
161167
});
162168

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

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

276-
if (registerCheckBox.isSelected()) {
281+
if (registerCheckBox.isSelected() && CENTRAL_USER_REGISTRATION) {
277282
parent.registerUser(user);
278283
}
279284

@@ -316,7 +321,7 @@ private void registerCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//
316321
userConsentCheckBox.setSelected(false);
317322
userConsentCheckBox.setEnabled(false);
318323
}
319-
userEditPanel.setRequiredFields(false, true);
324+
userEditPanel.setRequiredFields(allRequired, true);
320325
}//GEN-LAST:event_registerCheckBoxActionPerformed
321326

322327
public boolean getResult() {

client/src/com/mirth/connect/client/ui/Frame.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
package com.mirth.connect.client.ui;
1111

12+
import static com.mirth.connect.client.core.BrandingConstants.CENTRAL_USER_REGISTRATION;
13+
import static com.mirth.connect.client.core.BrandingConstants.CHECK_FOR_NOTIFICATIONS;
14+
import static com.mirth.connect.client.core.BrandingConstants.SEND_USAGE_STATISTICS;
15+
1216
import java.awt.AWTEvent;
1317
import java.awt.BorderLayout;
1418
import java.awt.Color;
@@ -1250,7 +1254,9 @@ private void createOtherPane() {
12501254
otherPane.setTitle("Other");
12511255
otherPane.setName(TaskConstants.OTHER_KEY);
12521256
otherPane.setFocusable(false);
1253-
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);
1257+
if (CHECK_FOR_NOTIFICATIONS) {
1258+
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);
1259+
}
12541260
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);
12551261
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);
12561262
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);
@@ -1268,6 +1274,10 @@ public JXTaskPane getOtherPane() {
12681274
}
12691275

12701276
public void updateNotificationTaskName(int notifications) {
1277+
if (!CHECK_FOR_NOTIFICATIONS) {
1278+
return;
1279+
}
1280+
12711281
String taskName = UIConstants.VIEW_NOTIFICATIONS;
12721282
if (notifications > 0) {
12731283
taskName += " (" + notifications + ")";
@@ -1949,6 +1959,10 @@ public User getCurrentUser(Component parentComponent, boolean alertOnFailure) {
19491959
}
19501960

19511961
public void registerUser(final User user) {
1962+
if (!CENTRAL_USER_REGISTRATION) {
1963+
return;
1964+
}
1965+
19521966
final String workingId = startWorking("Registering user...");
19531967

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

19741988
public void sendUsageStatistics() {
1989+
if (!SEND_USAGE_STATISTICS) {
1990+
return;
1991+
}
1992+
19751993
UpdateSettings updateSettings = null;
19761994
try {
19771995
updateSettings = mirthClient.getUpdateSettings();

client/src/com/mirth/connect/client/ui/LoginPanel.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
package com.mirth.connect.client.ui;
1111

12+
import static com.mirth.connect.client.core.BrandingConstants.CHECK_FOR_NOTIFICATIONS;
13+
1214
import java.awt.Color;
1315
import java.awt.Cursor;
1416
import java.util.Collections;
@@ -609,7 +611,8 @@ private boolean handleSuccess(LoginStatus loginStatus) throws ClientException {
609611

610612
// Check for new notifications from update server if enabled
611613
String checkForNotifications = userPreferences.getProperty("checkForNotifications");
612-
if (checkForNotifications == null || BooleanUtils.toBoolean(checkForNotifications)) {
614+
if (CHECK_FOR_NOTIFICATIONS
615+
&& (checkForNotifications == null || BooleanUtils.toBoolean(checkForNotifications))) {
613616
Set<Integer> archivedNotifications = new HashSet<Integer>();
614617
String archivedNotificationString = userPreferences.getProperty("archivedNotifications");
615618
if (archivedNotificationString != null) {

client/src/com/mirth/connect/client/ui/SettingsPanelServer.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
package com.mirth.connect.client.ui;
1111

12+
import static com.mirth.connect.client.core.BrandingConstants.SEND_USAGE_STATISTICS;
13+
1214
import java.awt.Color;
1315
import java.awt.Cursor;
1416
import java.awt.Font;
@@ -81,8 +83,12 @@ public SettingsPanelServer(String tabName) {
8183
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")));
8284
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")));
8385

84-
provideUsageStatsMoreInfoLabel.setToolTipText(BrandingConstants.PRIVACY_TOOLTIP);
85-
provideUsageStatsMoreInfoLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
86+
if (!SEND_USAGE_STATISTICS) {
87+
provideUsageStatsLabel.setVisible(false);
88+
provideUsageStatsYesRadio.setVisible(false);
89+
provideUsageStatsNoRadio.setVisible((false));
90+
provideUsageStatsMoreInfoLabel.setVisible(false);
91+
}
8692
queueBufferSizeField.setDocument(new MirthFieldConstraints(8, false, false, true));
8793
smtpTimeoutField.setDocument(new MirthFieldConstraints(0, false, false, false));
8894
administratorAutoLogoutIntervalField.setDocument(new MirthFieldConstraints(2, false, false, true));
@@ -728,8 +734,8 @@ public void actionPerformed(ActionEvent evt) {
728734
provideUsageStatsButtonGroup.add(provideUsageStatsNoRadio);
729735

730736
provideUsageStatsMoreInfoLabel = new JLabel("<html><font color=blue><u>More Info</u></font></html>");
731-
provideUsageStatsMoreInfoLabel.setEnabled(false);
732-
provideUsageStatsMoreInfoLabel.setVisible(false);
737+
provideUsageStatsMoreInfoLabel.setToolTipText(BrandingConstants.PRIVACY_TOOLTIP);
738+
provideUsageStatsMoreInfoLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
733739
provideUsageStatsMoreInfoLabel.addMouseListener(new MouseAdapter() {
734740
public void mouseClicked(MouseEvent evt) {
735741
provideUsageStatsMoreInfoLabelMouseClicked(evt);

server/src/com/mirth/connect/client/core/BrandingConstants.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,12 @@ public class BrandingConstants {
99
public static final String CLIENT_CONNECTION_HEADER = "openintegrationengine-client";
1010

1111
public static final String SERVER_CERTIFICATE_CN = "oie-engine";
12+
13+
public static final String CONNECT_SERVER_URL = "https://connect.openintegrationengine.org";
14+
public static final String NOTIFICATIONS_URL = "https://api.github.com/repos/openintegrationengine/engine/releases";
15+
16+
public static final boolean CENTRAL_USER_REGISTRATION = false;
17+
public static final boolean MANDATORY_USER_REGISTRATION = false;
18+
public static final boolean CHECK_FOR_NOTIFICATIONS = true;
19+
public static final boolean SEND_USAGE_STATISTICS = false;
1220
}

server/src/com/mirth/connect/client/core/ConnectServiceUtil.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,27 @@
5151
import com.fasterxml.jackson.databind.JsonMappingException;
5252
import com.fasterxml.jackson.databind.JsonNode;
5353
import com.fasterxml.jackson.databind.ObjectMapper;
54+
5455
import com.github.zafarkhaja.semver.Version;
56+
5557
import com.mirth.connect.model.User;
5658
import com.mirth.connect.model.converters.ObjectXMLSerializer;
5759
import com.mirth.connect.model.notification.Notification;
5860
import com.mirth.connect.util.MirthSSLUtil;
5961

6062
public class ConnectServiceUtil {
61-
private final static String URL_CONNECT_SERVER = "https://connect.mirthcorp.com";
63+
private final static String URL_CONNECT_SERVER = BrandingConstants.CONNECT_SERVER_URL;
6264
private final static String URL_REGISTRATION_SERVLET = "/RegistrationServlet";
6365
private final static String URL_USAGE_SERVLET = "/UsageStatisticsServlet";
64-
private static String URL_NOTIFICATIONS = "https://api.github.com/repos/openintegrationengine/engine/releases";
66+
private static String URL_NOTIFICATIONS = BrandingConstants.NOTIFICATIONS_URL;
6567
private final static int TIMEOUT = 10000;
6668
public final static Integer MILLIS_PER_DAY = 86400000;
6769

6870
public static void registerUser(String serverId, String mirthVersion, User user, String[] protocols, String[] cipherSuites) throws ClientException {
71+
if (!BrandingConstants.CENTRAL_USER_REGISTRATION) {
72+
throw new UnsupportedOperationException("User Registration is disabled");
73+
}
74+
6975
CloseableHttpClient httpClient = null;
7076
CloseableHttpResponse httpResponse = null;
7177
NameValuePair[] params = { new BasicNameValuePair("serverId", serverId),
@@ -107,6 +113,10 @@ public static void registerUser(String serverId, String mirthVersion, User user,
107113
* @throws Exception should anything fail dealing with the web request and the handling of its response
108114
*/
109115
public static List<Notification> getNotifications(String serverId, String mirthVersion, Map<String, String> extensionVersions, String[] protocols, String[] cipherSuites) throws Exception {
116+
if (!BrandingConstants.CHECK_FOR_NOTIFICATIONS) {
117+
throw new UnsupportedOperationException("Checking for Notifications is disabled.");
118+
}
119+
110120
List<Notification> validNotifications = Collections.emptyList();
111121
Optional<Version> parsedMirthVersion = Version.tryParse(mirthVersion);
112122
if (!parsedMirthVersion.isPresent()) {
@@ -208,6 +218,10 @@ protected static Notification toNotification(JsonNode node) {
208218
}
209219

210220
public static int getNotificationCount(String serverId, String mirthVersion, Map<String, String> extensionVersions, Set<Integer> archivedNotifications, String[] protocols, String[] cipherSuites) {
221+
if (!BrandingConstants.CHECK_FOR_NOTIFICATIONS) {
222+
throw new UnsupportedOperationException("Checking for Notifications is disabled.");
223+
}
224+
211225
Long notificationCount = 0L;
212226
try {
213227
notificationCount = getNotifications(serverId, mirthVersion, extensionVersions, protocols, cipherSuites)
@@ -222,6 +236,10 @@ public static int getNotificationCount(String serverId, String mirthVersion, Map
222236
}
223237

224238
public static boolean sendStatistics(String serverId, String mirthVersion, boolean server, String data, String[] protocols, String[] cipherSuites) {
239+
if (!BrandingConstants.SEND_USAGE_STATISTICS) {
240+
throw new UnsupportedOperationException("Sending Usage Statistics is disabled.");
241+
}
242+
225243
if (data == null) {
226244
return false;
227245
}

server/src/com/mirth/connect/server/Mirth.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,10 @@ public void startup() {
401401
printSplashScreen();
402402

403403
// schedule usage statistics to be sent at startup and every 24 hours
404-
Timer timer = new Timer();
405-
timer.schedule(new UsageSenderTask(), 0, ConnectServiceUtil.MILLIS_PER_DAY);
404+
if (BrandingConstants.SEND_USAGE_STATISTICS) {
405+
Timer timer = new Timer();
406+
timer.schedule(new UsageSenderTask(), 0, ConnectServiceUtil.MILLIS_PER_DAY);
407+
}
406408
}
407409

408410
/**

0 commit comments

Comments
 (0)