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:net.jcreate.xkins.XkinsLoader.java

/**
 * Carga los skins. Mtodo privado que utilizan los dems. Usa el Digester.
 * @param in/*from   www.j  a  v a2s  .c om*/
 * @param xk
 * @return
 * @throws XkinsException
 */
private Xkins loadSkins(InputStream in, Xkins xk) throws XkinsException {
    try {
        Digester digester = new Digester();
        Xkins xkLoading = new Xkins();
        URL url = this.getClass().getResource(this.dtd);
        if (url != null) {
            digester.register(this.registration, url.toString());
            //digester.setValidating(true);
        }
        digester.push(xkLoading);
        digester.addSetProperties("xkins");
        //Crea los Skins
        digester.addFactoryCreate("xkins/skin", new SkinFactory(xkLoading));
        digester.addSetProperties("xkins/skin");
        digester.addSetProperty("xkins/skin/set-property", "property", "value");
        digester.addSetTop("xkins/skin", "setXkins", XKINS_CLASS_NAME);

        digester.addObjectCreate("xkins/global-processor", PROCESSOR_CLASS_NAME);
        digester.addSetProperties("xkins/global-processor");
        digester.addSetNext("xkins/global-processor", "addProcessor", PROCESSOR_CLASS_NAME);

        this.skinDigester(digester, "xkins/");

        //Agrega el skin
        digester.addSetNext("xkins/skin", "addSkin", SKIN_CLASS_NAME);
        try {
            // Parse the input stream to initialize our database
            digester.parse(in);
            in.close();
        } catch (SAXException e) {
            System.out.println(":" + e.getMessage());
            System.out.println(":" + e);
            e.printStackTrace();
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (Exception e) {
                }
            }
        }
        this.loadSkinsDefinition(xkLoading);
        //copio los xkins cargados al xk
        Iterator it = xkLoading.getSkins().keySet().iterator();
        while (it.hasNext()) {
            String skinName = (String) it.next();
            Skin sk = (Skin) xkLoading.getSkins().get(skinName);
            sk.setXkins(xk);
            xk.addSkin(sk);
        }
        XkinsLoadEvent xle = new XkinsLoadEvent(this);
        xle.setXkins(xk);
        xk.sendEvent(xle);
        xk.addProcessors(xkLoading.getProcessors());
        return xk;
    } catch (Throwable thr) {
        thr.printStackTrace();
        throw new XkinsException(thr);
    }
}

From source file:de.nware.app.hsDroid.provider.onlineService2Provider.java

/**
 * Parses the exam info.//  w w w.  j a v a  2 s. c om
 * 
 * @param htmlContentString
 *            der/die/das html content string
 * @return der/die/das cursor
 * @throws SAXException
 */
private Cursor parseExamInfo(String htmlContentString) throws SAXException {
    final MatrixCursor cursor = new MatrixCursor(EXAM_INFOS_COLUMNS);
    try {
        ExamInfoParser handler = new ExamInfoParser();
        System.out.println("content exam info: " + htmlContentString);
        Xml.parse(htmlContentString, handler);
        ExamInfo exInfos = handler.getExamInfos();
        cursor.addRow(new Object[] { 0, exInfos.getSehrGutAmount(), exInfos.getGutAmount(),
                exInfos.getBefriedigendAmount(), exInfos.getAusreichendAmount(),
                exInfos.getNichtAusreichendAmount(), exInfos.getAttendees(), exInfos.getAverage() });
    } catch (SAXException e) {
        Log.e("read:SAXException:", e.getMessage());
        e.printStackTrace();
        throw new SAXException(e);
    }
    return cursor;
}

From source file:de.nware.app.hsDroid.provider.onlineService2Provider.java

/**
 * Notenspiegel Lesen/*from  w  ww .j a  va  2  s.com*/
 * 
 * @param htmlContent
 *            html content
 * @return integer[] mit gesamt anzahl der Prfungsleistungen und anzahl der
 *         Neuen Prfungen
 */
