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;
}
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());
}
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());
}
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;
}
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);
}
}
Aggregations