use of nl.nn.adapterframework.core.PipeRunException in project iaf by ibissource.
the class TestPipeLine method doPost.
private String doPost(IPipeLineSession session) throws PipeRunException {
Object form_file = session.get("file");
String form_message = null;
form_message = (String) session.get("message");
if (form_file == null && (StringUtils.isEmpty(form_message))) {
throw new PipeRunException(this, getLogPrefix(session) + "Nothing to send or test");
}
String form_adapterName = (String) session.get("adapterName");
if (StringUtils.isEmpty(form_adapterName)) {
throw new PipeRunException(this, getLogPrefix(session) + "No adapter selected");
}
IAdapter adapter = RestListenerUtils.retrieveIbisManager(session).getRegisteredAdapter(form_adapterName);
if (adapter == null) {
throw new PipeRunException(this, getLogPrefix(session) + "Adapter with specified name [" + form_adapterName + "] could not be retrieved");
}
boolean writeSecLogMessage = false;
if (secLogMessage) {
writeSecLogMessage = (Boolean) session.get("writeSecLogMessage");
}
if (form_file != null) {
if (form_file instanceof InputStream) {
InputStream inputStream = (InputStream) form_file;
String form_fileName = (String) session.get("fileName");
String form_fileEncoding = (String) session.get("fileEncoding");
try {
if (inputStream.available() > 0) {
String fileEncoding;
if (StringUtils.isNotEmpty(form_fileEncoding)) {
fileEncoding = form_fileEncoding;
} else {
fileEncoding = Misc.DEFAULT_INPUT_STREAM_ENCODING;
}
if (StringUtils.endsWithIgnoreCase(form_fileName, ".zip")) {
try {
form_message = processZipFile(session, inputStream, fileEncoding, adapter, writeSecLogMessage);
} catch (Exception e) {
throw new PipeRunException(this, getLogPrefix(session) + "exception on processing zip file", e);
}
} else {
form_message = Misc.streamToString(inputStream, "\n", fileEncoding, false);
}
}
} catch (IOException e) {
throw new PipeRunException(this, getLogPrefix(session) + "exception on converting stream to string", e);
}
} else {
form_message = form_file.toString();
}
session.put("message", form_message);
}
if (StringUtils.isNotEmpty(form_message)) {
try {
PipeLineResult plr = processMessage(adapter, form_message, writeSecLogMessage);
session.put("state", plr.getState());
session.put("result", plr.getResult());
} catch (Exception e) {
throw new PipeRunException(this, getLogPrefix(session) + "exception on sending message", e);
}
}
return "<dummy/>";
}
use of nl.nn.adapterframework.core.PipeRunException 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;
}
use of nl.nn.adapterframework.core.PipeRunException in project iaf by ibissource.
the class XsltPipeErrorTest method documentNotFound2.
@Test
public void documentNotFound2() throws Exception {
// error not during configure(), but during doPipe()
ErrorOutputStream errorOutputStream = new ErrorOutputStream();
System.setErr(new PrintStream(errorOutputStream));
XsltPipe xsltPipe = new XsltPipe();
xsltPipe.registerForward(createPipeSuccessForward());
xsltPipe.setStyleSheetName("/Xslt/documentNotFound/root2.xsl");
xsltPipe.setXslt2(true);
xsltPipe.configure();
xsltPipe.start();
String input = getFile("/Xslt/documentNotFound/in.xml");
String errorMessage = null;
try {
xsltPipe.doPipe(input, session);
} catch (PipeRunException e) {
errorMessage = e.getMessage();
}
assertEquals(true, errorOutputStream.isEmpty());
assertEquals(0, testAppender.getNumberOfAlerts());
assertEquals(true, errorMessage.contains("java.io.FileNotFoundException"));
}
use of nl.nn.adapterframework.core.PipeRunException in project iaf by ibissource.
the class ConfigData method activeConfigQuery.
private String activeConfigQuery(IPipeLineSession session, String name, String formJmsRealm, String result) throws PipeRunException {
FixedQuerySender qs = (FixedQuerySender) ibisContext.createBeanAutowireByName(FixedQuerySender.class);
try {
qs.setName("QuerySender");
qs.setJmsRealm(formJmsRealm);
qs.setQueryType("update");
qs.setQuery("UPDATE IBISCONFIG SET ACTIVECONFIG = '" + qs.getDbmsSupport().getBooleanValue(false) + "' 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 Webservices method doGet.
private String doGet(IPipeLineSession session) throws PipeRunException {
IbisManager ibisManager = RestListenerUtils.retrieveIbisManager(session);
String uri = (String) session.get("uri");
String indent = (String) session.get("indent");
String useIncludes = (String) session.get("useIncludes");
if (StringUtils.isNotEmpty(uri) && (uri.endsWith(getWsdlExtention()) || uri.endsWith(".zip"))) {
String adapterName = StringUtils.substringBeforeLast(StringUtils.substringAfterLast(uri, "/"), ".");
IAdapter adapter = ibisManager.getRegisteredAdapter(adapterName);
if (adapter == null) {
throw new PipeRunException(this, getLogPrefix(session) + "adapter [" + adapterName + "] doesn't exist");
}
try {
if (uri.endsWith(getWsdlExtention())) {
RestListenerUtils.setResponseContentType(session, "application/xml");
wsdl((Adapter) adapter, session, indent, useIncludes);
} else {
RestListenerUtils.setResponseContentType(session, "application/octet-stream");
zip((Adapter) adapter, session);
}
} catch (Exception e) {
throw new PipeRunException(this, getLogPrefix(session) + "exception on retrieving wsdl", e);
}
return "";
} else {
return list(ibisManager);
}
}
Aggregations