use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValidationResultType in project midpoint by Evolveum.
the class ValidateExecutor method execute.
@Override
public PipelineData execute(ActionExpressionType expression, PipelineData input, ExecutionContext context, OperationResult globalResult) throws ScriptExecutionException {
PipelineData output = PipelineData.createEmpty();
for (PipelineItem item : input.getData()) {
PrismValue value = item.getValue();
OperationResult result = operationsHelper.createActionResult(item, this, globalResult);
context.checkTaskStop();
if (value instanceof PrismObjectValue && ((PrismObjectValue<?>) value).asObjectable() instanceof ResourceType) {
// noinspection unchecked
PrismObject<ResourceType> resourceTypePrismObject = ((PrismObjectValue<ResourceType>) value).asPrismObject();
ResourceType resourceType = resourceTypePrismObject.asObjectable();
Operation op = operationsHelper.recordStart(context, resourceType);
try {
ValidationResult validationResult = resourceValidator.validate(resourceTypePrismObject, Scope.THOROUGH, null, context.getTask(), result);
PrismContainerDefinition<ValidationResultType> pcd = prismContext.getSchemaRegistry().findContainerDefinitionByElementName(SchemaConstantsGenerated.C_VALIDATION_RESULT);
PrismContainer<ValidationResultType> pc = pcd.instantiate();
// noinspection unchecked
pc.add(validationResult.toValidationResultType().asPrismContainerValue());
context.println("Validated " + resourceTypePrismObject + ": " + validationResult.getIssues().size() + " issue(s)");
operationsHelper.recordEnd(context, op, null, result);
output.add(new PipelineItem(pc.getValue(), item.getResult()));
} catch (SchemaException | RuntimeException e) {
operationsHelper.recordEnd(context, op, e, result);
context.println("Error validation " + resourceTypePrismObject + ": " + e.getMessage());
// noinspection ThrowableNotThrown
processActionException(e, NAME, value, context);
output.add(item);
}
} else {
// noinspection ThrowableNotThrown
processActionException(new ScriptExecutionException("Item is not a PrismObject<ResourceType>"), NAME, value, context);
}
operationsHelper.trimAndCloneResult(result, item.getResult());
}
return output;
}
Aggregations