Search in sources :

Example 26 with ObjectDeltaOperation

use of com.evolveum.midpoint.schema.ObjectDeltaOperation in project midpoint by Evolveum.

the class DummyAuditService method getExecutionDeltas.

public Collection<ObjectDeltaOperation<? extends ObjectType>> getExecutionDeltas(int index) {
    AuditEventRecord executionRecord = getExecutionRecord(index);
    Collection<ObjectDeltaOperation<? extends ObjectType>> deltas = executionRecord.getDeltas();
    assert deltas != null : "Execution audit record has null deltas";
    return deltas;
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord)

Example 27 with ObjectDeltaOperation

use of com.evolveum.midpoint.schema.ObjectDeltaOperation in project midpoint by Evolveum.

the class Clockwork method addRecordMessage.

/**
	 * Adds a message to the record by pulling the messages from individual delta results.
	 */
private void addRecordMessage(AuditEventRecord auditRecord, OperationResult result) {
    if (auditRecord.getMessage() != null) {
        return;
    }
    if (!StringUtils.isEmpty(result.getMessage())) {
        String message = result.getMessage();
        auditRecord.setMessage(message);
        return;
    }
    Collection<ObjectDeltaOperation<? extends ObjectType>> deltas = auditRecord.getDeltas();
    if (deltas == null || deltas.isEmpty()) {
        return;
    }
    StringBuilder sb = new StringBuilder();
    for (ObjectDeltaOperation<? extends ObjectType> delta : deltas) {
        OperationResult executionResult = delta.getExecutionResult();
        if (executionResult != null) {
            String message = executionResult.getMessage();
            if (!StringUtils.isEmpty(message)) {
                if (sb.length() != 0) {
                    sb.append("; ");
                }
                sb.append(message);
            }
        }
    }
    auditRecord.setMessage(sb.toString());
}
Also used : ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 28 with ObjectDeltaOperation

use of com.evolveum.midpoint.schema.ObjectDeltaOperation in project midpoint by Evolveum.

the class Clockwork method logFinalReadable.

/**
	 * Logs the entire operation in a human-readable fashion.
	 */
private <F extends ObjectType> void logFinalReadable(LensContext<F> context, Task task, OperationResult result) throws SchemaException {
    if (!LOGGER.isDebugEnabled()) {
        return;
    }
    // a priori: sync delta
    boolean hasSyncDelta = false;
    for (LensProjectionContext projectionContext : context.getProjectionContexts()) {
        ObjectDelta<ShadowType> syncDelta = projectionContext.getSyncDelta();
        if (syncDelta != null) {
            hasSyncDelta = true;
        }
    }
    Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas = context.getExecutedDeltas();
    if (!hasSyncDelta && executedDeltas == null || executedDeltas.isEmpty()) {
        // Not worth mentioning
        return;
    }
    StringBuilder sb = new StringBuilder();
    String channel = context.getChannel();
    if (channel != null) {
        sb.append("Channel: ").append(channel).append("\n");
    }
    if (hasSyncDelta) {
        sb.append("Triggered by synchronization delta\n");
        for (LensProjectionContext projectionContext : context.getProjectionContexts()) {
            ObjectDelta<ShadowType> syncDelta = projectionContext.getSyncDelta();
            if (syncDelta != null) {
                sb.append(syncDelta.debugDump(1));
                sb.append("\n");
            }
            DebugUtil.debugDumpLabel(sb, "Situation", 1);
            sb.append(" ");
            sb.append(projectionContext.getSynchronizationSituationDetected());
            sb.append(" -> ");
            sb.append(projectionContext.getSynchronizationSituationResolved());
            sb.append("\n");
        }
    }
    for (LensProjectionContext projectionContext : context.getProjectionContexts()) {
        if (projectionContext.isSyncAbsoluteTrigger()) {
            sb.append("Triggered by absolute state of ").append(projectionContext.getHumanReadableName());
            sb.append(": ");
            sb.append(projectionContext.getSynchronizationSituationDetected());
            sb.append(" -> ");
            sb.append(projectionContext.getSynchronizationSituationResolved());
            sb.append("\n");
        }
    }
    // focus primary
    LensFocusContext<F> focusContext = context.getFocusContext();
    if (focusContext != null) {
        ObjectDelta<F> focusPrimaryDelta = focusContext.getPrimaryDelta();
        if (focusPrimaryDelta != null) {
            sb.append("Triggered by focus primary delta\n");
            DebugUtil.indentDebugDump(sb, 1);
            sb.append(focusPrimaryDelta.toString());
            sb.append("\n");
        }
    }
    // projection primary
    Collection<ObjectDelta<ShadowType>> projPrimaryDeltas = new ArrayList<ObjectDelta<ShadowType>>();
    for (LensProjectionContext projectionContext : context.getProjectionContexts()) {
        ObjectDelta<ShadowType> projPrimaryDelta = projectionContext.getPrimaryDelta();
        if (projPrimaryDelta != null) {
            projPrimaryDeltas.add(projPrimaryDelta);
        }
    }
    if (!projPrimaryDeltas.isEmpty()) {
        sb.append("Triggered by projection primary delta\n");
        for (ObjectDelta<ShadowType> projDelta : projPrimaryDeltas) {
            DebugUtil.indentDebugDump(sb, 1);
            sb.append(projDelta.toString());
            sb.append("\n");
        }
    }
    if (focusContext != null) {
        sb.append("Focus: ").append(focusContext.getHumanReadableName()).append("\n");
    }
    if (!context.getProjectionContexts().isEmpty()) {
        sb.append("Projections (").append(context.getProjectionContexts().size()).append("):\n");
        for (LensProjectionContext projectionContext : context.getProjectionContexts()) {
            DebugUtil.indentDebugDump(sb, 1);
            sb.append(projectionContext.getHumanReadableName());
            sb.append(": ");
            sb.append(projectionContext.getSynchronizationPolicyDecision());
            sb.append("\n");
        }
    }
    if (executedDeltas == null || executedDeltas.isEmpty()) {
        sb.append("Executed: nothing\n");
    } else {
        sb.append("Executed:\n");
        for (ObjectDeltaOperation<? extends ObjectType> executedDelta : executedDeltas) {
            ObjectDelta<? extends ObjectType> delta = executedDelta.getObjectDelta();
            OperationResult deltaResult = executedDelta.getExecutionResult();
            DebugUtil.indentDebugDump(sb, 1);
            sb.append(delta.toString());
            sb.append(": ");
            sb.append(deltaResult.getStatus());
            sb.append("\n");
        }
    }
    LOGGER.debug("\n###[ CLOCKWORK SUMMARY ]######################################\n{}" + "##############################################################", sb.toString());
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation)

