use of com.evolveum.midpoint.schema.validator.ObjectValidator 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.ObjectValidator in project midpoint by Evolveum.
the class TestInitialObjects method testInitialObjects.
@Test
public void testInitialObjects() throws Exception {
ObjectValidator validator = new ObjectValidator(getPrismContext());
validator.setAllWarnings();
StringBuilder errorsSb = new StringBuilder();
for (File file : DIR_INITIAL_OBJECTS.listFiles()) {
if (file.isFile()) {
try {
testInitialObject(validator, errorsSb, file);
} catch (Throwable e) {
String msg = "Error processing file " + file.getName() + ": " + e.getMessage();
logger.error(msg, e);
displayException(msg, e);
throw e;
}
}
}
if (errorsSb.length() != 0) {
throw new SchemaException(errorsSb.toString());
}
}
use of com.evolveum.midpoint.schema.validator.ObjectValidator in project midpoint by Evolveum.
the class VerifyConsumerWorker method init.
@Override
protected void init() {
validator = new ObjectValidator(context.getPrismContext());
String warnOption = options.getWarn();
if (warnOption == null) {
validator.setAllWarnings();
} else {
String[] warnCategories = warnOption.split(",");
for (String warnCategory : warnCategories) {
switch(warnCategory) {
case "deprecated":
validator.setWarnDeprecated(true);
break;
case "plannedRemoval":
validator.setWarnPlannedRemoval(true);
break;
case "uuid":
validator.setWarnIncorrectOids(true);
break;
default:
System.err.println("Unknown warn option '" + warnCategory + "'");
break;
}
}
}
}
Aggregations