Search in sources :

Example 16 with ParserConfigurationException

use of javax.xml.parsers.ParserConfigurationException in project jmonkeyengine by jMonkeyEngine.

the class XMLExporter method save.

@Override
public void save(Savable object, OutputStream f) throws IOException {
    try {
        //Initialize Document when saving so we don't retain state of previous exports
        this.domOut = new DOMOutputCapsule(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(), this);
        domOut.write(object, object.getClass().getName(), null);
        DOMSerializer serializer = new DOMSerializer();
        serializer.serialize(domOut.getDoc(), f);
        f.flush();
    } catch (ParserConfigurationException ex) {
        throw new IOException(ex);
    }
}
Also used : ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException)

Example 17 with ParserConfigurationException

use of javax.xml.parsers.ParserConfigurationException in project Apktool by iBotPeaches.

the class ResXmlPatcher method removeApplicationDebugTag.

/**
     * Removes "debug" tag from file
     *
     * @param file AndroidManifest file
     * @throws AndrolibException
     */
public static void removeApplicationDebugTag(File file) throws AndrolibException {
    if (file.exists()) {
        try {
            Document doc = loadDocument(file);
            Node application = doc.getElementsByTagName("application").item(0);
            // load attr
            NamedNodeMap attr = application.getAttributes();
            Node debugAttr = attr.getNamedItem("android:debuggable");
            // remove application:debuggable
            if (debugAttr != null) {
                attr.removeNamedItem("android:debuggable");
            }
            saveDocument(file, doc);
        } catch (SAXException | ParserConfigurationException | IOException | TransformerException ignored) {
        }
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) Document(org.w3c.dom.Document) TransformerException(javax.xml.transform.TransformerException) SAXException(org.xml.sax.SAXException)

Example 18 with ParserConfigurationException

use of javax.xml.parsers.ParserConfigurationException in project Apktool by iBotPeaches.

the class ResXmlPatcher method removeManifestVersions.

/**
     * Removes attributes like "versionCode" and "versionName" from file.
     *
     * @param file File representing AndroidManifest.xml
     * @throws AndrolibException
     */
public static void removeManifestVersions(File file) throws AndrolibException {
    if (file.exists()) {
        try {
            Document doc = loadDocument(file);
            Node manifest = doc.getFirstChild();
            NamedNodeMap attr = manifest.getAttributes();
            Node vCode = attr.getNamedItem("android:versionCode");
            Node vName = attr.getNamedItem("android:versionName");
            if (vCode != null) {
                attr.removeNamedItem("android:versionCode");
            }
            if (vName != null) {
                attr.removeNamedItem("android:versionName");
            }
            saveDocument(file, doc);
        } catch (SAXException | ParserConfigurationException | IOException | TransformerException ignored) {
        }
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) Document(org.w3c.dom.Document) TransformerException(javax.xml.transform.TransformerException) SAXException(org.xml.sax.SAXException)

Example 19 with ParserConfigurationException

use of javax.xml.parsers.ParserConfigurationException in project Openfire by igniterealtime.

the class GatewayDWR method configure.

@Override
public void configure(ServletConfig servletConfig, Configuration configuration) throws ServletException {
    try {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = dbf.newDocumentBuilder();
        document = builder.newDocument();
        Element root = document.createElement("dwr");
        document.appendChild(root);
        Element allowElement = document.createElement("allow");
        allowElement.appendChild(buildCreator("ConfigManager", "net.sf.kraken.web.ConfigManager"));
        allowElement.appendChild(buildCreator("ConnectionTester", "net.sf.kraken.web.ConnectionTester"));
        root.appendChild(allowElement);
    } catch (ParserConfigurationException e) {
        Log.error("Error configuring DWR for gateway plugin: ", e);
    }
    configuration.addConfig(document);
    // Specify the path for the js files 
    Object bean = container.getBean("interface");
    if (bean instanceof DefaultInterfaceProcessor) {
        DefaultInterfaceProcessor processor = (DefaultInterfaceProcessor) bean;
        processor.setOverridePath("/plugins/kraken/dwr");
    }
}
Also used : DefaultInterfaceProcessor(uk.ltd.getahead.dwr.impl.DefaultInterfaceProcessor) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 20 with ParserConfigurationException

use of javax.xml.parsers.ParserConfigurationException in project Openfire by igniterealtime.

the class MonitoringDWR method configure.

@Override
public void configure(ServletConfig servletConfig, Configuration configuration) throws ServletException {
    try {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = dbf.newDocumentBuilder();
        document = builder.newDocument();
        Element root = document.createElement("dwr");
        document.appendChild(root);
        Element allowElement = document.createElement("allow");
        // Build stats bean
        Element createElement = buildCreator("Stats", org.jivesoftware.openfire.reporting.stats.StatsAction.class.getName());
        Element convertConversationElement = document.createElement("convert");
        convertConversationElement.setAttribute("converter", "bean");
        convertConversationElement.setAttribute("match", org.jivesoftware.openfire.archive.ConversationInfo.class.getName());
        // Build conversation Element.
        Element conversationElement = buildCreator("conversations", org.jivesoftware.openfire.archive.ConversationUtils.class.getName());
        allowElement.appendChild(createElement);
        allowElement.appendChild(convertConversationElement);
        allowElement.appendChild(conversationElement);
        root.appendChild(allowElement);
    } catch (ParserConfigurationException e) {
        Log.error("error creating DWR configuration: " + e);
    }
    configuration.addConfig(document);
    // Specify the path for the Stat.js file 
    Object bean = container.getBean("interface");
    if (bean instanceof DefaultInterfaceProcessor) {
        DefaultInterfaceProcessor processor = (DefaultInterfaceProcessor) bean;
        processor.setOverridePath("/plugins/" + MonitoringConstants.NAME + "/dwr");
    }
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) Element(org.w3c.dom.Element) DefaultInterfaceProcessor(uk.ltd.getahead.dwr.impl.DefaultInterfaceProcessor) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Aggregations

ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1435 SAXException (org.xml.sax.SAXException)1039 IOException (java.io.IOException)951 Document (org.w3c.dom.Document)751 DocumentBuilder (javax.xml.parsers.DocumentBuilder)687 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)622 Element (org.w3c.dom.Element)389 InputSource (org.xml.sax.InputSource)260 NodeList (org.w3c.dom.NodeList)248 Node (org.w3c.dom.Node)225 SAXParser (javax.xml.parsers.SAXParser)185 File (java.io.File)171 InputStream (java.io.InputStream)170 TransformerException (javax.xml.transform.TransformerException)167 SAXParserFactory (javax.xml.parsers.SAXParserFactory)144 ByteArrayInputStream (java.io.ByteArrayInputStream)141 StringReader (java.io.StringReader)127 ArrayList (java.util.ArrayList)122 DOMSource (javax.xml.transform.dom.DOMSource)114 StreamResult (javax.xml.transform.stream.StreamResult)98