use of nl.nn.adapterframework.parameters.ParameterResolutionContext in project iaf by ibissource.
the class ConfigData method processJarFile.
private String processJarFile(IPipeLineSession session, String name, String version, String fileName, String fileNameSessionKey) throws PipeRunException {
String formJmsRealm = (String) session.get("jmsRealm");
String activeConfig = (String) session.get(ACTIVE_CONFIG);
String autoReload = (String) session.get(AUTO_RELOAD);
String result = selectConfigQuery(session, name);
if ("on".equals(activeConfig)) {
activeConfigQuery(session, name, formJmsRealm, result);
}
if (Integer.parseInt(result) > 0) {
deleteConfigQuery(session, name, formJmsRealm, version);
}
String remoteUser = (String) session.get("principal");
FixedQuerySender qs = (FixedQuerySender) ibisContext.createBeanAutowireByName(FixedQuerySender.class);
try {
qs.setName("QuerySender");
qs.setJmsRealm(formJmsRealm);
qs.setQueryType("insert");
if (StringUtils.isEmpty(remoteUser)) {
qs.setQuery("INSERT INTO IBISCONFIG (NAME, VERSION, FILENAME, CONFIG, CRE_TYDST, ACTIVECONFIG, AUTORELOAD) VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP, ?, ?)");
} else {
qs.setQuery("INSERT INTO IBISCONFIG (NAME, VERSION, FILENAME, CONFIG, CRE_TYDST, RUSER, ACTIVECONFIG, AUTORELOAD) VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP, ?, ?, ?)");
}
Parameter param = new Parameter();
param.setName("name");
param.setValue(name);
qs.addParameter(param);
param = new Parameter();
param.setName("version");
param.setValue(version);
qs.addParameter(param);
param = new Parameter();
param.setName("fileName");
param.setValue(fileName);
qs.addParameter(param);
param = new Parameter();
param.setName("config");
param.setSessionKey(fileNameSessionKey);
param.setType(Parameter.TYPE_INPUTSTREAM);
qs.addParameter(param);
if (StringUtils.isNotEmpty(remoteUser)) {
param = new Parameter();
param.setName("ruser");
param.setValue(remoteUser);
qs.addParameter(param);
}
setActiveConfig(activeConfig, qs);
setAutoReload(autoReload, qs);
qs.configure();
qs.open();
ParameterResolutionContext prc = new ParameterResolutionContext(DUMMY, session);
result = qs.sendMessage(DUMMY, DUMMY, prc);
} catch (Exception t) {
throw new PipeRunException(this, getLogPrefix(session) + "Error occured on executing jdbc query", t);
} finally {
qs.close();
}
return result;
}
use of nl.nn.adapterframework.parameters.ParameterResolutionContext in project iaf by ibissource.
the class ConfigData method deleteConfigQuery.
private String deleteConfigQuery(IPipeLineSession session, String name, String formJmsRealm, String version) throws PipeRunException {
FixedQuerySender qs = (FixedQuerySender) ibisContext.createBeanAutowireByName(FixedQuerySender.class);
String result = "";
try {
qs.setName("QuerySender");
qs.setJmsRealm(formJmsRealm);
qs.setQuery("DELETE FROM IBISCONFIG WHERE NAME = ? AND VERSION = ?");
Parameter param = new Parameter();
param.setName("name");
param.setValue(name);
qs.addParameter(param);
param = new Parameter();
param.setName("version");
param.setValue(version);
qs.addParameter(param);
qs.setScalar(true);
qs.configure();
qs.open();
ParameterResolutionContext prc = new ParameterResolutionContext(DUMMY, session);
result = qs.sendMessage(DUMMY, DUMMY, prc);
} catch (Exception t) {
throw new PipeRunException(this, getLogPrefix(session) + "Error occured on executing jdbc query", t);
} finally {
qs.close();
}
return result;
}
use of nl.nn.adapterframework.parameters.ParameterResolutionContext in project iaf by ibissource.
the class ConfigData method selectConfigQuery.
private String selectConfigQuery(IPipeLineSession session, String name) throws PipeRunException {
String formJmsRealm = (String) session.get("jmsRealm");
String result = "";
FixedQuerySender qs = (FixedQuerySender) ibisContext.createBeanAutowireByName(FixedQuerySender.class);
try {
qs.setName("QuerySender");
qs.setJmsRealm(formJmsRealm);
qs.setQueryType("select");
qs.setQuery("SELECT COUNT(*) FROM IBISCONFIG WHERE NAME=?");
Parameter param = new Parameter();
param.setName("name");
param.setValue(name);
qs.addParameter(param);
qs.setScalar(true);
qs.configure();
qs.open();
ParameterResolutionContext prc = new ParameterResolutionContext(DUMMY, session);
result = qs.sendMessage(DUMMY, DUMMY, prc);
} catch (Exception t) {
throw new PipeRunException(this, getLogPrefix(session) + "Error occured on executing jdbc query", t);
} finally {
qs.close();
}
return result;
}
use of nl.nn.adapterframework.parameters.ParameterResolutionContext in project iaf by ibissource.
the class XQueryPipe method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
if (input == null) {
throw new PipeRunException(this, getLogPrefix(session) + "got null input");
}
if (!(input instanceof String)) {
throw new PipeRunException(this, getLogPrefix(session) + "got an invalid type as input, expected String, got " + input.getClass().getName());
}
try {
String stringResult = (String) input;
// We already specifically use Saxon in this pipe, hence set xslt2
// to true to make XmlUtils use the Saxon
// DocumentBuilderFactoryImpl.
ParameterResolutionContext prc = new ParameterResolutionContext(stringResult, session, isNamespaceAware(), true);
Map parametervalues = null;
if (getParameterList() != null) {
parametervalues = prc.getValueMap(getParameterList());
}
preparedExpression.bindDocument(XQConstants.CONTEXT_ITEM, stringResult, null, null);
Iterator iterator = getParameterList().iterator();
while (iterator.hasNext()) {
Parameter parameter = (Parameter) iterator.next();
preparedExpression.bindObject(new QName(parameter.getName()), parametervalues.get(parameter.getName()), null);
}
XQResultSequence resultSequence = preparedExpression.executeQuery();
stringResult = resultSequence.getSequenceAsString(null);
return new PipeRunResult(getForward(), stringResult);
} catch (Exception e) {
throw new PipeRunException(this, getLogPrefix(session) + " Exception on running xquery", e);
}
}
use of nl.nn.adapterframework.parameters.ParameterResolutionContext in project iaf by ibissource.
the class XmlSwitch method doPipe.
/**
* This is where the action takes place, the switching is done. Pipes may only throw a PipeRunException,
* to be handled by the caller of this object.<br/>
* As WebLogic has the problem that when an non-well formed XML stream is given to
* weblogic.xerces the transformer gets corrupt, on an exception the configuration is done again, so that the
* transformer is re-initialized.
*/
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
String forward = "";
String sInput = (String) input;
PipeForward pipeForward = null;
if (StringUtils.isNotEmpty(getSessionKey())) {
sInput = (String) session.get(sessionKey);
}
if (transformerPool != null) {
ParameterList parameterList = null;
ParameterResolutionContext prc = new ParameterResolutionContext(sInput, session, isNamespaceAware());
;
try {
Map parametervalues = null;
if (getParameterList() != null) {
parameterList = getParameterList();
parametervalues = prc.getValueMap(parameterList);
}
forward = transformerPool.transform(prc.getInputSource(), parametervalues);
} catch (Throwable e) {
throw new PipeRunException(this, getLogPrefix(session) + "got exception on transformation", e);
}
} else {
forward = sInput;
}
log.debug(getLogPrefix(session) + "determined forward [" + forward + "]");
if (StringUtils.isEmpty(forward) && getEmptyForwardName() != null) {
throwEvent(XML_SWITCH_FORWARD_FOUND_MONITOR_EVENT);
pipeForward = findForward(getEmptyForwardName());
} else {
if (findForward(forward) != null) {
throwEvent(XML_SWITCH_FORWARD_FOUND_MONITOR_EVENT);
pipeForward = findForward(forward);
} else {
log.info(getLogPrefix(session) + "determined forward [" + forward + "], which is not defined. Will use [" + getNotFoundForwardName() + "] instead");
throwEvent(XML_SWITCH_FORWARD_NOT_FOUND_MONITOR_EVENT);
pipeForward = findForward(getNotFoundForwardName());
}
}
if (pipeForward == null) {
throw new PipeRunException(this, getLogPrefix(session) + "cannot find forward or pipe named [" + forward + "]");
}
return new PipeRunResult(pipeForward, input);
}
Aggregations