private Integer[] read(String htmlContent) {
    Integer[] counter = { 0, 0 };
    try {

        ExamParser handler = new ExamParser();
        Xml.parse(htmlContent, handler);

        for (Exam iterable_element : handler.getExams()) {
            // Log.d(TAG, "update: lid: " + iterable_element.getInfoID());
            if (!examExists(iterable_element.getExamNr(), iterable_element.getExamDate())) {
                counter[1]++;
                // Log.d(TAG, "exam: insert " +
                // iterable_element.getExamName() + " into DB");
                ContentValues values = new ContentValues();
                values.put(onlineService2Data.ExamsCol.SEMESTER, iterable_element.getSemester());
                // values.put(onlineService2Data.ExamsCol.PASSED,
                // (iterable_element.isPassed() ? 1 : 0));
                values.put(onlineService2Data.ExamsCol.PASSED, iterable_element.isPassed());
                values.put(onlineService2Data.ExamsCol.EXAMNAME, iterable_element.getExamName());
                values.put(onlineService2Data.ExamsCol.EXAMNR, iterable_element.getExamNr());
                values.put(onlineService2Data.ExamsCol.EXAMDATE, iterable_element.getExamDate());
                values.put(onlineService2Data.ExamsCol.ADMITTED, iterable_element.getAdmitted());
                values.put(onlineService2Data.ExamsCol.NOTATION, iterable_element.getNotation());
                values.put(onlineService2Data.ExamsCol.ATTEMPTS, iterable_element.getAttempts());
                values.put(onlineService2Data.ExamsCol.GRADE, iterable_element.getGrade());
                values.put(onlineService2Data.ExamsCol.LINKID, iterable_element.getInfoID());
                values.put(onlineService2Data.ExamsCol.STUDIENGANG, iterable_element.getStudiengang());
                // Log.d(TAG, "insert..");
                insert(onlineService2Data.ExamsCol.CONTENT_URI, values);
            } else {
                // Log.d(TAG, "exam: " + iterable_element.getExamName() +
                // " already in DB");
            }
            counter[0]++;
        }
    } catch (SAXException e) {
        Log.e("read:SAXException:", e.getMessage());
        e.printStackTrace();
    }
    return counter;
}

From source file:com.obidea.semantika.app.ApplicationFactory.java

protected ApplicationFactory doConfigure(InputStream stream, String resourceName)
        throws ConfigurationException {
    Document doc = null;/*w  w w  . j a  v  a  2 s  .  c o m*/
    try {
        List<SAXParseException> errorList = new ArrayList<SAXParseException>();
        doc = mXmlHelper.createDocumentBuilder(resourceName, errorList, XmlHelper.DEFAULT_DTD_RESOLVER)
                .parse(stream);
        if (errorList.size() != 0) {
            throw new ConfigurationException("Invalid configuration", errorList.get(0)); //$NON-NLS-1$
        }
    } catch (SAXException e) {
        throw new ConfigurationException("Syntax error", e); //$NON-NLS-1$
    } catch (IOException e) {
        throw new ConfigurationException("Configuration loading error", e); //$NON-NLS-1$
    } catch (ParserConfigurationException e) {
        throw new ConfigurationException("Configuration error", e); //$NON-NLS-1$
    } finally {
        try {
            stream.close();
        } catch (IOException e) {
            LOG.warn("Could not close input stream {}", resourceName); //$NON-NLS-1$
            LOG.warn("Detailed cause: {}", e.getMessage()); //$NON-NLS-1$
        }
    }
    return doConfigure(doc);
}

From source file:ddf.test.itests.platform.TestSingleSignOn.java

private void validateSaml(String xml, SamlSchema schema) throws IOException {

    // Prepare the schema and xml
    String schemaFileName = "saml-schema-" + schema.toString().toLowerCase() + "-2.0.xsd";
    URL schemaURL = getClass().getClassLoader().getResource(schemaFileName);
    StreamSource streamSource = new StreamSource(new StringReader(xml));

    // If we fail to create a validator we don't want to stop the show, so we just log a warning
    Validator validator = null;//from  ww w . ja v a 2  s . c o  m
    try {
        validator = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(schemaURL)
                .newValidator();
    } catch (SAXException e) {
        LOGGER.warn("Exception creating validator. ", e);
    }

    // If the xml is invalid, then we want to fail completely
    if (validator != null) {
        try {
            validator.validate(streamSource);
        } catch (SAXException e) {
            fail("Failed to validate SAML " + e.getMessage());
        }
    }
}

From source file:com.sshtools.common.configuration.SshToolsConnectionProfile.java

