mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Fixing the monitoring task for not to notify the blocked and inactive devices
This commit is contained in:
parent
bd75f70a24
commit
2769392bc0
@ -22,6 +22,7 @@ package org.wso2.carbon.policy.mgt.core.task;
|
|||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
|
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
||||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||||
@ -32,6 +33,7 @@ import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder;
|
|||||||
import org.wso2.carbon.policy.mgt.core.mgt.MonitoringManager;
|
import org.wso2.carbon.policy.mgt.core.mgt.MonitoringManager;
|
||||||
import org.wso2.carbon.policy.mgt.core.mgt.impl.MonitoringManagerImpl;
|
import org.wso2.carbon.policy.mgt.core.mgt.impl.MonitoringManagerImpl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -56,7 +58,7 @@ public class MonitoringTask implements Task {
|
|||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
|
|
||||||
if(log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Monitoring task started to run.");
|
log.debug("Monitoring task started to run.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,14 +74,33 @@ public class MonitoringTask implements Task {
|
|||||||
List<Device> devices = deviceManagementProviderService.getAllDevices(deviceType.getName());
|
List<Device> devices = deviceManagementProviderService.getAllDevices(deviceType.getName());
|
||||||
if (monitoringService != null && !devices.isEmpty()) {
|
if (monitoringService != null && !devices.isEmpty()) {
|
||||||
monitoringManager.addMonitoringOperation(devices);
|
monitoringManager.addMonitoringOperation(devices);
|
||||||
monitoringService.notifyDevices(devices);
|
|
||||||
|
List<Device> notifiableDevices = new ArrayList<>();
|
||||||
|
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Removing inactive and blocked devices from the list for the device type : " +
|
||||||
|
deviceType);
|
||||||
|
}
|
||||||
|
for (Device device : devices) {
|
||||||
|
if (device.getEnrolmentInfo().getStatus().equals(EnrolmentInfo.Status.INACTIVE) ||
|
||||||
|
device.getEnrolmentInfo().getStatus().equals(EnrolmentInfo.Status.BLOCKED)) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
notifiableDevices.add(device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Following devices selected to send the notification for " + deviceType);
|
||||||
|
for (Device device : notifiableDevices) {
|
||||||
|
log.debug(device.getDeviceIdentifier());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
monitoringService.notifyDevices(notifiableDevices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
if(log.isDebugEnabled()) {
|
|
||||||
log.debug("Monitoring task running completed.");
|
log.debug("Monitoring task running completed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String msg = "Error occurred while trying to run a task.";
|
String msg = "Error occurred while trying to run a task.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user