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:org.pentaho.pac.server.biplatformproxy.xmlserializer.SubscriptionXmlSerializer.java

public void detectSubscriptionErrorInXml(String strXml) throws SchedulerServiceException {

    SubscriptionErrorParserHandler errorHandler;
    try {/*from  ww  w.  j a  v a2s.  c o m*/
        errorHandler = parseSubscriptionErrorXml(strXml);
    } catch (SAXException e) {
        logger.error(e.getMessage());
        throw new SchedulerServiceException(e.getMessage());
    } catch (IOException e) {
        logger.error(e.getMessage());
        throw new SchedulerServiceException(e.getMessage());
    } catch (ParserConfigurationException e) {
        logger.error(e.getMessage());
        throw new SchedulerServiceException(e.getMessage());
    }
    if (null != errorHandler.errorMessage) {
        throw new SchedulerServiceException(errorHandler.errorMessage);
    }
}

From source file:org.pentaho.pac.server.biplatformproxy.xmlserializer.XActionXmlSerializer.java

public String getXActionResponseStatusFromXml(String strXml) throws XmlSerializerException {
    XActionResponseParserHandler h = null;
    try {// w w  w  . j  a v a2s . c  o  m
        h = parseXActionResponseXml(strXml);
    } catch (SAXException e) {
        logger.error(e.getMessage());
        throw new XmlSerializerException(e.getMessage());
    } catch (IOException e) {
        logger.error(e.getMessage());
        throw new XmlSerializerException(e.getMessage());
    } catch (ParserConfigurationException e) {
        logger.error(e.getMessage());
        throw new XmlSerializerException(e.getMessage());
    }
    return h.getErrorMsg();
}

From source file:org.pentaho.reporting.tools.configeditor.model.ModuleNodeFactory.java

public void load(final InputStream in, final boolean append) throws IOException {
    if (append == false) {
        configEntryLookup.clear();/* w ww. j a va 2  s.  com*/
    }
    final ConfigDescriptionModel model = new ConfigDescriptionModel();
    try {
        model.load(in);
    } catch (SAXException saxException) {
        final String error = messages.getString("ModuleNodeFactory.ERROR_0001_PARSE_FAILURE",
                saxException.getMessage()); //$NON-NLS-1$
        ModuleNodeFactory.logger.error(error, saxException);
        throw new IOException(error);
    } catch (ParserConfigurationException pE) {
        final String error = messages.getString("ModuleNodeFactory.ERROR_0002_PARSER_CONFIG_ERROR",
                pE.getMessage()); //$NON-NLS-1$
        ModuleNodeFactory.logger.error(error, pE);
        throw new IOException(error);
    }

    final ConfigDescriptionEntry[] entries = model.toArray();
    for (int i = 0; i < entries.length; i++) {
        //Log.debug ("Entry: " + entries[i].getKeyName() + " registered");
        configEntryLookup.put(entries[i].getKeyName(), entries[i]);
    }
}

From source file:org.photovault.common.Test_NewSchemaMigration.java

/** 
 Add the tables from previous schema and populate with data from 
 testfiles/migration_test_data_0.5.0.xml.
 *///w  w w  .  j  a  v  a 2  s .co  m
