use of com.evolveum.midpoint.schema.validator.ValidationItem in project midpoint by Evolveum.
the class TestInitialObjects method testInitialObject.
private <O extends ObjectType> void testInitialObject(ObjectValidator validator, StringBuilder errorsSb, File file) throws SchemaException, IOException {
PrismObject<O> object = getPrismContext().parseObject(file);
ValidationResult validationResult = validator.validate(object);
if (validationResult.isEmpty() || isIgnoredWarning(validationResult)) {
display("Checked " + object + ": no warnings");
return;
}
displayDumpable("Validation warnings for " + object, validationResult);
for (ValidationItem valItem : validationResult.getItems()) {
errorsSb.append(file.getName());
errorsSb.append(" ");
errorsSb.append(object);
errorsSb.append(" ");
valItem.shortDump(errorsSb);
errorsSb.append("\n");
}
}
use of com.evolveum.midpoint.schema.validator.ValidationItem in project midpoint-studio by Evolveum.
the class VerifyAction method processFiles.
private void processFiles(AnActionEvent evt, MidPointService mm, Environment env, List<VirtualFile> files) {
ObjectValidator validator = new ObjectValidator(MidPointUtils.DEFAULT_PRISM_CONTEXT);
validator.setAllWarnings();
MidPointClient client = new MidPointClient(evt.getProject(), env);
for (VirtualFile file : files) {
RunnableUtils.runReadAction(() -> {
try {
List<MidPointObject> objects = MidPointUtils.parseProjectFile(evt.getProject(), file, NOTIFICATION_KEY);
for (MidPointObject obj : objects) {
try {
PrismObject object = client.parseObject(obj.getContent());
ValidationResult validationResult = validator.validate(object);
for (ValidationItem validationItem : validationResult.getItems()) {
String msg = buildValidationItem(object, validationItem);
mm.printToConsole(env, VerifyAction.class, msg);
}
} catch (Exception ex) {
mm.printToConsole(env, VerifyAction.class, "Couldn't parse object '" + obj.getName() + "'(" + obj.getType() + ") from file '" + file.getPath() + "', reason: " + ex.getMessage());
}
}
} catch (Exception ex) {
mm.printToConsole(env, VerifyAction.class, "Couldn't parse objects from file '" + file.getPath() + "', reason: " + ex.getMessage());
}
});
}
}
use of com.evolveum.midpoint.schema.validator.ValidationItem in project midpoint by Evolveum.
the class VerifyConsumerWorker method write.
@Override
protected void write(Writer writer, ObjectType object) throws IOException {
PrismObject<?> prismObject = object.asPrismObject();
ValidationResult validationResult = validator.validate(prismObject);
for (ValidationItem validationItem : validationResult.getItems()) {
writeValidationItem(writer, prismObject, validationItem);
}
}
Aggregations