use of org.apache.jackrabbit.core.config.ConfigurationErrorHandler in project jackrabbit by apache.
the class DefaultLoginModuleTest method parseXML.
private static Element parseXML(InputSource xml, boolean validate) throws ConfigurationException {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(validate);
DocumentBuilder builder = factory.newDocumentBuilder();
if (validate) {
builder.setErrorHandler(new ConfigurationErrorHandler());
}
builder.setEntityResolver(ConfigurationEntityResolver.INSTANCE);
Document document = builder.parse(xml);
return document.getDocumentElement();
} catch (ParserConfigurationException e) {
throw new ConfigurationException("Unable to create configuration XML parser", e);
} catch (SAXParseException e) {
throw new ConfigurationException("Configuration file syntax error. (Line: " + e.getLineNumber() + " Column: " + e.getColumnNumber() + ")", e);
} catch (SAXException e) {
throw new ConfigurationException("Configuration file syntax error. ", e);
} catch (IOException e) {
throw new ConfigurationException("Configuration file could not be read.", e);
}
}
Aggregations