Example usage for javax.xml.parsers ParserConfigurationException toString

List of usage examples for javax.xml.parsers ParserConfigurationException toString

Introduction

In this page you can find the example usage for javax.xml.parsers ParserConfigurationException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:org.smartfrog.avalanche.client.sf.apps.gt4wscore.UndeployFrmTomcat.java

public void cleanXMLFiles() throws TomcatConfigException {
    String serverxml = new String(tomcatDir.concat("/conf/server.xml"));
    serverxml = serverxml.replace('\\', File.separatorChar);
    serverxml = serverxml.replace('/', File.separatorChar);

    EditXML xmlHelper = null;//w w  w.  j av  a 2 s. co  m
    Element connector = null;
    Element valve = null;
    try {
        xmlHelper = new EditXML(serverxml);

        if (version.startsWith("4.1")) {
            connector = xmlHelper.getElementByTagNameAttrName("Connector", "className",
                    "org.apache.catalina.connector.http.HttpConnector");
            xmlHelper.removeNode(connector);

            valve = xmlHelper.getElementByTagNameAttrName("Valve", "className",
                    "org.globus.tomcat.catalina.valves.HTTPSValve");
            xmlHelper.removeNode(valve);
        } else if (version.startsWith("5.")) {
            connector = xmlHelper.getElementByTagNameAttrName("Connector", "className",
                    "org.globus.tomcat.coyote.net.HTTPSConnector");
            xmlHelper.removeNode(connector);

            valve = xmlHelper.getElementByTagNameAttrName("Valve", "className",
                    "org.globus.tomcat.coyote.valves.HTTPSValve");
            xmlHelper.removeNode(valve);
        } else {
            log.error("The version " + version + " is not supported");
            throw new TomcatConfigException("The version " + version + " is not supported");
        }
    } catch (ParserConfigurationException pce) {
        throw new TomcatConfigException(pce.toString());
    } catch (IOException ioe) {
        throw new TomcatConfigException(ioe.toString());
    } catch (SAXException se) {
        throw new TomcatConfigException(se.toString());
    } finally {
        try {
            xmlHelper.commitChanges();
        } catch (FileNotFoundException fnf) {
            log.error(fnf);
            throw new TomcatConfigException(fnf);
        } catch (TransformerException te) {
            log.error(te);
            throw new TomcatConfigException(te);
        }
    }
}

From source file:pl.psnc.synat.wrdz.common.metadata.mets.MetsMetadataBuilder.java

/**
 * Gets new MdWrap section.//  w  w  w .j a  v a 2  s . com
 * 
 * @param type
 *            namespace type (= metadata type)
 * @param metadataFile
 *            file with the xml
 * @param metadataLabel
 *            filename with metadata
 * @return new MdWrap section
 */
private MdWrap getNewMdWrapSection(NamespaceType type, File metadataFile, String metadataLabel) {
    MdWrap mdWrap = new MdWrap();
    mdWrap.setLABEL(metadataLabel);
    if (type.equals(NamespaceType.UNKNOWN)) {
        mdWrap.setMDTYPE(MetsConsts.METS_METADATA_TYPE_OTHER);
    } else {
        mdWrap.setMDTYPE(type.name().replace('_', ':'));
    }
    DocumentBuilder documentBuilder = null;
    try {
        documentBuilder = domBuilderFactory.newDocumentBuilder();
    } catch (ParserConfigurationException e) {
        logger.error("Problem with creation of document builder." + e.toString());
        throw new RuntimeException(e);
    }

    Document document = null;
    Element element = null;
    try {
        document = documentBuilder.parse(new InputSource(new FileInputStream(metadataFile)));
        element = document.getDocumentElement();
        clearWhitespacesBetweenElements(element);
        XmlData xmlData = new XmlData();
        xmlData.getAny().add(element);
        mdWrap.setXmlData(xmlData);
    } catch (Exception e) {
        logger.error("Reading metadata as a XML failed. Trying as binary data." + e.toString());
        try {
            mdWrap.setBinData(IOUtils.toByteArray(new FileInputStream(metadataFile)));
        } catch (Exception f) {
            logger.error("Problem with reading metadata as binary data." + f.toString());
            throw new RuntimeException(f);
        }
    }
    return mdWrap;
}