From 1413ff52685da0c50e2efa8cd30370a83e2c4257 Mon Sep 17 00:00:00 2001 From: kamidu Date: Thu, 14 Dec 2017 14:43:28 +0530 Subject: [PATCH] Fixing https://github.com/wso2/product-iots/issues/1526 --- .../impl/RoleManagementServiceImpl.java | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java index 978b449885..896c6d7d26 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -604,28 +604,20 @@ public class RoleManagementServiceImpl implements RoleManagementService { private List getRolesFromUserStore(String filter, String userStore) throws UserStoreException { AbstractUserStoreManager userStoreManager = (AbstractUserStoreManager) DeviceMgtAPIUtils.getUserStoreManager(); String[] roles; - boolean filterRolesByName = (!((filter == null) || filter.isEmpty())); + if ((filter == null) || filter.isEmpty()) { + filter = "*"; + } if (log.isDebugEnabled()) { log.debug("Getting the list of user roles"); } if (userStore.equals("all")) { - roles = userStoreManager.getRoleNames("*", -1, false, true, true); + roles = userStoreManager.getRoleNames(filter, -1, true, true, true); } else { - roles = userStoreManager.getRoleNames(userStore + "/*", -1, false, true, true); + roles = userStoreManager.getRoleNames(userStore + "/" + filter, -1, true, true, true); } - // removing all internal roles, roles created for Service-providers and application related roles. List filteredRoles = new ArrayList<>(); for (String role : roles) { - if (!(role.startsWith("Internal/") || role.startsWith("Authentication/") || role.startsWith( - "Application/"))) { - if (!filterRolesByName) { - filteredRoles.add(role); - } else { - if (role.contains(filter)) { - filteredRoles.add(role); - } - } - } + filteredRoles.add(role); } return filteredRoles; }