|
|
@ -22,7 +22,14 @@ import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.w3c.dom.Document;
|
|
|
|
import org.w3c.dom.Document;
|
|
|
|
import org.wso2.carbon.device.mgt.common.Device;
|
|
|
|
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.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.PolicyOperation;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
|
|
|
|
import org.wso2.carbon.policy.mgt.common.Policy;
|
|
|
|
import org.wso2.carbon.policy.mgt.common.Policy;
|
|
|
@ -47,6 +54,10 @@ public class PolicyManagerUtil {
|
|
|
|
|
|
|
|
|
|
|
|
private static final Log log = LogFactory.getLog(PolicyManagerUtil.class);
|
|
|
|
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 {
|
|
|
|
public static Document convertToDocument(File file) throws PolicyManagementException {
|
|
|
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
|
|
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
|
|
|
factory.setNamespaceAware(true);
|
|
|
|
factory.setNamespaceAware(true);
|
|
|
@ -182,4 +193,35 @@ public class PolicyManagerUtil {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return deviceHashMap;
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|