Search in sources :

Example 1 with ConfigurationErrorHandler

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);
    }
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) ConfigurationException(org.apache.jackrabbit.core.config.ConfigurationException) SAXParseException(org.xml.sax.SAXParseException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) Document(org.w3c.dom.Document) ConfigurationErrorHandler(org.apache.jackrabbit.core.config.ConfigurationErrorHandler) SAXException(org.xml.sax.SAXException)

Aggregations

IOException (java.io.IOException)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 ConfigurationErrorHandler (org.apache.jackrabbit.core.config.ConfigurationErrorHandler)1 ConfigurationException (org.apache.jackrabbit.core.config.ConfigurationException)1 Document (org.w3c.dom.Document)1 SAXException (org.xml.sax.SAXException)1 SAXParseException (org.xml.sax.SAXParseException)1