Example usage for org.xml.sax SAXException getMessage

List of usage examples for org.xml.sax SAXException getMessage

Introduction

In this page you can find the example usage for org.xml.sax SAXException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Return a detail message for this exception.

Usage

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

private void read(String sheetName) throws RuntimeException {
    ReadOnlySharedStringsTable strings;/*from   w  w  w .j a  v a 2 s. co 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 (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:org.eclipse.skalli.nexus.internal.NexusClientImpl.java

Element getElementFromUrlResponse(URL nexusUrl) throws IOException, NexusClientException {
    HttpClient client = getClient(nexusUrl);
    HttpGet method = new HttpGet(nexusUrl.toExternalForm());
    HttpResponse response = null;/*  www.  j  a v  a2  s  . c  o m*/
    try {
        LOG.info("GET " + nexusUrl); //$NON-NLS-1$
        response = client.execute(method);
        int status = response.getStatusLine().getStatusCode();
        LOG.info(status + " " + response.getStatusLine().getReasonPhrase()); //$NON-NLS-1$
        if (status == HttpStatus.SC_OK) {
            InputStream in = response.getEntity().getContent();
            Document document;
            try {
                document = XMLUtils.documentFromStream(in);
            } catch (SAXException e) {
                throw new NexusClientException(
                        MessageFormat.format("Problems found for {0}: {1}", nexusUrl, e.getMessage()), e);
            } catch (ParserConfigurationException e) {
                throw new NexusClientException(
                        MessageFormat.format("Problems found for {0}: {1}", nexusUrl, e.getMessage()), e);
            }
            return document.getDocumentElement();
        } else {
            switch (status) {
            case SC_UNAUTHORIZED:
                throw new IOException(MessageFormat.format("{0} found but authentication required", nexusUrl));
            case SC_MOVED_PERMANENTLY:
                throw new IOException(
                        MessageFormat.format("{0} not found. Resource has been moved permanently to {1}",
                                nexusUrl, response.getFirstHeader("Location")));
            default:
                throw new IOException(
                        MessageFormat.format("{0} not found. Host reports a temporary problem: {1} {2}",
                                nexusUrl, status, response.getStatusLine().getReasonPhrase()));
            }
        }
    } finally {
        HttpUtils.consumeQuietly(response);
    }
}

From source file:com.espertech.esperio.http.config.ConfigurationHTTPAdapter.java

/**
 * Use the ConfigurationHTTPAdapter specified by the given XML String.
 * The format of the document obtained from the URL is defined in
 * <tt>esper-configuration-2.0.xsd</tt>.
 *
 * @param xml XML string/*from www  .ja  v a  2 s.  c om*/
 * @return A ConfigurationHTTPAdapter configured via the file
 * @throws RuntimeException is thrown when the URL could not be access
 */
public ConfigurationHTTPAdapter configureFromString(String xml) throws RuntimeException {
    if (log.isInfoEnabled()) {
        log.info("Configuring from string");
    }
    try {
        InputSource source = new InputSource(new StringReader(xml));
        DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
        builderFactory.setNamespaceAware(true);
        Document doc = builderFactory.newDocumentBuilder().parse(source);

        ConfigurationHTTPAdapterParser.doConfigure(this, doc);
        return this;
    } catch (IOException ioe) {
        throw new RuntimeException("could not configure from String: " + ioe.getMessage(), ioe);
    } catch (SAXException e) {
        throw new RuntimeException("could not configure from String: " + e.getMessage(), e);
    } catch (ParserConfigurationException e) {
        throw new RuntimeException("could not configure from String: " + e.getMessage(), e);
    }
}

From source file:com.google.gsa.valve.configuration.ValveConfigurationDigester.java

/**
 * Executes the parameter reading process to get all the configuration
 * attributes present in the security framework.
 * /*from w  w w. java2s . c  om*/
 * @param configurationFile configuration file path
 * @return the valve configuration
 */
