use of nl.nn.adapterframework.core.PipeRunException 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.core.PipeRunException in project iaf by ibissource.
the class ConfigData method doPost.
private String doPost(IPipeLineSession session) throws PipeRunException {
String multipleConfigs = (String) session.get("multipleConfigs");
String fileName = (String) session.get("fileName");
String name = (String) session.get("name");
String version = (String) session.get("version");
ConfigData configData = new ConfigData(multipleConfigs, fileName, name, version);
String result;
if (!"on".equals(multipleConfigs)) {
processMultipleConfigs(configData, session);
}
Object file = session.get("file");
if (file == null) {
throw new PipeRunException(this, getLogPrefix(session) + "Nothing to send or test");
}
if ("on".equals(multipleConfigs)) {
try {
result = processZipFile(session);
} catch (IOException e) {
throw new PipeRunException(this, getLogPrefix(session) + "Error while processing zip file", e);
}
} else {
result = processJarFile(session, name, version, fileName, "file");
}
session.put("result", result);
return "<dummy/>";
}
use of nl.nn.adapterframework.core.PipeRunException 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.core.PipeRunException 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.core.PipeRunException in project iaf by ibissource.
the class CoolGenWrapperPipe method doPipe.
/**
* Transform the input (optionally), check the conformance to the schema (optionally),
* call the required proxy, transform the output (optionally)
*/
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
Writer proxyResult;
String proxypreProc = null;
Variant inputVar;
String wrapperResult = "";
CoolGenXMLProxy proxy;
ActionListener actionListener = new ActionListener() {
/**
* @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
*/
public String errorMessage;
public void actionPerformed(ActionEvent e) {
errorMessage = e.toString();
}
public String toString() {
return errorMessage;
}
};
Source in;
try {
log.info(getLogPrefix(session) + "instantiating proxy [" + proxyClassName + "] as a temporary fix for broken comm-bridge connections");
proxy = createProxy(proxyClassName);
} catch (ConfigurationException ce) {
String msg = getLogPrefix(session) + "cannot recreate proxy after exception";
log.error(msg, ce);
throw new PipeRunException(this, msg, ce);
}
proxy.addExceptionListener(actionListener);
try {
inputVar = new Variant(input);
in = inputVar.asXmlSource();
if (preProcTransformer != null) {
proxypreProc = XmlUtils.transformXml(preProcTransformer, in);
log.debug(getLogPrefix(session) + "] preprocessing transformed message into [" + proxypreProc + "]");
} else
proxypreProc = inputVar.asString();
if (proxyInputFixTransformer != null)
proxypreProc = XmlUtils.transformXml(proxyInputFixTransformer, proxypreProc);
proxyResult = new StringWriter(10 * 1024);
try {
proxy.clear();
} catch (PropertyVetoException e) {
throw new PipeRunException(this, getLogPrefix(session) + "cannot clear CoolGen proxy", e);
}
try {
proxy.executeXML(new StringReader(proxypreProc), proxyResult);
proxy.removeExceptionListener(actionListener);
String err = actionListener.toString();
if (err != null) {
// if an error occurs, recreate the proxy and throw an exception
log.debug(getLogPrefix(session) + "got error, recreating proxy with class [" + proxyClassName + "]");
try {
proxy = createProxy(proxyClassName);
} catch (ConfigurationException e) {
throw new PipeRunException(this, getLogPrefix(session) + "cannot recreate proxy [" + proxyClassName + "]", e);
}
throw new PipeRunException(this, getLogPrefix(session) + "error excuting proxy [" + proxyClassName + "]:" + err);
}
} catch (XmlProxyException xpe) {
try {
proxy = createProxy(proxyClassName);
} catch (ConfigurationException ce) {
log.error(getLogPrefix(session) + "cannot recreate proxy", xpe);
}
throw new PipeRunException(this, getLogPrefix(session) + "error excecuting proxy", xpe);
}
if (postProcTransformer != null) {
log.debug(getLogPrefix(session) + " CoolGen proxy returned: [" + proxyResult.toString() + "]");
wrapperResult = XmlUtils.transformXml(postProcTransformer, proxyResult.toString());
} else
wrapperResult = proxyResult.toString();
} catch (DomBuilderException e) {
throw new PipeRunException(this, getLogPrefix(session) + "DomBuilderException excecuting proxy", e);
} catch (IOException e) {
throw new PipeRunException(this, getLogPrefix(session) + "IOException excecuting proxy", e);
} catch (TransformerException e) {
throw new PipeRunException(this, getLogPrefix(session) + "TransformerException excecuting proxy", e);
}
return new PipeRunResult(getForward(), wrapperResult);
}
Aggregations