SAXBuilder saxBuilder = new SAXBuilder();
StringReader reader = new StringReader(xml);
Document document = saxBuilder.build(reader);
Element root = document.getRootElement();
String name = root.getAttribute("name").getValue();
PageSecurity pageSecurity = pageManager.getPageSecurity();
SecurityConstraintsDef def = pageSecurity.getSecurityConstraintsDef(name);
int defsSize = 0;
if (def == null)
{
def = pageManager.newSecurityConstraintsDef();
def.setName(name);
added = true;
}
int xmlSize = root.getChildren("security-constraint").size();
if (added == false)
{
defsSize = def.getSecurityConstraints().size();
}
int min = (xmlSize < defsSize) ? xmlSize : defsSize;
List xmlConstraints = root.getChildren("security-constraint");
List constraints = def.getSecurityConstraints();
Element owner = root.getChild("owner");
if (owner != null)
{
}
for (int ix = 0; ix < min; ix++)
{
Element xmlConstraint = (Element)xmlConstraints.get(ix);
SecurityConstraint constraint = (SecurityConstraint)constraints.get(ix);
updateConstraintValues(xmlConstraint, constraint);
count++;
}
if (xmlSize < defsSize)
{
// remove constraints
List deletes = new ArrayList(defsSize - xmlSize);
for (int ix = min; ix < defsSize; ix++)
{
deletes.add(constraints.get(ix));
}
for (int ix = 0; ix < deletes.size(); ix++)
{
constraints.remove(deletes.get(ix));
count++;
}
}
else if (xmlSize > defsSize)
{
// add new constraints
for (int ix = min; ix < xmlSize; ix++)
{
Element xmlConstraint = (Element)xmlConstraints.get(ix);
SecurityConstraint constraint = pageManager.newPageSecuritySecurityConstraint();
updateConstraintValues(xmlConstraint, constraint);
constraints.add(constraint);
count++;
}
}
if (added)
{
pageSecurity.getSecurityConstraintsDefs().add(def);
pageSecurity.setSecurityConstraintsDefs(pageSecurity.getSecurityConstraintsDefs());
}
pageManager.updatePageSecurity(pageSecurity);
}
catch (Exception e)
{