Search in sources :

Example 1 with WfsParseException

use of org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsParseException in project ddf by codice.

the class WfsResponseExceptionMapper method unmarshalResponseEntity.

private WfsException unmarshalResponseEntity(String msg) {
    WfsException wfsEx;
    try {
        JAXBElementProvider<ExceptionReport> provider = new JAXBElementProvider<>();
        Unmarshaller um = provider.getJAXBContext(ExceptionReport.class, ExceptionReport.class).createUnmarshaller();
        XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory();
        xmlInputFactory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
        xmlInputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
        xmlInputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false);
        XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(new StringReader(msg));
        ExceptionReport report = (ExceptionReport) um.unmarshal(xmlStreamReader);
        wfsEx = convertToWfsException(report);
    } catch (JAXBException | XMLStreamException e) {
        wfsEx = new WfsParseException(msg, e);
    }
    return wfsEx;
}
Also used : JAXBElementProvider(org.apache.cxf.jaxrs.provider.JAXBElementProvider) WfsParseException(org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsParseException) XMLStreamReader(javax.xml.stream.XMLStreamReader) XMLStreamException(javax.xml.stream.XMLStreamException) WfsException(org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsException) ExceptionReport(net.opengis.ows.v_1_0_0.ExceptionReport) JAXBException(javax.xml.bind.JAXBException) StringReader(java.io.StringReader) Unmarshaller(javax.xml.bind.Unmarshaller) XMLInputFactory(javax.xml.stream.XMLInputFactory)

Aggregations

StringReader (java.io.StringReader)1 JAXBException (javax.xml.bind.JAXBException)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 XMLInputFactory (javax.xml.stream.XMLInputFactory)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1 ExceptionReport (net.opengis.ows.v_1_0_0.ExceptionReport)1 JAXBElementProvider (org.apache.cxf.jaxrs.provider.JAXBElementProvider)1 WfsException (org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsException)1 WfsParseException (org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsParseException)1