XPath xpa = XPath.newInstance("/api/query/users/user");
List results = xpa.selectNodes(root);
Iterator iter = results.iterator();
while (iter.hasNext()) {
Element currentNode = (Element) iter.next();
User user = new User(currentNode.getAttributeValue("name"));
List<String> groups = new ArrayList<String>();
XPath xpaGroups = XPath.newInstance("./groups/g");
List resultGroups = xpaGroups.selectNodes(currentNode);
Iterator itGroups = resultGroups.iterator();
while (itGroups.hasNext()) {
groups.add(((Element) itGroups.next()).getValue());
}
user.setGroups(groups);
List<String> rights = new ArrayList<String>();
XPath xpaRights = XPath.newInstance("./rights/r");
List resultRights = xpaRights.selectNodes(currentNode);
Iterator itRights = resultRights.iterator();
while (itRights.hasNext()) {
rights.add(((Element) itRights.next()).getValue());
}
user.setRights(rights);
return user;
}
} catch (JDOMException e) {
log.error("Error retrieving user information", e);
throw new APIException("Error parsing XML", e);