Search in sources :

Example 6 with OperationResultBuilder

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);
    }
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DelegateWorkItemsRequest(com.evolveum.midpoint.cases.api.request.DelegateWorkItemsRequest) OperationResultBuilder(com.evolveum.midpoint.schema.result.OperationResultBuilder)

Example 7 with OperationResultBuilder

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);
        }
    }
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) HookOperationMode(com.evolveum.midpoint.model.api.hooks.HookOperationMode) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) OperationResultBuilder(com.evolveum.midpoint.schema.result.OperationResultBuilder)

Example 8 with OperationResultBuilder

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();
}
Also used : OperationResultBuilder(com.evolveum.midpoint.schema.result.OperationResultBuilder)

Aggregations

OperationResultBuilder (com.evolveum.midpoint.schema.result.OperationResultBuilder)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 ClaimWorkItemsRequest (com.evolveum.midpoint.cases.api.request.ClaimWorkItemsRequest)1 CompleteWorkItemsRequest (com.evolveum.midpoint.cases.api.request.CompleteWorkItemsRequest)1 DelegateWorkItemsRequest (com.evolveum.midpoint.cases.api.request.DelegateWorkItemsRequest)1 ReleaseWorkItemsRequest (com.evolveum.midpoint.cases.api.request.ReleaseWorkItemsRequest)1 HookOperationMode (com.evolveum.midpoint.model.api.hooks.HookOperationMode)1 PrismContext (com.evolveum.midpoint.prism.PrismContext)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 UcfAsyncUpdateChange (com.evolveum.midpoint.provisioning.ucf.api.UcfAsyncUpdateChange)1 AcknowledgementSink (com.evolveum.midpoint.schema.AcknowledgementSink)1 VariablesMap (com.evolveum.midpoint.schema.expression.VariablesMap)1 MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)1 SecurityContextManager (com.evolveum.midpoint.security.api.SecurityContextManager)1 Task (com.evolveum.midpoint.task.api.Task)1 Tracer (com.evolveum.midpoint.task.api.Tracer)1 Authentication (org.springframework.security.core.Authentication)1