From f091d26f9c30bd1517550f335fb9ee3bb4523bb7 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Thu, 27 Jul 2023 16:39:08 +0530 Subject: [PATCH] Fix issues with retrieving visible roles --- .../jaxrs/service/impl/RoleManagementServiceImpl.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 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 6c06dc6720..748bcc485c 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,14 +126,14 @@ public class RoleManagementServiceImpl implements RoleManagementService { List visibleRoles; RoleList visibleRoleList = new RoleList(); try { - String metaValue = "{\"isUserAbleToViewAllRoles\":false}"; + boolean decision = false; if(DeviceMgtAPIUtils.getMetadataManagementService().retrieveMetadata(metaKey) != null){ metadata = DeviceMgtAPIUtils.getMetadataManagementService().retrieveMetadata(metaKey); - metaValue = metadata.getMetaValue(); + String metaValue = metadata.getMetaValue(); + JSONParser parser = new JSONParser(); + JSONObject jsonObject = (JSONObject) parser.parse(metaValue); + decision = (boolean) jsonObject.get(Constants.IS_USER_ABLE_TO_VIEW_ALL_ROLES); } - JSONParser parser = new JSONParser(); - JSONObject jsonObject = (JSONObject) parser.parse(metaValue); - boolean decision = (boolean) jsonObject.get(Constants.IS_USER_ABLE_TO_VIEW_ALL_ROLES); if (decision) { if (userStore == null || "".equals(userStore)){ userStore = PRIMARY_USER_STORE;