use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class Adios2XmlPipe method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
Variant v = new Variant(input);
String result;
if (DIRECTION_BACKWARD.equalsIgnoreCase(getDirection())) {
result = makeAdios(v.asXmlInputSource(), session);
} else {
String inputstring = v.asString();
String firstToken = new StringTokenizer(inputstring).nextToken();
if (firstToken.startsWith("<")) {
log.info(getLogPrefix(session) + "input is already XML, no conversion performed");
return new PipeRunResult(noConversionForward, inputstring);
}
result = makeXml(v.asString(), session);
}
return new PipeRunResult(getForward(), result);
}
use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class ScanTibcoSolutionPipe method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
StringWriter stringWriter = new StringWriter();
XMLStreamWriter xmlStreamWriter;
try {
xmlStreamWriter = XmlUtils.OUTPUT_FACTORY.createXMLStreamWriter(stringWriter);
xmlStreamWriter.writeStartDocument();
xmlStreamWriter.writeStartElement("root");
xmlStreamWriter.writeAttribute("url", getUrl());
// xmlStreamWriter.writeAttribute("level",
// String.valueOf(getLevel()));
process(xmlStreamWriter, getUrl(), getLevel());
xmlStreamWriter.writeEndDocument();
xmlStreamWriter.flush();
xmlStreamWriter.close();
} catch (XMLStreamException e) {
throw new PipeRunException(this, "XMLStreamException", e);
} catch (DomBuilderException e) {
throw new PipeRunException(this, "DomBuilderException", e);
} catch (XPathExpressionException e) {
throw new PipeRunException(this, "XPathExpressionException", e);
}
return new PipeRunResult(getForward(), stringWriter.getBuffer().toString());
}
use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class RestListener method transformToXml.
public String transformToXml(String message) throws PipeRunException {
JsonPipe pipe = new JsonPipe();
PipeRunResult pipeResult = pipe.doPipe(message, new PipeLineSessionBase());
return (String) pipeResult.getResult();
}
use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class RestListener method transformToJson.
public String transformToJson(String message) throws PipeRunException {
JsonPipe pipe = new JsonPipe();
pipe.setDirection("xml2json");
PipeRunResult pipeResult = pipe.doPipe(message, new PipeLineSessionBase());
return (String) pipeResult.getResult();
}
use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class ZipWriterPipe method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
if (ACTION_CLOSE.equals(getAction())) {
closeZipWriterHandle(session, true);
return new PipeRunResult(getForward(), input);
}
String msg = null;
if (input instanceof String) {
msg = (String) input;
}
ParameterResolutionContext prc = new ParameterResolutionContext(msg, session);
ParameterValueList pvl;
try {
pvl = prc.getValues(getParameterList());
} catch (ParameterException e1) {
throw new PipeRunException(this, getLogPrefix(session) + "cannot determine filename", e1);
}
ZipWriter sessionData = getZipWriter(session);
if (ACTION_OPEN.equals(getAction())) {
if (sessionData != null) {
throw new PipeRunException(this, getLogPrefix(session) + "zipWriterHandle in session key [" + getZipWriterHandle() + "] is already open");
}
sessionData = createZipWriter(session, pvl, input);
return new PipeRunResult(getForward(), input);
}
// from here on action must be 'write' or 'stream'
if (sessionData == null) {
throw new PipeRunException(this, getLogPrefix(session) + "zipWriterHandle in session key [" + getZipWriterHandle() + "] is not open");
}
String filename = (String) pvl.getParameterValue(PARAMETER_FILENAME).getValue();
if (StringUtils.isEmpty(filename)) {
throw new PipeRunException(this, getLogPrefix(session) + "filename cannot be empty");
}
try {
if (ACTION_STREAM.equals(getAction())) {
sessionData.openEntry(filename);
PipeRunResult prr = new PipeRunResult(getForward(), sessionData.getZipoutput());
return prr;
}
if (ACTION_WRITE.equals(getAction())) {
try {
if (isCompleteFileHeader()) {
sessionData.writeEntryWithCompletedHeader(filename, input, isCloseInputstreamOnExit(), getCharset());
} else {
sessionData.writeEntry(filename, input, isCloseInputstreamOnExit(), getCharset());
}
} catch (IOException e) {
throw new PipeRunException(this, getLogPrefix(session) + "cannot add data to zipentry for [" + filename + "]", e);
}
return new PipeRunResult(getForward(), input);
}
throw new PipeRunException(this, getLogPrefix(session) + "illegal action [" + getAction() + "]");
} catch (CompressionException e) {
throw new PipeRunException(this, getLogPrefix(session) + "cannot add zipentry for [" + filename + "]", e);
}
}
Aggregations