|
|
@ -28,7 +28,7 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementExcept
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
|
|
|
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.config.DeviceConfigurationManager;
|
|
|
|
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
|
|
|
|
import org.wso2.carbon.device.mgt.core.config.EnrolmentNotifications;
|
|
|
|
import org.wso2.carbon.device.mgt.core.config.email.EnrolmentNotifications;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
|
|
|
@ -36,7 +36,7 @@ import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.Status;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.Status;
|
|
|
|
import org.wso2.carbon.device.mgt.core.email.sender.EmailConfig;
|
|
|
|
import org.wso2.carbon.device.mgt.core.email.EmailConstants;
|
|
|
|
import org.wso2.carbon.device.mgt.core.internal.EmailServiceDataHolder;
|
|
|
|
import org.wso2.carbon.device.mgt.core.internal.EmailServiceDataHolder;
|
|
|
|
import org.wso2.carbon.device.mgt.core.license.mgt.LicenseManagerImpl;
|
|
|
|
import org.wso2.carbon.device.mgt.core.license.mgt.LicenseManagerImpl;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
|
|
|
@ -231,15 +231,11 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void sendEnrollInvitation(EmailConfig config) throws DeviceManagementException {
|
|
|
|
public void sendEnrollInvitation(EmailMessageProperties emailMessageProperties) throws DeviceManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
EmailMessageProperties emailMessageProperties = new EmailMessageProperties();
|
|
|
|
|
|
|
|
EnrolmentNotifications enrolmentNotifications = DeviceConfigurationManager.getInstance()
|
|
|
|
EnrolmentNotifications enrolmentNotifications = DeviceConfigurationManager.getInstance()
|
|
|
|
.getNotificationMessagesConfig().getEnrolmentNotifications();
|
|
|
|
.getNotificationMessagesConfig().getEnrolmentNotifications();
|
|
|
|
|
|
|
|
|
|
|
|
emailMessageProperties.setMailTo(new String[] { config.getAddress() });
|
|
|
|
|
|
|
|
emailMessageProperties.setSubject(enrolmentNotifications.getSubject());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String messageHeader = enrolmentNotifications.getHeader();
|
|
|
|
String messageHeader = enrolmentNotifications.getHeader();
|
|
|
|
String messageBody = enrolmentNotifications.getBody();
|
|
|
|
String messageBody = enrolmentNotifications.getBody();
|
|
|
|
String messageFooter = enrolmentNotifications.getFooter();
|
|
|
|
String messageFooter = enrolmentNotifications.getFooter();
|
|
|
@ -247,22 +243,29 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
|
|
|
|
StringBuilder messageBuilder = new StringBuilder();
|
|
|
|
StringBuilder messageBuilder = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
messageHeader = messageHeader.replaceAll("\\{title\\}", URLEncoder.encode(config.getSubject(), "UTF-8"));
|
|
|
|
messageHeader = messageHeader.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.TITLE + "\\}",
|
|
|
|
|
|
|
|
URLEncoder.encode(emailMessageProperties.getSubject(),
|
|
|
|
|
|
|
|
EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME));
|
|
|
|
|
|
|
|
|
|
|
|
messageHeader =
|
|
|
|
messageHeader =
|
|
|
|
messageHeader.replaceAll("\\{user-name\\}", URLEncoder.encode(config.getFirstName(), "UTF-8"));
|
|
|
|
messageHeader.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.USERNAME + "\\}",
|
|
|
|
|
|
|
|
URLEncoder.encode(emailMessageProperties.getFirstName(),
|
|
|
|
|
|
|
|
EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME));
|
|
|
|
|
|
|
|
|
|
|
|
messageBody = messageBody + System.getProperty("line.separator") + enrolmentNotifications.getUrl()
|
|
|
|
messageBody = messageBody + System.getProperty("line.separator") + enrolmentNotifications.getUrl()
|
|
|
|
.replaceAll("\\{downloadUrl\\}", URLEncoder.encode(config.getEnrollmentUrl(), "UTF-8"));
|
|
|
|
.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.DOwN_LOAD_URL + "\\}",
|
|
|
|
|
|
|
|
URLDecoder.decode(emailMessageProperties.getEnrolmentUrl(),
|
|
|
|
|
|
|
|
EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME));
|
|
|
|
|
|
|
|
|
|
|
|
messageBuilder.append(messageHeader).append(System.getProperty("line.separator")).append(
|
|
|
|
messageBuilder.append(messageHeader).append(System.getProperty("line.separator")).append(
|
|
|
|
System.getProperty("line.separator"));
|
|
|
|
System.getProperty("line.separator"));
|
|
|
|
|
|
|
|
|
|
|
|
messageBuilder.append(messageBody).append(System.getProperty("line.separator")).append(
|
|
|
|
messageBuilder.append(messageBody).append(System.getProperty("line.separator")).append(
|
|
|
|
System.getProperty("line.separator")).append(messageFooter);
|
|
|
|
System.getProperty("line.separator")).append(messageFooter);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
throw new DeviceManagementException("Error replacing tags in email template '" +
|
|
|
|
throw new DeviceManagementException("Error replacing tags in email template '" +
|
|
|
|
config.getSubject() + "'", e);
|
|
|
|
emailMessageProperties.getSubject() + "'", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
emailMessageProperties.setMessageBody(messageBuilder.toString());
|
|
|
|
emailMessageProperties.setMessageBody(messageBuilder.toString());
|
|
|
|
EmailServiceDataHolder.getInstance().getEmailServiceProvider().sendEmail(emailMessageProperties);
|
|
|
|
EmailServiceDataHolder.getInstance().getEmailServiceProvider().sendEmail(emailMessageProperties);
|
|
|
|