use of org.apache.commons.jxpath.JXPathInvalidAccessException in project vorto by eclipse.
the class AbstractDataMapper method mapFunctionBlock.
private FunctionblockData mapFunctionBlock(ModelProperty fbProperty, JXPathContext context) {
FunctionblockData fbData = new FunctionblockData(fbProperty.getName());
FunctionblockModel fbModel = specification.getFunctionBlock(fbProperty.getName());
for (ModelProperty statusProperty : fbModel.getStatusProperties()) {
try {
Object mapped = this.mapProperty(statusProperty, context);
if (mapped != null) {
fbData.withStatusProperty(statusProperty.getName(), mapped);
}
} catch (JXPathNotFoundException | JXPathInvalidAccessException ex) {
if (statusProperty.isMandatory()) {
return null;
}
}
}
for (ModelProperty configProperty : fbModel.getConfigurationProperties()) {
try {
Object mapped = this.mapProperty(configProperty, context);
if (mapped != null) {
fbData.withConfigurationProperty(configProperty.getName(), mapped);
}
} catch (JXPathNotFoundException | JXPathInvalidAccessException ex) {
if (configProperty.isMandatory()) {
return null;
}
}
}
return onlyReturnIfPopulated(fbData);
}
use of org.apache.commons.jxpath.JXPathInvalidAccessException in project vorto by eclipse.
the class JavascriptEvalFunction method invoke.
@Override
@SuppressWarnings({ "rawtypes" })
public Object invoke(ExpressionContext context, Object[] parameters) {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("JavaScript");
try {
engine.eval(functionBody);
} catch (ScriptException e) {
throw new JXPathException("Problem evaluating " + functionName, e);
}
Invocable inv = (Invocable) engine;
try {
Object[] args;
int pi = 0;
Class[] types = toTypes(parameters);
if (types.length >= 1 && ExpressionContext.class.isAssignableFrom(types[0])) {
pi = 1;
}
args = new Object[parameters.length + pi];
if (pi == 1) {
args[0] = context;
}
for (int i = 0; i < parameters.length; i++) {
args[i + pi] = TypeUtils.convert(parameters[i], types[i + pi]);
}
return inv.invokeFunction(functionName, unwrap(args));
} catch (Throwable ex) {
throw new JXPathInvalidAccessException("Cannot invoke " + functionName, ex);
}
}
Aggregations