use of nl.nn.adapterframework.parameters.Parameter 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.Parameter in project iaf by ibissource.
the class ConfigData method setAutoReload.
private FixedQuerySender setAutoReload(String autoReload, FixedQuerySender qs) {
Parameter param = new Parameter();
param.setName(AUTO_RELOAD);
if ("on".equals(autoReload)) {
param.setValue(qs.getDbmsSupport().getBooleanValue(true));
} else {
param.setValue(qs.getDbmsSupport().getBooleanValue(false));
}
qs.addParameter(param);
return qs;
}
use of nl.nn.adapterframework.parameters.Parameter 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.Parameter in project iaf by ibissource.
the class CompareStringPipe method configure.
@Override
public void configure() throws ConfigurationException {
super.configure();
if (null == findForward(LESSTHANFORWARD))
throw new ConfigurationException(getLogPrefix(null) + "forward [" + LESSTHANFORWARD + "] is not defined");
if (null == findForward(GREATERTHANFORWARD))
throw new ConfigurationException(getLogPrefix(null) + "forward [" + GREATERTHANFORWARD + "] is not defined");
if (null == findForward(EQUALSFORWARD))
throw new ConfigurationException(getLogPrefix(null) + "forward [" + EQUALSFORWARD + "] is not defined");
if (StringUtils.isEmpty(sessionKey1) && StringUtils.isEmpty(sessionKey2)) {
boolean operand1Exists = false;
boolean operand2Exists = false;
ParameterList parameterList = getParameterList();
for (int i = 0; i < parameterList.size(); i++) {
Parameter parameter = parameterList.getParameter(i);
if (parameter.getName().equalsIgnoreCase(OPERAND1)) {
operand1Exists = true;
} else {
if (parameter.getName().equalsIgnoreCase(OPERAND2)) {
operand2Exists = true;
}
}
}
if (!operand1Exists && !operand2Exists) {
throw new ConfigurationException(getLogPrefix(null) + "has neither parameter [" + OPERAND1 + "] nor parameter [" + OPERAND2 + "] specified");
}
}
}
use of nl.nn.adapterframework.parameters.Parameter in project iaf by ibissource.
the class EtagHandlerPipe method doPipe.
@Override
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());
}
String uriPatternSessionKey = null;
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);
if ("uriPattern".equalsIgnoreCase(parameter.getName()))
uriPatternSessionKey = (String) parameter.getValue(pvl, prc);
}
}
} catch (ParameterException e) {
throw new PipeRunException(this, getLogPrefix(session) + "exception extracting parameters", e);
}
}
// hash over data genereren, uit cache lezen en teruggeven, in cache updaten, verwijderen uit cache, cache naar disk wegschrijven, cache legen
String cacheKey = null;
if (uriPatternSessionKey != null && !uriPatternSessionKey.isEmpty())
cacheKey = getRestPath() + "_" + uriPatternSessionKey.toLowerCase();
else
cacheKey = getRestPath() + "_" + getUriPattern();
if (cache != null && cache.containsKey(cacheKey)) {
Object returnCode = false;
if (getAction().equalsIgnoreCase("generate")) {
cache.put(cacheKey, RestListenerUtils.formatEtag(getRestPath(), getUriPattern(), input.hashCode()));
returnCode = true;
} else if (getAction().equalsIgnoreCase("get")) {
returnCode = cache.get(cacheKey);
} else if (getAction().equalsIgnoreCase("set")) {
cache.put(cacheKey, input.toString());
returnCode = true;
} else if (getAction().equalsIgnoreCase("delete")) {
returnCode = cache.remove(cacheKey);
} else if (getAction().equalsIgnoreCase("flush")) {
if (cache instanceof ApiEhcache) {
((ApiEhcache) cache).flush();
returnCode = true;
}
} else if (getAction().equalsIgnoreCase("clear")) {
cache.clear();
returnCode = true;
} else {
throw new PipeRunException(this, getLogPrefix(session) + "action not found [" + getAction() + "]");
}
if (log.isDebugEnabled())
log.debug("found eTag cacheKey [" + cacheKey + "] with action [" + getAction() + "]");
return new PipeRunResult(getForward(), returnCode);
} else {
PipeForward pipeForward = findForward("exception");
String msg;
if (cache == null)
msg = "failed to locate cache";
else
msg = "failed to locate eTag [" + cacheKey + "] in cache";
if (pipeForward == null) {
throw new PipeRunException(this, getLogPrefix(session) + msg);
}
return new PipeRunResult(pipeForward, "");
}
}
Aggregations