Search in sources :

Example 6 with AddonPropertiesException

use of org.openecard.addon.AddonPropertiesException in project open-ecard by ecsec.

the class LogSettingsGroup method getLoglevel.

private static String getLoglevel(Document conf, String path) throws AddonPropertiesException {
    try {
        XPath p = XPathFactory.newInstance().newXPath();
        XPathExpression exp = p.compile(String.format("/configuration/logger[@name='%s']", path));
        Element e = (Element) exp.evaluate(conf, XPathConstants.NODE);
        // no element means NO level
        if (e == null) {
            return "";
        } else {
            return e.getAttribute("level");
        }
    } catch (DOMException | XPathExpressionException ex) {
        throw new AddonPropertiesException("Failed to operate on log config document.");
    }
}
Also used : XPath(javax.xml.xpath.XPath) XPathExpression(javax.xml.xpath.XPathExpression) DOMException(org.w3c.dom.DOMException) XPathExpressionException(javax.xml.xpath.XPathExpressionException) Element(org.w3c.dom.Element) AddonPropertiesException(org.openecard.addon.AddonPropertiesException)

Aggregations

AddonPropertiesException (org.openecard.addon.AddonPropertiesException)6 XPath (javax.xml.xpath.XPath)4 XPathExpression (javax.xml.xpath.XPathExpression)4 XPathExpressionException (javax.xml.xpath.XPathExpressionException)4 DOMException (org.w3c.dom.DOMException)4 Element (org.w3c.dom.Element)4 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 HTMLDocument (javax.swing.text.html.HTMLDocument)2 WSMarshaller (org.openecard.ws.marshal.WSMarshaller)2 WSMarshallerException (org.openecard.ws.marshal.WSMarshallerException)2 Document (org.w3c.dom.Document)2 SAXException (org.xml.sax.SAXException)2 JoranException (ch.qos.logback.core.joran.spi.JoranException)1 FileOutputStream (java.io.FileOutputStream)1 FileWriter (java.io.FileWriter)1 InputStream (java.io.InputStream)1 Properties (java.util.Properties)1 TransformerException (javax.xml.transform.TransformerException)1