Example usage for javax.xml.parsers ParserConfigurationException getMessage

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

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:be.e_contract.mycarenet.xkms2.ProofOfPossessionSignatureSOAPHandler.java

@Override
public boolean handleMessage(SOAPMessageContext context) {
    if (null == this.sessionKey) {
        return true;
    }/*from  ww  w . j  a  va2 s . c o  m*/
    if (null == this.prototypeKeyBindingId) {
        return true;
    }

    Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if (false == outboundProperty) {
        return true;
    }
    LOG.debug("adding proof of possession signature");
    SOAPMessage soapMessage = context.getMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();

    NodeList registerRequestNodeList = soapPart.getElementsByTagNameNS(XKMS2ServiceFactory.XKMS2_NAMESPACE,
            "RegisterRequest");
    Element registerRequestElement = (Element) registerRequestNodeList.item(0);
    Document xkmsDocument;
    try {
        xkmsDocument = copyDocument(registerRequestElement);
    } catch (ParserConfigurationException e) {
        LOG.error("error copying XKMS request: " + e.getMessage(), e);
        return false;
    }

    NodeList proofOfPossessionNodeList = xkmsDocument
            .getElementsByTagNameNS(XKMS2ServiceFactory.XKMS2_NAMESPACE, "ProofOfPossession");
    Element proofOfPossessionElement = (Element) proofOfPossessionNodeList.item(0);
    try {
        prepareDocument(xkmsDocument);
        addSignature(proofOfPossessionElement);
    } catch (Exception e) {
        LOG.error("error adding proof signature: " + e.getMessage(), e);
        return false;
    }
    Node signatureNode = soapPart.importNode(proofOfPossessionElement.getFirstChild(), true);

    proofOfPossessionNodeList = soapPart.getElementsByTagNameNS(XKMS2ServiceFactory.XKMS2_NAMESPACE,
            "ProofOfPossession");
    proofOfPossessionElement = (Element) proofOfPossessionNodeList.item(0);
    proofOfPossessionElement.appendChild(signatureNode);
    return true;
}

From source file:com.iflytek.spider.util.domain.DomainSuffixesReader.java

void read(DomainSuffixes tldEntries, InputStream input) throws IOException {
    try {/* w  w  w.j  a  v  a  2s .c o m*/

        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setIgnoringComments(true);
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document document = builder.parse(new InputSource(input));

        Element root = document.getDocumentElement();

        if (root != null && root.getTagName().equals("domains")) {

            Element tlds = (Element) root.getElementsByTagName("tlds").item(0);
            Element suffixes = (Element) root.getElementsByTagName("suffixes").item(0);

            //read tlds
            readITLDs(tldEntries, (Element) tlds.getElementsByTagName("itlds").item(0));
            readGTLDs(tldEntries, (Element) tlds.getElementsByTagName("gtlds").item(0));
            readCCTLDs(tldEntries, (Element) tlds.getElementsByTagName("cctlds").item(0));

            readSuffixes(tldEntries, suffixes);
        } else {
            throw new IOException("xml file is not valid");
        }
    } catch (ParserConfigurationException ex) {
        LOG.warn(StringUtils.stringifyException(ex));
        throw new IOException(ex.getMessage());
    } catch (SAXException ex) {
        LOG.warn(StringUtils.stringifyException(ex));
        throw new IOException(ex.getMessage());
    }
}

From source file:net.bpelunit.framework.control.deploy.activevos9.ActiveVOSAdministrativeFunctions.java

public void deployBpr(String bprFileName, byte[] contents) throws DeployException {
    AesDeployBprType deployBprInput = new AesDeployBprType();
    AesStringResponseType deployBpr;/*from  www.  j a  v  a  2 s  . co m*/

    deployBprInput.setBprFilename(bprFileName);
    deployBprInput.setBase64File(contents);
    deployBpr = getActiveBpelAdminPort().deployBpr(deployBprInput);

    String responseMessage = deployBpr.getResponse();
    try {
        Document xml = XMLUtil.parseXML(responseMessage);
        Node item = xml.getFirstChild().getAttributes().getNamedItem(ATTRIBUTE_ERROR_COUNT);
        if (Integer.parseInt(item.getTextContent()) != 0) {
            throw new DeployException("Errors while deploying process: " + responseMessage);
        }
    } catch (ParserConfigurationException e) {
        throw new DeployException("Internal error: " + e.getMessage(), e);
    } catch (SAXException e) {
        throw new DeployException("Internal reading response XML: " + e.getMessage(), e);
    } catch (IOException e) {
        throw new DeployException(e.getMessage(), e);
    }
}

From source file:com.test.demo.ccbpay.XLSX2CSV.java

/**
 * Parses and shows the content of one sheet
 * using the specified styles and shared-strings tables.
 *
 * @param styles/*from   ww  w .  j a  v  a2s .c o m*/
 * @param strings
 * @param sheetInputStream
 */
public void processSheet(StylesTable styles, ReadOnlySharedStringsTable strings,
        SheetContentsHandler sheetHandler, InputStream sheetInputStream)
        throws IOException, ParserConfigurationException, SAXException {
    DataFormatter formatter = new DataFormatter();
    InputSource sheetSource = new InputSource(sheetInputStream);
    try {
        XMLReader sheetParser = SAXHelper.newXMLReader();
        ContentHandler handler = new XSSFSheetXMLHandler(styles, null, strings, sheetHandler, formatter, false);
        sheetParser.setContentHandler(handler);
        sheetParser.parse(sheetSource);
    } catch (ParserConfigurationException e) {
        throw new RuntimeException("SAX parser appears to be broken - " + e.getMessage());
    }
}

From source file:io.wcm.tooling.commons.contentpackagebuilder.XmlContentBuilder.java

