Grantee granteeObject;
String privilege;
// intermediate holders
Iterator routines;
RoutineSchema routine;
Object[] row;
OrderedHashSet grantees =
session.getGrantee().getGranteeAndAllRolesWithPublic();
routines = database.schemaManager.databaseObjectIterator(
SchemaObject.ROUTINE);
while (routines.hasNext()) {
routine = (RoutineSchema) routines.next();
for (int i = 0; i < grantees.size(); i++) {
granteeObject = (Grantee) grantees.get(i);
OrderedHashSet rights =
granteeObject.getAllDirectPrivileges(routine);
OrderedHashSet grants =
granteeObject.getAllGrantedPrivileges(routine);
if (!grants.isEmpty()) {
grants.addAll(rights);
rights = grants;
}
for (int j = 0; j < rights.size(); j++) {
Right right = (Right) rights.get(j);
Right grantableRight = right.getGrantableRights();
for (int k = 0; k < Right.privilegeTypes.length; k++) {
if (!right.canAccessFully(Right.privilegeTypes[k])) {
continue;
}
Routine[] specifics = routine.getSpecificRoutines();
for (int m = 0; m < specifics.length; m++) {
privilege = Right.privilegeNames[k];
row = t.getEmptyRowData();
//
row[grantor] = right.getGrantor().getName().name;
row[grantee] = right.getGrantee().getName().name;
row[specific_catalog] =
database.getCatalogName().name;
row[specific_schema] =
specifics[m].getSchemaName().name;
row[specific_name] =
specifics[m].getSpecificName().name;
row[routine_catalog] =
database.getCatalogName().name;
row[routine_schema] = routine.getSchemaName().name;
row[routine_name] = routine.getName().name;
row[privilege_type] = privilege;
row[is_grantable] =
right.getGrantee() == routine.getOwner()
|| grantableRight.canAccessFully(
Right.privilegeTypes[k]) ? "YES"
: "NO";
try {