Code refactoring of device-status-task which Resolves harshanl/product-iots#518

4.x.x
Harshan Liyanage 8 years ago
parent 52bbdfcd78
commit 9871122c0a

@ -43,7 +43,7 @@ import java.util.Map;
*/
public class DeviceStatusMonitoringTask implements Task {
private static Log log = LogFactory.getLog(DeviceStatusMonitoringTask.class);
private static final Log log = LogFactory.getLog(DeviceStatusMonitoringTask.class);
private String deviceType;
private DeviceStatusTaskPluginConfig deviceStatusTaskPluginConfig;
private int deviceTypeId = -1;
@ -70,7 +70,7 @@ public class DeviceStatusMonitoringTask implements Task {
EnrolmentInfo enrolmentInfo;
try {
operationEnrolmentMappings = this.getOperationEnrolmentMappings();
if (operationEnrolmentMappings.size() > 0) {
if (operationEnrolmentMappings != null && operationEnrolmentMappings.size() > 0) {
lastActivities = this.getLastDeviceActivities();
}
} catch (DeviceStatusTaskException e) {
@ -78,7 +78,7 @@ public class DeviceStatusMonitoringTask implements Task {
}
for (OperationEnrolmentMapping mapping:operationEnrolmentMappings) {
long lastActivity = -1;
if (lastActivities.containsKey(mapping.getEnrolmentId())) {
if (lastActivities != null && lastActivities.containsKey(mapping.getEnrolmentId())) {
lastActivity = lastActivities.get(mapping.getEnrolmentId());
}
EnrolmentInfo.Status newStatus = this.determineDeviceStatus(mapping, lastActivity);

@ -39,13 +39,13 @@ import java.util.Map;
*/
public class DeviceStatusTaskManagerServiceImpl implements DeviceStatusTaskManagerService {
private static Log log = LogFactory.getLog(DeviceStatusTaskManagerServiceImpl.class);
private static final Log log = LogFactory.getLog(DeviceStatusTaskManagerServiceImpl.class);
public static final String DEVICE_STATUS_MONITORING_TASK_TYPE = "DEVICE_STATUS_MONITORING";
static final String DEVICE_TYPE = "DEVICE_TYPE";
static final String DEVICE_TYPE_ID = "DEVICE_TYPE_ID";
static final String DEVICE_STATUS_TASK_CONFIG = "DEVICE_STATUS_TASK_CONFIG";
private static String TASK_CLASS = DeviceStatusMonitoringTask.class.getName();
private static final String TASK_CLASS = DeviceStatusMonitoringTask.class.getName();
@Override
public void startTask(DeviceType deviceType, DeviceStatusTaskPluginConfig deviceStatusTaskConfig)

Loading…
Cancel
Save