protected ModelAndView ruleList(String surt, Long editingRuleId, HttpServletRequest request,
HttpServletResponse response) throws Exception {
surt = cleanSurt(surt);
int surtSegments = new NewSurtTokenizer(surt).toList().size();
Map<String, Object> model = new HashMap<String, Object>();
RuleSet rules = ruleDao.getRuleTree(surt);
ArrayList<DisplayRule> ruleList = new ArrayList<DisplayRule>();
ArrayList<String> childSurts = new ArrayList<String>();
for (Rule rule: rules) {
int comparison = rule.getSurt().compareTo(surt);
if (comparison <= 0) {
DisplayRule displayRule = new DisplayRule(rule, comparison != 0);
displayRule.setEditing(rule.getId().equals(editingRuleId));
ruleList.add(displayRule);
} else {
try {
String segment = new NewSurtTokenizer(rule.getSurt())
.toList().get(surtSegments);
if (!childSurts.contains(segment)) {
childSurts.add(segment);
}
} catch (IndexOutOfBoundsException e) {