Skip to content

Commit

Permalink
Fix #90: replace getTextContent() by getFirstChild().getNodeValue()
Browse files Browse the repository at this point in the history
  • Loading branch information
Bauke Scholtz committed Jan 12, 2015
1 parent 4daaac3 commit bf31d4d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/java/org/omnifaces/config/WebXml.java
Expand Up @@ -437,7 +437,7 @@ private static List<String> parseWelcomeFiles(Element webXml, XPath xpath) throw
List<String> welcomeFiles = new ArrayList<>(welcomeFileList.getLength());

for (int i = 0; i < welcomeFileList.getLength(); i++) {
welcomeFiles.add(welcomeFileList.item(i).getTextContent().trim());
welcomeFiles.add(getTextContent(welcomeFileList.item(i)));
}

return Collections.unmodifiableList(welcomeFiles);
Expand All @@ -453,7 +453,7 @@ private static Map<Class<Throwable>, String> parseErrorPageLocations(Element web

for (int i = 0; i < exceptionTypes.getLength(); i++) {
Node node = exceptionTypes.item(i);
Class<Throwable> exceptionClass = (Class<Throwable>) Class.forName(node.getTextContent().trim());
Class<Throwable> exceptionClass = (Class<Throwable>) Class.forName(getTextContent(node));
String exceptionLocation = xpath.compile(XPATH_LOCATION).evaluate(node.getParentNode()).trim();
Class<Throwable> key = (exceptionClass == Throwable.class) ? null : exceptionClass;

Expand Down Expand Up @@ -510,7 +510,7 @@ private static Map<String, Set<String>> parseSecurityConstraints(Element webXml,
roles = new HashSet<>(authRoles.getLength());

for (int j = 0; j < authRoles.getLength(); j++) {
roles.add(authRoles.item(j).getTextContent().trim());
roles.add(getTextContent(authRoles.item(j)));
}

roles = Collections.unmodifiableSet(roles);
Expand All @@ -519,7 +519,7 @@ private static Map<String, Set<String>> parseSecurityConstraints(Element webXml,
NodeList urlPatterns = getNodeList(constraint, xpath, XPATH_WEB_RESOURCE_URL_PATTERN);

for (int j = 0; j < urlPatterns.getLength(); j++) {
String urlPattern = urlPatterns.item(j).getTextContent().trim();
String urlPattern = getTextContent(urlPatterns.item(j));
securityConstraints.put(urlPattern, roles);
}
}
Expand All @@ -541,4 +541,8 @@ private static NodeList getNodeList(Node node, XPath xpath, String expression) t
return (NodeList) xpath.compile(expression).evaluate(node, XPathConstants.NODESET);
}

private static String getTextContent(Node node) {
return node.getFirstChild().getNodeValue().trim();
}

}

0 comments on commit bf31d4d

Please sign in to comment.