throws XMLException
{
if (level==3) {
switch (item.getType()) {
case ElementItem:
Element e = (Element)item;
if (e.getName().equals(XML.ROLE_NAME)) {
String sid = e.getAttributeValue("id");
String name = e.getAttributeValue("name");
if (sid==null) {
log.warning("A role is missing the 'id' attribute.");
return;
}
if (name==null) {
log.warning("A role is missing the 'name' attribute.");
return;
}
try {
UUID uuid = UUID.fromString(sid);
role = db.getRole(uuid);
if (role==null) {
log.info("Creating role ("+name+","+sid+")");
role = db.createRole(name,uuid);
} else {
if (!role.getName().equals(name)) {
log.warning("Role ("+name+","+sid+") exists but has a different name, recreating.");
role.delete();
role = db.createRole(name,uuid);
} else {
log.info("Role ("+name+","+sid+") already exists.");
}
}
} 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 {