From 200e7e69c2481e49c8cce829c06087759def0a98 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Wed, 8 Nov 2023 17:05:25 +0530 Subject: [PATCH] Fix to ignore devicetype check for webclip --- .../core/impl/SubscriptionManagerImpl.java | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index fceb70e072..931c45ddcf 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -177,23 +177,26 @@ public class SubscriptionManagerImpl implements SubscriptionManager { try { // Only for iOS devices int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); - if (DeviceTypes.IOS.toString().equalsIgnoreCase(APIUtil.getDeviceTypeData(applicationDTO - .getDeviceTypeId()).getName())) { - // TODO: replace getAssetByAppId with the correct one in DAO - // Check if the app trying to subscribe is a VPP asset. - VppAssetDTO storedAsset = vppApplicationDAO.getAssetByAppId(applicationDTO.getId(), tenantId); - if (storedAsset != null) { // This is a VPP asset - List users = new ArrayList<>(); - List devices = applicationSubscriptionInfo.getDevices();// get - // subscribed device list, so that we can extract the users of those devices. - for (Device device : devices) { - VppUserDTO user = vppApplicationDAO.getUserByDMUsername(device.getEnrolmentInfo() - .getOwner(), PrivilegedCarbonContext.getThreadLocalCarbonContext() - .getTenantId(true)); - users.add(user); + // Ignore checking device type if app is a web clip + if(!applicationDTO.getType().equals("WEB_CLIP")){ + if (DeviceTypes.IOS.toString().equalsIgnoreCase(APIUtil.getDeviceTypeData(applicationDTO + .getDeviceTypeId()).getName())) { + // TODO: replace getAssetByAppId with the correct one in DAO + // Check if the app trying to subscribe is a VPP asset. + VppAssetDTO storedAsset = vppApplicationDAO.getAssetByAppId(applicationDTO.getId(), tenantId); + if (storedAsset != null) { // This is a VPP asset + List users = new ArrayList<>(); + List devices = applicationSubscriptionInfo.getDevices();// get + // subscribed device list, so that we can extract the users of those devices. + for (Device device : devices) { + VppUserDTO user = vppApplicationDAO.getUserByDMUsername(device.getEnrolmentInfo() + .getOwner(), PrivilegedCarbonContext.getThreadLocalCarbonContext() + .getTenantId(true)); + users.add(user); + } + VPPApplicationManager vppManager = APIUtil.getVPPManager(); + vppManager.addAssociation(storedAsset, users); } - VPPApplicationManager vppManager = APIUtil.getVPPManager(); - vppManager.addAssociation(storedAsset, users); } } } catch (BadRequestException e) {