// If Grant is for ALL and Either INSERT/SELECT already exists..
// need to remove it and GRANT ALL..
if (privilege.getAction().equalsIgnoreCase("*")) {
TSentryPrivilege tNotAll = new TSentryPrivilege(privilege);
tNotAll.setAction(AccessConstants.SELECT);
MSentryPrivilege mSelect = getMSentryPrivilege(
constructPrivilegeName(tNotAll), pm);
tNotAll.setAction(AccessConstants.INSERT);
MSentryPrivilege mInsert = getMSentryPrivilege(
constructPrivilegeName(tNotAll), pm);
if ((mSelect != null) && (mRole.getPrivileges().contains(mSelect))) {
mSelect.removeRole(mRole);
pm.makePersistent(mSelect);
}
if ((mInsert != null) && (mRole.getPrivileges().contains(mInsert))) {
mInsert.removeRole(mRole);
pm.makePersistent(mInsert);
}
} else {
// If Grant is for Either INSERT/SELECT and ALL already exists..
// do nothing..
TSentryPrivilege tAll = new TSentryPrivilege(privilege);
tAll.setAction(AccessConstants.ALL);
MSentryPrivilege mAll = getMSentryPrivilege(
constructPrivilegeName(tAll), pm);
if ((mAll != null) && (mRole.getPrivileges().contains(mAll))) {
return;
}
}
}
MSentryPrivilege mPrivilege = getMSentryPrivilege(
constructPrivilegeName(privilege), pm);
if (mPrivilege == null) {
mPrivilege = convertToMSentryPrivilege(privilege);
}
mPrivilege.appendRole(mRole);
pm.makePersistent(mRole);
pm.makePersistent(mPrivilege);
}
return;
}