use of com.evolveum.midpoint.schema.result.OperationResultBuilder in project midpoint by Evolveum.
the class WorkItemManager method delegateWorkItem.
// TODO when calling from model API, what should we put into escalationLevelName+DisplayName ?
// Probably the API should look different. E.g. there could be an "Escalate" button, that would look up the
// appropriate escalation timed action, and invoke it. We'll solve this when necessary. Until that time, be
// aware that escalationLevelName/DisplayName are for internal use only.
// We can eventually provide bulk version of this method as well.
void delegateWorkItem(@NotNull WorkItemId workItemId, @NotNull WorkItemDelegationRequestType delegationRequest, WorkItemEscalationLevelType escalation, Duration newDuration, WorkItemEventCauseInformationType causeInformation, XMLGregorianCalendar now, Task task, OperationResult parentResult) throws ObjectNotFoundException, SecurityViolationException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException {
List<ObjectReferenceType> delegates = delegationRequest.getDelegate();
WorkItemDelegationMethodType method = delegationRequest.getMethod();
String comment = delegationRequest.getComment();
OperationResultBuilder builder = parentResult.subresult(OPERATION_DELEGATE_WORK_ITEM).addArbitraryObjectAsParam("workItemId", workItemId).addArbitraryObjectAsParam("escalation", escalation).addArbitraryObjectCollectionAsParam("delegates", delegates).addArbitraryObjectAsParam("method", method).addParam("comment", delegationRequest.getComment());
boolean tracingRequested = startTracingIfRequested(builder, task, parentResult);
OperationResult result = builder.build();
try {
LOGGER.trace("Delegating work item {} to {} ({}): escalation={}; cause={}; comment={}", workItemId, delegates, method, escalation != null ? escalation.getName() + "/" + escalation.getDisplayName() : "none", causeInformation, comment);
DelegateWorkItemsRequest request = new DelegateWorkItemsRequest(workItemId.caseOid, causeInformation, now);
request.getDelegations().add(new DelegateWorkItemsRequest.SingleDelegation(workItemId.id, delegationRequest, escalation, newDuration));
caseEngine.executeRequest(request, task, result);
} catch (SecurityViolationException | RuntimeException | ObjectNotFoundException | SchemaException | CommunicationException | ConfigurationException e) {
result.recordFatalError("Couldn't delegate/escalate work item " + workItemId + ": " + e.getMessage(), e);
throw e;
} catch (ObjectAlreadyExistsException e) {
throw new IllegalStateException(e);
} finally {
result.computeStatusIfUnknown();
storeTraceIfRequested(tracingRequested, task, result, parentResult);
}
}
use of com.evolveum.midpoint.schema.result.OperationResultBuilder in project midpoint by Evolveum.
the class Clockwork method run.
public <F extends ObjectType> HookOperationMode run(LensContext<F> context, Task task, OperationResult parentResult) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException {
OperationResultBuilder builder = parentResult.subresult(OP_RUN);
boolean tracingRequested = startTracingIfRequested(context, task, builder, parentResult);
OperationResult result = builder.build();
// There are some parts of processing (e.g. notifications deep in provisioning module) that have no access
// to context.channel value, only to task.channel. So we have to get the two into sync. To return to the original
// state, we restore task.channel afterwards.
String originalTaskChannel = task.getChannel();
task.setChannel(context.getChannel());
ClockworkRunTraceType trace = null;
try {
trace = recordTraceAtStart(context, result);
ClockworkConflictResolver.Context conflictResolutionContext = new ClockworkConflictResolver.Context();
HookOperationMode mode = runWithConflictDetection(context, conflictResolutionContext, task, result);
return clockworkConflictResolver.resolveFocusConflictIfPresent(context, conflictResolutionContext, mode, task, result);
} catch (CommonException t) {
result.recordFatalError(t.getMessage(), t);
throw t;
} finally {
task.setChannel(originalTaskChannel);
result.computeStatusIfUnknown();
recordTraceAtEnd(context, trace, result);
if (tracingRequested) {
tracer.storeTrace(task, result, parentResult);
}
}
}
use of com.evolveum.midpoint.schema.result.OperationResultBuilder in project midpoint by Evolveum.
the class ItemProcessingGatekeeper method initializeOperationResultIncludingTracingOrReporting.
private OperationResult initializeOperationResultIncludingTracingOrReporting(OperationResult parentResult) throws SchemaException {
OperationResultBuilder builder = parentResult.subresult(OP_HANDLE).addParam("object", iterationItemInformation.toString());
if (workerTask.getTracingRequestedFor().contains(TracingRootType.ACTIVITY_ITEM_PROCESSING)) {
tracingRequested = true;
builder.tracingProfile(getTracer().compileProfile(workerTask.getTracingProfile(), parentResult));
} else if (activityRun.shouldReportInternalOperations() && beforeConditionForInternalOpReportPasses(parentResult)) {
internalOperationReportRequested = true;
builder.preserve();
}
return builder.build();
}
Aggregations