public ValveConfiguration run(String configurationFile) {

    //Valve Config definition
    ValveConfiguration valveConfig = null;

    try {
        Digester digester = new Digester();
        digester.setValidating(false);

        //Load individual parameters
        digester.addObjectCreate("GSAValveConfiguration", ValveConfiguration.class);
        digester.addBeanPropertySetter("GSAValveConfiguration/authCookieDomain", "authCookieDomain");
        digester.addBeanPropertySetter("GSAValveConfiguration/authenticationProcessImpl",
                "authenticationProcessImpl");
        digester.addBeanPropertySetter("GSAValveConfiguration/authenticationProcessImpl",
                "authenticationProcessImpl");
        digester.addBeanPropertySetter("GSAValveConfiguration/authorizationProcessImpl",
                "authorizationProcessImpl");
        digester.addBeanPropertySetter("GSAValveConfiguration/authenticateServletPath",
                "authenticateServletPath");
        digester.addBeanPropertySetter("GSAValveConfiguration/authCookiePath", "authCookiePath");
        digester.addBeanPropertySetter("GSAValveConfiguration/authMaxAge", "authMaxAge");
        digester.addBeanPropertySetter("GSAValveConfiguration/authCookieName", "authCookieName");
        digester.addBeanPropertySetter("GSAValveConfiguration/refererCookieName", "refererCookieName");
        digester.addBeanPropertySetter("GSAValveConfiguration/loginUrl", "loginUrl");
        digester.addBeanPropertySetter("GSAValveConfiguration/maxConnectionsPerHost", "maxConnectionsPerHost");
        digester.addBeanPropertySetter("GSAValveConfiguration/maxTotalConnections", "maxTotalConnections");
        digester.addBeanPropertySetter("GSAValveConfiguration/testFormsCrawlUrl", "testFormsCrawlUrl");
        digester.addBeanPropertySetter("GSAValveConfiguration/errorLocation", "errorLocation");

        //Call Method addSearchHost that takes a single parameter
        digester.addCallMethod("GSAValveConfiguration/searchHost", "addSearchHost", 1);

        //Set value of the parameter for the addSearchHost method
        digester.addCallParam("GSAValveConfiguration/searchHost", 0);

        //Krb, Sessions and SAML
        digester.addObjectCreate("GSAValveConfiguration/kerberos", ValveKerberosConfiguration.class);
        digester.addSetProperties("GSAValveConfiguration/kerberos", "isKerberos", "isKerberos");
        digester.addSetProperties("GSAValveConfiguration/kerberos", "isNegotiate", "isNegotiate");
        digester.addSetProperties("GSAValveConfiguration/kerberos", "krbini", "krbini");
        digester.addSetProperties("GSAValveConfiguration/kerberos", "krbconfig", "krbconfig");
        digester.addSetProperties("GSAValveConfiguration/kerberos", "KrbAdditionalAuthN", "KrbAdditionalAuthN");
        digester.addSetProperties("GSAValveConfiguration/kerberos", "KrbLoginUrl", "KrbLoginUrl");
        digester.addSetProperties("GSAValveConfiguration/kerberos", "KrbUsrPwdCrawler", "KrbUsrPwdCrawler");
        digester.addSetProperties("GSAValveConfiguration/kerberos", "KrbUsrPwdCrawlerUrl",
                "KrbUsrPwdCrawlerUrl");
        digester.addSetNext("GSAValveConfiguration/kerberos", "setKrbConfig");

        digester.addObjectCreate("GSAValveConfiguration/sessions", ValveSessionConfiguration.class);
        digester.addSetProperties("GSAValveConfiguration/sessions", "isSessionEnabled", "isSessionEnabled");
        digester.addSetProperties("GSAValveConfiguration/sessions", "sessionTimeout", "sessionTimeout");
        digester.addSetProperties("GSAValveConfiguration/sessions", "sessionCleanup", "sessionCleanup");
        digester.addSetProperties("GSAValveConfiguration/sessions", "sendCookies", "sendCookies");

        digester.addSetNext("GSAValveConfiguration/sessions", "setSessionConfig");

        digester.addObjectCreate("GSAValveConfiguration/saml", ValveSAMLConfiguration.class);
        digester.addSetProperties("GSAValveConfiguration/saml", "isSAML", "isSAML");
        digester.addSetProperties("GSAValveConfiguration/saml", "maxArtifactAge", "maxArtifactAge");
        digester.addSetProperties("GSAValveConfiguration/saml", "samlTimeout", "samlTimeout");
        digester.addSetNext("GSAValveConfiguration/saml", "setSAMLConfig");

        digester.addObjectCreate("GSAValveConfiguration/repository", ValveRepositoryConfiguration.class);
        digester.addSetProperties("GSAValveConfiguration/repository", "id", "id");
        digester.addSetProperties("GSAValveConfiguration/repository", "pattern", "pattern");
        digester.addSetProperties("GSAValveConfiguration/repository", "authN", "authN");
        digester.addSetProperties("GSAValveConfiguration/repository", "authZ", "authZ");
        digester.addSetProperties("GSAValveConfiguration/repository", "failureAllow", "failureAllow");
        digester.addSetProperties("GSAValveConfiguration/repository", "checkAuthN", "checkAuthN");

        digester.addObjectCreate("GSAValveConfiguration/repository/P", ValveRepositoryParameter.class);
        digester.addSetProperties("GSAValveConfiguration/repository/P", "N", "name");
        digester.addSetProperties("GSAValveConfiguration/repository/P", "V", "value");
        digester.addSetNext("GSAValveConfiguration/repository/P", "addParameter");

        digester.addSetNext("GSAValveConfiguration/repository", "addRepository");

        //Read and parse the file
        File inputFile = new File(configurationFile);
        valveConfig = (ValveConfiguration) digester.parse(inputFile);

    } catch (IOException ioexp) {
        logger.error("Failed to read from configuration file: " + configurationFile, ioexp);

    } catch (SAXException e) {
        logger.error("SAX Exception when reading configuration file: " + e.getMessage(), e);
        e.printStackTrace();
    }

    return valveConfig;

}

