From 9db742e95a735329e18127ef5e0646aee4da1897 Mon Sep 17 00:00:00 2001 From: sameera910409 Date: Tue, 18 Jul 2017 00:15:31 +0530 Subject: [PATCH] fixing https://github.com/wso2/product-iots/issues/1136 : DeviceDetailsRetrieverTask attempts to add operations to a device that has been removed --- .../carbon/device/mgt/core/task/impl/DeviceTaskManagerImpl.java | 2 +- .../org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceTaskManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceTaskManagerImpl.java index ebcd3d58866..41d291e74e7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceTaskManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceTaskManagerImpl.java @@ -92,7 +92,7 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager { operations = this.getValidOperationNames(); //list operations for each device type devices = deviceManagementProviderService.getAllDevices(deviceType, false);//list devices for each type if (!devices.isEmpty()) { - if (operations != null) { + if (operations != null && DeviceManagerUtil.getValidDeviceIdentifiers(devices).size() != 0) { for (String str : operations) { CommandOperation operation = new CommandOperation(); operation.setEnabled(true); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java index 339567fc3ce..50582799cee 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java @@ -247,6 +247,7 @@ public final class DeviceManagerUtil { switch (device.getEnrolmentInfo().getStatus()) { case BLOCKED: case REMOVED: + break; case SUSPENDED: break; default: