use of nl.nn.adapterframework.parameters.ParameterValueList in project iaf by ibissource.
the class SchedulerSender method sendMessage.
public String sendMessage(String correlationID, String message, ParameterResolutionContext prc) throws SenderException {
try {
ParameterValueList values = prc.getValues(paramList);
String jobName = getName() + correlationID;
String cronExpression = values.getParameterValue("_cronexpression").getValue().toString();
if (StringUtils.isNotEmpty(jobNamePattern)) {
jobName = values.getParameterValue("_jobname").getValue().toString();
;
}
schedule(jobName, cronExpression, correlationID, message);
return jobName;
} catch (SenderException e) {
throw e;
} catch (Exception e) {
throw new SenderException("Error during scheduling " + message, e);
}
}
use of nl.nn.adapterframework.parameters.ParameterValueList in project iaf by ibissource.
the class PutParametersInSession method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
ParameterValueList pvl = null;
ParameterList parameterList = getParameterList();
if (parameterList != null) {
ParameterResolutionContext prc = new ParameterResolutionContext((String) input, session);
try {
pvl = prc.getValues(getParameterList());
if (pvl != null) {
for (int i = 0; i < parameterList.size(); i++) {
Parameter parameter = parameterList.getParameter(i);
String pn = parameter.getName();
Object pv = parameter.getValue(pvl, prc);
session.put(pn, pv);
log.debug(getLogPrefix(session) + "stored [" + pv + "] in pipeLineSession under key [" + pn + "]");
}
}
} catch (ParameterException e) {
throw new PipeRunException(this, getLogPrefix(session) + "exception extracting parameters", e);
}
}
return new PipeRunResult(getForward(), input);
}
use of nl.nn.adapterframework.parameters.ParameterValueList in project iaf by ibissource.
the class RhinoPipe method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
// INIT
String eol = System.getProperty("line.separator");
if (input == null) {
// No input from previous pipes. We will use filename and or string input.
if ((StringUtils.isEmpty(fileInput)) && inputString == null && isLookupAtRuntime()) {
// No input from file or input string. Nowhere to GO!
throw new PipeRunException(this, getLogPrefix(session) + "No input specified anywhere. No string input, no file input and no previous pipe input");
}
}
if (!(input instanceof String)) {
throw new PipeRunException(this, getLogPrefix(session) + "got an invalid type as input, expected String, got " + input.getClass().getName());
}
inputString = (String) input;
// Get the input from the file at Run Time
if (StringUtils.isNotEmpty(getFileName()) && isLookupAtRuntime()) {
URL resource = null;
try {
resource = ClassUtils.getResourceURL(classLoader, getFileName());
} catch (Throwable e) {
throw new PipeRunException(this, getLogPrefix(session) + "got exception searching for [" + getFileName() + "]", e);
}
if (resource == null) {
throw new PipeRunException(this, getLogPrefix(session) + "cannot find resource [" + getFileName() + "]");
}
try {
fileInput = Misc.resourceToString(resource, SystemUtils.LINE_SEPARATOR);
} catch (Throwable e) {
throw new PipeRunException(this, getLogPrefix(session) + "got exception loading [" + getFileName() + "]", e);
}
}
// Get all params as input
if (getParameterList() != null) {
ParameterResolutionContext prc = new ParameterResolutionContext((String) input, session);
ParameterValueList pvl;
try {
pvl = prc.getValues(getParameterList());
} catch (ParameterException e) {
throw new PipeRunException(this, getLogPrefix(session) + "exception extracting parameters", e);
}
for (int i = 0; i < pvl.size(); i++) {
ParameterValue pv = pvl.getParameterValue(i);
paramsInput = pv.asStringValue("") + eol + paramsInput;
}
}
String javascriptcode = "Packages.java;" + eol;
if (fileInput != null) {
javascriptcode = javascriptcode + fileInput;
}
if (paramsInput != null) {
javascriptcode = paramsInput + eol + javascriptcode;
}
String stringResult = (String) javascriptcode;
stringResult = "INPUTSTREAM used in case of ERROR" + eol + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + eol + stringResult;
// Start your engines
// Rhino engine Ok.
Context cx = Context.enter();
Scriptable scope = cx.initStandardObjects();
if (isDebug()) {
System.out.println("debug active");
cx.setLanguageVersion(Context.VERSION_1_2);
cx.setGeneratingDebug(true);
}
// Load javascript factory with javascript functions from file, stringinput and paraminput
String jsResult = "";
try {
cx.evaluateString(scope, javascriptcode, "jsScript", 1, null);
Function fct = (Function) scope.get(jsfunctionName, scope);
// Object result = fct.call(cx, scope, scope, new Object[]{jsfunctionArguments});
Object result = fct.call(cx, scope, scope, new Object[] { input });
if (isDebug()) {
System.out.println(cx.jsToJava(result, String.class));
}
;
jsResult = (String) cx.jsToJava(result, String.class);
} catch (org.mozilla.javascript.EcmaError ex) {
throw new PipeRunException(this, "org.mozilla.javascript.EcmaError -> ", ex);
// System.out.println(ex.getMessage());
} finally {
Context.exit();
}
// Use the result
if (!(jsResult instanceof String)) {
} else {
if ((String) jsResult != null) {
stringResult = (String) jsResult;
}
}
if (StringUtils.isEmpty(getSessionKey())) {
return new PipeRunResult(getForward(), stringResult);
} else {
session.put(getSessionKey(), stringResult);
return new PipeRunResult(getForward(), input);
}
}
use of nl.nn.adapterframework.parameters.ParameterValueList in project iaf by ibissource.
the class IfsaRequesterSender method convertParametersToMap.
protected Map convertParametersToMap(ParameterResolutionContext prc) throws SenderException {
ParameterValueList paramValueList;
try {
paramValueList = prc.getValues(paramList);
} catch (ParameterException e) {
throw new SenderException(getLogPrefix() + "caught ParameterException in sendMessage() determining serviceId", e);
}
Map params = new HashMap();
if (paramValueList != null && paramList != null) {
for (int i = 0; i < paramList.size(); i++) {
String key = paramList.getParameter(i).getName();
String value = paramValueList.getParameterValue(i).asStringValue(null);
params.put(key, value);
}
}
return params;
}
use of nl.nn.adapterframework.parameters.ParameterValueList in project iaf by ibissource.
the class FileHandler method createFile.
private File createFile(byte[] in, IPipeLineSession session, ParameterList paramList) throws IOException, ParameterException {
File tmpFile;
String writeSuffix_work = null;
if (paramList != null) {
ParameterResolutionContext prc = new ParameterResolutionContext((String) null, session);
ParameterValueList pvl = prc.getValues(paramList);
if (pvl != null) {
ParameterValue writeSuffixParamValue = pvl.getParameterValue("writeSuffix");
if (writeSuffixParamValue != null) {
writeSuffix_work = (String) writeSuffixParamValue.getValue();
}
}
}
if (writeSuffix_work == null) {
writeSuffix_work = getWriteSuffix();
}
String name = getEffectiveFileName(null, session);
if (StringUtils.isEmpty(getDirectory())) {
if (StringUtils.isEmpty(name)) {
tmpFile = File.createTempFile("ibis", writeSuffix_work);
} else {
tmpFile = new File(name);
}
} else {
if (StringUtils.isEmpty(name)) {
tmpFile = File.createTempFile("ibis", writeSuffix_work, new File(getDirectory()));
} else {
tmpFile = new File(getDirectory() + File.separator + name);
}
}
return tmpFile;
}
Aggregations