From 8573a284e092bcee1cb00cdc07b5d2b7b335a54d Mon Sep 17 00:00:00 2001 From: Kamidu Sachith Date: Thu, 26 Nov 2015 11:39:11 +0530 Subject: [PATCH] Enable Domain name in the invitation main --- .../carbon/device/mgt/common/EmailMessageProperties.java | 9 +++++++++ .../carbon/device/mgt/core/email/EmailConstants.java | 1 + .../service/DeviceManagementProviderServiceImpl.java | 9 ++++++++- .../src/main/resources/conf/notification-messages.xml | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EmailMessageProperties.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EmailMessageProperties.java index 2418e0247a8..7bac7098cc8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EmailMessageProperties.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EmailMessageProperties.java @@ -31,6 +31,7 @@ public class EmailMessageProperties { private String title; private String password; private String userName; + private String domainName; public String getUserName() { return userName; @@ -40,6 +41,14 @@ public class EmailMessageProperties { this.userName = userName; } + public String getDomainName() { + return domainName; + } + + public void setDomainName(String domainName) { + this.domainName = domainName; + } + public String getMessageBody() { return messageBody; } 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 2fac0913196..270501a032b 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,6 +20,7 @@ package org.wso2.carbon.device.mgt.core.email; public final class EmailConstants { public static final class EnrolmentEmailConstants { + public static final String DOMAIN = "domain"; public static final String USERNAME = "user-name"; public static final String DOWNLOAD_URL = "downloadUrl"; public static final String ENCODED_SCHEME = "UTF-8"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 5e211a48848..04611b27574 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -588,7 +588,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv break; } } - +log.error("======================================================================"); + log.error(messageBody); +log.error("======================================================================"); StringBuilder messageBuilder = new StringBuilder(); try { @@ -609,6 +611,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv + "\\}", URLEncoder.encode(emailMessageProperties.getUserName(), EmailConstants.EnrolmentEmailConstants .ENCODED_SCHEME)); + messageBody = messageBody.trim().replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.DOMAIN + + "\\}", + URLEncoder.encode(emailMessageProperties.getDomainName(), EmailConstants.EnrolmentEmailConstants + .ENCODED_SCHEME)); messageBody = messageBody.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.PASSWORD + "\\}", URLEncoder.encode(emailMessageProperties.getPassword(), EmailConstants.EnrolmentEmailConstants @@ -624,6 +630,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv messageFooter1.trim()); messageBuilder.append(System.getProperty("line.separator")).append(messageFooter2.trim()); messageBuilder.append(System.getProperty("line.separator")).append(messageFooter3.trim()); + log.info(messageBuilder.toString()); } catch (IOException e) { throw new DeviceManagementException("Error replacing tags in email template '" + 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 9b13c5d8088..9ee0a480041 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 @@ -21,6 +21,7 @@
Dear {first-name},
You have been registered to WSO2 MDM with following credentials. +Domain: {domain} Username: {user-name} Password: {password} Below is the link to enroll.