use of com.evolveum.midpoint.xml.ns._public.model.scripting_3.PipelineDataType in project midpoint by Evolveum.
the class ModelWebService method doExecuteScripts.
private ExecuteScriptsResponseType doExecuteScripts(List<JAXBElement<?>> scriptsToExecute, ExecuteScriptsOptionsType options, Task task, OperationResult result) {
ExecuteScriptsResponseType response = new ExecuteScriptsResponseType();
ScriptOutputsType outputs = new ScriptOutputsType();
response.setOutputs(outputs);
try {
for (JAXBElement<?> script : scriptsToExecute) {
Object scriptValue = script.getValue();
if (!(scriptValue instanceof ScriptingExpressionType)) {
throw new SchemaException("Expected that scripts will be of type ScriptingExpressionType, but it was " + scriptValue.getClass().getName());
}
ScriptExecutionResult executionResult = scriptingService.evaluateExpression((ScriptingExpressionType) script.getValue(), task, result);
SingleScriptOutputType output = new SingleScriptOutputType();
outputs.getOutput().add(output);
output.setTextOutput(executionResult.getConsoleOutput());
if (options == null || options.getOutputFormat() == null || options.getOutputFormat() == OutputFormatType.XML) {
output.setDataOutput(prepareXmlData(executionResult.getDataOutput(), null));
} else {
// temporarily we send serialized XML in the case of MSL output
PipelineDataType jaxbOutput = prepareXmlData(executionResult.getDataOutput(), null);
output.setMslData(prismContext.xmlSerializer().serializeAnyData(jaxbOutput, SchemaConstants.C_VALUE));
}
}
result.computeStatusIfUnknown();
} catch (ScriptExecutionException | JAXBException | SchemaException | RuntimeException | SecurityViolationException e) {
result.recordFatalError(e.getMessage(), e);
LoggingUtils.logException(LOGGER, "Exception while executing script", e);
}
result.summarize();
response.setResult(result.createOperationResultType());
return response;
}
use of com.evolveum.midpoint.xml.ns._public.model.scripting_3.PipelineDataType in project midpoint by Evolveum.
the class ModelWebService method prepareXmlData.
public static PipelineDataType prepareXmlData(List<PipelineItem> output, ScriptingExpressionEvaluationOptionsType options) throws JAXBException, SchemaException {
boolean hideResults = options != null && Boolean.TRUE.equals(options.isHideOperationResults());
PipelineDataType rv = new PipelineDataType();
if (output != null) {
for (PipelineItem item : output) {
PipelineItemType itemType = new PipelineItemType();
PrismValue value = item.getValue();
if (value instanceof PrismReferenceValue) {
// This is a bit of hack: value.getRealValue() would return unserializable object (PRV$1 - does not have type QName)
ObjectReferenceType ort = new ObjectReferenceType();
ort.setupReferenceValue((PrismReferenceValue) value);
itemType.setValue(ort);
} else {
// TODO - ok?
itemType.setValue(value.getRealValue());
}
if (!hideResults) {
itemType.setResult(item.getResult().createOperationResultType());
}
rv.getItem().add(itemType);
}
}
return rv;
}
Aggregations