/** * Create an instance of {@link ActionExpressionType } * */ public ActionExpressionType createActionExpressionType() { return new ActionExpressionType(); }
/** * Creates a new {@code ActionExpressionType} instance by deeply copying a given {@code ActionExpressionType} instance. * * * @param o * The instance to copy. * @throws NullPointerException * if {@code o} is {@code null}. */ public ActionExpressionType(final ActionExpressionType o) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 super(o); if (o == null) { throw new NullPointerException("Cannot create a copy of 'ActionExpressionType' from 'null'."); } // CBuiltinLeafInfo: java.lang.String this.type = ((o.type == null)?null:o.getType()); // 'Parameter' collection. if (o.parameter!= null) { copyParameter(o.getParameter(), this.getParameter()); } }
public ActionExpressionType type(String value) { setType(value); return this; }
public int hashCode(ObjectLocator locator, HashCodeStrategy strategy) { int currentHashCode = super.hashCode(locator, strategy); { String theType; theType = this.getType(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "type", theType), currentHashCode, theType); } { List<ActionParameterValueType> theParameter; theParameter = (((this.parameter!= null)&&(!this.parameter.isEmpty()))?this.getParameter():null); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "parameter", theParameter), currentHashCode, theParameter); } return currentHashCode; }
public ActionExpressionType parameter(ActionParameterValueType value) { getParameter().add(value); return this; }
/** * Asynchronously executes simple scripting expressions, consisting of one search command and one action. * * @param objectType Object type to search (e.g. c:UserType) * @param filter Filter to be applied (ObjectFilter) * @param actionName Action to be executed on objects found (e.g. "disable", "delete", "recompute", etc). * @param task Task in context of which the script should execute. The task should be "clean", i.e. * (1) transient, (2) without any handler. This method puts the task into background, * and assigns ScriptExecutionTaskHandler to it, to execute the script. */ @Deprecated public void evaluateExpressionInBackground(QName objectType, ObjectFilter filter, String actionName, Task task, OperationResult parentResult) throws SchemaException { Validate.notNull(objectType); Validate.notNull(actionName); Validate.notNull(task); SearchExpressionType search = new SearchExpressionType(); search.setType(objectType); if (filter != null) { search.setSearchFilter(prismContext.getQueryConverter().createSearchFilterType(filter)); } ActionExpressionType action = new ActionExpressionType(); action.setType(actionName); search.setScriptingExpression(objectFactory.createAction(action)); evaluateExpressionInBackground(search, task, parentResult); }
private PipelineData executeAction(ActionExpressionType command, PipelineData input, ExecutionContext context, OperationResult globalResult) throws ScriptExecutionException { Validate.notNull(command, "command"); Validate.notNull(command.getType(), "command.actionType"); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Executing action {} on {}", command.getType(), input.debugDump()); } else if (LOGGER.isDebugEnabled()) { LOGGER.debug("Executing action {}", command.getType()); } ActionExecutor executor = actionExecutors.get(command.getType()); if (executor == null) { throw new IllegalStateException("Unsupported action type: " + command.getType()); } else { PipelineData retval = executor.execute(command, input, context, globalResult); globalResult.setSummarizeSuccesses(true); globalResult.summarize(); return retval; } }
/** * Creates and returns a deep copy of a given {@code javax.xml.bind.JAXBElement<com.evolveum.midpoint.xml.ns._public.model.scripting_3.ActionExpressionType>} instance. * * @param e * The instance to copy or {@code null}. * @return * A deep copy of {@code e} or {@code null} if {@code e} is {@code null}. */ @SuppressWarnings("unchecked") private static JAXBElement<ActionExpressionType> copyOfActionExpressionTypeElement(final JAXBElement<ActionExpressionType> e) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 if (e!= null) { final JAXBElement<ActionExpressionType> copy = new JAXBElement<ActionExpressionType>(e.getName(), e.getDeclaredType(), e.getScope(), e.getValue()); copy.setNil(e.isNil()); // CClassInfo: com.evolveum.midpoint.xml.ns._public.model.scripting_3.ActionExpressionType copy.setValue(((((ActionExpressionType) copy.getValue()) == null)?null:((ActionExpressionType) copy.getValue()).clone())); return copy; } return null; }
public boolean equals(Object object) { final EqualsStrategy strategy = DomAwareEqualsStrategy.INSTANCE; return equals(null, null, object, strategy); }
lhsType = this.getType(); String rhsType; rhsType = that.getType(); if (!strategy.equals(LocatorUtils.property(thisLocator, "type", lhsType), LocatorUtils.property(thatLocator, "type", rhsType), lhsType, rhsType)) { return false; lhsParameter = (((this.parameter!= null)&&(!this.parameter.isEmpty()))?this.getParameter():null); List<ActionParameterValueType> rhsParameter; rhsParameter = (((that.parameter!= null)&&(!that.parameter.isEmpty()))?that.getParameter():null); if (!strategy.equals(LocatorUtils.property(thisLocator, "parameter", lhsParameter), LocatorUtils.property(thatLocator, "parameter", rhsParameter), lhsParameter, rhsParameter)) { return false;
protected boolean getParamDryRun(ActionExpressionType expression, PipelineData input, ExecutionContext context, OperationResult result) throws ScriptExecutionException { return expressionHelper.getArgumentAsBoolean(expression.getParameter(), PARAM_DRY_RUN, input, context, false, PARAM_DRY_RUN, result); }
@Override public PipelineData execute(ActionExpressionType expression, PipelineData input, ExecutionContext context, OperationResult globalResult) throws ScriptExecutionException { boolean isEnable = NAME_ENABLE.equals(expression.getType()); ModelExecuteOptions executionOptions = getOptions(expression, input, context, globalResult); boolean dryRun = getParamDryRun(expression, input, context, globalResult); PrismValue value = item.getValue(); OperationResult result = operationsHelper.createActionResult(item, this, context, globalResult); result.addParam("operation", expression.getType()); context.checkTaskStop(); if (value instanceof PrismObjectValue) { } catch (Throwable ex) { operationsHelper.recordEnd(context, objectType, started, ex); exception = processActionException(ex, expression.getType(), value, context); context.println((exception != null ? "Attempted to " + expression.getType() : (isEnable ? "Enabled " : "Disabled ")) + prismObject.toString() + optionsSuffix(executionOptions, dryRun) + exceptionSuffix(exception)); } else { processActionException(new ScriptExecutionException("Item is not a PrismObject"), expression.getType(), value, context);
/** * Creates and returns a deep copy of a given {@code javax.xml.bind.JAXBElement<com.evolveum.midpoint.xml.ns._public.model.scripting_3.ActionExpressionType>} instance. * * @param e * The instance to copy or {@code null}. * @return * A deep copy of {@code e} or {@code null} if {@code e} is {@code null}. */ @SuppressWarnings("unchecked") private static JAXBElement<ActionExpressionType> copyOfActionExpressionTypeElement(final JAXBElement<ActionExpressionType> e) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 if (e!= null) { final JAXBElement<ActionExpressionType> copy = new JAXBElement<ActionExpressionType>(e.getName(), e.getDeclaredType(), e.getScope(), e.getValue()); copy.setNil(e.isNil()); // CClassInfo: com.evolveum.midpoint.xml.ns._public.model.scripting_3.ActionExpressionType copy.setValue(((((ActionExpressionType) copy.getValue()) == null)?null:((ActionExpressionType) copy.getValue()).clone())); return copy; } return null; }
/** * Creates and returns a deep copy of this object. * * * @return * A deep copy of this object. */ @Override public ActionExpressionType clone() { { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 final ActionExpressionType clone = ((ActionExpressionType) super.clone()); // CBuiltinLeafInfo: java.lang.String clone.type = ((this.type == null)?null:this.getType()); // 'Parameter' collection. if (this.parameter!= null) { clone.parameter = null; copyParameter(this.getParameter(), clone.getParameter()); } return clone; } }
/** * Create an instance of {@link ActionExpressionType } * */ public ActionExpressionType createActionExpressionType() { return new ActionExpressionType(); }
@Override public PipelineData execute(ActionExpressionType expression, PipelineData input, ExecutionContext context, OperationResult parentResult) throws ScriptExecutionException { String levelAsString = expressionHelper.getArgumentAsString(expression.getParameter(), PARAM_LEVEL, input, context, LEVEL_INFO, NAME, parentResult); String message = expressionHelper.getArgumentAsString(expression.getParameter(), PARAM_MESSAGE, input, context, "Current data: ", NAME, parentResult); message += "{}"; if (LEVEL_INFO.equals(levelAsString)) { if (LOGGER.isInfoEnabled()) { LOGGER.info(message, DebugUtil.debugDump(input)); } } else if (LEVEL_DEBUG.equals(levelAsString)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(message, DebugUtil.debugDump(input)); } } else if (LEVEL_TRACE.equals(levelAsString)) { if (LOGGER.isTraceEnabled()) { LOGGER.trace(message, DebugUtil.debugDump(input)); } } else { LOGGER.warn("Invalid logging level specified for 'log' scripting action: " + levelAsString); } return input; } }
@SuppressWarnings("unchecked") @Override protected void assertPrismPropertyValueLocal(PrismPropertyValue<ExpressionPipelineType> value) throws SchemaException { ExpressionPipelineType pipe = value.getValue(); JAXBElement<ExpressionSequenceType> sequenceJaxb1 = (JAXBElement<ExpressionSequenceType>) pipe.getScriptingExpression().get(0); assertEquals("Wrong element name (1)", SchemaConstants.S_SEQUENCE, sequenceJaxb1.getName()); assertEquals("Wrong element type (1)", ExpressionSequenceType.class, sequenceJaxb1.getValue().getClass()); JAXBElement<SearchExpressionType> searchJaxb1_1 = (JAXBElement<SearchExpressionType>) sequenceJaxb1.getValue().getScriptingExpression().get(0); assertEquals("Wrong first element name", SchemaConstants.S_SEARCH, searchJaxb1_1.getName()); assertEquals("Wrong element type (1.1)", SearchExpressionType.class, searchJaxb1_1.getValue().getClass()); assertEquals(new QName("RoleType"), searchJaxb1_1.getValue().getType()); assertNotNull(searchJaxb1_1.getValue().getSearchFilter()); JAXBElement<ActionExpressionType> actionJaxb1_2 = (JAXBElement<ActionExpressionType>) sequenceJaxb1.getValue().getScriptingExpression().get(1); assertEquals("Wrong element type (1.2)", ActionExpressionType.class, actionJaxb1_2.getValue().getClass()); assertEquals("log", actionJaxb1_2.getValue().getType()); JAXBElement<ExpressionSequenceType> sequenceJaxb2 = (JAXBElement<ExpressionSequenceType>) pipe.getScriptingExpression().get(1); assertEquals("Wrong second element name", SchemaConstants.S_SEQUENCE, sequenceJaxb2.getName()); assertEquals("Wrong element type (2)", ExpressionSequenceType.class, sequenceJaxb2.getValue().getClass()); JAXBElement<ActionExpressionType> actionJaxb2_1 = (JAXBElement<ActionExpressionType>) sequenceJaxb2.getValue().getScriptingExpression().get(0); JAXBElement<ActionExpressionType> actionJaxb2_2 = (JAXBElement<ActionExpressionType>) sequenceJaxb2.getValue().getScriptingExpression().get(1); JAXBElement<SearchExpressionType> searchJaxb2_3 = (JAXBElement<SearchExpressionType>) sequenceJaxb2.getValue().getScriptingExpression().get(2); assertEquals("Wrong element name (2.1)", SchemaConstants.S_ACTION, actionJaxb2_1.getName()); assertEquals("Wrong element type (2.1)", ActionExpressionType.class, actionJaxb2_1.getValue().getClass()); assertEquals("Wrong element name (2.2)", SchemaConstants.S_ACTION, actionJaxb2_2.getName()); assertEquals("Wrong element type (2.2)", ActionExpressionType.class, actionJaxb2_2.getValue().getClass()); assertEquals("Wrong element name (2.3)", SchemaConstants.S_SEARCH, searchJaxb2_3.getName()); assertEquals("Wrong element type (2.3)", SearchExpressionType.class, searchJaxb2_3.getValue().getClass()); }
/** * Creates and returns a deep copy of a given {@code javax.xml.bind.JAXBElement<com.evolveum.midpoint.xml.ns._public.model.scripting_3.ActionExpressionType>} instance. * * @param e * The instance to copy or {@code null}. * @return * A deep copy of {@code e} or {@code null} if {@code e} is {@code null}. */ @SuppressWarnings("unchecked") private static JAXBElement<ActionExpressionType> copyOfActionExpressionTypeElement(final JAXBElement<ActionExpressionType> e) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 if (e!= null) { final JAXBElement<ActionExpressionType> copy = new JAXBElement<ActionExpressionType>(e.getName(), e.getDeclaredType(), e.getScope(), e.getValue()); copy.setNil(e.isNil()); // CClassInfo: com.evolveum.midpoint.xml.ns._public.model.scripting_3.ActionExpressionType copy.setValue(((((ActionExpressionType) copy.getValue()) == null)?null:((ActionExpressionType) copy.getValue()).clone())); return copy; } return null; }
/** * Create an instance of {@link ActionExpressionType } * */ public ActionExpressionType createActionExpressionType() { return new ActionExpressionType(); }
protected ModelExecuteOptions getOptions(ActionExpressionType expression, PipelineData input, ExecutionContext context, OperationResult result) throws ScriptExecutionException { boolean raw = expressionHelper.getArgumentAsBoolean(expression.getParameter(), PARAM_RAW, input, context, false, PARAM_RAW, result); boolean skipApprovals = expressionHelper.getArgumentAsBoolean(expression.getParameter(), PARAM_SKIP_APPROVALS, input, context, false, PARAM_RAW, result); ModelExecuteOptionsType optionsBean = expressionHelper.getSingleArgumentValue(expression.getParameter(), PARAM_OPTIONS, false, false, "options", input, context, ModelExecuteOptionsType.class, result); ModelExecuteOptions options; if (optionsBean != null) { options = ModelExecuteOptions.fromModelExecutionOptionsType(optionsBean); } else { options = new ModelExecuteOptions(); } if (raw) { options.setRaw(true); } if (skipApprovals) { if (options.getPartialProcessing() != null) { options.getPartialProcessing().setApprovals(SKIP); } else { options.setPartialProcessing(new PartialProcessingOptionsType().approvals(SKIP)); } } return options; }