diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java index a938a718600..206ed55be9c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -80,6 +80,8 @@ import org.wso2.carbon.device.mgt.common.search.PropertyMap; import org.wso2.carbon.device.mgt.common.search.SearchContext; import org.wso2.carbon.device.mgt.common.type.mgt.DeviceStatus; import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService; +import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; +import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig; import org.wso2.carbon.device.mgt.core.dao.TrackerManagementDAOException; import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException; import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; @@ -791,6 +793,12 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { if (log.isDebugEnabled()) { log.debug("Sending enrollment invitation mail to existing user."); } + DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); + if (!config.getEnrollmentGuideConfiguration().isEnabled()) { + String msg = "Sending enrollment guide config is not enabled."; + log.error(msg); + return Response.status(Response.Status.FORBIDDEN).entity(msg).build(); + } DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService(); try { dms.sendEnrolmentGuide(enrolmentGuide); 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 052bb878864..cc3a3dc5b4f 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 @@ -25,6 +25,7 @@ import org.wso2.carbon.device.mgt.core.config.cache.BillingCacheConfiguration; import org.wso2.carbon.device.mgt.core.config.cache.CertificateCacheConfiguration; import org.wso2.carbon.device.mgt.core.config.cache.DeviceCacheConfiguration; import org.wso2.carbon.device.mgt.core.config.cache.GeoFenceCacheConfiguration; +import org.wso2.carbon.device.mgt.core.config.enrollment.guide.EnrollmentGuideConfiguration; import org.wso2.carbon.device.mgt.core.config.operation.timeout.OperationTimeoutConfiguration; import org.wso2.carbon.device.mgt.core.event.config.EventOperationTaskConfiguration; import org.wso2.carbon.device.mgt.core.config.geo.location.GeoLocationConfiguration; @@ -70,7 +71,7 @@ public final class DeviceManagementConfig { private EnrollmentNotificationConfiguration enrollmentNotificationConfiguration; private DefaultRoles defaultRoles; private OperationTimeoutConfiguration operationTimeoutConfiguration; - private String enrollmentGuideMail; + private EnrollmentGuideConfiguration enrollmentGuideConfiguration; @XmlElement(name = "ManagementRepository", required = true) public DeviceManagementConfigRepository getDeviceManagementConfigRepository() { @@ -267,13 +268,13 @@ public final class DeviceManagementConfig { this.operationTimeoutConfiguration = operationTimeoutConfiguration; } - @XmlElement(name = "EnrollmentGuideMail", required = true) - public String getEnrollmentGuideMail() { - return enrollmentGuideMail; + @XmlElement(name = "EnrollmentGuideConfiguration", required = true) + public EnrollmentGuideConfiguration getEnrollmentGuideConfiguration() { + return enrollmentGuideConfiguration; } - public void setEnrollmentGuideMail(String enrollmentGuideMail) { - this.enrollmentGuideMail = enrollmentGuideMail; + public void setEnrollmentGuideConfiguration(EnrollmentGuideConfiguration enrollmentGuideConfiguration) { + this.enrollmentGuideConfiguration = enrollmentGuideConfiguration; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/enrollment/guide/EnrollmentGuideConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/enrollment/guide/EnrollmentGuideConfiguration.java new file mode 100644 index 00000000000..5f54cf79d41 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/enrollment/guide/EnrollmentGuideConfiguration.java @@ -0,0 +1,30 @@ +package org.wso2.carbon.device.mgt.core.config.enrollment.guide; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "EnrollmentGuideConfiguration") +public class EnrollmentGuideConfiguration { + + private boolean isEnabled; + private String mail; + + @XmlElement(name = "Enable", required = true) + public boolean isEnabled() { + return isEnabled; + } + + public void setEnabled(boolean enabled) { + isEnabled = enabled; + } + + @XmlElement(name = "Mail", required = true) + public String getMail() { + return mail; + } + + public void setMail(String mail) { + this.mail = mail; + } + +} 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 2ae6e1f7c55..6257e0b34d2 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 @@ -1560,7 +1560,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv public void sendEnrolmentGuide(String enrolmentGuide) throws DeviceManagementException { DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); - String recipientMail = config.getEnrollmentGuideMail(); + String recipientMail = config.getEnrollmentGuideConfiguration().getMail(); Properties props = new Properties(); props.setProperty("mail-subject", "[Enrollment Guide Triggered] (#" + ++count + ")"); props.setProperty("enrollment-guide", enrolmentGuide); 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 9598f16000c..f0ebf0de840 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,6 +187,9 @@ - support-dev-group@entgra.io + + false + Replace with mail + 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 42077b0afd0..09e3fad19be 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 @@ -351,10 +351,14 @@ {% endif%} - {% if device_mgt_conf.enrollment_guide_mail is defined %} - {{device_mgt_conf.enrollment_guide_mail}} - {% else %} - support-dev-group@entgra.io - {% endif %} + + {% if device_mgt_conf.enrollment_guide_conf is defined %} + {{device_mgt_conf.enrollment_guide_conf.enable}} + {{device_mgt_conf.enrollment_guide_conf.mail}} + {% else %} + false + Replace with mail + {% endif %} +