Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve asynchronous execution of scripting rules
Full support for three modes of asynchronous execution of "execute script" policy actions (iterative, single run, single run with no input). Removed obsolete query classes from repo API. Introduced experimental CompleteQuery class to encapsulate substantial items related to a query (type, options). A part of MID-5967 implementation.
- Loading branch information
Showing
40 changed files
with
1,347 additions
and
712 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ExecuteScriptUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2020 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
package com.evolveum.midpoint.schema.util; | ||
|
||
import com.evolveum.midpoint.prism.PrismValue; | ||
import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExecuteScriptType; | ||
import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ValueListType; | ||
|
||
import java.util.Collection; | ||
|
||
public class ExecuteScriptUtil { | ||
|
||
/** | ||
* "Implants" specified input into ExecuteScriptType, not changing the original. | ||
*/ | ||
public static ExecuteScriptType implantInput(ExecuteScriptType originalBean, ValueListType input) { | ||
return originalBean.clone().input(input); | ||
} | ||
|
||
public static ValueListType createInput(Collection<? extends PrismValue> values) { | ||
ValueListType input = new ValueListType(); | ||
values.forEach(o -> input.getValue().add(o)); | ||
return input; | ||
} | ||
|
||
public static ValueListType createInputCloned(Collection<? extends PrismValue> values) { | ||
ValueListType input = new ValueListType(); | ||
values.forEach(o -> input.getValue().add(o.clone())); | ||
return input; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...idpoint/model/impl/lens/projector/policy/scriptExecutor/AbstractSingleRunTaskCreator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (c) 2020 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
package com.evolveum.midpoint.model.impl.lens.projector.policy.scriptExecutor; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import com.evolveum.midpoint.model.api.ModelPublicConstants; | ||
import com.evolveum.midpoint.schema.result.OperationResult; | ||
import com.evolveum.midpoint.util.exception.*; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; | ||
import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExecuteScriptType; | ||
|
||
/** | ||
* Creates "single run" scripting task. | ||
*/ | ||
abstract class AbstractSingleRunTaskCreator extends ScriptingTaskCreator { | ||
|
||
AbstractSingleRunTaskCreator(@NotNull ActionContext actx) { | ||
super(actx); | ||
} | ||
|
||
@NotNull | ||
TaskType createTaskForSingleRunScript(ExecuteScriptType executeScript, OperationResult result) | ||
throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, | ||
SecurityViolationException, ExpressionEvaluationException { | ||
TaskType newTask = createArchetypedTask(result); | ||
setScriptInTask(newTask, executeScript); | ||
return newTask; | ||
} | ||
|
||
@NotNull | ||
private TaskType createArchetypedTask(OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, | ||
ConfigurationException, SecurityViolationException, ExpressionEvaluationException { | ||
|
||
TaskType newTask = createEmptyTask(result); | ||
newTask.setHandlerUri(ModelPublicConstants.SCRIPT_EXECUTION_TASK_HANDLER_URI); | ||
|
||
// TODO task customizer | ||
// TODO task archetype | ||
|
||
return newTask; | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
.../com/evolveum/midpoint/model/impl/lens/projector/policy/scriptExecutor/ActionContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2020 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
package com.evolveum.midpoint.model.impl.lens.projector.policy.scriptExecutor; | ||
|
||
import com.evolveum.midpoint.model.impl.lens.EvaluatedPolicyRuleImpl; | ||
import com.evolveum.midpoint.model.impl.lens.LensContext; | ||
import com.evolveum.midpoint.model.impl.lens.LensFocusContext; | ||
import com.evolveum.midpoint.task.api.Task; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ScriptExecutionPolicyActionType; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Context of execution of specific "script execution" policy action. | ||
*/ | ||
class ActionContext { | ||
|
||
@NotNull final ScriptExecutionPolicyActionType action; | ||
@NotNull final EvaluatedPolicyRuleImpl rule; | ||
@NotNull final LensContext<?> context; | ||
@NotNull final LensFocusContext<?> focusContext; | ||
@NotNull final Task task; | ||
@NotNull final PolicyRuleScriptExecutor beans; | ||
|
||
ActionContext(@NotNull ScriptExecutionPolicyActionType action, @NotNull EvaluatedPolicyRuleImpl rule, | ||
@NotNull LensContext<?> context, @NotNull Task task, @NotNull PolicyRuleScriptExecutor beans) { | ||
this.action = action; | ||
this.rule = rule; | ||
this.context = context; | ||
this.focusContext = context.getFocusContextRequired(); | ||
this.task = task; | ||
this.beans = beans; | ||
} | ||
} |
Oops, something went wrong.