Change config implementation

fixes https://roadmap.entgra.net/issues/9939
live-chat-feature
osh 2 years ago
parent 7747d7b425
commit 5275bb180e

@ -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.search.SearchContext;
import org.wso2.carbon.device.mgt.common.type.mgt.DeviceStatus; 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.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.dao.TrackerManagementDAOException;
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException; import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException;
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
@ -791,6 +793,12 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Sending enrollment invitation mail to existing user."); 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(); DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService();
try { try {
dms.sendEnrolmentGuide(enrolmentGuide); dms.sendEnrolmentGuide(enrolmentGuide);

@ -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.CertificateCacheConfiguration;
import org.wso2.carbon.device.mgt.core.config.cache.DeviceCacheConfiguration; 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.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.config.operation.timeout.OperationTimeoutConfiguration;
import org.wso2.carbon.device.mgt.core.event.config.EventOperationTaskConfiguration; import org.wso2.carbon.device.mgt.core.event.config.EventOperationTaskConfiguration;
import org.wso2.carbon.device.mgt.core.config.geo.location.GeoLocationConfiguration; import org.wso2.carbon.device.mgt.core.config.geo.location.GeoLocationConfiguration;
@ -70,7 +71,7 @@ public final class DeviceManagementConfig {
private EnrollmentNotificationConfiguration enrollmentNotificationConfiguration; private EnrollmentNotificationConfiguration enrollmentNotificationConfiguration;
private DefaultRoles defaultRoles; private DefaultRoles defaultRoles;
private OperationTimeoutConfiguration operationTimeoutConfiguration; private OperationTimeoutConfiguration operationTimeoutConfiguration;
private String enrollmentGuideMail; private EnrollmentGuideConfiguration enrollmentGuideConfiguration;
@XmlElement(name = "ManagementRepository", required = true) @XmlElement(name = "ManagementRepository", required = true)
public DeviceManagementConfigRepository getDeviceManagementConfigRepository() { public DeviceManagementConfigRepository getDeviceManagementConfigRepository() {
@ -267,13 +268,13 @@ public final class DeviceManagementConfig {
this.operationTimeoutConfiguration = operationTimeoutConfiguration; this.operationTimeoutConfiguration = operationTimeoutConfiguration;
} }
@XmlElement(name = "EnrollmentGuideMail", required = true) @XmlElement(name = "EnrollmentGuideConfiguration", required = true)
public String getEnrollmentGuideMail() { public EnrollmentGuideConfiguration getEnrollmentGuideConfiguration() {
return enrollmentGuideMail; return enrollmentGuideConfiguration;
} }
public void setEnrollmentGuideMail(String enrollmentGuideMail) { public void setEnrollmentGuideConfiguration(EnrollmentGuideConfiguration enrollmentGuideConfiguration) {
this.enrollmentGuideMail = enrollmentGuideMail; this.enrollmentGuideConfiguration = enrollmentGuideConfiguration;
} }
} }

@ -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;
}
}

@ -1560,7 +1560,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
public void sendEnrolmentGuide(String enrolmentGuide) throws DeviceManagementException { public void sendEnrolmentGuide(String enrolmentGuide) throws DeviceManagementException {
DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
String recipientMail = config.getEnrollmentGuideMail(); String recipientMail = config.getEnrollmentGuideConfiguration().getMail();
Properties props = new Properties(); Properties props = new Properties();
props.setProperty("mail-subject", "[Enrollment Guide Triggered] (#" + ++count + ")"); props.setProperty("mail-subject", "[Enrollment Guide Triggered] (#" + ++count + ")");
props.setProperty("enrollment-guide", enrolmentGuide); props.setProperty("enrollment-guide", enrolmentGuide);

@ -187,6 +187,9 @@
<OperationTimeouts> <OperationTimeouts>
</OperationTimeouts> </OperationTimeouts>
</OperationTimeoutConfigurations> </OperationTimeoutConfigurations>
<EnrollmentGuideMail>support-dev-group@entgra.io</EnrollmentGuideMail> <EnrollmentGuideConfiguration>
<Enable>false</Enable>
<Mail>Replace with mail</Mail>
</EnrollmentGuideConfiguration>
</DeviceMgtConfiguration> </DeviceMgtConfiguration>

@ -351,10 +351,14 @@
{% endif%} {% endif%}
</OperationTimeouts> </OperationTimeouts>
</OperationTimeoutConfigurations> </OperationTimeoutConfigurations>
{% if device_mgt_conf.enrollment_guide_mail is defined %} <EnrollmentGuideConfiguration>
<EnrollmentGuideMail>{{device_mgt_conf.enrollment_guide_mail}}</EnrollmentGuideMail> {% if device_mgt_conf.enrollment_guide_conf is defined %}
{% else %} <Enable>{{device_mgt_conf.enrollment_guide_conf.enable}}</Enable>
<EnrollmentGuideMail>support-dev-group@entgra.io</EnrollmentGuideMail> <Mail>{{device_mgt_conf.enrollment_guide_conf.mail}}</Mail>
{% endif %} {% else %}
<Enable>false</Enable>
<Mail>Replace with mail</Mail>
{% endif %}
</EnrollmentGuideConfiguration>
</DeviceMgtConfiguration> </DeviceMgtConfiguration>

Loading…
Cancel
Save