Skip to content

Commit e3ffc1e

Browse files
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: Tony Germano <tony@germano.name> Signed-off-by: Mitch Gaffigan <mitch.gaffigan@comcast.net> Issue: #5 Signed-off-by: Tony Germano <tony@germano.name> Co-authored-by: Tony Germano <tony@germano.name> Signed-off-by: Mitch Gaffigan <mitch.gaffigan@comcast.net>
1 parent cb867db commit e3ffc1e

File tree

7 files changed

+60
-30
lines changed

7 files changed

+60
-30
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,4 @@ public class BrandingConstants {
4040
// These images must be at 215px x 30px scale
4141
public static final ImageIcon LOGO = new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/branding/oie_logo_banner_text_215x30.png"));
4242
public static final ImageIcon LOGO_GRAY = new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/branding/oie_white_logo_banner_text_215x30.png"));
43-
44-
public static final boolean CENTRAL_USER_REGISTRATION = false;
45-
public static final boolean MANDATORY_USER_REGISTRATION = false;
46-
public static final boolean CHECK_FOR_NOTIFICATIONS = true;
47-
public static final boolean SEND_USAGE_STATISTICS = false;
4843
}

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

Lines changed: 13 additions & 17 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,19 +50,14 @@ public FirstLoginDialog(User currentUser) {
4750
finishButton.setEnabled(false);
4851

4952
userEditPanel.setUser(this, currentUser);
50-
userEditPanel.setRequiredFields(false, true);
51-
if (BrandingConstants.CENTRAL_USER_REGISTRATION) {
52-
if (currentUser.getId() == 1 && BrandingConstants.MANDATORY_USER_REGISTRATION) {
53-
// When MANDATORY_USER_REGISTRATION is set, registration is compulsatory
54-
// for the first user of the system.
55-
registerCheckBox.setVisible(false);
56-
}
57-
} else {
58-
registerCheckBox.setVisible(false);
59-
registerCheckBox.setSelected(false);
60-
userConsentCheckBox.setVisible(false);
61-
userConsentCheckBox.setSelected(false);
62-
}
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);
6361

6462
jLabel2.setForeground(UIConstants.HEADER_TITLE_TEXT_COLOR);
6563
setModal(true);
@@ -160,7 +158,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
160158
jScrollPane1.setViewportView(jTextPane1);
161159

162160
registerCheckBox.setBackground(new java.awt.Color(255, 255, 255));
163-
registerCheckBox.setSelected(BrandingConstants.MANDATORY_USER_REGISTRATION);
164161
registerCheckBox.setText(String.format("Register user with %s", BrandingConstants.COMPANY_NAME));
165162
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));
166163
registerCheckBox.addActionListener(new java.awt.event.ActionListener() {
@@ -170,7 +167,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
170167
});
171168

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

@@ -282,7 +278,7 @@ private void finishButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
282278
return;
283279
}
284280

285-
if (registerCheckBox.isSelected() && BrandingConstants.CENTRAL_USER_REGISTRATION) {
281+
if (registerCheckBox.isSelected() && CENTRAL_USER_REGISTRATION) {
286282
parent.registerUser(user);
287283
}
288284

@@ -325,7 +321,7 @@ private void registerCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//
325321
userConsentCheckBox.setSelected(false);
326322
userConsentCheckBox.setEnabled(false);
327323
}
328-
userEditPanel.setRequiredFields(false, true);
324+
userEditPanel.setRequiredFields(allRequired, true);
329325
}//GEN-LAST:event_registerCheckBoxActionPerformed
330326

331327
public boolean getResult() {

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

Lines changed: 14 additions & 2 deletions
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,7 @@ private void createOtherPane() {
12501254
otherPane.setTitle("Other");
12511255
otherPane.setName(TaskConstants.OTHER_KEY);
12521256
otherPane.setFocusable(false);
1253-
if (BrandingConstants.CHECK_FOR_NOTIFICATIONS) {
1257+
if (CHECK_FOR_NOTIFICATIONS) {
12541258
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);
12551259
}
12561260
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);
@@ -1270,6 +1274,10 @@ public JXTaskPane getOtherPane() {
12701274
}
12711275

12721276
public void updateNotificationTaskName(int notifications) {
1277+
if (!CHECK_FOR_NOTIFICATIONS) {
1278+
return;
1279+
}
1280+
12731281
String taskName = UIConstants.VIEW_NOTIFICATIONS;
12741282
if (notifications > 0) {
12751283
taskName += " (" + notifications + ")";
@@ -1951,6 +1959,10 @@ public User getCurrentUser(Component parentComponent, boolean alertOnFailure) {
19511959
}
19521960

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

19561968
SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
@@ -1974,7 +1986,7 @@ public void done() {
19741986
}
19751987

19761988
public void sendUsageStatistics() {
1977-
if (!BrandingConstants.SEND_USAGE_STATISTICS) {
1989+
if (!SEND_USAGE_STATISTICS) {
19781990
return;
19791991
}
19801992

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

Lines changed: 3 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,7 @@ 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 (BrandingConstants.CHECK_FOR_NOTIFICATIONS
614+
if (CHECK_FOR_NOTIFICATIONS
613615
&& (checkForNotifications == null || BooleanUtils.toBoolean(checkForNotifications))) {
614616
Set<Integer> archivedNotifications = new HashSet<Integer>();
615617
String archivedNotificationString = userPreferences.getProperty("archivedNotifications");

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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,9 @@ public class BrandingConstants {
1212

1313
public static final String CONNECT_SERVER_URL = "https://connect.openintegrationengine.org";
1414
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;
1519
public static final boolean SEND_USAGE_STATISTICS = false;
1620
}

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454

5555
import com.github.zafarkhaja.semver.Version;
5656

57-
import com.mirth.connect.client.core.BrandingConstants;
5857
import com.mirth.connect.model.User;
5958
import com.mirth.connect.model.converters.ObjectXMLSerializer;
6059
import com.mirth.connect.model.notification.Notification;
@@ -69,6 +68,10 @@ public class ConnectServiceUtil {
6968
public final static Integer MILLIS_PER_DAY = 86400000;
7069

7170
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+
7275
CloseableHttpClient httpClient = null;
7376
CloseableHttpResponse httpResponse = null;
7477
NameValuePair[] params = { new BasicNameValuePair("serverId", serverId),
@@ -110,6 +113,10 @@ public static void registerUser(String serverId, String mirthVersion, User user,
110113
* @throws Exception should anything fail dealing with the web request and the handling of its response
111114
*/
112115
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+
113120
List<Notification> validNotifications = Collections.emptyList();
114121
Optional<Version> parsedMirthVersion = Version.tryParse(mirthVersion);
115122
if (!parsedMirthVersion.isPresent()) {
@@ -211,6 +218,10 @@ protected static Notification toNotification(JsonNode node) {
211218
}
212219

213220
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+
214225
Long notificationCount = 0L;
215226
try {
216227
notificationCount = getNotifications(serverId, mirthVersion, extensionVersions, protocols, cipherSuites)
@@ -225,6 +236,10 @@ public static int getNotificationCount(String serverId, String mirthVersion, Map
225236
}
226237

227238
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+
228243
if (data == null) {
229244
return false;
230245
}

0 commit comments

Comments
 (0)