-
Notifications
You must be signed in to change notification settings - Fork 188
/
ExpressionUtil.java
542 lines (477 loc) · 23.4 KB
/
ExpressionUtil.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
/*
* Copyright (c) 2010-2013 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.model.common.expression;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.xml.bind.JAXBException;
import javax.xml.namespace.QName;
import com.evolveum.midpoint.prism.query.ExpressionWrapper;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;
import org.w3c.dom.Element;
import com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions;
import com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctionsXPath;
import com.evolveum.midpoint.model.common.expression.functions.FunctionLibrary;
import com.evolveum.midpoint.model.common.expression.functions.LogExpressionFunctions;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.Item;
import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.Objectable;
import com.evolveum.midpoint.prism.PrismConstants;
import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismContainerDefinition;
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismObjectDefinition;
import com.evolveum.midpoint.prism.PrismPropertyDefinition;
import com.evolveum.midpoint.prism.PrismPropertyValue;
import com.evolveum.midpoint.prism.PrismValue;
import com.evolveum.midpoint.prism.Recomputable;
import com.evolveum.midpoint.prism.Structured;
import com.evolveum.midpoint.prism.Visitable;
import com.evolveum.midpoint.prism.Visitor;
import com.evolveum.midpoint.prism.crypto.EncryptionException;
import com.evolveum.midpoint.prism.crypto.Protector;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.path.ItemPathSegment;
import com.evolveum.midpoint.prism.path.NameItemPathSegment;
import com.evolveum.midpoint.prism.polystring.PolyString;
import com.evolveum.midpoint.prism.query.EqualFilter;
import com.evolveum.midpoint.prism.query.LogicalFilter;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.query.PropertyValueFilter;
import com.evolveum.midpoint.prism.query.ValueFilter;
import com.evolveum.midpoint.prism.util.JavaTypeConverter;
import com.evolveum.midpoint.prism.util.PrismUtil;
import com.evolveum.midpoint.prism.xml.XsdTypeMapper;
import com.evolveum.midpoint.schema.constants.ExpressionConstants;
import com.evolveum.midpoint.schema.constants.MidPointConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectResolver;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.util.PrettyPrinter;
import com.evolveum.midpoint.util.exception.ExpressionEvaluationException;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
/**
* @author semancik
*
*/
public class ExpressionUtil {
private static final Trace LOGGER = TraceManager.getTrace(ExpressionUtil.class);
public static <V extends PrismValue> PrismValueDeltaSetTriple<V> toOutputTriple(PrismValueDeltaSetTriple<V> resultTriple,
ItemDefinition outputDefinition, final ItemPath residualPath, final Protector protector, final PrismContext prismContext) {
final Class<?> resultTripleValueClass = resultTriple.getRealValueClass();
if (resultTripleValueClass == null) {
// triple is empty. type does not matter.
return resultTriple;
}
Class<?> expectedJavaType = XsdTypeMapper.toJavaType(outputDefinition.getTypeName());
if (expectedJavaType == null) {
expectedJavaType = prismContext.getSchemaRegistry().getCompileTimeClass(outputDefinition.getTypeName());
}
if (resultTripleValueClass == expectedJavaType) {
return resultTriple;
}
final Class<?> finalExpectedJavaType = expectedJavaType;
PrismValueDeltaSetTriple<V> clonedTriple = resultTriple.clone();
clonedTriple.accept(new Visitor() {
@Override
public void visit(Visitable visitable) {
if (visitable instanceof PrismPropertyValue<?>) {
PrismPropertyValue<Object> pval = (PrismPropertyValue<Object>)visitable;
Object realVal = pval.getValue();
if (realVal != null) {
if (Structured.class.isAssignableFrom(resultTripleValueClass)) {
if (residualPath != null && !residualPath.isEmpty()) {
realVal = ((Structured)realVal).resolve(residualPath);
}
}
if (finalExpectedJavaType != null) {
Object convertedVal = convertValue(finalExpectedJavaType, realVal, protector, prismContext);
pval.setValue(convertedVal);
}
}
}
}
});
return clonedTriple;
}
/**
* Slightly more powerful version of "convert" as compared to JavaTypeConverter.
* This version can also encrypt/decrypt and also handles polystrings.
*/
public static <I,O> O convertValue(Class<O> finalExpectedJavaType, I inputVal,
Protector protector, PrismContext prismContext) {
if (inputVal == null) {
return null;
}
if (finalExpectedJavaType.isInstance(inputVal)) {
return (O) inputVal;
}
Object intermediateVal = inputVal;
if (finalExpectedJavaType == ProtectedStringType.class) {
String valueToEncrypt;
if (inputVal instanceof String) {
valueToEncrypt = (String)inputVal;
} else {
valueToEncrypt = JavaTypeConverter.convert(String.class, inputVal);
}
try {
intermediateVal = protector.encryptString(valueToEncrypt);
} catch (EncryptionException e) {
throw new SystemException(e.getMessage(),e);
}
} else {
if (inputVal instanceof ProtectedStringType) {
String decryptedString;
try {
intermediateVal = protector.decryptString((ProtectedStringType)inputVal);
} catch (EncryptionException e) {
throw new SystemException(e.getMessage(),e);
}
}
}
O convertedVal = JavaTypeConverter.convert(finalExpectedJavaType, intermediateVal);
PrismUtil.recomputeRealValue(convertedVal, prismContext);
return convertedVal;
}
public static Object resolvePath(ItemPath path, ExpressionVariables variables, Object defaultContext,
ObjectResolver objectResolver, String shortDesc, OperationResult result) throws SchemaException, ObjectNotFoundException {
Object root = defaultContext;
ItemPath relativePath = path;
ItemPathSegment first = path.first();
String varDesc = "default context";
if (first instanceof NameItemPathSegment && ((NameItemPathSegment)first).isVariable()) {
QName varName = ((NameItemPathSegment)first).getName();
varDesc = "variable "+PrettyPrinter.prettyPrint(varName);
relativePath = path.rest();
if (variables.containsKey(varName)) {
root = variables.get(varName);
} else {
throw new SchemaException("No variable with name "+varName+" in "+shortDesc);
}
}
if (root == null) {
return null;
}
if (relativePath.isEmpty()) {
return root;
}
if (root instanceof ObjectReferenceType) {
root = resolveReference((ObjectReferenceType)root, objectResolver, varDesc, shortDesc, result);
}
if (root instanceof Objectable) {
return (((Objectable) root).asPrismObject()).find(relativePath);
} if (root instanceof PrismObject<?>) {
return ((PrismObject<?>)root).find(relativePath);
} else if (root instanceof PrismContainer<?>) {
return ((PrismContainer<?>)root).find(relativePath);
} else if (root instanceof PrismContainerValue<?>) {
return ((PrismContainerValue<?>)root).find(relativePath);
} else if (root instanceof Item<?>) {
// Except for container (which is handled above)
throw new SchemaException("Cannot apply path "+relativePath+" to "+root+" in "+shortDesc);
} else if (root instanceof ObjectDeltaObject<?>) {
return ((ObjectDeltaObject<?>)root).findIdi(relativePath);
} else if (root instanceof ItemDeltaItem<?>) {
return ((ItemDeltaItem<?>)root).findIdi(relativePath);
} else {
throw new IllegalArgumentException("Unexpected root "+root+" (relative path:"+relativePath+") in "+shortDesc);
}
}
private static PrismObject<?> resolveReference(ObjectReferenceType ref, ObjectResolver objectResolver, String varDesc, String contextDescription,
OperationResult result) throws SchemaException, ObjectNotFoundException {
if (ref.getOid() == null) {
throw new SchemaException("Null OID in reference in variable "+varDesc+" in "+contextDescription);
} else {
try {
ObjectType objectType = objectResolver.resolve(ref, ObjectType.class, null, contextDescription, result);
if (objectType == null) {
throw new IllegalArgumentException("Resolve returned null for "+ref+" in "+contextDescription);
}
return objectType.asPrismObject();
} catch (ObjectNotFoundException e) {
throw new ObjectNotFoundException("Object not found during variable "+varDesc+" resolution in "+contextDescription+": "+e.getMessage(),e, ref.getOid());
} catch (SchemaException e) {
throw new SchemaException("Schema error during variable "+varDesc+" resolution in "+contextDescription+": "+e.getMessage(), e);
}
}
}
public static ItemDefinition resolveDefinitionPath(ItemPath path, ExpressionVariables variables,
PrismObjectDefinition<?> defaultContext, String shortDesc) throws SchemaException {
while (path!=null && !path.isEmpty() && !(path.first() instanceof NameItemPathSegment)) {
path = path.rest();
}
Object root = defaultContext;
ItemPath relativePath = path;
NameItemPathSegment first = (NameItemPathSegment)path.first();
if (first.isVariable()) {
relativePath = path.rest();
QName varName = first.getName();
if (variables.containsKey(varName)) {
Object varValue = variables.get(varName);
if (varValue instanceof ItemDeltaItem<?>) {
root = ((ItemDeltaItem<?>)varValue).getDefinition();
} else if (varValue instanceof Item<?>) {
root = ((Item<?>)varValue).getDefinition();
} else if (varValue instanceof Objectable) {
root = ((Objectable)varValue).asPrismObject().getDefinition();
} else if (varValue instanceof ItemDefinition) {
root = varValue;
} else {
throw new IllegalStateException("Unexpected content of variable "+varName+": "+varValue+" ("+varValue.getClass()+")");
}
if (root == null) {
throw new IllegalStateException("Null definition in content of variable "+varName+": "+varValue);
}
} else {
throw new SchemaException("No variable with name "+varName+" in "+shortDesc);
}
}
if (root == null) {
return null;
}
if (relativePath.isEmpty()) {
return (ItemDefinition) root;
}
ItemDefinition result = null;
if (root instanceof PrismObjectDefinition<?>) {
return ((PrismObjectDefinition<?>)root).findItemDefinition(relativePath);
} else if (root instanceof PrismContainerDefinition<?>) {
return ((PrismContainerDefinition<?>)root).findItemDefinition(relativePath);
} else if (root instanceof ItemDefinition) {
// Except for container (which is handled above)
throw new SchemaException("Cannot apply path "+relativePath+" to "+root+" in "+shortDesc);
} else {
throw new IllegalArgumentException("Unexpected root "+root+" in "+shortDesc);
}
}
public static <V extends PrismValue> ItemDeltaItem<V> toItemDeltaItem(Object object, ObjectResolver objectResolver,
String string, OperationResult result) {
if (object == null) {
return null;
}
if (object instanceof ItemDeltaItem<?>) {
return (ItemDeltaItem<V>) object;
}
if (object instanceof PrismObject<?>) {
return (ItemDeltaItem<V>) new ObjectDeltaObject((PrismObject<?>)object, null, (PrismObject<?>)object);
} else if (object instanceof Item<?>) {
return new ItemDeltaItem<V>((Item<V>)object, null, (Item<V>)object);
} else if (object instanceof ItemDelta<?>) {
return new ItemDeltaItem<V>(null, (ItemDelta<V>)object, null);
} else {
throw new IllegalArgumentException("Unexpected object "+object+" "+object.getClass());
}
}
public static FunctionLibrary createBasicFunctionLibrary(PrismContext prismContext, Protector protector) {
FunctionLibrary lib = new FunctionLibrary();
lib.setVariableName(MidPointConstants.FUNCTION_LIBRARY_BASIC_VARIABLE_NAME);
lib.setNamespace(MidPointConstants.NS_FUNC_BASIC);
BasicExpressionFunctions func = new BasicExpressionFunctions(prismContext, protector);
lib.setGenericFunctions(func);
BasicExpressionFunctionsXPath funcXPath = new BasicExpressionFunctionsXPath(func);
lib.setXmlFunctions(funcXPath);
return lib;
}
public static FunctionLibrary createLogFunctionLibrary(PrismContext prismContext) {
FunctionLibrary lib = new FunctionLibrary();
lib.setVariableName(MidPointConstants.FUNCTION_LIBRARY_LOG_VARIABLE_NAME);
lib.setNamespace(MidPointConstants.NS_FUNC_LOG);
LogExpressionFunctions func = new LogExpressionFunctions(prismContext);
lib.setGenericFunctions(func);
return lib;
}
public static ObjectQuery evaluateQueryExpressions(ObjectQuery origQuery, ExpressionVariables variables,
ExpressionFactory expressionFactory, PrismContext prismContext,
String shortDesc, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
if (origQuery == null) {
return null;
}
ObjectQuery query = origQuery.clone();
evaluateFilterExpressionsInternal(query.getFilter(), variables, expressionFactory, prismContext, shortDesc, task, result);
return query;
}
public static ObjectFilter evaluateFilterExpressions(ObjectFilter origFilter, ExpressionVariables variables,
ExpressionFactory expressionFactory, PrismContext prismContext,
String shortDesc, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
if (origFilter == null) {
return null;
}
ObjectFilter filter = origFilter.clone();
evaluateFilterExpressionsInternal(filter, variables, expressionFactory, prismContext, shortDesc, task, result);
return filter;
}
private static void evaluateFilterExpressionsInternal(ObjectFilter filter, ExpressionVariables variables,
ExpressionFactory expressionFactory, PrismContext prismContext,
String shortDesc, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
if (filter == null) {
return;
}
if (filter instanceof LogicalFilter) {
List<ObjectFilter> conditions = ((LogicalFilter) filter).getConditions();
for (ObjectFilter condition : conditions) {
evaluateFilterExpressionsInternal(condition, variables, expressionFactory, prismContext, shortDesc, task, result);
}
return;
} else if (filter instanceof PropertyValueFilter) {
PropertyValueFilter pvfilter = (PropertyValueFilter) filter;
if (pvfilter.getValues() != null && !pvfilter.getValues().isEmpty()) {
// We have value. Nothing to evaluate.
return;
}
ExpressionWrapper expressionWrapper = pvfilter.getExpression();
if (expressionWrapper == null || expressionWrapper.getExpression() == null) {
LOGGER.warn("No valueExpression in filter in {}", shortDesc);
return;
}
if (!(expressionWrapper.getExpression() instanceof ExpressionType)) {
throw new SchemaException("Unexpected expression type " + expressionWrapper.getExpression().getClass() + " in filter in " + shortDesc);
}
ExpressionType valueExpression = (ExpressionType) expressionWrapper.getExpression();
try {
PrismPropertyValue expressionResult = evaluateExpression(variables, prismContext,
valueExpression, filter, expressionFactory, shortDesc, task, result);
if (expressionResult == null || expressionResult.isEmpty()) {
LOGGER.debug("Result of search filter expression was null or empty. Expression: {}",
valueExpression);
return;
}
// TODO: log more context
LOGGER.trace("Search filter expression in the rule for {} evaluated to {}.", new Object[] {
shortDesc, expressionResult });
if (filter instanceof EqualFilter) {
((EqualFilter) filter).setValue(expressionResult);
pvfilter.setExpression(null);
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Transformed filter to:\n{}", filter.debugDump());
}
} catch (RuntimeException ex) {
LoggingUtils.logException(LOGGER, "Couldn't evaluate expression " + valueExpression + ".", ex);
throw new SystemException("Couldn't evaluate expression" + valueExpression + ": "
+ ex.getMessage(), ex);
} catch (SchemaException ex) {
LoggingUtils.logException(LOGGER, "Couldn't evaluate expression " + valueExpression + ".", ex);
throw new SchemaException("Couldn't evaluate expression" + valueExpression + ": "
+ ex.getMessage(), ex);
} catch (ObjectNotFoundException ex) {
LoggingUtils.logException(LOGGER, "Couldn't evaluate expression " + valueExpression + ".", ex);
throw new ObjectNotFoundException("Couldn't evaluate expression" + valueExpression + ": "
+ ex.getMessage(), ex);
} catch (ExpressionEvaluationException ex) {
LoggingUtils.logException(LOGGER, "Couldn't evaluate expression " + valueExpression + ".", ex);
throw new ExpressionEvaluationException("Couldn't evaluate expression" + valueExpression + ": "
+ ex.getMessage(), ex);
}
} else {
throw new IllegalStateException("Unsupported filter type: " + filter.getClass());
}
}
// seems to be unused [mederly]
// public static ExpressionType createExpression(Element valueExpressionElement, PrismContext prismContext) throws SchemaException {
// ExpressionType valueExpression = null;
// try {
// valueExpression = prismContext.getJaxbDomHack().toJavaValue(
// valueExpressionElement, ExpressionType.class);
//
// if (LOGGER.isTraceEnabled()) {
// LOGGER.trace("Filter transformed to expression\n{}", valueExpression);
// }
// } catch (JAXBException ex) {
// LoggingUtils.logException(LOGGER, "Expression element couldn't be transformed.", ex);
// throw new SchemaException("Expression element couldn't be transformed: " + ex.getMessage(), ex);
// }
//
// return valueExpression;
//
// }
private static PrismPropertyValue evaluateExpression(ExpressionVariables variables, PrismContext prismContext,
ExpressionType expressionType, ObjectFilter filter, ExpressionFactory expressionFactory,
String shortDesc, Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
//TODO rafactor after new query engine is implemented
ItemDefinition outputDefinition = null;
if (filter instanceof ValueFilter){
outputDefinition = ((ValueFilter)filter).getDefinition();
}
if (outputDefinition == null){
outputDefinition = new PrismPropertyDefinition(ExpressionConstants.OUTPUT_ELMENT_NAME,
DOMUtil.XSD_STRING, prismContext);
}
return evaluateExpression(variables, outputDefinition, expressionType, expressionFactory, shortDesc, task, parentResult);
// String expressionResult = expressionHandler.evaluateExpression(currentShadow, valueExpression,
// shortDesc, result);
}
public static PrismPropertyValue evaluateExpression(ExpressionVariables variables,
ItemDefinition outputDefinition, ExpressionType expressionType,
ExpressionFactory expressionFactory,
String shortDesc, Task task, OperationResult parentResult) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException {
Expression<PrismPropertyValue> expression = expressionFactory.makeExpression(expressionType,
outputDefinition, shortDesc, parentResult);
ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, variables, shortDesc, task, parentResult);
PrismValueDeltaSetTriple<PrismPropertyValue> outputTriple = expression.evaluate(params);
LOGGER.trace("Result of the expression evaluation: {}", outputTriple);
if (outputTriple == null) {
return null;
}
Collection<PrismPropertyValue> nonNegativeValues = outputTriple.getNonNegativeValues();
if (nonNegativeValues == null || nonNegativeValues.isEmpty()) {
return null;
}
if (nonNegativeValues.size() > 1) {
throw new ExpressionEvaluationException("Expression returned more than one value ("+nonNegativeValues.size()+") in "+shortDesc);
}
return nonNegativeValues.iterator().next();
}
public static PrismPropertyValue<Boolean> evaluateCondition(ExpressionVariables variables, ExpressionType expressionType,
ExpressionFactory expressionFactory,
String shortDesc, Task task, OperationResult parentResult) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException{
ItemDefinition outputDefinition = new PrismPropertyDefinition<Boolean>(ExpressionConstants.OUTPUT_ELMENT_NAME,
DOMUtil.XSD_BOOLEAN, expressionFactory.getPrismContext());
return evaluateExpression(variables, outputDefinition, expressionType, expressionFactory, shortDesc, task, parentResult);
}
public static Map<QName, Object> compileVariablesAndSources(ExpressionEvaluationContext params) {
Map<QName, Object> variablesAndSources = new HashMap<QName, Object>();
if (params.getVariables() != null) {
for (Entry<QName, Object> entry: params.getVariables().entrySet()) {
variablesAndSources.put(entry.getKey(), entry.getValue());
}
}
if (params.getSources() != null) {
for (Source<?> source: params.getSources()) {
variablesAndSources.put(source.getName(), source);
}
}
return variablesAndSources;
}
}