From d2bc4632842871a58eaf5f689b4018fd24614e97 Mon Sep 17 00:00:00 2001 From: osh Date: Tue, 28 Mar 2023 12:34:11 +0530 Subject: [PATCH] Resolve comments fixes http://roadmap.entgra.net/issues/9939 --- .../device/mgt/core/config/DeviceManagementConfig.java | 10 ++++++++++ .../service/DeviceManagementProviderServiceImpl.java | 7 ++++--- .../src/main/resources/conf/cdm-config.xml | 1 + .../templates/repository/conf/cdm-config.xml.j2 | 9 +++++++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java index f2ad40abb7..052bb87886 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java @@ -70,6 +70,7 @@ public final class DeviceManagementConfig { private EnrollmentNotificationConfiguration enrollmentNotificationConfiguration; private DefaultRoles defaultRoles; private OperationTimeoutConfiguration operationTimeoutConfiguration; + private String enrollmentGuideMail; @XmlElement(name = "ManagementRepository", required = true) public DeviceManagementConfigRepository getDeviceManagementConfigRepository() { @@ -265,5 +266,14 @@ public final class DeviceManagementConfig { public void setOperationTimeoutConfiguration(OperationTimeoutConfiguration operationTimeoutConfiguration) { this.operationTimeoutConfiguration = operationTimeoutConfiguration; } + + @XmlElement(name = "EnrollmentGuideMail", required = true) + public String getEnrollmentGuideMail() { + return enrollmentGuideMail; + } + + public void setEnrollmentGuideMail(String enrollmentGuideMail) { + this.enrollmentGuideMail = enrollmentGuideMail; + } } 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 f6b9274ac7..2ae6e1f7c5 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 @@ -1559,17 +1559,18 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public void sendEnrolmentGuide(String enrolmentGuide) throws DeviceManagementException { + DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); + String recipientMail = config.getEnrollmentGuideMail(); Properties props = new Properties(); props.setProperty("mail-subject", "[Enrollment Guide Triggered] (#" + ++count + ")"); props.setProperty("enrollment-guide", enrolmentGuide); try { - EmailMetaInfo metaInfo = new EmailMetaInfo("support-dev-group@entgra.io", props); + EmailMetaInfo metaInfo = new EmailMetaInfo(recipientMail, props); sendEnrolmentInvitation(DeviceManagementConstants.EmailAttributes.ENROLLMENT_GUIDE_TEMPLATE, metaInfo); - } catch (ConfigurationManagementException e) { String msg = "Error occurred while sending the mail."; - log.error(msg); + log.error(msg, e); throw new DeviceManagementException(msg, e); } } diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml index 340b22802b..9598f16000 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml @@ -187,5 +187,6 @@ + support-dev-group@entgra.io diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 index f567bb9dd2..42077b0afd 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 @@ -322,7 +322,7 @@ - + @@ -350,6 +350,11 @@ {% endfor %} {% endif%} - + + {% if device_mgt_conf.enrollment_guide_mail is defined %} + {{device_mgt_conf.enrollment_guide_mail}} + {% else %} + support-dev-group@entgra.io + {% endif %}