Search in sources :

Example 1 with ExecuteScriptActionExpressionType

use of com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExecuteScriptActionExpressionType in project midpoint by Evolveum.

the class ExecuteScriptExecutor method getParameters.

private Parameters getParameters(ActionExpressionType action, PipelineData input, ExecutionContext context, OperationResult globalResult) throws CommunicationException, ObjectNotFoundException, SchemaException, ScriptExecutionException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException {
    ScriptExpressionEvaluatorType script = expressionHelper.getActionArgument(ScriptExpressionEvaluatorType.class, action, ExecuteScriptActionExpressionType.F_SCRIPT, PARAM_SCRIPT, input, context, null, PARAM_SCRIPT, globalResult);
    ItemDefinition<?> outputDefinition;
    String outputItemUri = expressionHelper.getSingleArgumentValue(action.getParameter(), PARAM_OUTPUT_ITEM, false, false, NAME, input, context, String.class, globalResult);
    if (StringUtils.isNotBlank(outputItemUri)) {
        outputDefinition = getItemDefinition(outputItemUri);
    } else if (action instanceof ExecuteScriptActionExpressionType) {
        ExecuteScriptActionExpressionType execute = (ExecuteScriptActionExpressionType) action;
        if (execute.getOutputItemName() != null) {
            outputDefinition = getItemDefinitionFromItemName(execute.getOutputItemName());
        } else if (execute.getOutputTypeName() != null) {
            outputDefinition = getItemDefinitionFromTypeName(execute.getOutputTypeName());
        } else {
            outputDefinition = null;
        }
    } else {
        outputDefinition = null;
    }
    boolean forWholeInput = expressionHelper.getActionArgument(Boolean.class, action, ExecuteScriptActionExpressionType.F_FOR_WHOLE_INPUT, PARAM_FOR_WHOLE_INPUT, input, context, false, PARAM_FOR_WHOLE_INPUT, globalResult);
    boolean quiet = expressionHelper.getActionArgument(Boolean.class, action, ExecuteScriptActionExpressionType.F_QUIET, PARAM_QUIET, input, context, false, PARAM_QUIET, globalResult);
    if (script == null) {
        throw new IllegalArgumentException("No script provided");
    }
    // TODO
    ExpressionProfile expressionProfile = null;
    ScriptExpression scriptExpression;
    try {
        scriptExpression = scriptExpressionFactory.createScriptExpression(script, outputDefinition, expressionProfile, expressionFactory, "script", globalResult);
    } catch (ExpressionSyntaxException | SecurityViolationException e) {
        throw new ScriptExecutionException("Couldn't parse script expression: " + e.getMessage(), e);
    }
    return new Parameters(scriptExpression, outputDefinition, forWholeInput, quiet);
}
Also used : ExecuteScriptActionExpressionType(com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExecuteScriptActionExpressionType) ExpressionProfile(com.evolveum.midpoint.schema.expression.ExpressionProfile) ScriptExpressionEvaluatorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ScriptExpressionEvaluatorType) ScriptExpression(com.evolveum.midpoint.model.common.expression.script.ScriptExpression) ExpressionSyntaxException(com.evolveum.midpoint.repo.common.expression.ExpressionSyntaxException)

Aggregations

ScriptExpression (com.evolveum.midpoint.model.common.expression.script.ScriptExpression)1 ExpressionSyntaxException (com.evolveum.midpoint.repo.common.expression.ExpressionSyntaxException)1 ExpressionProfile (com.evolveum.midpoint.schema.expression.ExpressionProfile)1 ScriptExpressionEvaluatorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ScriptExpressionEvaluatorType)1 ExecuteScriptActionExpressionType (com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExecuteScriptActionExpressionType)1