/** * Creates and returns a deep copy of this object. * * * @return * A deep copy of this object. */ @Override public ExecuteScriptType clone() { try { { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 final ExecuteScriptType clone = ((ExecuteScriptType) super.clone()); // 'ScriptingExpression' property. clone.scriptingExpression = ((this.scriptingExpression == null)?null:copyOfScriptingExpression(this.getScriptingExpression())); // CClassInfo: com.evolveum.midpoint.xml.ns._public.model.scripting_3.ValueListType clone.input = ((this.input == null)?null:((this.getInput() == null)?null:this.getInput().clone())); // CClassInfo: com.evolveum.midpoint.xml.ns._public.model.scripting_3.ScriptingExpressionEvaluationOptionsType clone.options = ((this.options == null)?null:((this.getOptions() == null)?null:this.getOptions().clone())); // CClassInfo: com.evolveum.midpoint.xml.ns._public.model.scripting_3.ScriptingVariablesDefinitionType clone.variables = ((this.variables == null)?null:((this.getVariables() == null)?null:this.getVariables().clone())); return clone; } } catch (CloneNotSupportedException e) { // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ throw new AssertionError(e); } }
/** * Creates a new {@code ExecuteScriptType} instance by deeply copying a given {@code ExecuteScriptType} instance. * * * @param o * The instance to copy. * @throws NullPointerException * if {@code o} is {@code null}. */ public ExecuteScriptType(final ExecuteScriptType o) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 super(); if (o == null) { throw new NullPointerException("Cannot create a copy of 'ExecuteScriptType' from 'null'."); } // 'ScriptingExpression' property. this.scriptingExpression = ((o.scriptingExpression == null)?null:copyOfScriptingExpression(o.getScriptingExpression())); // CClassInfo: com.evolveum.midpoint.xml.ns._public.model.scripting_3.ValueListType this.input = ((o.input == null)?null:((o.getInput() == null)?null:o.getInput().clone())); // CClassInfo: com.evolveum.midpoint.xml.ns._public.model.scripting_3.ScriptingExpressionEvaluationOptionsType this.options = ((o.options == null)?null:((o.getOptions() == null)?null:o.getOptions().clone())); // CClassInfo: com.evolveum.midpoint.xml.ns._public.model.scripting_3.ScriptingVariablesDefinitionType this.variables = ((o.variables == null)?null:((o.getVariables() == null)?null:o.getVariables().clone())); }
private ExecutionContext evaluateExpression(@NotNull ExecuteScriptType executeScript, Map<String, Object> initialVariables, boolean privileged, boolean recordProgressAndIterationStatistics, Task task, OperationResult result) throws ScriptExecutionException { Validate.notNull(executeScript.getScriptingExpression(), "Scripting expression must be present"); try { Map<String, Object> frozenVariables = VariablesUtil.initialPreparation(initialVariables, executeScript.getVariables(), expressionFactory, modelObjectResolver, prismContext, task, result); PipelineData pipelineData = PipelineData.parseFrom(executeScript.getInput(), frozenVariables, prismContext); ExecutionContext context = new ExecutionContext(executeScript.getOptions(), task, this, privileged, recordProgressAndIterationStatistics, frozenVariables); PipelineData output = evaluateExpression(executeScript.getScriptingExpression().getValue(), pipelineData, context, result); context.setFinalOutput(output); result.computeStatusIfUnknown(); context.computeResults(); return context; } catch (ExpressionEvaluationException | SchemaException | ObjectNotFoundException | RuntimeException | CommunicationException | ConfigurationException | SecurityViolationException e) { result.recordFatalError("Couldn't execute script", e); throw new ScriptExecutionException("Couldn't execute script: " + e.getMessage(), e); } }
@Test public void testParseTaskFile() throws Exception { System.out.println("===[ testParseTaskFile ]==="); // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); // WHEN PrismObject<TaskType> task = prismContext.parserFor(TASK_FILE).xml().parse(); // THEN System.out.println("Parsed task:"); System.out.println(task.debugDump()); assertTask(task); Item executeScriptItem = task.findExtensionItem(new QName("executeScript")); ExecuteScriptType executeScript = (ExecuteScriptType) executeScriptItem.getRealValue(); Object o = executeScript.getInput().getValue().get(0); System.out.println(o); assertTrue("Raw value is not parsed", o instanceof RawType && ((RawType) o).getAlreadyParsedValue() != null); }
private void executeScript(ScriptExecutionPolicyActionType action, EvaluatedPolicyRule rule, ModelContext<?> context, Task task, OperationResult parentResult, ExecuteScriptType executeScriptBean) { OperationResult result = parentResult.createSubresult(EXECUTE_SCRIPT_OPERATION); try { Map<String, Object> initialVariables = createInitialVariables(action, rule, context); if (executeScriptBean.getInput() == null && context.getFocusContext() != null) { PrismObject objectAny = ((LensFocusContext) context.getFocusContext()).getObjectAny(); if (objectAny != null) { ValueListType input = new ValueListType(); input.getValue().add(objectAny.getValue().clone()); executeScriptBean.setInput(input); } } scriptingExpressionEvaluator.evaluateExpression(executeScriptBean, initialVariables, false, task, result); } catch (ScriptExecutionException | RuntimeException e) { result.recordFatalError("Couldn't execute script policy action: " + e.getMessage(), e); LoggingUtils.logUnexpectedException(LOGGER, "Couldn't execute script with id={} in scriptExecution policy action '{}' (rule '{}'): {}", e, action.getId(), action.getName(), rule.getName(), e.getMessage()); } finally { result.computeStatusIfUnknown(); } }
Object o = executeScript.getInput().getValue().get(0); System.out.println(o); assertTrue("Raw value is not parsed", o instanceof RawType && ((RawType) o).getAlreadyParsedValue() != null);
public int hashCode(ObjectLocator locator, HashCodeStrategy strategy) { int currentHashCode = 1; { JAXBElement<? extends ScriptingExpressionType> theScriptingExpression; theScriptingExpression = this.getScriptingExpression(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "scriptingExpression", theScriptingExpression), currentHashCode, theScriptingExpression); } { ValueListType theInput; theInput = this.getInput(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "input", theInput), currentHashCode, theInput); } { ScriptingExpressionEvaluationOptionsType theOptions; theOptions = this.getOptions(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "options", theOptions), currentHashCode, theOptions); } { ScriptingVariablesDefinitionType theVariables; theVariables = this.getVariables(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "variables", theVariables), currentHashCode, theVariables); } return currentHashCode; }