Example #1
0
 private static void elementToSecurityConstraints(Element element, RetsConfig config) {
   if (element == null) {
     config.setSecurityConstraints(new ArrayList());
     return;
   }
   List securityConstraints = new ArrayList();
   List children = element.getChildren(GROUP_RULES);
   for (int i = 0; i < children.size(); i++) {
     Element child = (Element) children.get(i);
     String groupName = child.getAttributeValue(GROUP);
     GroupRules groupRules = new GroupRules(groupName);
     List grandChildren = child.getChildren();
     for (int j = 0; j < grandChildren.size(); j++) {
       Element grandChild = (Element) grandChildren.get(j);
       RuleDescription ruleDescription = new RuleDescription();
       if (grandChild.getName().equals(INCLUDE_RULE)) {
         ruleDescription.setType(RuleDescription.INCLUDE);
       } else if (grandChild.getName().equals(EXCLUDE_RULE)) {
         ruleDescription.setType(RuleDescription.EXCLUDE);
       } else {
         LOG.warn("Unknown rule" + grandChild.toString());
         continue;
       }
       ruleDescription.setResource(grandChild.getAttributeValue(RESOURCE));
       ruleDescription.setRetsClass(grandChild.getAttributeValue(CLASS));
       String systemNamesText = grandChild.getChildTextNormalize(SYSTEM_NAMES);
       String[] systemNamesArray = StringUtils.split(systemNamesText, " ");
       ruleDescription.setSystemNames(Arrays.asList(systemNamesArray));
       groupRules.addRule(ruleDescription);
     }
     securityConstraints.add(groupRules);
   }
   config.setSecurityConstraints(securityConstraints);
 }