if (!isUserAdmin()) {
throw new HiveAccessControlException("Current user : " + currentUserName+ " is not"
+ " allowed get principals in a role. " + ADMIN_ONLY_MSG);
}
try {
GetPrincipalsInRoleResponse princGrantInfo =
metastoreClientFactory.getHiveMetastoreClient().get_principals_in_role(new GetPrincipalsInRoleRequest(roleName));
List<HiveRoleGrant> hiveRoleGrants = new ArrayList<HiveRoleGrant>();
for(RolePrincipalGrant thriftRoleGrant : princGrantInfo.getPrincipalGrants()){
hiveRoleGrants.add(new HiveRoleGrant(thriftRoleGrant));
}
return hiveRoleGrants;
} catch (Exception e) {
throw new HiveAuthzPluginException("Error getting principals for all roles", e);