1 17 package org.alfresco.web.config; 18 19 import java.util.Iterator ; 20 21 import org.alfresco.config.ConfigElement; 22 import org.alfresco.config.ConfigException; 23 import org.alfresco.config.xml.elementreader.ConfigElementReader; 24 import org.dom4j.Element; 25 26 31 public class NavigationElementReader implements ConfigElementReader 32 { 33 public static final String ELEMENT_NAVIGATION = "navigation"; 34 public static final String ELEMENT_OVERRIDE = "override"; 35 public static final String ATTR_FROM_VIEWID = "from-view-id"; 36 public static final String ATTR_FROM_OUTCOME = "from-outcome"; 37 public static final String ATTR_TO_VIEWID = "to-view-id"; 38 public static final String ATTR_TO_OUTCOME = "to-outcome"; 39 40 43 public ConfigElement parse(Element element) 44 { 45 NavigationConfigElement configElement = null; 46 47 if (element != null) 48 { 49 String name = element.getName(); 50 if (ELEMENT_NAVIGATION.equals(name) == false) 51 { 52 throw new ConfigException("NavigationElementReader can only parse " + 53 ELEMENT_NAVIGATION + "elements, " + "the element passed was '" + 54 name + "'"); 55 } 56 57 configElement = new NavigationConfigElement(); 58 59 Iterator <Element> items = element.elementIterator(); 61 while (items.hasNext()) 62 { 63 Element item = items.next(); 64 65 if (ELEMENT_OVERRIDE.equals(item.getName())) 67 { 68 String fromViewId = item.attributeValue(ATTR_FROM_VIEWID); 69 String fromOutcome = item.attributeValue(ATTR_FROM_OUTCOME); 70 String toViewId = item.attributeValue(ATTR_TO_VIEWID); 71 String toOutcome = item.attributeValue(ATTR_TO_OUTCOME); 72 73 configElement.addOverride(fromViewId, fromOutcome, toViewId, toOutcome); 74 } 75 } 76 } 77 78 return configElement; 79 } 80 } 81 | Popular Tags |