1 17 package org.alfresco.web.config; 18 19 import org.alfresco.config.ConfigElement; 20 import org.alfresco.config.ConfigException; 21 import org.alfresco.config.xml.elementreader.ConfigElementReader; 22 import org.dom4j.Element; 23 24 29 public class ServerElementReader implements ConfigElementReader 30 { 31 public static final String ELEMENT_SERVER = "server"; 32 public static final String ELEMENT_ERROR_PAGE = "error-page"; 33 public static final String ELEMENT_LOGIN_PAGE = "login-page"; 34 35 38 public ConfigElement parse(Element element) 39 { 40 ServerConfigElement configElement = null; 41 42 if (element != null) 43 { 44 String name = element.getName(); 45 if (name.equals(ELEMENT_SERVER) == false) 46 { 47 throw new ConfigException("ServerElementReader can only parse " + 48 ELEMENT_SERVER + "elements, " + "the element passed was '" + 49 name + "'"); 50 } 51 52 configElement = new ServerConfigElement(); 53 54 Element errorPage = element.element(ELEMENT_ERROR_PAGE); 56 if (errorPage != null) 57 { 58 configElement.setErrorPage(errorPage.getTextTrim()); 59 } 60 61 Element loginPage = element.element(ELEMENT_LOGIN_PAGE); 63 if (loginPage != null) 64 { 65 configElement.setLoginPage(loginPage.getTextTrim()); 66 } 67 } 68 69 return configElement; 70 } 71 } 72 | Popular Tags |