Change config implementation

fixes https://roadmap.entgra.net/issues/9939
scep-fix2
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.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);

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

@ -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 {
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);

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

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

Loading…
Cancel
Save