mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge branch 'master' of https://github.com/wso2/carbon-device-mgt
This commit is contained in:
commit
9b40f73597
@ -766,6 +766,8 @@ public class PolicyDAOImpl implements PolicyDAO {
|
||||
policy.setProfileId(resultSet.getInt("PROFILE_ID"));
|
||||
policy.setCompliance(resultSet.getString("COMPLIANCE"));
|
||||
policy.setDescription(resultSet.getString("DESCRIPTION"));
|
||||
policy.setUpdated(PolicyManagerUtil.convertIntToBoolean(resultSet.getInt("UPDATED")));
|
||||
policy.setActive(PolicyManagerUtil.convertIntToBoolean(resultSet.getInt("ACTIVE")));
|
||||
}
|
||||
return policy;
|
||||
|
||||
@ -800,6 +802,8 @@ public class PolicyDAOImpl implements PolicyDAO {
|
||||
policy.setPriorityId(resultSet.getInt("PRIORITY"));
|
||||
policy.setCompliance(resultSet.getString("COMPLIANCE"));
|
||||
policy.setDescription(resultSet.getString("DESCRIPTION"));
|
||||
policy.setUpdated(PolicyManagerUtil.convertIntToBoolean(resultSet.getInt("UPDATED")));
|
||||
policy.setActive(PolicyManagerUtil.convertIntToBoolean(resultSet.getInt("ACTIVE")));
|
||||
}
|
||||
return policy;
|
||||
} catch (SQLException e) {
|
||||
|
||||
@ -35,6 +35,7 @@ import org.wso2.carbon.policy.mgt.core.config.datasource.DataSourceConfig;
|
||||
import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory;
|
||||
import org.wso2.carbon.policy.mgt.core.task.TaskScheduleService;
|
||||
import org.wso2.carbon.policy.mgt.core.task.TaskScheduleServiceImpl;
|
||||
import org.wso2.carbon.policy.mgt.core.util.PolicyManagerUtil;
|
||||
import org.wso2.carbon.user.core.service.RealmService;
|
||||
|
||||
/**
|
||||
@ -86,11 +87,13 @@ public class PolicyManagementServiceComponent {
|
||||
componentContext.getBundleContext().registerService(
|
||||
PolicyManagerService.class.getName(), new PolicyManagerServiceImpl(), null);
|
||||
|
||||
|
||||
|
||||
PolicyConfiguration policyConfiguration = DeviceConfigurationManager.getInstance().getDeviceManagementConfig().
|
||||
getDeviceManagementConfigRepository().getPolicyConfiguration();
|
||||
if(policyConfiguration.getMonitoringEnable()) {
|
||||
TaskScheduleService taskScheduleService = new TaskScheduleServiceImpl();
|
||||
taskScheduleService.startTask(policyConfiguration.getMonitoringFrequency());
|
||||
taskScheduleService.startTask(PolicyManagerUtil.getMonitoringFequency());
|
||||
}
|
||||
|
||||
} catch (Throwable t) {
|
||||
|
||||
@ -22,7 +22,14 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfigurationManagementService;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
|
||||
import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration;
|
||||
import org.wso2.carbon.device.mgt.core.config.tenant.TenantConfigurationManagementServiceImpl;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.PolicyOperation;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
|
||||
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||
@ -47,6 +54,10 @@ public class PolicyManagerUtil {
|
||||
|
||||
private static final Log log = LogFactory.getLog(PolicyManagerUtil.class);
|
||||
|
||||
public static final String GENERAL_CONFIG_RESOURCE_PATH = "general";
|
||||
public static final String MONITORING_FREQUENCY = "notifierFrequency";
|
||||
|
||||
|
||||
public static Document convertToDocument(File file) throws PolicyManagementException {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setNamespaceAware(true);
|
||||
@ -182,4 +193,35 @@ public class PolicyManagerUtil {
|
||||
}
|
||||
return deviceHashMap;
|
||||
}
|
||||
|
||||
|
||||
public static int getMonitoringFequency() {
|
||||
|
||||
TenantConfigurationManagementService configMgtService = new TenantConfigurationManagementServiceImpl();
|
||||
TenantConfiguration tenantConfiguration = null;
|
||||
int monitoringFrequency = 0;
|
||||
try {
|
||||
tenantConfiguration = configMgtService.getConfiguration(GENERAL_CONFIG_RESOURCE_PATH);
|
||||
List<ConfigurationEntry> configuration = tenantConfiguration.getConfiguration();
|
||||
|
||||
if (configuration != null && !configuration.isEmpty()) {
|
||||
for (ConfigurationEntry cEntry : configuration) {
|
||||
if (cEntry.getName().equalsIgnoreCase(MONITORING_FREQUENCY)) {
|
||||
monitoringFrequency = (int) cEntry.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (ConfigurationManagementException e) {
|
||||
log.error("Error while getting the configurations from registry.", e);
|
||||
}
|
||||
|
||||
if (monitoringFrequency == 0) {
|
||||
PolicyConfiguration policyConfiguration = DeviceConfigurationManager.getInstance().
|
||||
getDeviceManagementConfig().getDeviceManagementConfigRepository().getPolicyConfiguration();
|
||||
monitoringFrequency = policyConfiguration.getMonitoringFrequency();
|
||||
}
|
||||
|
||||
return monitoringFrequency;
|
||||
}
|
||||
}
|
||||
|
||||
12
pom.xml
12
pom.xml
@ -312,6 +312,10 @@
|
||||
<groupId>commons-pool.wso2</groupId>
|
||||
<artifactId>commons-pool</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -386,6 +390,10 @@
|
||||
<groupId>org.wso2.carbon.registry</groupId>
|
||||
<artifactId>org.wso2.carbon.registry.extensions</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- End of Governance dependencies -->
|
||||
@ -808,6 +816,10 @@
|
||||
<groupId>org.wso2.carbon.registry</groupId>
|
||||
<artifactId>org.wso2.carbon.registry.ws.client</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user