From ed28a724837e128aabbc0ccf6314f8f02404457b Mon Sep 17 00:00:00 2001 From: Harshan Liyanage Date: Tue, 13 Jun 2017 17:12:40 +0530 Subject: [PATCH] Prevented getDevice calls from loading uncessary device-info. --- .../impl/DeviceManagementServiceImpl.java | 4 ++-- .../android/util/AndroidDeviceUtils.java | 2 +- .../impl/DeviceManagementServiceImpl.java | 19 +++++++++++-------- .../syncml/impl/SyncmlServiceImpl.java | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java index 6ef393cf3..dfe2d1cee 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java @@ -189,7 +189,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { DeviceIdentifier id = new DeviceIdentifier(); id.setId(deviceId); id.setType(AndroidConstants.DEVICE_TYPE_ANDROID); - String deviceName = AndroidAPIUtils.getDeviceManagementService().getDevice(id).getName(); + String deviceName = AndroidAPIUtils.getDeviceManagementService().getDevice(id, false).getName(); notification.setOperationId(operation.getId()); notification.setStatus(org.wso2.carbon.device.mgt.common.notification.mgt.Notification. Status.NEW.toString()); @@ -477,7 +477,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { location.setLatitude(Double.valueOf(latitude)); location.setLongitude(Double.valueOf(longitude)); location.setDeviceIdentifier(deviceIdentifier); - Device savedDevice = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); + Device savedDevice = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier, false); location.setDeviceId(savedDevice.getId()); } return location; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java index 58d8d4895..61a4c5183 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java @@ -83,7 +83,7 @@ public class AndroidDeviceUtils { public static boolean isValidDeviceIdentifier(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { Device device = AndroidAPIUtils.getDeviceManagementService(). - getDevice(deviceIdentifier); + getDevice(deviceIdentifier, false); if (device == null || device.getDeviceIdentifier() == null || device.getDeviceIdentifier().isEmpty() || device.getEnrolmentInfo() == null) { return false; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/impl/DeviceManagementServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/impl/DeviceManagementServiceImpl.java index ae0e59a9c..8dd5f93cb 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/impl/DeviceManagementServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/impl/DeviceManagementServiceImpl.java @@ -26,12 +26,10 @@ import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.device.details.*; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants; -import org.wso2.carbon.device.mgt.mobile.windows.api.common.beans.CacheEntry; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.SyncmlMessageFormatException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.SyncmlOperationException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsConfigurationException; @@ -39,13 +37,18 @@ import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDe import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.AuthenticationInfo; import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.DeviceUtil; import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.WindowsAPIUtils; -import org.wso2.carbon.device.mgt.mobile.windows.api.operations.*; -import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.*; -import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.DeviceInfo; +import org.wso2.carbon.device.mgt.mobile.windows.api.operations.ItemTag; +import org.wso2.carbon.device.mgt.mobile.windows.api.operations.ReplaceTag; +import org.wso2.carbon.device.mgt.mobile.windows.api.operations.SyncmlDocument; +import org.wso2.carbon.device.mgt.mobile.windows.api.operations.SyncmlHeader; +import org.wso2.carbon.device.mgt.mobile.windows.api.operations.WindowsOperationException; +import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.Constants; +import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.OperationCode; +import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.OperationHandler; +import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.OperationReply; +import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.SyncmlParser; import org.wso2.carbon.device.mgt.mobile.windows.api.services.DeviceManagementService; import org.wso2.carbon.device.mgt.mobile.windows.impl.dto.MobileCacheEntry; -import org.wso2.carbon.policy.mgt.common.PolicyManagementException; -import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import javax.ws.rs.core.Response; import java.util.ArrayList; @@ -116,7 +119,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { return Response.ok().entity(operationReply.generateReply( syncmlDocument, pendingOperations)).build(); } else { - if (WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier) != null) { + if (WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier, false) != null) { WindowsAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier); return Response.ok().entity(operationReply.generateReply(syncmlDocument, null)).build(); } else { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/impl/SyncmlServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/impl/SyncmlServiceImpl.java index 356035f04..9add9bf17 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/impl/SyncmlServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/impl/SyncmlServiceImpl.java @@ -190,7 +190,7 @@ public class SyncmlServiceImpl implements SyncmlService { pendingOperations = operationHandler.getPendingOperations(syncmlDocument); return Response.ok().entity(generateReply(syncmlDocument, pendingOperations)).build(); } else { - if (WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier) != null) { + if (WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier, false) != null) { WindowsAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier); return Response.ok().entity(generateReply(syncmlDocument, null)).build(); } else {