Search in sources :

Example 1 with ImportHandlerMimeTypeDefinitionsDto

use of org.pentaho.platform.plugin.services.importer.mimeType.bindings.ImportHandlerMimeTypeDefinitionsDto in project pentaho-platform by pentaho.

the class MimeTypeListFactory method fromXml.

private ImportHandlerMimeTypeDefinitionsDto fromXml(FileInputStream input) throws JAXBException {
    SAXParserFactory secureSAXParserFactory;
    try {
        secureSAXParserFactory = XMLParserFactoryProducer.createSecureSAXParserFactory();
    } catch (SAXNotSupportedException | SAXNotRecognizedException | ParserConfigurationException ex) {
        throw new JAXBException(ex);
    }
    XMLReader xmlReader;
    try {
        xmlReader = secureSAXParserFactory.newSAXParser().getXMLReader();
        xmlReader.setFeature("http://xml.org/sax/features/namespaces", true);
    } catch (SAXException | ParserConfigurationException ex) {
        throw new JAXBException(ex);
    }
    Source xmlSource = new SAXSource(xmlReader, new InputSource(input));
    JAXBContext jc = JAXBContext.newInstance("org.pentaho.platform.plugin.services.importer.mimeType.bindings");
    Unmarshaller u = jc.createUnmarshaller();
    JAXBElement<ImportHandlerMimeTypeDefinitionsDto> o = (JAXBElement) (u.unmarshal(xmlSource));
    ImportHandlerMimeTypeDefinitionsDto mimeTypeDefinitions = o.getValue();
    return mimeTypeDefinitions;
}
Also used : InputSource(org.xml.sax.InputSource) JAXBException(javax.xml.bind.JAXBException) SAXNotRecognizedException(org.xml.sax.SAXNotRecognizedException) JAXBContext(javax.xml.bind.JAXBContext) ImportHandlerMimeTypeDefinitionsDto(org.pentaho.platform.plugin.services.importer.mimeType.bindings.ImportHandlerMimeTypeDefinitionsDto) JAXBElement(javax.xml.bind.JAXBElement) Source(javax.xml.transform.Source) InputSource(org.xml.sax.InputSource) SAXSource(javax.xml.transform.sax.SAXSource) SAXException(org.xml.sax.SAXException) SAXNotSupportedException(org.xml.sax.SAXNotSupportedException) SAXSource(javax.xml.transform.sax.SAXSource) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Unmarshaller(javax.xml.bind.Unmarshaller) XMLReader(org.xml.sax.XMLReader) SAXParserFactory(javax.xml.parsers.SAXParserFactory)

Aggregations

JAXBContext (javax.xml.bind.JAXBContext)1 JAXBElement (javax.xml.bind.JAXBElement)1 JAXBException (javax.xml.bind.JAXBException)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1 Source (javax.xml.transform.Source)1 SAXSource (javax.xml.transform.sax.SAXSource)1 ImportHandlerMimeTypeDefinitionsDto (org.pentaho.platform.plugin.services.importer.mimeType.bindings.ImportHandlerMimeTypeDefinitionsDto)1 InputSource (org.xml.sax.InputSource)1 SAXException (org.xml.sax.SAXException)1 SAXNotRecognizedException (org.xml.sax.SAXNotRecognizedException)1 SAXNotSupportedException (org.xml.sax.SAXNotSupportedException)1 XMLReader (org.xml.sax.XMLReader)1