Skip to content

Commit

Permalink
Resolve import filters in bulk modify actions
Browse files Browse the repository at this point in the history
Preliminary solution of MID-4138: filters in deltas are resolved just
before they are applied to objects via "modify" bulk action.
  • Loading branch information
mederly committed May 16, 2018
1 parent 45d5b3a commit 463c357
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Expand Up @@ -30,6 +30,7 @@
import com.evolveum.midpoint.prism.PrismValue;
import com.evolveum.midpoint.provisioning.api.ProvisioningService;

import com.evolveum.midpoint.repo.api.RepositoryService;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.security.api.SecurityContextManager;
Expand All @@ -48,6 +49,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.PartialProcessingOptionsType;
import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ActionExpressionType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import static com.evolveum.midpoint.xml.ns._public.common.common_3.PartialProcessingTypeType.SKIP;

Expand All @@ -72,6 +74,7 @@ public abstract class BaseActionExecutor implements ActionExecutor {
@Autowired protected SecurityEnforcer securityEnforcer;
@Autowired protected SecurityContextManager securityContextManager;
@Autowired protected TaskService taskService;
@Autowired @Qualifier("cacheRepositoryService") protected RepositoryService cacheRepositoryService;

// todo move to some helper?

Expand Down
Expand Up @@ -21,6 +21,7 @@
import com.evolveum.midpoint.model.impl.scripting.ExecutionContext;
import com.evolveum.midpoint.model.api.ScriptExecutionException;
import com.evolveum.midpoint.model.api.PipelineItem;
import com.evolveum.midpoint.model.impl.util.Utils;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.schema.DeltaConvertor;
Expand All @@ -32,6 +33,7 @@
import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ActionExpressionType;
import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ActionParameterValueType;
import com.evolveum.prism.xml.ns._public.types_3.ChangeTypeType;
import com.evolveum.prism.xml.ns._public.types_3.EvaluationTimeType;
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType;

import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -76,6 +78,15 @@ public PipelineData execute(ActionExpressionType expression, PipelineData input,
try {
ObjectDelta<? extends ObjectType> delta = createDelta(objectType, deltaData);
result.addParam("delta", delta);
// This is only a preliminary solution for MID-4138. There are few things to improve:
// 1. References could be resolved earlier (before the main cycle); however it would require much more
// coding, as we have only skeleton of ObjectDeltaType there - we don't know the specific object type
// the delta will be applied to. It is not a big problem, but still a bit of work.
// 2. If the evaluation time is IMPORT, and the bulk action is part of a task that is being imported into
// repository, it should be perhaps resolved at that time. But again, it is a lot of work and it does
// not cover bulk actions which are not part of a task.
// We consider this solution to be adequate for now.
Utils.resolveReferences(delta, cacheRepositoryService, false, false, EvaluationTimeType.IMPORT, true, prismContext, result);
operationsHelper.applyDelta(delta, executionOptions, dryRun, context, result);
operationsHelper.recordEnd(context, objectType, started, null);
} catch (Throwable ex) {
Expand Down

0 comments on commit 463c357

Please sign in to comment.