/**
 *
 *
 * @param in/* ww  w  .j ava  2 s . c  o  m*/
 *
 * @throws InvalidProfileFileException
 */
public void open(InputStream in) throws InvalidProfileFileException {
    try {
        SAXParserFactory saxFactory = SAXParserFactory.newInstance();
        SAXParser saxParser = saxFactory.newSAXParser();
        XMLHandler handler = new XMLHandler();
        saxParser.parse(in, handler);
        handler = null;

        //            in.close();
    } catch (IOException ioe) {
        throw new InvalidProfileFileException("IO error. " + ioe.getMessage());
    } catch (SAXException sax) {
        throw new InvalidProfileFileException("SAX Error: " + sax.getMessage());
    } catch (ParserConfigurationException pce) {
        throw new InvalidProfileFileException("SAX Parser Error: " + pce.getMessage());
    } finally {
    }
}

From source file:eu.eidas.auth.engine.core.stork.StorkExtensionProcessor.java

private static void parseSignedDoc(List<XMLObject> attributeValues, String value) {
    Document document;/*w w  w.  j a  v a 2  s .  c  om*/

    // Parse the signedDoc value into an XML DOM Document
    try {
        document = DocumentBuilderFactoryUtil.parse(value);
    } catch (SAXException e1) {
        LOG.info("ERROR : SAX Error while parsing signModule attribute", e1.getMessage());
        LOG.debug("ERROR : SAX Error while parsing signModule attribute", e1);
        throw new EIDASSAMLEngineRuntimeException(e1);
    } catch (ParserConfigurationException e2) {
        LOG.info("ERROR : Parser Configuration Error while parsing signModule attribute", e2.getMessage());
        LOG.debug("ERROR : Parser Configuration Error while parsing signModule attribute", e2);
        throw new EIDASSAMLEngineRuntimeException(e2);
    } catch (IOException e4) {
        LOG.info("ERROR : IO Error while parsing signModule attribute", e4.getMessage());
        LOG.debug("ERROR : IO Error while parsing signModule attribute", e4);
        throw new EIDASSAMLEngineRuntimeException(e4);
    }

    // Create the XML statement(this will be overwritten with the previous DOM structure)
    final XSAny xmlValue = (XSAny) BuilderFactoryUtil.buildXmlObject(XML_VALUE_TYPE, XSAny.TYPE_NAME);

    //Set the signedDoc XML content to this element
    xmlValue.setDOM(document.getDocumentElement());

    // Create the attribute statement
    final XSAny attrValue = (XSAny) BuilderFactoryUtil.buildXmlObject(STORK_REQUESTED_ATTRIBUTE_VALUE_TYPE,
            XSAny.TYPE_NAME);

    //Add previous signedDocXML to the AttributeValue Element
    attrValue.getUnknownXMLObjects().add(xmlValue);

    attributeValues.add(attrValue);
}

From source file:edu.lternet.pasta.dml.dataquery.DataquerySpecification.java

/**
 * construct an instance of the QuerySpecification class
 *
 * @param queryspec//from ww w . j  a va  2s . c  o  m
 *            the XML representation of the query (should conform to
 *            dataquery.xsd) as a Reader
 * @param parserName
 *            the fully qualified name of a Java Class implementing the
 *            org.xml.sax.Parser interface
 */
public DataquerySpecification(Reader queryspec, String parserName,
        DatabaseConnectionPoolInterface connectionPool, EcogridEndPointInterface ecogridEndPoint)
        throws IOException {
    super();

    //for the DataManager
    this.connectionPool = connectionPool;
    this.ecogridEndPoint = ecogridEndPoint;

    // Initialize the class variables
    this.parserName = parserName;

    // Initialize the parser and read the queryspec
    XMLReader parser = initializeParser();
    if (parser == null) {
        log.error("SAX parser not instantiated properly.");
    }
    try {
        parser.parse(new InputSource(queryspec));
    } catch (SAXException e) {
        log.error("error parsing data in " + "DataquerySpecification.DataquerySpecification");
        log.error(e.getMessage());
    }
}

From source file:com.liferay.portal.struts.PortalTilesDefinitionsFactory.java

