Search in sources :

Example 1 with ProjectorComponentTraceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ProjectorComponentTraceType in project midpoint by Evolveum.

the class ClockworkMedic method partialExecute.

public void partialExecute(String baseComponentName, ProjectorComponentRunnable runnable, Supplier<PartialProcessingTypeType> optionSupplier, Class<?> executingClass, LensContext<?> context, LensProjectionContext projectionContext, OperationResult initialParentResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, ConflictDetectedException {
    context.checkAbortRequested();
    OperationResult parentResult;
    if (initialParentResult == null) {
        LOGGER.warn("No parentResult in ClockworkMedic.partialExecute! Creating dummy one");
        parentResult = new OperationResult(ClockworkMedic.class.getName() + ".partialExecute");
    } else {
        parentResult = initialParentResult;
    }
    String componentName;
    if (projectionContext != null) {
        componentName = baseComponentName + " " + projectionContext.getHumanReadableName();
    } else {
        componentName = baseComponentName;
    }
    ClockworkInspector clockworkInspector = getClockworkInspector();
    PartialProcessingTypeType option = optionSupplier.get();
    if (option == PartialProcessingTypeType.SKIP) {
        LOGGER.debug("Skipping projector component {} because partial execution option is set to {}", componentName, option);
        if (clockworkInspector != null) {
            clockworkInspector.projectorComponentSkip(componentName);
        }
    } else {
        String operationName = executingClass.getName() + "." + baseComponentName;
        String qualifier = context.getOperationQualifier();
        if (projectionContext != null) {
            qualifier += "." + projectionContext.getResourceOid() + "." + projectionContext.getResourceShadowDiscriminator().getKind() + "." + projectionContext.getResourceShadowDiscriminator().getIntent();
        }
        OperationResult result = parentResult.subresult(operationName).addQualifier(qualifier).build();
        ProjectorComponentTraceType trace;
        if (result.isTracingAny(ProjectorComponentTraceType.class)) {
            trace = new ProjectorComponentTraceType();
            if (result.isTracingNormal(ProjectorComponentTraceType.class)) {
                trace.setInputLensContextText(context.debugDump());
            }
            trace.setInputLensContext(context.toLensContextType(getExportType(trace, result)));
            if (projectionContext != null) {
                trace.setResourceShadowDiscriminator(LensUtil.createDiscriminatorBean(projectionContext.getResourceShadowDiscriminator(), context));
            }
            result.addTrace(trace);
        } else {
            trace = null;
        }
        try {
            LOGGER.trace("Projector component started: {}", componentName);
            if (clockworkInspector != null) {
                clockworkInspector.projectorComponentStart(componentName);
            }
            runnable.run(result);
            LOGGER.trace("Projector component finished: {}", componentName);
        } catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | SecurityViolationException | PolicyViolationException | ExpressionEvaluationException | ObjectAlreadyExistsException | ConflictDetectedException | RuntimeException | Error e) {
            LOGGER.trace("Projector component error: {}: {}: {}", componentName, e.getClass().getSimpleName(), e.getMessage());
            result.recordFatalError(e);
            throw e;
        } finally {
            result.computeStatusIfUnknown();
            if (trace != null) {
                if (result.isTracingNormal(ProjectorComponentTraceType.class)) {
                    trace.setOutputLensContextText(context.debugDump());
                }
                trace.setOutputLensContext(context.toLensContextType(getExportType(trace, result)));
            }
            if (clockworkInspector != null) {
                clockworkInspector.projectorComponentFinish(componentName);
            }
        }
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ProjectorComponentTraceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ProjectorComponentTraceType) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ClockworkInspector(com.evolveum.midpoint.model.api.util.ClockworkInspector) PartialProcessingTypeType(com.evolveum.midpoint.xml.ns._public.common.common_3.PartialProcessingTypeType) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)

Aggregations

ClockworkInspector (com.evolveum.midpoint.model.api.util.ClockworkInspector)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)1 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)1 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)1 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)1 PartialProcessingTypeType (com.evolveum.midpoint.xml.ns._public.common.common_3.PartialProcessingTypeType)1 ProjectorComponentTraceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ProjectorComponentTraceType)1