in tobago-core/src/main/java/org/apache/myfaces/tobago/util/WebXmlUtils.java [78:133]
private static void init() {
final FacesContext facesContext = FacesContext.getCurrentInstance();
final ExternalContext externalContext = facesContext.getExternalContext();
try {
final List<Document> webXmls = getWebXmls(facesContext);
String locationDefault = null;
String location500 = null;
for (final Document document : webXmls) {
if (document != null) {
final NodeList errorPages = document.getElementsByTagName("error-page");
for (int i = 0; i < errorPages.getLength(); i++) {
final Node errorPage = errorPages.item(i);
String errorCode = null;
String exceptionType = null;
String location = null;
final NodeList children = errorPage.getChildNodes();
for (int j = 0; j < children.getLength(); j++) {
final Node child = children.item(j);
final String name = child.getNodeName();
if ("error-code".equals(name)) {
errorCode = child.getFirstChild().getNodeValue().trim();
} else if ("exception-type".equals(name)) {
exceptionType = child.getFirstChild().getNodeValue().trim();
} else if ("location".equals(name)) {
location = child.getFirstChild().getNodeValue().trim();
}
}
if (exceptionType != null) {
final Class<Throwable> key = (Class<Throwable>) Class.forName(exceptionType);
final String value = normalizePath(externalContext, location);
ERROR_PAGE_LOCATIONS.put(key, value);
} else if ("500".equals(errorCode)) {
location500 = location;
} else if (errorCode == null && exceptionType == null) {
locationDefault = location;
}
}
}
}
if (!ERROR_PAGE_LOCATIONS.containsKey(null)) {
final String value = normalizePath(externalContext, location500 != null ? location500 : locationDefault);
ERROR_PAGE_LOCATIONS.put(null, value);
}
} catch (IOException | ParserConfigurationException | ClassNotFoundException | SAXException e) {
throw new UnsupportedOperationException(e);
}
}