revert-70aa11f8
manoj 10 years ago
commit d0b553d26a

@ -17,11 +17,8 @@
*/ */
package org.wso2.carbon.device.mgt.core; 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.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.spi.DeviceManager; 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 org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
import java.util.HashMap; import java.util.HashMap;

@ -257,24 +257,16 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
StringBuilder messageBuilder = new StringBuilder(); StringBuilder messageBuilder = new StringBuilder();
try { 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 + "\\}", messageHeader = messageHeader.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.FIRST_NAME + "\\}",
URLEncoder.encode(emailMessageProperties.getFirstName(), URLEncoder.encode(emailMessageProperties.getFirstName(),
EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME));
messageBody = messageBody + System.getProperty("line.separator") + url.replaceAll("\\{" messageBody = messageBody + System.getProperty("line.separator") + url.replaceAll("\\{"
+ EmailConstants.EnrolmentEmailConstants.DOwN_LOAD_URL + "\\}", + EmailConstants.EnrolmentEmailConstants.DOWNLOAD_URL + "\\}",
URLDecoder.decode(emailMessageProperties.getEnrolmentUrl(), URLDecoder.decode(emailMessageProperties.getEnrolmentUrl(),
EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); 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( messageBuilder.append(messageHeader).append(System.getProperty("line.separator"));
System.getProperty("line.separator")).append(messageFooter); messageBuilder.append(messageBody).append(System.getProperty("line.separator")).append(messageFooter);
} catch (IOException e) { } catch (IOException e) {
log.error("IO error in processing enrol email message "+emailMessageProperties); log.error("IO error in processing enrol email message "+emailMessageProperties);
@ -312,12 +304,6 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
StringBuilder messageBuilder = new StringBuilder(); StringBuilder messageBuilder = new StringBuilder();
try { 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 + "\\}", messageHeader = messageHeader.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.FIRST_NAME + "\\}",
URLEncoder.encode(emailMessageProperties.getFirstName(), URLEncoder.encode(emailMessageProperties.getFirstName(),
EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME));
@ -327,18 +313,16 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
.ENCODED_SCHEME)); .ENCODED_SCHEME));
messageBody = messageBody.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.PASSWORD + "\\}", messageBody = messageBody.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.PASSWORD + "\\}",
URLEncoder.encode(emailMessageProperties.getUserName(), EmailConstants.EnrolmentEmailConstants URLEncoder.encode(emailMessageProperties.getPassword(), EmailConstants.EnrolmentEmailConstants
.ENCODED_SCHEME)); .ENCODED_SCHEME));
messageBody = messageBody + System.getProperty("line.separator") + url.replaceAll("\\{" messageBody = messageBody + System.getProperty("line.separator") + url.replaceAll("\\{"
+ EmailConstants.EnrolmentEmailConstants.DOwN_LOAD_URL + "\\}", + EmailConstants.EnrolmentEmailConstants.DOWNLOAD_URL + "\\}",
URLDecoder.decode(emailMessageProperties.getEnrolmentUrl(), URLDecoder.decode(emailMessageProperties.getEnrolmentUrl(),
EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); 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( messageBuilder.append(messageHeader).append(System.getProperty("line.separator"));
System.getProperty("line.separator")).append(messageFooter); messageBuilder.append(messageBody).append(System.getProperty("line.separator")).append(messageFooter);
} catch (IOException e) { } catch (IOException e) {
log.error("IO error in processing enrol email message "+emailMessageProperties); log.error("IO error in processing enrol email message "+emailMessageProperties);

@ -20,9 +20,8 @@ package org.wso2.carbon.device.mgt.core.email;
public final class EmailConstants { public final class EmailConstants {
public static final class EnrolmentEmailConstants { public static final class EnrolmentEmailConstants {
public static final String TITLE = "title";
public static final String USERNAME = "user-name"; 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 ENCODED_SCHEME = "UTF-8";
public static final String PASSWORD = "password"; public static final String PASSWORD = "password";
public static final String FIRST_NAME = "first-name"; public static final String FIRST_NAME = "first-name";

@ -19,29 +19,34 @@
<Notifications> <Notifications>
<NotificationMessage type="enrol"> <NotificationMessage type="enrol">
<Header>Dear {title} {first-name},</Header> <Subject>Enroll your Device with WSO2 MDM</Subject>
<Body>You have been registered to the WSO2 MDM. Below is the link to enroll.</Body> <Header>Dear {first-name},</Header>
<Url>{downloadUrl}</Url> <Body>
<Footer> You have been registered to the WSO2 MDM. Below is the link to enroll.
</Body>
<Url>{downloadUrl}</Url>
<Footer>
Best Regards, Best Regards,
WSO2 MDM Team WSO2 MDM Team.
http://www.wso2.com http://www.wso2.com
</Footer> </Footer>
<Subject>Enrol your device with WSO2 MDM</Subject>
</NotificationMessage> </NotificationMessage>
<NotificationMessage type="userRegistration"> <NotificationMessage type="userRegistration">
<Header>Dear {title} {first-name},</Header> <Subject>Enroll your Device with WSO2 MDM</Subject>
<Body>You have been registered to WSO2 MDM with following credentials. <Header>Dear {first-name},</Header>
<Body>
You have been registered to WSO2 MDM with following credentials.
Username: {user-name} Username: {user-name}
Password: {password} Password: {password}
Below is the link to enroll. Below is the link to enroll.
</Body> </Body>
<Url>{downloadUrl}</Url> <Url>{downloadUrl}</Url>
<Footer> <Footer>
Best Regards, Best Regards,
WSO2 MDM Team WSO2 MDM Team.
http://www.wso2.com http://www.wso2.com
</Footer> </Footer>
<Subject>Enrol your device with WSO2 MDM</Subject>
</NotificationMessage> </NotificationMessage>
</Notifications> </Notifications>
Loading…
Cancel
Save