use of nl.nn.adapterframework.core.IPipeLineSession in project iaf by ibissource.
the class Json2XmlValidatorSmileyTest method xmlToJsonViaPipe.
public String xmlToJsonViaPipe(String xml) throws ConfigurationException, PipeStartException, PipeRunException {
Json2XmlValidator json2xml = new Json2XmlValidator();
json2xml.setWarn(false);
json2xml.setSchema(xsd);
json2xml.setRoot("x");
json2xml.setOutputFormat(json2xml.FORMAT_JSON);
json2xml.setThrowException(true);
json2xml.registerForward(new PipeForward("success", null));
json2xml.configure();
json2xml.start();
IPipeLineSession pipeLineSession = new PipeLineSessionBase();
PipeRunResult prr = json2xml.doPipe(xml, pipeLineSession);
return (String) prr.getResult();
}
use of nl.nn.adapterframework.core.IPipeLineSession in project iaf by ibissource.
the class Json2XmlValidatorSmileyTest method jsonToXmlViaPipe.
public String jsonToXmlViaPipe(String json) throws ConfigurationException, PipeStartException, PipeRunException {
Json2XmlValidator json2xml = new Json2XmlValidator();
json2xml.setWarn(false);
json2xml.setSchema(xsd);
json2xml.setRoot("x");
json2xml.setThrowException(true);
json2xml.registerForward(new PipeForward("success", null));
json2xml.configure();
json2xml.start();
IPipeLineSession pipeLineSession = new PipeLineSessionBase();
PipeRunResult prr = json2xml.doPipe(json, pipeLineSession);
return (String) prr.getResult();
}
use of nl.nn.adapterframework.core.IPipeLineSession in project iaf by ibissource.
the class GetTibcoQueues method doPipeWithTimeoutGuarded.
public String doPipeWithTimeoutGuarded(Object input, IPipeLineSession session) throws PipeRunException {
String result;
String url_work;
String authAlias_work;
String userName_work;
String password_work;
String queueName_work = null;
ParameterValueList pvl = null;
if (getParameterList() != null) {
ParameterResolutionContext prc = new ParameterResolutionContext((String) input, session);
try {
pvl = prc.getValues(getParameterList());
} catch (ParameterException e) {
throw new PipeRunException(this, getLogPrefix(session) + "exception on extracting parameters", e);
}
}
url_work = getParameterValue(pvl, "url");
if (url_work == null) {
url_work = getUrl();
}
authAlias_work = getParameterValue(pvl, "authAlias");
if (authAlias_work == null) {
authAlias_work = getAuthAlias();
}
userName_work = getParameterValue(pvl, "userName");
if (userName_work == null) {
userName_work = getUserName();
}
password_work = getParameterValue(pvl, "password");
if (password_work == null) {
password_work = getPassword();
}
CredentialFactory cf = new CredentialFactory(authAlias_work, userName_work, password_work);
Connection connection = null;
Session jSession = null;
TibjmsAdmin admin = null;
try {
admin = TibcoUtils.getActiveServerAdmin(url_work, cf);
if (admin == null) {
throw new PipeRunException(this, "could not find an active server");
}
String ldapUrl = getParameterValue(pvl, "ldapUrl");
LdapSender ldapSender = null;
if (StringUtils.isNotEmpty(ldapUrl)) {
ldapSender = retrieveLdapSender(ldapUrl, cf);
}
queueName_work = getParameterValue(pvl, "queueName");
if (StringUtils.isNotEmpty(queueName_work)) {
String countOnly_work = getParameterValue(pvl, "countOnly");
boolean countOnly = ("true".equalsIgnoreCase(countOnly_work) ? true : false);
if (countOnly) {
return getQueueMessageCountOnly(admin, queueName_work);
}
}
ConnectionFactory factory = new com.tibco.tibjms.TibjmsConnectionFactory(url_work);
connection = factory.createConnection(cf.getUsername(), cf.getPassword());
jSession = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
if (StringUtils.isNotEmpty(queueName_work)) {
String queueItem_work = getParameterValue(pvl, "queueItem");
int qi;
if (StringUtils.isNumeric(queueItem_work)) {
qi = Integer.parseInt(queueItem_work);
} else {
qi = 1;
}
result = getQueueMessage(jSession, admin, queueName_work, qi, ldapSender);
} else {
String showAge_work = getParameterValue(pvl, "showAge");
boolean showAge = ("true".equalsIgnoreCase(showAge_work) ? true : false);
result = getQueuesInfo(jSession, admin, showAge, ldapSender);
}
} catch (Exception e) {
String msg = getLogPrefix(session) + "exception on showing Tibco queues, url [" + url_work + "]" + (StringUtils.isNotEmpty(queueName_work) ? " queue [" + queueName_work + "]" : "");
throw new PipeRunException(this, msg, e);
} finally {
if (admin != null) {
try {
admin.close();
} catch (TibjmsAdminException e) {
log.warn(getLogPrefix(session) + "exception on closing Tibjms Admin", e);
}
}
if (connection != null) {
try {
connection.close();
} catch (JMSException e) {
log.warn(getLogPrefix(session) + "exception on closing connection", e);
}
}
}
return result;
}
use of nl.nn.adapterframework.core.IPipeLineSession in project iaf by ibissource.
the class TestPipeline method processMessage.
@SuppressWarnings({ "rawtypes", "unchecked" })
private PipeLineResult processMessage(IAdapter adapter, String message, boolean writeSecLogMessage) {
String messageId = "testmessage" + Misc.createSimpleUUID();
IPipeLineSession pls = new PipeLineSessionBase();
Map ibisContexts = XmlUtils.getIbisContext(message);
String technicalCorrelationId = null;
if (ibisContexts != null) {
String contextDump = "ibisContext:";
for (Iterator it = ibisContexts.keySet().iterator(); it.hasNext(); ) {
String key = (String) it.next();
String value = (String) ibisContexts.get(key);
if (log.isDebugEnabled()) {
contextDump = contextDump + "\n " + key + "=[" + value + "]";
}
if (key.equals(IPipeLineSession.technicalCorrelationIdKey)) {
technicalCorrelationId = value;
} else {
pls.put(key, value);
}
}
if (log.isDebugEnabled()) {
log.debug(contextDump);
}
}
Date now = new Date();
PipeLineSessionBase.setListenerParameters(pls, messageId, technicalCorrelationId, now, now);
if (writeSecLogMessage) {
secLog.info("message [" + message + "]");
}
return adapter.processMessage(messageId, message, pls);
}
use of nl.nn.adapterframework.core.IPipeLineSession in project iaf by ibissource.
the class XmlValidatorTest2 method validate.
@Override
public String validate(String rootNamespace, String schemaLocation, boolean addNamespaceToSchema, boolean ignoreUnknownNamespaces, String inputfile, String[] expectedFailureReasons) throws ConfigurationException, InstantiationException, IllegalAccessException, XmlValidatorException, PipeRunException, IOException {
String testXml = inputfile != null ? getTestXml(inputfile + ".xml") : null;
IPipeLineSession session = new PipeLineSessionBase();
try {
XmlValidator validator = getValidator(schemaLocation, addNamespaceToSchema, implementation);
validator.setIgnoreUnknownNamespaces(ignoreUnknownNamespaces);
PipeForward forward = validator.validate(testXml, session);
evaluateResult(forward.getName(), session, null, expectedFailureReasons);
} catch (Exception e) {
evaluateResult(null, session, e, expectedFailureReasons);
return "Invalid XML";
}
return null;
}
Aggregations