Email format

revert-70aa11f8
manoj 10 years ago
parent 48a2062f64
commit cfe9bd5f9f

@ -255,7 +255,9 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
String messageHeader = ""; String messageHeader = "";
String messageBody = ""; String messageBody = "";
String messageFooter = ""; String messageFooter1 = "";
String messageFooter2 = "";
String messageFooter3 = "";
String url = ""; String url = "";
String subject = ""; String subject = "";
@ -264,7 +266,9 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
equals(notificationMessage.getType())) { equals(notificationMessage.getType())) {
messageHeader = notificationMessage.getHeader(); messageHeader = notificationMessage.getHeader();
messageBody = notificationMessage.getBody(); messageBody = notificationMessage.getBody();
messageFooter = notificationMessage.getFooter(); messageFooter1 = notificationMessage.getFooterLine1();
messageFooter2 = notificationMessage.getFooterLine2();
messageFooter3 = notificationMessage.getFooterLine3();
url = notificationMessage.getUrl(); url = notificationMessage.getUrl();
subject = notificationMessage.getSubject(); subject = notificationMessage.getSubject();
break; break;
@ -277,13 +281,19 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
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.trim() + System.getProperty("line.separator") +
System.getProperty("line.separator") + url.replaceAll("\\{"
+ EmailConstants.EnrolmentEmailConstants.DOWNLOAD_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")); messageBuilder.append(messageHeader).append(System.getProperty("line.separator"))
messageBuilder.append(messageBody).append(System.getProperty("line.separator")).append(messageFooter); .append(System.getProperty("line.separator"));
messageBuilder.append(messageBody);
messageBuilder.append(System.getProperty("line.separator")).append(System.getProperty("line.separator"));
messageBuilder.append(messageFooter1.trim())
.append(System.getProperty("line.separator")).append(messageFooter2.trim()).append(System
.getProperty("line.separator")).append(messageFooter3.trim());
} 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);
@ -302,7 +312,9 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
String messageHeader = ""; String messageHeader = "";
String messageBody = ""; String messageBody = "";
String messageFooter = ""; String messageFooter1 = "";
String messageFooter2 = "";
String messageFooter3 = "";
String url = ""; String url = "";
String subject = ""; String subject = "";
@ -311,7 +323,9 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
equals(notificationMessage.getType())) { equals(notificationMessage.getType())) {
messageHeader = notificationMessage.getHeader(); messageHeader = notificationMessage.getHeader();
messageBody = notificationMessage.getBody(); messageBody = notificationMessage.getBody();
messageFooter = notificationMessage.getFooter(); messageFooter1 = notificationMessage.getFooterLine1();
messageFooter2 = notificationMessage.getFooterLine2();
messageFooter3 = notificationMessage.getFooterLine3();
url = notificationMessage.getUrl(); url = notificationMessage.getUrl();
subject = notificationMessage.getSubject(); subject = notificationMessage.getSubject();
break; break;
@ -325,7 +339,9 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
URLEncoder.encode(emailMessageProperties.getFirstName(), URLEncoder.encode(emailMessageProperties.getFirstName(),
EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME));
messageBody = messageBody.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.USERNAME + "\\}", messageBody = messageBody.trim().replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants
.USERNAME
+ "\\}",
URLEncoder.encode(emailMessageProperties.getUserName(), EmailConstants.EnrolmentEmailConstants URLEncoder.encode(emailMessageProperties.getUserName(), EmailConstants.EnrolmentEmailConstants
.ENCODED_SCHEME)); .ENCODED_SCHEME));
@ -339,7 +355,9 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME));
messageBuilder.append(messageHeader).append(System.getProperty("line.separator")); messageBuilder.append(messageHeader).append(System.getProperty("line.separator"));
messageBuilder.append(messageBody).append(System.getProperty("line.separator")).append(messageFooter); messageBuilder.append(messageBody).append(System.getProperty("line.separator")).append(messageFooter1.trim());
messageBuilder.append(System.getProperty("line.separator")).append(messageFooter2.trim());
messageBuilder.append(System.getProperty("line.separator")).append(messageFooter3.trim());
} 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);
@ -488,7 +506,7 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
devicesList = this.getDeviceDAO().getDeviceListOfUser(userName, tenantId); devicesList = this.getDeviceDAO().getDeviceListOfUser(userName, tenantId);
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
throw new DeviceManagementException("Error occurred while obtaining the devices of user '" throw new DeviceManagementException("Error occurred while obtaining the devices of user '"
+ userName + "'", e); + userName + "'", e);
} }
//Fetch the DeviceList from device plugin dbs & append the properties //Fetch the DeviceList from device plugin dbs & append the properties
@ -509,8 +527,8 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
} }
devicesOfUser.add(convertedDevice); devicesOfUser.add(convertedDevice);
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
log.error("Error occurred while obtaining the device type of DeviceTypeId '"+ log.error("Error occurred while obtaining the device type of DeviceTypeId '" +
device.getDeviceTypeId() + "'",e); device.getDeviceTypeId() + "'", e);
} }
} }
return devicesOfUser; return devicesOfUser;
@ -531,15 +549,15 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
int tenantId = DeviceManagerUtil.getTenantId(); int tenantId = DeviceManagerUtil.getTenantId();
//Obtaining the list of users of role //Obtaining the list of users of role
try { try {
users = DeviceManagementDataHolder.getInstance().getUserManager().getUsersForTenantAndRole( users = DeviceManagementDataHolder.getInstance().getUserManager().getUsersForTenantAndRole(
tenantId, roleName); tenantId, roleName);
} catch (org.wso2.carbon.device.mgt.user.common.UserManagementException e) { } catch (org.wso2.carbon.device.mgt.user.common.UserManagementException e) {
throw new DeviceManagementException("Error occurred while obtaining the users of role '" throw new DeviceManagementException("Error occurred while obtaining the users of role '"
+ roleName + "'", e); + roleName + "'", e);
} }
//Obtaining the devices per user //Obtaining the devices per user
for(org.wso2.carbon.device.mgt.user.common.User user:users){ for (org.wso2.carbon.device.mgt.user.common.User user : users) {
try { try {
userName = user.getUserName(); userName = user.getUserName();
devicesList = this.getDeviceDAO().getDeviceListOfUser(userName, tenantId); devicesList = this.getDeviceDAO().getDeviceListOfUser(userName, tenantId);
@ -560,13 +578,13 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
} }
devicesOfRole.add(convertedDevice); devicesOfRole.add(convertedDevice);
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
log.error("Error occurred while obtaining the device type of DeviceTypeId '"+ log.error("Error occurred while obtaining the device type of DeviceTypeId '" +
device.getDeviceTypeId() + "'",e); device.getDeviceTypeId() + "'", e);
} }
} }
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
log.error("Error occurred while obtaining the devices of user '" log.error("Error occurred while obtaining the devices of user '"
+ userName + "'", e); + userName + "'", e);
} }
} }
return devicesOfRole; return devicesOfRole;