XmlContentBuilder(Map<String, String> xmlNamespaces) {
    this.documentBuilderFactory = DocumentBuilderFactory.newInstance();
    this.documentBuilderFactory.setNamespaceAware(true);
    try {//from   ww w .ja v  a 2  s  . c om
        this.documentBuilder = documentBuilderFactory.newDocumentBuilder();
    } catch (ParserConfigurationException ex) {
        throw new RuntimeException("Failed to set up XML document builder: " + ex.getMessage(), ex);
    }
    this.xmlNamespaces = xmlNamespaces;
}

From source file:io.fabric8.tooling.archetype.ArchetypeUtils.java

public ArchetypeUtils() {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);/*from w  ww.  j  a  v a  2 s . c  o m*/
    try {
        this.documentBuilder = dbf.newDocumentBuilder();
        this.transformerFactory = TransformerFactory.newInstance();
    } catch (ParserConfigurationException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}

From source file:io.fabric8.tooling.archetype.builder.ArchetypeHelper.java

public ArchetypeHelper() {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);//from  w  w w.  ja  v a 2  s.  co  m
    try {
        this.documentBuilder = dbf.newDocumentBuilder();
        this.transformerFactory = TransformerFactory.newInstance();
    } catch (ParserConfigurationException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}

From source file:com.myjeeva.poi.ExcelReader.java

private void read(int sheetNumber) throws RuntimeException {
    ReadOnlySharedStringsTable strings;//from w  w  w.  j av  a2 s .  c o m
    try {
        strings = new ReadOnlySharedStringsTable(this.xlsxPackage);
        XSSFReader xssfReader = new XSSFReader(this.xlsxPackage);
        StylesTable styles = xssfReader.getStylesTable();
        XSSFReader.SheetIterator worksheets = (XSSFReader.SheetIterator) xssfReader.getSheetsData();

        for (int sheetIndex = 0; worksheets.hasNext(); sheetIndex++) {
            InputStream stream = worksheets.next();
            if (null != sheetCallback)
                this.sheetCallback.startSheet(sheetIndex, worksheets.getSheetName());

            if ((READ_ALL == sheetNumber) || (sheetIndex == sheetNumber)) {
                readSheet(styles, strings, stream);
            }
            IOUtils.closeQuietly(stream);

            if (null != sheetCallback)
                this.sheetCallback.endSheet();
        }
    } catch (IOException ioe) {
        LOG.error(ioe.getMessage(), ioe.getCause());
    } catch (SAXException se) {
        LOG.error(se.getMessage(), se.getCause());
    } catch (OpenXML4JException oxe) {
        LOG.error(oxe.getMessage(), oxe.getCause());
    } catch (ParserConfigurationException pce) {
        LOG.error(pce.getMessage(), pce.getCause());
    }
}

From source file:com.myjeeva.poi.ExcelReader.java

private void read(String sheetName) throws RuntimeException {
    ReadOnlySharedStringsTable strings;//from w  w  w.  j  a va  2s  .c om
    try {
        strings = new ReadOnlySharedStringsTable(this.xlsxPackage);
        XSSFReader xssfReader = new XSSFReader(this.xlsxPackage);
        StylesTable styles = xssfReader.getStylesTable();
        XSSFReader.SheetIterator worksheets = (XSSFReader.SheetIterator) xssfReader.getSheetsData();

        for (int sheetIndex = 0; worksheets.hasNext(); sheetIndex++) {
            InputStream stream = worksheets.next();
            if (null != sheetCallback)
                this.sheetCallback.startSheet(sheetIndex, worksheets.getSheetName());

            if (sheetName.equals(worksheets.getSheetName())) {
                readSheet(styles, strings, stream);
            }
            IOUtils.closeQuietly(stream);

            if (null != sheetCallback)
                this.sheetCallback.endSheet();
        }
    } catch (IOException ioe) {
        LOG.error(ioe.getMessage(), ioe.getCause());
    } catch (SAXException se) {
        LOG.error(se.getMessage(), se.getCause());
    } catch (OpenXML4JException oxe) {
        LOG.error(oxe.getMessage(), oxe.getCause());
    } catch (ParserConfigurationException pce) {
        LOG.error(pce.getMessage(), pce.getCause());
    }
}

From source file:net.sourceforge.fenixedu.presentationTier.servlets.filters.AnnualTeachingCreditsDocumentFilter.java

protected ByteArrayOutputStream getAnnualTeacherCreditsDocument(ServletRequest arg0, ServletResponse arg1,
        FilterChain arg2, Teacher teacher, ExecutionYear executionYear, RoleType role)
        throws IOException, ServletException {
    HttpServletRequest request = (HttpServletRequest) arg0;
    ResponseWrapper response = (ResponseWrapper) arg1;
    request.setAttribute("teacher", teacher);
    request.setAttribute("executionYear", executionYear);
    arg2.doFilter(arg0, arg1);// www .j  ava2  s.c  o m
    String responseHtml = clean(response.getContent());
    DocumentBuilder builder;
    try {
        builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    } catch (ParserConfigurationException e) {
        throw new IOException(e.getMessage());
    }
    Document doc;
    try {
        doc = builder.parse(new ByteArrayInputStream(responseHtml.getBytes()));
    } catch (SAXException e) {
        throw new IOException(e.getMessage());
    }
    patchLinks(doc, request);
    ITextRenderer renderer = new ITextRenderer();
    renderer.setDocument(doc, "");
    renderer.layout();
    ByteArrayOutputStream pdfStream = new ByteArrayOutputStream();
    try {
        renderer.createPDF(pdfStream);
    } catch (DocumentException e) {
        throw new IOException(e.getMessage());
    }
    return pdfStream;
}