/** * Create an instance of {@link ExecuteScriptType } * */ public ExecuteScriptType createExecuteScriptType() { return new ExecuteScriptType(); }
/** * 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())); }
public ExecuteScriptType input(ValueListType value) { setInput(value); return this; }
public static ExecuteScriptType createExecuteScriptCommand(ScriptingExpressionType expression) { ExecuteScriptType executeScriptCommand = new ExecuteScriptType(); executeScriptCommand.setScriptingExpression(ScriptingJaxbUtil.toJaxbElement(expression)); return executeScriptCommand; }
executeScriptProperty.getValue().getValue().getScriptingExpression() == null) { throw new IllegalStateException("There's no script to be run in task " + coordinatorTask + " (property " + SchemaConstants.SE_EXECUTE_SCRIPT + ")"); if (executeScriptRequestTemplate.getInput() != null && !executeScriptRequestTemplate.getInput().getValue().isEmpty()) { LOGGER.warn("Ignoring input values in executeScript data in task {}", coordinatorTask);
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(); } }
@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); }
@Override protected boolean handleObject(PrismObject<ObjectType> object, Task workerTask, OperationResult result) { try { ExecuteScriptType executeScriptRequest = executeScriptRequestTemplate.clone(); executeScriptRequest.setInput(new ValueListType().value(object.asObjectable())); ScriptExecutionResult executionResult = scriptingService.evaluateExpression(executeScriptRequest, emptyMap(), false, workerTask, result); LOGGER.debug("Execution output: {} item(s)", executionResult.getDataOutput().size()); LOGGER.debug("Execution result:\n{}", executionResult.getConsoleOutput()); result.computeStatus(); } catch (ScriptExecutionException | SecurityViolationException | SchemaException | ObjectNotFoundException | ExpressionEvaluationException | CommunicationException | ConfigurationException e) { result.recordFatalError("Couldn't execute script: " + e.getMessage(), e); LoggingUtils.logUnexpectedException(LOGGER, "Couldn't execute script", e); } return true; } };
public ExecuteScriptType scriptingExpression(JAXBElement<? extends ScriptingExpressionType> value) { setScriptingExpression(value); return this; }
.output(new ExecuteScriptOutputType() .consoleOutput(executionResult.getConsoleOutput()) .dataOutput(ModelWebService.prepareXmlData(executionResult.getDataOutput(), command.getOptions()))); response = RestServiceUtil.createResponse(Response.Status.OK, responseData, result);
@Override public TaskRunResult run(Task task) { OperationResult result = task.getResult().createSubresult(DOT_CLASS + "run"); TaskRunResult runResult = new TaskRunResult(); PrismProperty<ExecuteScriptType> executeScriptProperty = task.getExtensionProperty(SchemaConstants.SE_EXECUTE_SCRIPT); if (executeScriptProperty == null || executeScriptProperty.getValue().getValue() == null || executeScriptProperty.getValue().getValue().getScriptingExpression() == null) { throw new IllegalStateException("There's no script to be run in task " + task + " (property " + SchemaConstants.SE_EXECUTE_SCRIPT + ")"); } try { ScriptExecutionResult executionResult = scriptingService.evaluateExpression(executeScriptProperty.getRealValue(), emptyMap(), true, task, result); LOGGER.debug("Execution output: {} item(s)", executionResult.getDataOutput().size()); LOGGER.debug("Execution result:\n{}", executionResult.getConsoleOutput()); result.computeStatus(); runResult.setRunResultStatus(TaskRunResult.TaskRunResultStatus.FINISHED); } catch (ScriptExecutionException | SecurityViolationException | SchemaException | ObjectNotFoundException | ExpressionEvaluationException | CommunicationException | ConfigurationException e) { result.recordFatalError("Couldn't execute script: " + e.getMessage(), e); LoggingUtils.logUnexpectedException(LOGGER, "Couldn't execute script", e); runResult.setRunResultStatus(TaskRunResult.TaskRunResultStatus.PERMANENT_ERROR); } task.getResult().computeStatus(); runResult.setOperationResult(task.getResult()); return runResult; }
Object o = executeScript.getInput().getValue().get(0); System.out.println(o); assertTrue("Raw value is not parsed", o instanceof RawType && ((RawType) o).getAlreadyParsedValue() != null);
/** * 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); } }
/** * Create an instance of {@link ExecuteScriptType } * */ public ExecuteScriptType createExecuteScriptType() { return new ExecuteScriptType(); }
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); } }
/** * Create an instance of {@link ExecuteScriptType } * */ public ExecuteScriptType createExecuteScriptType() { return new ExecuteScriptType(); }
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; }
public ExecuteScriptType beginExecuteScript() { ExecuteScriptType value = new ExecuteScriptType(); executeScript(value); return value; }
lhsScriptingExpression = this.getScriptingExpression(); JAXBElement<? extends ScriptingExpressionType> rhsScriptingExpression; rhsScriptingExpression = that.getScriptingExpression(); if (!strategy.equals(LocatorUtils.property(thisLocator, "scriptingExpression", lhsScriptingExpression), LocatorUtils.property(thatLocator, "scriptingExpression", rhsScriptingExpression), lhsScriptingExpression, rhsScriptingExpression)) { return false; lhsInput = this.getInput(); ValueListType rhsInput; rhsInput = that.getInput(); if (!strategy.equals(LocatorUtils.property(thisLocator, "input", lhsInput), LocatorUtils.property(thatLocator, "input", rhsInput), lhsInput, rhsInput)) { return false; lhsOptions = this.getOptions(); ScriptingExpressionEvaluationOptionsType rhsOptions; rhsOptions = that.getOptions(); if (!strategy.equals(LocatorUtils.property(thisLocator, "options", lhsOptions), LocatorUtils.property(thatLocator, "options", rhsOptions), lhsOptions, rhsOptions)) { return false; lhsVariables = this.getVariables(); ScriptingVariablesDefinitionType rhsVariables; rhsVariables = that.getVariables(); if (!strategy.equals(LocatorUtils.property(thisLocator, "variables", lhsVariables), LocatorUtils.property(thatLocator, "variables", rhsVariables), lhsVariables, rhsVariables)) { return false;
public ExecuteScriptType beginExecuteScript() { ExecuteScriptType value = new ExecuteScriptType(); executeScript(value); return value; }