// has the added twist that it expects rows for a given ACL to be
// grouped together by principal.
boolean more = true;
AclImpl result = new AclImpl(aclOwner, null);
AclEntryImpl entry = null;
String currentPrincipal = null;
try
{
do
{
String aclName = rs.getString(1);
String principal = rs.getString(2);
String permission = rs.getString(3);
if (name == null)
{
name = aclName;
}
else if (aclName.equals(name) == false)
{
break;
}
if (currentPrincipal == null || currentPrincipal.equals(principal) == false)
{
// We're dealing with a new principal, so create a new AclEntry.
currentPrincipal = principal;
// There's an ordering constraint imposed here by the
// AclImpl implementation: we must add all the Permissions
// we will need to an AclEntry before adding the AclEntry to
// the Acl.
if (entry != null)
{
result.addEntry(aclOwner, entry);
}
Principal p = getPrincipal(principal);
if (p == null)
{
throw new RDBMSException("acl \"" + name + "\" contains nonexistent " +
"principal \"" + principal + "\"");
}
entry = new AclEntryImpl(p);
}
entry.addPermission(new PermissionImpl(permission));
} while (more = rs.next());
if (entry != null)
{
result.addEntry(aclOwner, entry);
}
result.setName(aclOwner, name);
}
catch (NotOwnerException e)
{
throw new RDBMSException("caught unexpected exception", e);
}