From b9c04a91e3a3897882bb3a112155f15a765360ec Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Fri, 6 Dec 2019 21:08:08 +0530 Subject: [PATCH] Fix policy loading issue when enrolling Android --- .../api/impl/DeviceManagementAPIImpl.java | 3 +-- .../pom.xml | 4 ++++ .../pom.xml | 17 +++++------------ .../android/core/impl/AndroidServiceImpl.java | 4 +--- .../internal/AndroidPluginServiceComponent.java | 2 +- .../android/core/util/AndroidAPIUtils.java | 4 +--- 6 files changed, 13 insertions(+), 21 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/DeviceManagementAPIImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/DeviceManagementAPIImpl.java index 445593c97..a6a8e0046 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/DeviceManagementAPIImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/DeviceManagementAPIImpl.java @@ -146,8 +146,7 @@ public class DeviceManagementAPIImpl implements DeviceManagementAPI { } try { AndroidService androidService = AndroidAPIUtils.getAndroidService(); - Response response = androidService.enrollDevice(androidDevice); - return response; + return androidService.enrollDevice(androidDevice); } catch (DeviceManagementException e) { String msg = "Error occurred while enrolling the android, which carries the id '" + androidDevice.getDeviceIdentifier() + "'"; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/pom.xml index b04328c70..2f9db1994 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/pom.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/pom.xml @@ -79,6 +79,10 @@ + + org.eclipse.osgi + org.eclipse.osgi + org.wso2.carbon org.wso2.carbon.logging diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/pom.xml index 9ba42d84a..342234c45 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/pom.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/pom.xml @@ -67,14 +67,19 @@ javax.naming, org.wso2.carbon.context, org.wso2.carbon.utils.*, + org.wso2.carbon.device.mgt.mobile.android.common.*, org.wso2.carbon.device.mgt.common.*, + org.wso2.carbon.device.mgt.core.*, org.wso2.carbon.ndatasource.core, org.wso2.carbon.policy.mgt.common.*, + org.wso2.carbon.policy.mgt.core.*, org.wso2.carbon.registry.core, org.wso2.carbon.registry.core.session, org.wso2.carbon.registry.core.service, org.wso2.carbon.registry.api, org.wso2.carbon.device.mgt.extensions.license.mgt.registry, + org.wso2.carbon.analytics.datasource.commons.*, + org.wso2.carbon.base, com.google.gson.* @@ -161,17 +166,14 @@ org.wso2.carbon.devicemgt-plugins org.wso2.carbon.device.mgt.mobile.android.common - provided org.wso2.carbon.devicemgt org.wso2.carbon.device.application.mgt.common - provided org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.core - provided org.slf4j @@ -182,27 +184,22 @@ org.wso2.carbon.devicemgt org.wso2.carbon.policy.mgt.common - provided org.wso2.carbon.devicemgt org.wso2.carbon.policy.mgt.core - provided org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.application.extension - provided org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.common - provided org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.annotations - provided org.testng @@ -229,10 +226,6 @@ org.wso2.carbon.queuing test - - org.wso2.carbon - org.wso2.carbon.ndatasource.core - commons-dbcp.wso2 commons-dbcp diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/impl/AndroidServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/impl/AndroidServiceImpl.java index e8279628a..cbd7e6b26 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/impl/AndroidServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/impl/AndroidServiceImpl.java @@ -17,7 +17,6 @@ package org.wso2.carbon.device.mgt.mobile.android.core.impl; -import com.google.api.client.http.HttpStatusCodes; import com.google.api.services.androidenterprise.model.ProductsListResponse; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; @@ -838,9 +837,8 @@ public class AndroidServiceImpl implements AndroidService { operation.setCode(AndroidConstants.OperationCodes.REMOTE_APP_CONFIG); operation.setType(Operation.Type.PROFILE); operation.setPayLoad(applicationRestriction.toJSON()); - Response response = AndroidAPIUtils.getOperationResponse(applicationRestrictionBeanWrapper.getDeviceIDs(), + return AndroidAPIUtils.getOperationResponse(applicationRestrictionBeanWrapper.getDeviceIDs(), operation); - return response; } catch (InvalidDeviceException e) { String errorMessage = "Invalid Device Identifiers found."; log.error(errorMessage, e); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/internal/AndroidPluginServiceComponent.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/internal/AndroidPluginServiceComponent.java index 2ee731c65..0465449d2 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/internal/AndroidPluginServiceComponent.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/internal/AndroidPluginServiceComponent.java @@ -32,7 +32,7 @@ import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.registry.core.service.RegistryService; /** - * @scr.component name="org.wso2.carbon.device.mgt.mobile.android.core.impl.internal.AndroidPluginServiceComponent" + * @scr.component name="org.wso2.carbon.device.mgt.mobile.android.impl.internal.AndroidPluginServiceComponent" * immediate="true" * @scr.reference name="org.wso2.carbon.ndatasource" * interface="org.wso2.carbon.ndatasource.core.DataSourceService" diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/AndroidAPIUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/AndroidAPIUtils.java index 9eeced144..8318a36bb 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/AndroidAPIUtils.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/AndroidAPIUtils.java @@ -25,7 +25,6 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; @@ -35,7 +34,6 @@ import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderServ import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.mobile.android.common.AndroidConstants; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.ErrorResponse; import org.wso2.carbon.device.mgt.mobile.android.common.exception.AndroidDeviceMgtPluginException; import org.wso2.carbon.device.mgt.mobile.android.common.exception.BadRequestExceptionDup; import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidGoogleEnterpriseService; @@ -178,7 +176,7 @@ public class AndroidAPIUtils { public static Response getOperationResponse(List deviceIDs, Operation operation) throws AndroidDeviceMgtPluginException, OperationManagementException, InvalidDeviceException { - if (deviceIDs == null || deviceIDs.size() == 0) { + if (deviceIDs == null || deviceIDs.isEmpty()) { String errorMessage = "Device identifier list is empty"; log.error(errorMessage); throw new BadRequestExceptionDup(errorMessage);