use of org.apache.oozie.service.SchemaService in project oozie by apache.
the class V2ValidateServlet method validate.
private void validate(String xml) throws Exception {
SchemaService schemaService = Services.get().get(SchemaService.class);
Schema[] schemas = { schemaService.getSchema(SchemaService.SchemaName.WORKFLOW), schemaService.getSchema(SchemaService.SchemaName.COORDINATOR), schemaService.getSchema(SchemaService.SchemaName.BUNDLE), schemaService.getSchema(SchemaService.SchemaName.SLA_ORIGINAL) };
Exception exception = null;
for (int i = 0; i < schemas.length; i++) {
try {
validateSchema(schemas[i], new StringReader(xml));
exception = null;
break;
} catch (SAXException e) {
if (i == 0) {
exception = e;
}
// If invalid, move to next schema validation.
if (!e.getMessage().contains("cvc-elt.1")) {
exception = e;
break;
}
} catch (Exception e) {
exception = e;
break;
}
}
if (exception != null) {
throw exception;
}
}
Aggregations