if (!isUserAdmin()) {
throw new HiveAccessControlException("Current user : " + currentUserName+ " is not"
+ " allowed to add roles. " + ADMIN_ONLY_MSG);
}
if (RESERVED_ROLE_NAMES.contains(roleName.trim().toUpperCase())) {
throw new HiveAuthzPluginException("Role name cannot be one of the reserved roles: " +
RESERVED_ROLE_NAMES);
}
try {
String grantorName = adminGrantor == null ? null : adminGrantor.getName();
metastoreClientFactory.getHiveMetastoreClient().create_role(
new Role(roleName, 0, grantorName));
} catch (TException e) {
throw new HiveAuthzPluginException("Error create role : " + e.getMessage(), e);
}
}