// retrieve security-role
nodes = (NodeList)xpath.evaluate("/"+prefix+"web-app/"+prefix+"security-role", document, XPathConstants.NODESET);
if (nodes != null)
{
String roleName;
SecurityRole r;
Description d;
for (int i = 0, nsize = nodes.getLength(); i < nsize; i++)
{
element = (Element)nodes.item(i);
children = element.getElementsByTagName("role-name");
if (children != null && children.getLength() != 0)
{
roleName = children.item(0).getTextContent().trim();
if (roleName.length() > 0)
{
r = null;
for (SecurityRole sr : pa.getSecurityRoles())
{
if (sr.getName().equals(roleName))
{
r = sr;
break;
}
}
if (r == null)
{
r = pa.addSecurityRole(roleName);
}
// else: overwrite or merge existing descriptions with those of this last found entry
children = element.getElementsByTagName("description");
if (children != null)
{
for (int j = 0, csize = children.getLength(); j < csize; j++)
{
element = (Element)children.item(j);
String lang = element.getAttributeNS(XMLConstants.XML_NS_URI, "lang");
if (lang == null)
{
lang = "en";
}
if (r.getDescription(JetspeedLocale.convertStringToLocale(lang)) == null)
{
d = r.addDescription(lang);
d.setDescription(element.getTextContent());
}
}
}
}