Example 29 with ObjectDeltaOperation

use of com.evolveum.midpoint.schema.ObjectDeltaOperation in project midpoint by Evolveum.

the class ModelEvent method getAllExecutedDeltas.

public List<ObjectDeltaOperation> getAllExecutedDeltas() {
    List<ObjectDeltaOperation> retval = new ArrayList<ObjectDeltaOperation>();
    retval.addAll(getFocusContext().getExecutedDeltas());
    for (Object o : modelContext.getProjectionContexts()) {
        ModelProjectionContext modelProjectionContext = (ModelProjectionContext) o;
        retval.addAll(modelProjectionContext.getExecutedDeltas());
    }
    return retval;
}
Also used : ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) ArrayList(java.util.ArrayList) ModelProjectionContext(com.evolveum.midpoint.model.api.context.ModelProjectionContext)

Example 30 with ObjectDeltaOperation

use of com.evolveum.midpoint.schema.ObjectDeltaOperation in project midpoint by Evolveum.

the class ModelEvent method isStatusType.

@Override
public boolean isStatusType(EventStatusType eventStatusType) {
    boolean allSuccess = true, anySuccess = false, allFailure = true, anyFailure = false, anyInProgress = false;
    for (ObjectDeltaOperation objectDeltaOperation : getAllExecutedDeltas()) {
        if (objectDeltaOperation.getExecutionResult() != null) {
            switch(objectDeltaOperation.getExecutionResult().getStatus()) {
                case SUCCESS:
                    anySuccess = true;
                    allFailure = false;
                    break;
                case FATAL_ERROR:
                    allSuccess = false;
                    anyFailure = true;
                    break;
                case WARNING:
                    anySuccess = true;
                    allFailure = false;
                    break;
                case HANDLED_ERROR:
                    anySuccess = true;
                    allFailure = false;
                    break;
                case IN_PROGRESS:
                    allSuccess = false;
                    allFailure = false;
                    anyInProgress = true;
                    break;
                case NOT_APPLICABLE:
                    break;
                case PARTIAL_ERROR:
                    allSuccess = false;
                    anyFailure = true;
                    break;
                case UNKNOWN:
                    allSuccess = false;
                    allFailure = false;
                    break;
                default:
                    LOGGER.warn("Unknown execution result: " + objectDeltaOperation.getExecutionResult().getStatus());
            }
        } else {
            allSuccess = false;
            allFailure = false;
            anyInProgress = true;
        }
    }
    switch(eventStatusType) {
        case ALSO_SUCCESS:
            return anySuccess;
        case SUCCESS:
            return allSuccess;
        case FAILURE:
            return anyFailure;
        case ONLY_FAILURE:
            return allFailure;
        case IN_PROGRESS:
            return anyInProgress;
        default:
            throw new IllegalStateException("Invalid eventStatusType: " + eventStatusType);
    }
}
Also used : ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation)

Aggregations

ObjectDeltaOperation (com.evolveum.midpoint.schema.ObjectDeltaOperation)51 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)24 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)15 Task (com.evolveum.midpoint.task.api.Task)12 AuditEventRecord (com.evolveum.midpoint.audit.api.AuditEventRecord)11 Test (org.testng.annotations.Test)11 ArrayList (java.util.ArrayList)9 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)7 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)6 ModelProjectionContext (com.evolveum.midpoint.model.api.context.ModelProjectionContext)4 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)4 ModelService (com.evolveum.midpoint.model.api.ModelService)3 TestValidityRecomputeTask (com.evolveum.midpoint.model.intest.sync.TestValidityRecomputeTask)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 CommonException (com.evolveum.midpoint.util.exception.CommonException)3 MidPointApplication (com.evolveum.midpoint.web.security.MidPointApplication)3 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)3 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)3 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)3 AuditEventType (com.evolveum.midpoint.audit.api.AuditEventType)2