diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/email/EmailConfigurations.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/email/EmailConfigurations.java index b0a242df46a..b0e3a9009ae 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/email/EmailConfigurations.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/email/EmailConfigurations.java @@ -28,6 +28,8 @@ public class EmailConfigurations { private int maxNumOfThread; private int keepAliveTime; private int threadQueueCapacity; + private String lBHostPortPrefix; + private String enrollmentContextPath; @XmlElement(name = "minimumThread", required = true) public int getMinNumOfThread() { @@ -62,4 +64,22 @@ public class EmailConfigurations { public void setThreadQueueCapacity(int threadQueueCapacity) { this.threadQueueCapacity = threadQueueCapacity; } + + @XmlElement(name = "LBHostPortPrefix", required = true) + public String getlBHostPortPrefix() { + return lBHostPortPrefix; + } + + public void setlBHostPortPrefix(String lBHostPortPrefix) { + this.lBHostPortPrefix = lBHostPortPrefix; + } + + @XmlElement(name = "enrollmentContextPath", required = true) + public String getEnrollmentContextPath() { + return enrollmentContextPath; + } + + public void setEnrollmentContextPath(String enrollmentContextPath) { + this.enrollmentContextPath = enrollmentContextPath; + } } 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 054e4c5e3b0..26d5245ad0f 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 @@ -29,6 +29,7 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementExcept import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.core.DeviceManagementPluginRepository; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; +import org.wso2.carbon.device.mgt.core.config.email.EmailConfigurations; import org.wso2.carbon.device.mgt.core.config.email.NotificationMessages; import org.wso2.carbon.device.mgt.core.dao.*; import org.wso2.carbon.device.mgt.core.dto.DeviceType; @@ -494,6 +495,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv StringBuilder messageBuilder = new StringBuilder(); try { + + // Reading the download url from the cdm-config.xml file + EmailConfigurations emailConfig = + DeviceConfigurationManager.getInstance().getDeviceManagementConfig(). + getDeviceManagementConfigRepository().getEmailConfigurations(); + emailMessageProperties.setEnrolmentUrl(emailConfig.getlBHostPortPrefix()+ emailConfig.getEnrollmentContextPath()); + messageHeader = messageHeader.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.FIRST_NAME + "\\}", URLEncoder.encode(emailMessageProperties.getFirstName(), EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); @@ -549,6 +557,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv StringBuilder messageBuilder = new StringBuilder(); try { + + // Reading the download url from the cdm-config.xml file + EmailConfigurations emailConfig = + DeviceConfigurationManager.getInstance().getDeviceManagementConfig(). + getDeviceManagementConfigRepository().getEmailConfigurations(); + emailMessageProperties.setEnrolmentUrl(emailConfig.getlBHostPortPrefix()+ emailConfig.getEnrollmentContextPath()); + + messageHeader = messageHeader.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.FIRST_NAME + "\\}", URLEncoder.encode(emailMessageProperties.getFirstName(), EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml index 0f5861cc1d1..2fdabf455a3 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml @@ -29,6 +29,8 @@ 100 20 1000 + https://localhost:9443 + /mdm/enrollment https://localhost:9443