From 20906122dbbfe4be3deb1cde56029aba5e0a1ecb Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Thu, 27 Jul 2023 15:39:52 +0530 Subject: [PATCH] Fix for visible role issue --- .../api/jaxrs/service/impl/RoleManagementServiceImpl.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java index 077e814fe71..6c06dc6720a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -126,8 +126,11 @@ public class RoleManagementServiceImpl implements RoleManagementService { List visibleRoles; RoleList visibleRoleList = new RoleList(); try { - metadata = DeviceMgtAPIUtils.getMetadataManagementService().retrieveMetadata(metaKey); - String metaValue = metadata.getMetaValue(); + String metaValue = "{\"isUserAbleToViewAllRoles\":false}"; + if(DeviceMgtAPIUtils.getMetadataManagementService().retrieveMetadata(metaKey) != null){ + metadata = DeviceMgtAPIUtils.getMetadataManagementService().retrieveMetadata(metaKey); + metaValue = metadata.getMetaValue(); + } JSONParser parser = new JSONParser(); JSONObject jsonObject = (JSONObject) parser.parse(metaValue); boolean decision = (boolean) jsonObject.get(Constants.IS_USER_ABLE_TO_VIEW_ALL_ROLES);