private Element getSecurityContraintsElement() { Element securityContraints = new Element(SECURITY_CONSTRAINTS); List allGroupRules = mSecurityConstraints.getAllGroupRules(); for (int i = 0; i < allGroupRules.size(); i++) { GroupRules groupRules = (GroupRules) allGroupRules.get(i); List rules = groupRules.getRules(); if (rules.size() == 0) { continue; } Element groupRulesElement = new Element(GROUP_RULES); groupRulesElement.setAttribute(GROUP, groupRules.getGroupName()); for (int j = 0; j < rules.size(); j++) { RuleDescription ruleDescription = (RuleDescription) rules.get(j); Element ruleElement; if (ruleDescription.getType() == RuleDescription.INCLUDE) { ruleElement = new Element(INCLUDE_RULE); } else { ruleElement = new Element(EXCLUDE_RULE); } ruleElement.setAttribute(RESOURCE, ruleDescription.getResource()); ruleElement.setAttribute(CLASS, ruleDescription.getRetsClass()); String systemNames = StringUtils.join(ruleDescription.getSystemNames().iterator(), " "); Element systemNamesElement = new Element(SYSTEM_NAMES); systemNamesElement.setText(systemNames); ruleElement.addContent(systemNamesElement); groupRulesElement.addContent(ruleElement); } securityContraints.addContent(groupRulesElement); } return securityContraints; }
public void addRules(GroupRules rules) { List allRules = rules.getRules(); String groupName = rules.getGroupName(); for (int i = 0; i < allRules.size(); i++) { RuleDescription ruleDescription = (RuleDescription) allRules.get(i); String tableKey = ruleDescription.getResource() + ":" + ruleDescription.getRetsClass(); String rulesKey = groupName + ":" + tableKey; Set tables = (Set) mAllTables.get(tableKey); Set filteredTables = new HashSet(); for (Iterator iterator = tables.iterator(); iterator.hasNext(); ) { Table table = (Table) iterator.next(); if (ruleDescription.includeSystemName(table.getSystemName())) { filteredTables.add(table); } } mRules.put(rulesKey, filteredTables); } }