/**
 * Parse specified xml file and add definition to specified definitions set.
 * This method is used to load several description files in one instances list.
 * If filename exists and definition set is <code>null</code>, create a new set. Otherwise, return
 * passed definition set (can be <code>null</code>).
 * @param servletContext Current servlet context. Used to open file.
 * @param filename Name of file to parse.
 * @param xmlDefinitions Definitions set to which definitions will be added. If null, a definitions
 * set is created on request./*  w  w  w .j  a  va2s .  c om*/
 * @return XmlDefinitionsSet The definitions set created or passed as parameter.
 * @throws DefinitionsFactoryException On errors parsing file.
 */
private XmlDefinitionsSet parseXmlFile(ServletContext servletContext, String filename,
        XmlDefinitionsSet xmlDefinitions) throws DefinitionsFactoryException {

    try {
        InputStream input = servletContext.getResourceAsStream(filename);
        // Try to load using real path.
        // This allow to load config file under websphere 3.5.x
        // Patch proposed Houston, Stephen (LIT) on 5 Apr 2002
        if (null == input) {
            try {
                input = new java.io.FileInputStream(servletContext.getRealPath(filename));
            } catch (Exception e) {
            }
        }

        // If the config isn't in the servlet context, try the class loader
        // which allows the config files to be stored in a jar
        if (input == null) {
            input = getClass().getResourceAsStream(filename);
        }

        // If still nothing found, this mean no config file is associated
        if (input == null) {
            if (log.isDebugEnabled()) {
                log.debug("Can't open file '" + filename + "'");
            }
            return xmlDefinitions;
        }

        // Check if parser already exist.
        // Doesn't seem to work yet.
        //if( xmlParser == null )
        if (true) {
            xmlParser = new XmlParser();
            xmlParser.setValidating(isValidatingParser);
        }

        // Check if definition set already exist.
        if (xmlDefinitions == null) {
            xmlDefinitions = new XmlDefinitionsSet();
        }

        xmlParser.parse(input, xmlDefinitions);

    } catch (SAXException ex) {
        if (log.isDebugEnabled()) {
            log.debug("Error while parsing file '" + filename + "'.");
            ex.printStackTrace();
        }
        throw new DefinitionsFactoryException("Error while parsing file '" + filename + "'. " + ex.getMessage(),
                ex);

    } catch (IOException ex) {
        throw new DefinitionsFactoryException(
                "IO Error while parsing file '" + filename + "'. " + ex.getMessage(), ex);
    }

    return xmlDefinitions;
}

From source file:edu.unc.lib.dl.ingest.sip.METSPackageSIPProcessor.java

private void xsdValidate(File metsFile2) throws IngestException {
    // TODO can reuse schema object, it is thread safe
    javax.xml.validation.SchemaFactory schemaFactory = javax.xml.validation.SchemaFactory
            .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    StreamSource xml = new StreamSource(getClass().getResourceAsStream(schemaPackage + "xml.xsd"));
    StreamSource xlink = new StreamSource(getClass().getResourceAsStream(schemaPackage + "xlink.xsd"));
    StreamSource mets = new StreamSource(getClass().getResourceAsStream(schemaPackage + "mets.xsd"));
    StreamSource premis = new StreamSource(getClass().getResourceAsStream(schemaPackage + "premis-v2-0.xsd"));
    StreamSource mods = new StreamSource(getClass().getResourceAsStream(schemaPackage + "mods-3-4.xsd"));
    StreamSource acl = new StreamSource(getClass().getResourceAsStream(schemaPackage + "acl.xsd"));
    Schema schema;//  w  w w.  j a  v a2 s .  c om
    try {
        Source[] sources = { xml, xlink, mets, premis, mods, acl };
        schema = schemaFactory.newSchema(sources);
    } catch (SAXException e) {
        throw new Error("Cannot locate METS schema in classpath.", e);
    }

    Validator metsValidator = schema.newValidator();
    METSParseException handler = new METSParseException("There was a problem parsing METS XML.");
    metsValidator.setErrorHandler(handler);
    // TODO get a Result document for reporting error
    try {
        metsValidator.validate(new StreamSource(metsFile2));
    } catch (SAXException e) {
        if (log.isDebugEnabled()) {
            log.debug(e.getMessage());
        }
        throw handler;
    } catch (IOException e) {
        throw new IngestException("The supplied METS file is not readable.", e);
    }
}