@BeforeClass
public void setUpTestCase() throws DdlUtilsException, SQLException, IOException {
    PVDatabase db = PhotovaultSettings.getSettings().getCurrentDatabase();
    int oldVersion = db.getSchemaVersion();

    // Find needed information fr DdlUtils
    Session session = HibernateUtil.getSessionFactory().openSession();

    Platform platform = null;
    if (db.getDbDescriptor() instanceof DerbyDescriptor) {
        platform = PlatformFactory.createNewPlatformInstance("derby");
    } else if (db.getDbDescriptor() instanceof MysqlDescriptor) {
        platform = PlatformFactory.createNewPlatformInstance("mysql");
    }
    platform.getPlatformInfo().setDelimiterToken("");

    // Get the database schema XML file
    InputStream schemaIS = getClass().getClassLoader().getResourceAsStream("db_schema_0.5.0.xml");
    DatabaseIO dbio = new DatabaseIO();
    dbio.setValidateXml(false);
    Database dbModel = dbio.read(new InputStreamReader(schemaIS));

    // Alter tables to match corrent schema
    Transaction tx = session.beginTransaction();
    final Connection con = session.connection();
    DataSource ds = new DataSource() {

        public Connection getConnection() throws SQLException {
            return con;
        }

        public Connection getConnection(String arg0, String arg1) throws SQLException {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public PrintWriter getLogWriter() throws SQLException {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void setLogWriter(PrintWriter arg0) throws SQLException {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void setLoginTimeout(int arg0) throws SQLException {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public int getLoginTimeout() throws SQLException {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public <T> T unwrap(Class<T> arg0) throws SQLException {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public boolean isWrapperFor(Class<?> arg0) throws SQLException {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    };
    platform.createTables(con, dbModel, false, true);
    DbInfo dbinfo = DbInfo.getDbInfo();
    dbinfo.setVersion(11);
    session.update(dbinfo);
    session.flush();
    tx.commit();

    // Load data
    // Insert the seed data to database
    platform = PlatformFactory.createNewPlatformInstance("derby");
    platform.getPlatformInfo().setDelimiterToken("");
    platform.setDataSource(ds);
    DataToDatabaseSink sink = new DataToDatabaseSink(platform, dbModel);
    DataReader reader = new DataReader();
    reader.setModel(dbModel);
    reader.setSink(sink);
    try {
        sink.start();
        reader.parse(new File("testfiles", "migration_test_data_0.5.0.xml"));
        sink.end();
    } catch (SAXException ex) {
        log.error("SAXException: " + ex.getMessage(), ex);
    } catch (IOException ex) {
        log.error("IOException: " + ex.getMessage(), ex);
    }
    initTestVolume(db);
    initTestExtVolume(db);
    session.close();
}

From source file:org.photovault.image.Test_ChannelMapOperation.java

/**
 Test that converting ChannelMapOperation to its XML representation and back to 
 java object creates an identical object.
 *//*from w  ww  .j ava  2 s .com*/
@Test
public void testXmlConvert() {
    ChannelMapOperationFactory f = new ChannelMapOperationFactory();
    ColorCurve r = new ColorCurve();
    r.addPoint(0.0, 0.1);
    r.addPoint(0.2, 0.4);
    r.addPoint(1.0, 1.0);
    f.setChannelCurve("red", r);
    ColorCurve b = new ColorCurve();
    b.addPoint(0.0, 0.2);
    b.addPoint(0.4, 0.4);
    b.addPoint(1.0, 0.9);
    f.setChannelCurve("blue", b);
    ChannelMapOperation o = f.create();

    String xml = o.getAsXml();
    ChannelMapOperation o2 = null;
    Digester d = new Digester();
    d.addRuleSet(new ChannelMapRuleSet());
    try {
        ChannelMapOperationFactory f2 = (ChannelMapOperationFactory) d.parse(new StringReader(xml));
        o2 = f2.create();
    } catch (SAXException ex) {
        fail(ex.getMessage());
    } catch (IOException ex) {
        fail(ex.getMessage());
    }
    assertEquals(o, o2);
}

From source file:org.rhq.plugins.diameter.jbossas5.util.JnpConfig.java

private void read(File distributionDirectory, File file) throws IOException {
    try {//from  w ww .  j a  va2 s.  c  o  m
        parseServiceXML(distributionDirectory, file);
    } catch (SAXException e) {
        throw new IllegalArgumentException(e.getMessage());
    } catch (ParserConfigurationException e) {
        throw new IllegalArgumentException(e.getMessage());
    }

    // Not in that first xml - let's try the binding service xml...
    if (this.jnpPort == null && this.storeFile != null) {
        parseBindingManagerXML();
    }
}

From source file:org.rhq.plugins.jbossas.util.JnpConfig.java

private void read(File file) throws IOException {
    try {//from   w  ww.  j a v a  2s  . com
        parseServiceXML(file);
    } catch (SAXException e) {
        throw new IllegalArgumentException(e.getMessage());
    } catch (ParserConfigurationException e) {
        throw new IllegalArgumentException(e.getMessage());
    }

    // Not in that first xml - let's try the binding service xml...
    if (this.jnpPort == null && this.storeFile != null) {
        parseBindingManagerXML();
    }
}

From source file:org.roda.core.common.RodaUtils.java

/**
 * INFO 20160711 this method does not cache stylesheet related resources
 *//*w w  w  .  j av a 2  s . co  m*/
public static void applyStylesheet(Reader xsltReader, Reader fileReader, Map<String, String> parameters,
        Writer result) throws IOException, TransformerException {

    TransformerFactory factory = new net.sf.saxon.TransformerFactoryImpl();
    factory.setURIResolver(new RodaURIFileResolver());
    Source xsltSource = new StreamSource(xsltReader);
    Transformer transformer = factory.newTransformer(xsltSource);
    for (Entry<String, String> parameter : parameters.entrySet()) {
        transformer.setParameter(parameter.getKey(), parameter.getValue());
    }
    try {
        XMLReader xmlReader = XMLReaderFactory.createXMLReader();
        xmlReader.setEntityResolver(new RodaEntityResolver());
        InputSource source = new InputSource(fileReader);
        Source text = new SAXSource(xmlReader, source);
        transformer.transform(text, new StreamResult(result));
    } catch (SAXException se) {
        LOGGER.error(se.getMessage(), se);
    }
}

From source file:org.roda.core.common.validation.ValidationUtils.java

public static ValidationReport isXMLValid(ContentPayload xmlPayload) {
    ValidationReport ret = new ValidationReport();

    SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setValidating(false);/*from ww w . ja v a  2  s .  c  o m*/
    factory.setNamespaceAware(true);

    RodaErrorHandler errorHandler = new RodaErrorHandler();

    try (Reader reader = new InputStreamReader(new BOMInputStream(xmlPayload.createInputStream()))) {
        XMLReader xmlReader = XMLReaderFactory.createXMLReader();
        xmlReader.setEntityResolver(new RodaEntityResolver());
        InputSource inputSource = new InputSource(reader);

        xmlReader.setErrorHandler(errorHandler);
        xmlReader.parse(inputSource);
        ret.setValid(errorHandler.getErrors().isEmpty());
        for (SAXParseException saxParseException : errorHandler.getErrors()) {
            ret.addIssue(convertSAXParseException(saxParseException));
        }
    } catch (SAXException e) {
        ret.setValid(false);
        for (SAXParseException saxParseException : errorHandler.getErrors()) {
            ret.addIssue(convertSAXParseException(saxParseException));
        }
    } catch (IOException e) {
        ret.setValid(false);
        ret.setMessage(e.getMessage());
    }
    return ret;
}

From source file:org.roda.core.common.validation.ValidationUtils.java

/**
 * Validates descriptive medatada (e.g. against its schema, but other
 * strategies may be used)//from w ww  . j a v  a2 s.  c om
 * 
 * @param descriptiveMetadataType
 * 
 * @param failIfNoSchema
 * @throws ValidationException
 */
public static ValidationReport validateDescriptiveBinary(ContentPayload descriptiveMetadataPayload,
        String descriptiveMetadataType, String descriptiveMetadataVersion, boolean failIfNoSchema) {
    ValidationReport ret = new ValidationReport();
    InputStream inputStream = null;
    Optional<Schema> xmlSchema = RodaCoreFactory.getRodaSchema(descriptiveMetadataType,
            descriptiveMetadataVersion);
    try {
        if (xmlSchema.isPresent()) {
            RodaErrorHandler errorHandler = new RodaErrorHandler();

            try (InputStreamReader inputStreamReader = new InputStreamReader(
                    new BOMInputStream(descriptiveMetadataPayload.createInputStream()))) {

                XMLReader xmlReader = XMLReaderFactory.createXMLReader();
                xmlReader.setEntityResolver(new RodaEntityResolver());
                InputSource inputSource = new InputSource(inputStreamReader);
                Source source = new SAXSource(xmlReader, inputSource);

                Validator validator = xmlSchema.get().newValidator();

                validator.setErrorHandler(errorHandler);

                validator.validate(source);
                ret.setValid(errorHandler.getErrors().isEmpty());
                for (SAXParseException saxParseException : errorHandler.getErrors()) {
                    ret.addIssue(convertSAXParseException(saxParseException));
                }
            } catch (SAXException e) {
                LOGGER.debug("Error validating descriptive binary " + descriptiveMetadataType, e);
                ret.setValid(false);
                for (SAXParseException saxParseException : errorHandler.getErrors()) {
                    ret.addIssue(convertSAXParseException(saxParseException));
                }
            }
        } else {
            if (failIfNoSchema) {
                LOGGER.error(
                        "Will fail validating descriptive metadata with type '{}' and version '{}' because couldn't find its schema",
                        descriptiveMetadataType, descriptiveMetadataVersion);
                ret.setValid(false);
                ret.setMessage("No schema to validate " + descriptiveMetadataType);
            } else {
                LOGGER.debug(
                        "Found no schema do validate descriptive metadata but will try to validate XML syntax...");
                ret = isXMLValid(descriptiveMetadataPayload);
            }
        }
    } catch (IOException e) {
        LOGGER.error("Error validating descriptive metadata", e);
        ret.setValid(false);
        ret.setMessage(e.getMessage());
    } finally {
        IOUtils.closeQuietly(inputStream);
    }

    return ret;

}