@ -27,7 +27,9 @@ public class NotificationMessages {
private String header; private String header;
private String body; private String body;
private String footer; private String footerLine1;
private String footerLine2;
private String footerLine3;
private String subject; private String subject;
private String url; private String url;
@ -60,15 +62,6 @@ public class NotificationMessages {
this.body = body; this.body = body;
} }
@XmlElement(name = "Footer", required = true)
public String getFooter() {
return footer;
}
public void setFooter(String footer) {
this.footer = footer;
}
@XmlElement(name = "Subject", required = true) @XmlElement(name = "Subject", required = true)
public String getSubject() { public String getSubject() {
return subject; return subject;
@ -86,4 +79,32 @@ public class NotificationMessages {
public void setUrl(String url) { public void setUrl(String url) {
this.url = url; this.url = url;
} }
@XmlElement(name = "Footer1")
public String getFooterLine1() {
return footerLine1;
}
public void setFooterLine1(String footerLine1) {
this.footerLine1 = footerLine1;
}
@XmlElement(name = "Footer2")
public String getFooterLine2() {
return footerLine2;
}
public void setFooterLine2(String footerLine2) {
this.footerLine2 = footerLine2;
}
@XmlElement(name = "Footer3")
public String getFooterLine3() {
return footerLine3;
}
public void setFooterLine3(String footerLine3) {
this.footerLine3 = footerLine3;
}
} }

@ -1,22 +1,3 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ you may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<Notifications> <Notifications>
<NotificationMessage type="enrol"> <NotificationMessage type="enrol">
<Subject>Enroll your Device with WSO2 MDM</Subject> <Subject>Enroll your Device with WSO2 MDM</Subject>
@ -25,28 +6,34 @@
You have been registered to the WSO2 MDM. Below is the link to enroll. You have been registered to the WSO2 MDM. Below is the link to enroll.
</Body> </Body>
<Url>{downloadUrl}</Url> <Url>{downloadUrl}</Url>
<Footer> <Footer1>
Best Regards, Best Regards,
</Footer1>
<Footer2>
WSO2 MDM Team. WSO2 MDM Team.
</Footer2>
<Footer3>
http://www.wso2.com http://www.wso2.com
</Footer> </Footer3>
</NotificationMessage> </NotificationMessage>
<NotificationMessage type="userRegistration"> <NotificationMessage type="userRegistration">
<Subject>Enroll your Device with WSO2 MDM</Subject> <Subject>Enroll your Device with WSO2 MDM</Subject>
<Header>Dear {first-name},</Header> <Header>Dear {first-name},</Header>
<Body> <Body>
You have been registered to WSO2 MDM with following credentials. 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> <Footer1>
Best Regards, Best Regards,
</Footer1>
<Footer2>
WSO2 MDM Team. WSO2 MDM Team.
</Footer2>
<Footer3>
http://www.wso2.com http://www.wso2.com
</Footer> </Footer3>
</NotificationMessage> </NotificationMessage>
</Notifications> </Notifications>
Loading…
Cancel
Save