use of com.sun.xml.bind.api.AccessorException in project X-Road by nordic-institute.
the class SoapParserImpl method unmarshalHeader.
@SuppressWarnings("unchecked")
static <T> T unmarshalHeader(Class<?> clazz, SOAPHeader soapHeader, boolean checkRequiredFields) throws Exception {
Unmarshaller unmarshaller = JaxbUtils.createUnmarshaller(clazz);
if (checkRequiredFields) {
unmarshaller.setListener(new RequiredHeaderFieldsChecker(clazz));
}
unmarshaller.setEventHandler(event -> {
switch(event.getSeverity()) {
case ValidationEvent.WARNING:
return true;
case ValidationEvent.ERROR:
Throwable t = event.getLinkedException();
return !(t instanceof AccessorException && t.getCause() instanceof CodedException);
case ValidationEvent.FATAL_ERROR:
return false;
default:
return true;
}
});
JAXBElement<T> jaxbElement = (JAXBElement<T>) unmarshaller.unmarshal(soapHeader, clazz);
return jaxbElement.getValue();
}
Aggregations