}
}
} catch (IllegalArgumentException ex) {
log.warning("Bad UUID value '"+sid+"' on role.");
} catch (SQLException ex) {
throw new XMLException("Database error creating role "+sid,ex);
}
}
break;
case ElementEndItem:
role = null;
}
} else if (level==4 && role!=null) {
if (item.getType()==Item.ItemType.ElementItem) {
Element e = (Element)item;
if (e.getName().equals(XML.PERMISSION_NAME)) {
String sid = e.getAttributeValue("id");
String name = e.getAttributeValue("name");
if (sid==null && name==null) {
log.warning("A permission for role "+role.getUUID()+" must have at least the 'id' or 'name' attribute.");
return;
}
try {
Permission p = null;
if (sid!=null) {
UUID uuid = UUID.fromString(sid);
p = db.getPermission(uuid);
}
if (p==null && name!=null) {
p = db.getPermission(name);
}
if (p==null) {
log.warning("Cannot find permission ("+sid+","+name+") for role "+role.getUUID());
}
if (!role.hasPermission(p)) {
log.info("Adding permission ("+p.getName()+","+p.getUUID()+") to role.");
if (!role.addPermission(p)) {
log.warning("Cannot add permission "+p.getUUID()+" to role "+role.getUUID());
}
} else {
log.info("Role already has permission ("+p.getName()+","+p.getUUID()+") to role.");
}
} catch (IllegalArgumentException ex) {
log.warning("Bad UUID value '"+sid+"' on permission.");
} catch (SQLException ex) {
throw new XMLException("Database error adding permission "+sid+" to role "+role.getUUID(),ex);
}
}
}
}