From source file:org.openintents.lib.DeliciousApiHelper.java

public String[] getTags() throws java.io.IOException {

    String[] result = null;//from  w  w w  . j  av a 2  s.  c  om
    String rpc = mAPI + "tags/get";
    Element tag;
    java.net.URL u = null;

    try {
        u = new URL(rpc);

    } catch (java.net.MalformedURLException mu) {
        System.out.println("Malformed URL>>" + mu.getMessage());
    }

    Document doc = null;

    try {
        javax.net.ssl.HttpsURLConnection connection = (javax.net.ssl.HttpsURLConnection) u.openConnection();
        //that's actualy pretty ugly to do, but a neede workaround for m5.rc15
        javax.net.ssl.HostnameVerifier v = new org.apache.http.conn.ssl.AllowAllHostnameVerifier();

        connection.setHostnameVerifier(v);

        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();

        doc = db.parse(connection.getInputStream());

    } catch (java.io.IOException ioe) {
        System.out.println("Error >>" + ioe.getMessage());
        Log.e(_TAG, "Error >>" + ioe.getMessage());

    } catch (ParserConfigurationException pce) {
        System.out.println("ERror >>" + pce.getMessage());
        Log.e(_TAG, "ERror >>" + pce.getMessage());
    } catch (SAXException se) {
        System.out.println("ERRROR>>" + se.getMessage());
        Log.e(_TAG, "ERRROR>>" + se.getMessage());

    } catch (Exception e) {
        Log.e(_TAG, "Error while excecuting HTTP method. URL is: " + u);
        System.out.println("Error while excecuting HTTP method. URL is: " + u);
        e.printStackTrace();
    }

    if (doc == null) {
        Log.e(_TAG, "document was null, check internet connection?");
        throw new java.io.IOException("Error reading stream >>" + rpc + "<<");

    }
    int tagsLen = doc.getElementsByTagName("tag").getLength();
    result = new String[tagsLen];
    for (int i = 0; i < tagsLen; i++) {
        tag = (Element) doc.getElementsByTagName("tag").item(i);
        result[i] = new String(tag.getAttribute("tag").trim());
    }

    //System.out.println( new Scanner( u.openStream() ).useDelimiter( "\\Z" ).next() );
    return result;
}

From source file:com.espertech.esperio.db.config.ConfigurationDBAdapter.java

/**
 * Use the ConfigurationDBAdapter specified by the given XML String.
 * The format of the document obtained from the URL is defined in
 * <tt>esper-configuration-2.0.xsd</tt>.
 *
 * @param xml XML string//from  w  ww  . j  av  a  2  s .  co  m
 * @return A ConfigurationDBAdapter configured via the file
 * @throws RuntimeException is thrown when the URL could not be access
 */
public ConfigurationDBAdapter configureFromString(String xml) throws RuntimeException {
    if (log.isInfoEnabled()) {
        log.info("Configuring from string");
    }
    try {
        InputSource source = new InputSource(new StringReader(xml));
        DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
        builderFactory.setNamespaceAware(true);
        Document doc = builderFactory.newDocumentBuilder().parse(source);

        ConfigurationDBAdapterParser.doConfigure(this, doc);
        return this;
    } catch (IOException ioe) {
        throw new RuntimeException("could not configure from String: " + ioe.getMessage(), ioe);
    } catch (SAXException e) {
        throw new RuntimeException("could not configure from String: " + e.getMessage(), e);
    } catch (ParserConfigurationException e) {
        throw new RuntimeException("could not configure from String: " + e.getMessage(), e);
    }
}

From source file:com.aurel.track.admin.customize.category.filter.tree.io.TreeFilterParser.java

