ValidationEventCollector validationHandler = new ValidationEventCollector();
u.setEventHandler(validationHandler);
setSchema(jc, u);
Object obj = u.unmarshal(reader);
if (!clazz.isAssignableFrom(obj.getClass())) {
throw new CougarValidationException(ServerFaultCode.ClassConversionFailure, "Deserialised object was not of class "+clazz.getName());
}
validate(validationHandler);
return obj;
} catch (UnmarshalException e) {
Throwable linkedException = e.getLinkedException();
if(linkedException!=null) {
logger.log(Level.FINE, linkedException.getMessage());
if (linkedException instanceof SAXParseException) {
CougarValidationException cve = schemaValidationFailureParser.parse((SAXParseException)linkedException, SchemaValidationFailureParser.XmlSource.RESCRIPT);
if (cve != null) {
throw cve;
}
}
throw new CougarValidationException(ServerFaultCode.XMLDeserialisationFailure, linkedException);//NOSONAR
}
throw new CougarValidationException(ServerFaultCode.XMLDeserialisationFailure, e);
} catch (CougarValidationException e) {
throw e;
} catch (Exception e) {
throw new CougarServiceException(ServerFaultCode.XMLDeserialisationFailure, "Unable to deserialise REST/XML request", e);
}