From d315e739e46aade0eb6542f7e0bcd2aa2f3a20a1 Mon Sep 17 00:00:00 2001 From: madhawap Date: Tue, 2 Aug 2016 19:04:28 +0530 Subject: [PATCH 1/2] fix for the iOS device operations blocker --- .../device/mgt/common/DeviceTypeIdentifier.java | 4 ++-- .../mgt/core/DeviceManagementPluginRepository.java | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceTypeIdentifier.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceTypeIdentifier.java index 1eb5e28e46..1849a97c0d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceTypeIdentifier.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceTypeIdentifier.java @@ -29,12 +29,12 @@ public class DeviceTypeIdentifier implements Serializable { private static final int DEFAULT_SHARE_WITH_ALL_TENANTS_ID = -1; public DeviceTypeIdentifier(String deviceType, int tenantId) { - this.deviceType = deviceType; + this.deviceType = deviceType.toLowerCase(); this.tenantId = tenantId; } public DeviceTypeIdentifier(String deviceType) { - this.deviceType = deviceType; + this.deviceType = deviceType.toLowerCase(); this.tenantId = DEFAULT_SHARE_WITH_ALL_TENANTS_ID; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java index d55f553920..e117242a92 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java @@ -52,7 +52,7 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis } public void addDeviceManagementProvider(DeviceManagementService provider) throws DeviceManagementException { - String deviceType = provider.getType(); + String deviceType = provider.getType().toLowerCase(); ProvisioningConfig provisioningConfig = provider.getProvisioningConfig(); String tenantDomain = provisioningConfig.getProviderTenantDomain(); @@ -87,7 +87,7 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis } public void removeDeviceManagementProvider(DeviceManagementService provider) throws DeviceManagementException { - String deviceTypeName = provider.getType(); + String deviceTypeName = provider.getType().toLowerCase(); DeviceTypeIdentifier deviceTypeIdentifier; ProvisioningConfig provisioningConfig = provider.getProvisioningConfig(); if (provisioningConfig.isSharedWithAllTenants()) { @@ -103,10 +103,10 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis public DeviceManagementService getDeviceManagementService(String type, int tenantId) { //Priority need to be given to the tenant before public. - DeviceTypeIdentifier deviceTypeIdentifier = new DeviceTypeIdentifier(type, tenantId); + DeviceTypeIdentifier deviceTypeIdentifier = new DeviceTypeIdentifier(type.toLowerCase(), tenantId); DeviceManagementService provider = providers.get(deviceTypeIdentifier); if (provider == null) { - deviceTypeIdentifier = new DeviceTypeIdentifier(type); + deviceTypeIdentifier = new DeviceTypeIdentifier(type.toLowerCase()); provider = providers.get(deviceTypeIdentifier); } return provider; @@ -153,10 +153,10 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis public OperationManager getOperationManager(String deviceType, int tenantId) { //Priority need to be given to the tenant before public. - DeviceTypeIdentifier deviceTypeIdentifier = new DeviceTypeIdentifier(deviceType, tenantId); + DeviceTypeIdentifier deviceTypeIdentifier = new DeviceTypeIdentifier(deviceType.toLowerCase(), tenantId); OperationManager operationManager = operationManagerRepository.getOperationManager(deviceTypeIdentifier); if (operationManager == null) { - deviceTypeIdentifier = new DeviceTypeIdentifier(deviceType); + deviceTypeIdentifier = new DeviceTypeIdentifier(deviceType.toLowerCase()); operationManager = operationManagerRepository.getOperationManager(deviceTypeIdentifier); } return operationManager; From 5bd879545baa5d01524260742a9cc96265160a8c Mon Sep 17 00:00:00 2001 From: madhawap Date: Tue, 2 Aug 2016 19:45:39 +0530 Subject: [PATCH 2/2] fix for the iOS device operations blocker --- .../device/mgt/core/DeviceManagementPluginRepository.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java index e117242a92..504d29d5f1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java @@ -164,14 +164,15 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis @Override public void notifyObserver() { + String deviceTypeName; synchronized (providers) { for (DeviceManagementService provider : providers.values()) { try { provider.init(); - + deviceTypeName = provider.getType().toLowerCase(); ProvisioningConfig provisioningConfig = provider.getProvisioningConfig(); int tenantId = DeviceManagerUtil.getTenantId(provisioningConfig.getProviderTenantDomain()); - DeviceManagerUtil.registerDeviceType(provider.getType(), tenantId, provisioningConfig.isSharedWithAllTenants()); + DeviceManagerUtil.registerDeviceType(deviceTypeName, tenantId, provisioningConfig.isSharedWithAllTenants()); registerPushNotificationStrategy(provider); //TODO: //This is a temporory fix.