private void parse(String xml) {
    //get a factory
    SAXParserFactory spf = SAXParserFactory.newInstance();
    try {// w  ww.j av  a 2  s .c o  m
        //get a new instance of parser
        SAXParser sp = spf.newSAXParser();
        //parse the file and also register this class for call backs
        InputSource is = new InputSource(new StringReader(xml));
        sp.parse(is, this);
    } catch (SAXException se) {
        LOGGER.warn("Parsing expression: " + xml + " failed with " + se.getMessage());
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(ExceptionUtils.getStackTrace(se));
        }
    } catch (ParserConfigurationException pce) {
        LOGGER.warn("Parsing expression: " + xml + " failed with " + pce.getMessage());
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(ExceptionUtils.getStackTrace(pce));
        }
    } catch (IOException ie) {
        LOGGER.warn("Reading expression: " + xml + " failed with " + ie.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(ie));
    }
}

From source file:net.i2cat.netconf.transport.SSHTransport.java

public SSHTransport() {
    listeners = new Vector<TransportListener>();

    xmlHandler = new TransportContentParser();

    // populate/*from w  ww  . j  a v a2 s . com*/
    try {
        parser = XMLReaderFactory.createXMLReader();
        parser.setContentHandler(xmlHandler);
        parser.setErrorHandler(xmlHandler);
    } catch (SAXException e) {
        log.error(e.getMessage());
    }
}

From source file:net.sf.joost.trax.TrAXFilter.java

/**
 * Parses the <code>InputSource</code>
 * @param input A <code>InputSource</code> object.
 * @throws SAXException/*from   w  w  w.  j a v  a2 s . c o  m*/
 * @throws IOException
 */
public void parse(InputSource input) throws SAXException, IOException {

    Transformer transformer = null;
    if (DEBUG) {
        if (log.isDebugEnabled())
            log.debug("parsing InputSource " + input.getSystemId());
    }

    try {
        // get a new Transformer
        transformer = this.templates.newTransformer();
        if (transformer instanceof TransformerImpl) {
            this.processor = ((TransformerImpl) transformer).getStxProcessor();
        } else {
            String msg = "An error is occured, because the given transformer is "
                    + "not an instance of TransformerImpl";
            if (log != null)
                log.fatal(msg);
            else
                System.err.println("Fatal error - " + msg);

        }
        XMLReader parent = this.getParent();

        if (parent == null) {
            parent = XMLReaderFactory.createXMLReader();
            setParent(parent);
        }
        ContentHandler handler = this.getContentHandler();

        if (handler == null) {
            handler = parent.getContentHandler();
        }
        if (handler == null) {
            throw new SAXException("no ContentHandler registered");
        }
        //init StxEmitter
        StxEmitter out = null;

        //SAX specific Implementation
        out = new SAXEmitter(handler);

        if (this.processor != null) {
            this.processor.setContentHandler(out);
            this.processor.setLexicalHandler(out);
        } else {
            throw new SAXException("Joost-Processor is not correct configured.");
        }
        if (parent == null) {
            throw new SAXException("No parent for filter");
        }
        parent.setContentHandler(this.processor);
        parent.setProperty("http://xml.org/sax/properties/lexical-handler", this.processor);
        parent.setEntityResolver(this);
        parent.setDTDHandler(this);
        parent.setErrorHandler(this);
        parent.parse(input);

    } catch (TransformerConfigurationException tE) {
        try {
            configErrListener.fatalError(tE);
        } catch (TransformerConfigurationException innerE) {
            throw new SAXException(innerE.getMessage(), innerE);
        }
    } catch (SAXException sE) {
        try {
            configErrListener.fatalError(new TransformerConfigurationException(sE.getMessage(), sE));
        } catch (TransformerConfigurationException innerE) {
            throw new SAXException(innerE.getMessage(), innerE);
        }
    } catch (IOException iE) {
        try {
            configErrListener.fatalError(new TransformerConfigurationException(iE.getMessage(), iE));
        } catch (TransformerConfigurationException innerE) {
            throw new IOException(innerE.getMessage());
        }
    }
}

From source file:de.drv.dsrv.spoc.web.webservice.jax.ExtraSchemaValidationHandler.java

private void validateExtraRequest(final Node transportNode, final ServletContext servletContext)
        throws Exception {

    // Validator-Objekt mit eXTra-Schema als Basis erstellen
    final SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    final Schema schema = factory.newSchema(servletContext.getResource(SCHEMA_PATH));
    final Validator validator = schema.newValidator();

    try {/*w  w w .  j a  v  a2s  .  c  o  m*/
        // Validiere Transport-Element gegen eXTra-Schema
        validator.validate(new DOMSource(transportNode));
    } catch (final SAXException e) {
        // Falls MTOM-Attachement, dann den Fehler bzgl. cid-Referenz
        // ignorieren
        if (!(e.getMessage().contains("cid:") && e.getMessage().contains("'base64Binary'"))) {
            LOG.warn("Fehler bei der XML-Validierung: " + e.getMessage());
            throw new InvalidExtraRequestException(e.getMessage());
        }
    }
}