diff --git a/.gitignore b/.gitignore index cda5bab2e..02b06a07f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ # / +.DS_Store +.java-version .idea **/*.iml donkey/donkey-src diff --git a/client/src/com/mirth/connect/client/ui/FirstLoginDialog.form b/client/src/com/mirth/connect/client/ui/FirstLoginDialog.form index ba521e45c..32c03cc35 100644 --- a/client/src/com/mirth/connect/client/ui/FirstLoginDialog.form +++ b/client/src/com/mirth/connect/client/ui/FirstLoginDialog.form @@ -58,7 +58,6 @@ - @@ -77,8 +76,6 @@ - - @@ -159,19 +156,6 @@ - - - - - - - - - - - - - diff --git a/client/src/com/mirth/connect/client/ui/FirstLoginDialog.java b/client/src/com/mirth/connect/client/ui/FirstLoginDialog.java index fbfa5e90d..e35c9abe5 100644 --- a/client/src/com/mirth/connect/client/ui/FirstLoginDialog.java +++ b/client/src/com/mirth/connect/client/ui/FirstLoginDialog.java @@ -48,9 +48,6 @@ public FirstLoginDialog(User currentUser) { userEditPanel.setUser(this, currentUser); userEditPanel.setRequiredFields(false, true); - if (currentUser.getId() == 1) { - registerCheckBox.setVisible(false); - } jLabel2.setForeground(UIConstants.HEADER_TITLE_TEXT_COLOR); setModal(true); @@ -104,8 +101,6 @@ private void initComponents() { userEditPanel = new com.mirth.connect.client.ui.UserEditPanel(); jScrollPane1 = new javax.swing.JScrollPane(); jTextPane1 = new javax.swing.JTextPane(); - registerCheckBox = new javax.swing.JCheckBox(); - userConsentCheckBox = new javax.swing.JCheckBox(); contentTextPane = new javax.swing.JTextPane(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); @@ -149,21 +144,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jTextPane1.setDisabledTextColor(new java.awt.Color(0, 0, 0)); jTextPane1.setEnabled(false); 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("Register your user information with %s to help us
improve the product and provide better service.", BrandingConstants.COMPANY_NAME)); - registerCheckBox.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - registerCheckBoxActionPerformed(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(""); contentTextPane.setContentType("text/html"); contentTextPane.setText(String.format("    For more information on the processing of your personal data, click here to find our Privacy Policy.", BrandingConstants.PRIVACY_URL)); @@ -209,8 +189,6 @@ public void hyperlinkUpdate(HyperlinkEvent evt) { .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE) .addGroup(channelOverviewLayout.createSequentialGroup() .addGroup(channelOverviewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(registerCheckBox) - .addComponent(userConsentCheckBox) .addComponent(contentTextPane) .addComponent(userEditPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(0, 19, Short.MAX_VALUE))) @@ -224,10 +202,6 @@ public void hyperlinkUpdate(HyperlinkEvent evt) { .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(userEditPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(registerCheckBox) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(userConsentCheckBox) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(contentTextPane) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) @@ -262,21 +236,12 @@ private void finishButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN- parent.alertWarning(this, validateUserMessage); } else { User user = userEditPanel.getUser(); - if (userConsentCheckBox.isSelected()) { - user.setUserConsent(true); - } - boolean success = false; - - success = parent.updateCurrentUser(this, user, userEditPanel.getPassword()); + boolean success = parent.updateCurrentUser(this, user, userEditPanel.getPassword()); if (!success) { return; } - if (registerCheckBox.isSelected()) { - parent.registerUser(user); - } - try { User currentUser = parent.getCurrentUser(parent); parent.mirthClient.setUserPreference(currentUser.getId(), "firstlogin", "false"); @@ -307,18 +272,6 @@ private void finishButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN- } }//GEN-LAST:event_finishButtonActionPerformed - private void registerCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_registerCheckBoxActionPerformed - boolean allRequired = registerCheckBox.isSelected(); - if (allRequired) { - userConsentCheckBox.setSelected(true); - userConsentCheckBox.setEnabled(true); - } else { - userConsentCheckBox.setSelected(false); - userConsentCheckBox.setEnabled(false); - } - userEditPanel.setRequiredFields(false, true); - }//GEN-LAST:event_registerCheckBoxActionPerformed - public boolean getResult() { return this.result; } @@ -331,8 +284,6 @@ public boolean getResult() { private javax.swing.JSeparator jSeparator1; private javax.swing.JTextPane jTextPane1; private com.mirth.connect.client.ui.MirthHeadingPanel mirthHeadingPanel1; - private javax.swing.JCheckBox registerCheckBox; - private javax.swing.JCheckBox userConsentCheckBox; private com.mirth.connect.client.ui.UserEditPanel userEditPanel; private javax.swing.JTextPane contentTextPane; // End of variables declaration//GEN-END:variables diff --git a/client/src/com/mirth/connect/client/ui/Frame.java b/client/src/com/mirth/connect/client/ui/Frame.java index 717803561..4cabb5ca3 100644 --- a/client/src/com/mirth/connect/client/ui/Frame.java +++ b/client/src/com/mirth/connect/client/ui/Frame.java @@ -79,6 +79,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.http.conn.HttpHostConnectException; @@ -1948,68 +1949,6 @@ public User getCurrentUser(Component parentComponent, boolean alertOnFailure) { return currentUser; } - public void registerUser(final User user) { - final String workingId = startWorking("Registering user..."); - - SwingWorker worker = new SwingWorker() { - - public Void doInBackground() { - try { - ConnectServiceUtil.registerUser(PlatformUI.SERVER_ID, PlatformUI.SERVER_VERSION, user, PlatformUI.HTTPS_PROTOCOLS, PlatformUI.HTTPS_CIPHER_SUITES); - } catch (ClientException e) { - // ignore errors connecting to update/stats server - } - - return null; - } - - public void done() { - stopWorking(workingId); - } - }; - - worker.execute(); - } - - public void sendUsageStatistics() { - UpdateSettings updateSettings = null; - try { - updateSettings = mirthClient.getUpdateSettings(); - } catch (Exception e) { - } - - if (updateSettings != null && updateSettings.getStatsEnabled()) { - final String workingId = startWorking("Sending usage statistics..."); - - SwingWorker worker = new SwingWorker() { - - public Void doInBackground() { - try { - String usageData = mirthClient.getUsageData(getClientStats()); - if (usageData != null) { - boolean isSent = ConnectServiceUtil.sendStatistics(PlatformUI.SERVER_ID, PlatformUI.SERVER_VERSION, false, usageData, PlatformUI.HTTPS_PROTOCOLS, PlatformUI.HTTPS_CIPHER_SUITES); - if (isSent) { - UpdateSettings settings = new UpdateSettings(); - settings.setLastStatsTime(System.currentTimeMillis()); - mirthClient.setUpdateSettings(settings); - } - } - } catch (ClientException e) { - // ignore errors connecting to update/stats server - } - - return null; - } - - public void done() { - stopWorking(workingId); - } - }; - - worker.execute(); - } - } - private Map getClientStats() { Map clientStats = new HashMap(); clientStats.put("javaVersion", System.getProperty("java.version")); diff --git a/client/src/com/mirth/connect/client/ui/LoginPanel.java b/client/src/com/mirth/connect/client/ui/LoginPanel.java index d1c6bfef7..7d21ec637 100644 --- a/client/src/com/mirth/connect/client/ui/LoginPanel.java +++ b/client/src/com/mirth/connect/client/ui/LoginPanel.java @@ -631,8 +631,6 @@ private boolean handleSuccess(LoginStatus loginStatus) throws ClientException { PlatformUI.MIRTH_FRAME.alertThrowable(PlatformUI.MIRTH_FRAME, e); } - PlatformUI.MIRTH_FRAME.sendUsageStatistics(); - return true; } diff --git a/server/src/com/mirth/connect/client/core/ConnectServiceUtil.java b/server/src/com/mirth/connect/client/core/ConnectServiceUtil.java index 9a6b003e7..72113128f 100644 --- a/server/src/com/mirth/connect/client/core/ConnectServiceUtil.java +++ b/server/src/com/mirth/connect/client/core/ConnectServiceUtil.java @@ -49,44 +49,12 @@ public class ConnectServiceUtil { private final static String URL_CONNECT_SERVER = "https://connect.mirthcorp.com"; - private final static String URL_REGISTRATION_SERVLET = "/RegistrationServlet"; - private final static String URL_USAGE_SERVLET = "/UsageStatisticsServlet"; private final static String URL_NOTIFICATION_SERVLET = "/NotificationServlet"; private static String NOTIFICATION_GET = "getNotifications"; private static String NOTIFICATION_COUNT_GET = "getNotificationCount"; 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 { - CloseableHttpClient httpClient = null; - CloseableHttpResponse httpResponse = null; - NameValuePair[] params = { new BasicNameValuePair("serverId", serverId), - new BasicNameValuePair("version", mirthVersion), - new BasicNameValuePair("user", ObjectXMLSerializer.getInstance().serialize(user)) }; - - HttpPost post = new HttpPost(); - post.setURI(URI.create(URL_CONNECT_SERVER + URL_REGISTRATION_SERVLET)); - post.setEntity(new UrlEncodedFormEntity(Arrays.asList(params), Charset.forName("UTF-8"))); - RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(TIMEOUT).setConnectionRequestTimeout(TIMEOUT).setSocketTimeout(TIMEOUT).build(); - - try { - HttpClientContext postContext = HttpClientContext.create(); - postContext.setRequestConfig(requestConfig); - httpClient = getClient(protocols, cipherSuites); - httpResponse = httpClient.execute(post, postContext); - StatusLine statusLine = httpResponse.getStatusLine(); - int statusCode = statusLine.getStatusCode(); - if ((statusCode != HttpStatus.SC_OK) && (statusCode != HttpStatus.SC_MOVED_TEMPORARILY)) { - throw new Exception("Failed to connect to update server: " + statusLine); - } - } catch (Exception e) { - throw new ClientException(e); - } finally { - HttpClientUtils.closeQuietly(httpResponse); - HttpClientUtils.closeQuietly(httpClient); - } - } - public static List getNotifications(String serverId, String mirthVersion, Map extensionVersions, String[] protocols, String[] cipherSuites) throws Exception { CloseableHttpClient client = null; HttpPost post = new HttpPost(); @@ -195,43 +163,6 @@ public static int getNotificationCount(String serverId, String mirthVersion, Map return notificationCount; } - public static boolean sendStatistics(String serverId, String mirthVersion, boolean server, String data, String[] protocols, String[] cipherSuites) { - if (data == null) { - return false; - } - - boolean isSent = false; - - CloseableHttpClient client = null; - HttpPost post = new HttpPost(); - CloseableHttpResponse response = null; - NameValuePair[] params = { new BasicNameValuePair("serverId", serverId), - new BasicNameValuePair("version", mirthVersion), - new BasicNameValuePair("server", Boolean.toString(server)), - new BasicNameValuePair("data", data) }; - RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(TIMEOUT).setConnectionRequestTimeout(TIMEOUT).setSocketTimeout(TIMEOUT).build(); - - post.setURI(URI.create(URL_CONNECT_SERVER + URL_USAGE_SERVLET)); - post.setEntity(new UrlEncodedFormEntity(Arrays.asList(params), Charset.forName("UTF-8"))); - - try { - HttpClientContext postContext = HttpClientContext.create(); - postContext.setRequestConfig(requestConfig); - client = getClient(protocols, cipherSuites); - response = client.execute(post, postContext); - StatusLine statusLine = response.getStatusLine(); - int statusCode = statusLine.getStatusCode(); - if ((statusCode == HttpStatus.SC_OK)) { - isSent = true; - } - } catch (Exception e) { - } finally { - HttpClientUtils.closeQuietly(response); - HttpClientUtils.closeQuietly(client); - } - return isSent; - } - private static CloseableHttpClient getClient(String[] protocols, String[] cipherSuites) { RegistryBuilder socketFactoryRegistry = RegistryBuilder. create(); String[] enabledProtocols = MirthSSLUtil.getEnabledHttpsProtocols(protocols); diff --git a/server/src/com/mirth/connect/server/Mirth.java b/server/src/com/mirth/connect/server/Mirth.java index 24c64874a..c20321b15 100644 --- a/server/src/com/mirth/connect/server/Mirth.java +++ b/server/src/com/mirth/connect/server/Mirth.java @@ -399,10 +399,6 @@ public void startup() { configurationController.setStatus(ConfigurationController.STATUS_OK); eventController.dispatchEvent(new ServerEvent(configurationController.getServerId(), "Server startup complete")); 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); } /** @@ -650,19 +646,4 @@ private void initializeLogging() { } } } - - private class UsageSenderTask extends TimerTask { - @Override - public void run() { - boolean isSent = ConnectServiceUtil.sendStatistics(configurationController.getServerId(), configurationController.getServerVersion(), true, usageController.createUsageStats(null), configurationController.getHttpsClientProtocols(), configurationController.getHttpsCipherSuites()); - if (isSent) { - UpdateSettings settings = new UpdateSettings(); - settings.setLastStatsTime(System.currentTimeMillis()); - try { - configurationController.setUpdateSettings(settings); - } catch (ControllerException e) { - } - } - } - } }