From aabe9afff5ebe46cf1ee1c2f1fc77fec5d0ecccc Mon Sep 17 00:00:00 2001 From: DilanUA Date: Tue, 21 Apr 2015 15:06:07 +0530 Subject: [PATCH] Updated back-end email notification functionality --- .../mgt/core/DeviceManagementRepository.java | 3 -- .../DeviceManagementServiceProviderImpl.java | 30 +++++-------------- .../device/mgt/core/email/EmailConstants.java | 3 +- .../resources/conf/notification-messages.xml | 27 ++++++++++------- 4 files changed, 24 insertions(+), 39 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java index 048317a1e7..e2cd42c791 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java @@ -17,11 +17,8 @@ */ package org.wso2.carbon.device.mgt.core; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.spi.DeviceManager; -import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import java.util.HashMap; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java index 4618a1703c..5968b15365 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java @@ -257,24 +257,16 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ StringBuilder messageBuilder = new StringBuilder(); try { - String title = ""; - if (emailMessageProperties.getTitle() != null){ - title = emailMessageProperties.getTitle(); - } - messageHeader = messageHeader.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.TITLE + "\\}", - URLEncoder.encode(title, EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); messageHeader = messageHeader.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.FIRST_NAME + "\\}", URLEncoder.encode(emailMessageProperties.getFirstName(), EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); messageBody = messageBody + System.getProperty("line.separator") + url.replaceAll("\\{" - + EmailConstants.EnrolmentEmailConstants.DOwN_LOAD_URL + "\\}", + + EmailConstants.EnrolmentEmailConstants.DOWNLOAD_URL + "\\}", URLDecoder.decode(emailMessageProperties.getEnrolmentUrl(), EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); - messageBuilder.append(messageHeader).append(System.getProperty("line.separator")).append( - System.getProperty("line.separator")); - messageBuilder.append(messageBody).append(System.getProperty("line.separator")).append( - System.getProperty("line.separator")).append(messageFooter); + messageBuilder.append(messageHeader).append(System.getProperty("line.separator")); + messageBuilder.append(messageBody).append(System.getProperty("line.separator")).append(messageFooter); } catch (IOException e) { log.error("IO error in processing enrol email message "+emailMessageProperties); @@ -312,12 +304,6 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ StringBuilder messageBuilder = new StringBuilder(); try { - String title = ""; - if (emailMessageProperties.getTitle() != null){ - title = emailMessageProperties.getTitle(); - } - messageHeader = messageHeader.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.TITLE + "\\}", - URLEncoder.encode(title, EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); messageHeader = messageHeader.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.FIRST_NAME + "\\}", URLEncoder.encode(emailMessageProperties.getFirstName(), EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); @@ -327,18 +313,16 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ .ENCODED_SCHEME)); messageBody = messageBody.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.PASSWORD + "\\}", - URLEncoder.encode(emailMessageProperties.getUserName(), EmailConstants.EnrolmentEmailConstants + URLEncoder.encode(emailMessageProperties.getPassword(), EmailConstants.EnrolmentEmailConstants .ENCODED_SCHEME)); messageBody = messageBody + System.getProperty("line.separator") + url.replaceAll("\\{" - + EmailConstants.EnrolmentEmailConstants.DOwN_LOAD_URL + "\\}", + + EmailConstants.EnrolmentEmailConstants.DOWNLOAD_URL + "\\}", URLDecoder.decode(emailMessageProperties.getEnrolmentUrl(), EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); - messageBuilder.append(messageHeader).append(System.getProperty("line.separator")).append( - System.getProperty("line.separator")); - messageBuilder.append(messageBody).append(System.getProperty("line.separator")).append( - System.getProperty("line.separator")).append(messageFooter); + messageBuilder.append(messageHeader).append(System.getProperty("line.separator")); + messageBuilder.append(messageBody).append(System.getProperty("line.separator")).append(messageFooter); } catch (IOException e) { log.error("IO error in processing enrol email message "+emailMessageProperties); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java index 9e37b57ed6..2fac091319 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java @@ -20,9 +20,8 @@ package org.wso2.carbon.device.mgt.core.email; public final class EmailConstants { public static final class EnrolmentEmailConstants { - public static final String TITLE = "title"; public static final String USERNAME = "user-name"; - public static final String DOwN_LOAD_URL = "downloadUrl"; + public static final String DOWNLOAD_URL = "downloadUrl"; public static final String ENCODED_SCHEME = "UTF-8"; public static final String PASSWORD = "password"; public static final String FIRST_NAME = "first-name"; diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/notification-messages.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/notification-messages.xml index 796b7fd06e..e3aaa462a0 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/notification-messages.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/notification-messages.xml @@ -19,29 +19,34 @@ -
Dear {title} {first-name},
- You have been registered to the WSO2 MDM. Below is the link to enroll. - {downloadUrl} -
+ Enroll your Device with WSO2 MDM +
Dear {first-name},
+ + You have been registered to the WSO2 MDM. Below is the link to enroll. + + {downloadUrl} +
Best Regards, - WSO2 MDM Team + WSO2 MDM Team. http://www.wso2.com -
- Enrol your device with WSO2 MDM +
-
Dear {title} {first-name},
- You have been registered to WSO2 MDM with following credentials. + Enroll your Device with WSO2 MDM +
Dear {first-name},
+ + You have been registered to WSO2 MDM with following credentials. + Username: {user-name} Password: {password} + Below is the link to enroll. {downloadUrl}
Best Regards, - WSO2 MDM Team + WSO2 MDM Team. http://www.wso2.com
- Enrol your device with WSO2 MDM
\ No newline at end of file