try
{
while (tri.hasNext())
{
TableRow row = tri.next();
int childID = row.getIntColumn("eperson_group_id");
groupIDs.add(new Integer(childID));
}
}
finally
{
// close the TableRowIterator to free up resources
if (tri != null)
tri.close();
}
}
// Also need to get all "Special Groups" user is a member of!
// Otherwise, you're ignoring the user's membership to these groups!
// However, we only do this is we are looking up the special groups
// of the current user, as we cannot look up the special groups
// of a user who is not logged in.
if ((c.getCurrentUser() == null) || (((c.getCurrentUser() != null) && (c.getCurrentUser().getID() == e.getID()))))
{
Group[] specialGroups = c.getSpecialGroups();
for(Group special : specialGroups)
{
groupIDs.add(new Integer(special.getID()));
}
}
// all the users are members of the anonymous group
groupIDs.add(new Integer(0));
// now we have all owning groups, also grab all parents of owning groups
// yes, I know this could have been done as one big query and a union,
// but doing the Oracle port taught me to keep to simple SQL!
String groupQuery = "";
Iterator i = groupIDs.iterator();
// Build a list of query parameters
Object[] parameters = new Object[groupIDs.size()];
int idx = 0;
while (i.hasNext())
{
int groupID = ((Integer) i.next()).intValue();
parameters[idx++] = new Integer(groupID);
groupQuery += "child_id= ? ";
if (i.hasNext())
groupQuery += " OR ";
}
// was member of at least one group
// NOTE: even through the query is built dynamicaly all data is seperated into the
// the parameters array.
TableRowIterator tri = DatabaseManager.queryTable(c, "group2groupcache",
"SELECT * FROM group2groupcache WHERE " + groupQuery,
parameters);
try
{
while (tri.hasNext())
{
TableRow row = tri.next();
int parentID = row.getIntColumn("parent_id");
groupIDs.add(new Integer(parentID));
}
}
finally