use of org.eclipse.wst.json.core.internal.validation.JSONValidationReport in project webtools.sourceediting by eclipse.
the class Validator method validate.
@Override
public ValidationReport validate(String uri, InputStream inputstream, NestedValidatorContext context, ValidationResult result) {
JSONValidator validator = JSONValidator.getInstance();
JSONValidationConfiguration configuration = new JSONValidationConfiguration();
JSONValidationReport valreport = validator.validate(uri, inputstream, configuration, result, context);
String prefs = JSONCorePlugin.getDefault().getBundle().getSymbolicName();
IEclipsePreferences modelPreferences = InstanceScope.INSTANCE.getNode(prefs);
boolean validateSchema = modelPreferences.getBoolean(JSONCorePreferenceNames.SCHEMA_VALIDATION, false);
if (validateSchema) {
IJSONModel model = null;
try {
IStructuredModel temp = getModel(uri);
if (!(temp instanceof IJSONModel)) {
return valreport;
}
model = (IJSONModel) temp;
IJSONSchemaDocument schemaDocument = SchemaProcessorRegistryReader.getInstance().getSchemaDocument(model);
if (schemaDocument != null) {
JSONValidationInfo valinfo = null;
if (valreport instanceof JSONValidationInfo) {
valinfo = (JSONValidationInfo) valreport;
} else {
valinfo = new JSONValidationInfo(uri);
}
validate(model, schemaDocument, valinfo);
// valreport.getValidationMessages();
return valreport;
}
} catch (IOException e) {
logWarning(e);
return valreport;
} finally {
if (model != null) {
model.releaseFromRead();
}
}
}
return valreport;
}
Aggregations