* @param event the current {@link MuleEvent}
*/
public void validate(MuleEvent event) throws MuleException
{
Object input = event.getMessage().getPayload();
ProcessingReport report;
JsonNode jsonNode = null;
try
{
jsonNode = new DefaultJsonParser(event.getMuleContext()).asJsonNode(input);
if ((input instanceof Reader) || (input instanceof InputStream))
{
event.getMessage().setPayload(jsonNode.toString());
}
report = schema.validate(jsonNode);
}
catch (Exception e)
{
throw new JsonSchemaValidationException("Exception was found while trying to validate json schema",
jsonNode == null ? StringUtils.EMPTY : jsonNode.toString(),
e);
}
if (!report.isSuccess())
{
throw new JsonSchemaValidationException("Json content is not compliant with schema\n" + report.toString(), jsonNode.toString());
}
}