if (groupName == null) {
Query query = pm.newQuery(MSentryRole.class);
roles = new HashSet<MSentryRole>((List<MSentryRole>)query.execute());
} else {
Query query = pm.newQuery(MSentryGroup.class);
MSentryGroup sentryGroup;
groupName = groupName.trim();
query.setFilter("this.groupName == t");
query.declareParameters("java.lang.String t");
query.setUnique(true);
sentryGroup = (MSentryGroup) query.execute(groupName);
if (sentryGroup == null) {
throw new SentryNoSuchObjectException("Group " + groupName);
} else {
pm.retrieve(sentryGroup);
}
roles = sentryGroup.getRoles();
}
for ( MSentryRole role: roles) {
pm.retrieve(role);
}
commitTransaction(pm);