diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java index 5f2adfdccfbb..6eea68bd1114 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java @@ -5055,7 +5055,7 @@ public static Set extractVisibleEnvironmentsForUser(List en String[] permittedRoles = environment.getVisibilityRoles(); if (permittedRoles != null && permittedRoles[0].equals("all")) { environmentStringSet.add(environment.toString()); - } else { + } else if (permittedRoles != null) { for (String role : userRoles) { for (String permission : permittedRoles) { if (role.equals(permission)) { @@ -5063,6 +5063,8 @@ public static Set extractVisibleEnvironmentsForUser(List en } } } + } else { + environmentStringSet.add(environment.toString()); } } } @@ -5076,9 +5078,9 @@ public static Map extractVisibleEnvironmentsForUser(String Map environmentsMap = getEnvironments(organization); for (Environment environment : environmentsMap.values()) { String[] permittedRoles = environment.getVisibilityRoles(); - if (permittedRoles[0].equals("all")) { + if (permittedRoles != null && permittedRoles[0].equals("all")) { returnEnvironments.put(environment.getName(), environment); - } else { + } else if (permittedRoles != null) { for (String role : userRoles) { for (String permission : permittedRoles) { if (role.equals(permission)) { @@ -5086,6 +5088,8 @@ public static Map extractVisibleEnvironmentsForUser(String } } } + } else { + returnEnvironments.put(environment.getName(), environment); } } return returnEnvironments;