From 8f6b65946a79dba355b82d43dbc9b72e3932e6f1 Mon Sep 17 00:00:00 2001 From: Ace Date: Thu, 22 Feb 2018 13:05:00 +0530 Subject: [PATCH 1/3] Correcting wrong logic for retrieving apps in appm --- .../osgiconnector/ApplicationOperationsImpl.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java index f35823785..6f88b04cc 100644 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java @@ -256,11 +256,15 @@ public class ApplicationOperationsImpl implements ApplicationOperations { .getDeviceManagementService(applicationOperationDevice.getTenantId()). getDevicesOfUser(applicationOperationDevice.getCurrentUser().getUsername()); } else { - deviceList = MDMServiceAPIUtils - .getDeviceManagementService(applicationOperationDevice.getTenantId()). - getDevicesOfUser(applicationOperationDevice.getCurrentUser().getUsername(), - applicationOperationDevice.getPlatform()); - } + deviceList = MDMServiceAPIUtils + .getDeviceManagementService(applicationOperationDevice.getTenantId()). + getDevicesOfUser(applicationOperationDevice.getCurrentUser().getUsername(), + MDMAppConstants.ANDROID); + deviceList.addAll(MDMServiceAPIUtils + .getDeviceManagementService(applicationOperationDevice.getTenantId()). + getDevicesOfUser(applicationOperationDevice.getCurrentUser().getUsername(), + MDMAppConstants.IOS)); + } devices = new ArrayList<>(deviceList.size()); if(log.isDebugEnabled()){ log.debug("device list got from mdm "+ deviceList.toString()); From ed2781cecd6cb57eb56e9bb34bd2bb23335f3fd3 Mon Sep 17 00:00:00 2001 From: Ace Date: Thu, 22 Feb 2018 15:04:56 +0530 Subject: [PATCH 2/3] Fixing formatting issues and reusing variables --- .../ApplicationOperationsImpl.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java index 6f88b04cc..2b56de5f6 100644 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java @@ -44,6 +44,7 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.appmgt.mobile.utils.User; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.registry.core.session.UserRegistry; @@ -250,22 +251,22 @@ public class ApplicationOperationsImpl implements ApplicationOperations { List devices; List deviceList = null; try { - if (MDMAppConstants.WEBAPP.equals - (applicationOperationDevice.getPlatform())) { - deviceList = MDMServiceAPIUtils - .getDeviceManagementService(applicationOperationDevice.getTenantId()). - getDevicesOfUser(applicationOperationDevice.getCurrentUser().getUsername()); - } else { - deviceList = MDMServiceAPIUtils - .getDeviceManagementService(applicationOperationDevice.getTenantId()). - getDevicesOfUser(applicationOperationDevice.getCurrentUser().getUsername(), - MDMAppConstants.ANDROID); - deviceList.addAll(MDMServiceAPIUtils - .getDeviceManagementService(applicationOperationDevice.getTenantId()). - getDevicesOfUser(applicationOperationDevice.getCurrentUser().getUsername(), - MDMAppConstants.IOS)); + DeviceManagementProviderService deviceManagementService = MDMServiceAPIUtils + .getDeviceManagementService(applicationOperationDevice.getTenantId()); + final String username = applicationOperationDevice.getCurrentUser().getUsername(); + if (MDMAppConstants.WEBAPP.equals + (applicationOperationDevice.getPlatform())) { + deviceList = deviceManagementService. + getDevicesOfUser(username); + } else { + deviceList = deviceManagementService. + getDevicesOfUser(username, + MDMAppConstants.ANDROID); + deviceList.addAll(deviceManagementService. + getDevicesOfUser(username, + MDMAppConstants.IOS)); } - devices = new ArrayList<>(deviceList.size()); + devices = new ArrayList<>(deviceList.size()); if(log.isDebugEnabled()){ log.debug("device list got from mdm "+ deviceList.toString()); } From dec58900266b2cf82b03a3bab59dfd9627dc6bff Mon Sep 17 00:00:00 2001 From: Ace Date: Thu, 22 Feb 2018 15:16:50 +0530 Subject: [PATCH 3/3] Fixing formatting issues --- .../appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java index 2b56de5f6..7e2aeb6cc 100644 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java @@ -261,10 +261,10 @@ public class ApplicationOperationsImpl implements ApplicationOperations { } else { deviceList = deviceManagementService. getDevicesOfUser(username, - MDMAppConstants.ANDROID); + MDMAppConstants.ANDROID); deviceList.addAll(deviceManagementService. getDevicesOfUser(username, - MDMAppConstants.IOS)); + MDMAppConstants.IOS)); } devices = new ArrayList<>(deviceList.size()); if(log.isDebugEnabled()){