use of nl.nn.adapterframework.core.PipeRunException in project iaf by ibissource.
the class FtpFileRetrieverPipe method doPipe.
/**
* @see nl.nn.adapterframework.core.IPipe#doPipe(Object, IPipeLineSession)
*/
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
String orgFilename = (String) input;
try {
boolean close = !deleteAfterGet;
String localFilename = ftpSession.get(getParameterList(), session, localDirectory, remoteDirectory, orgFilename, localFilenamePattern, close);
if (deleteAfterGet) {
ftpSession.deleteRemote(remoteDirectory, orgFilename, true);
}
return new PipeRunResult(getForward(), localFilename);
} catch (Exception e) {
String msg = "Error while getting file [" + remoteDirectory + "/" + input + "]";
PipeForward exceptionForward = findForward(EXCEPTIONFORWARD);
if (exceptionForward != null) {
log.warn(msg, e);
return new PipeRunResult(exceptionForward, input);
}
throw new PipeRunException(this, msg, e);
}
}
use of nl.nn.adapterframework.core.PipeRunException in project iaf by ibissource.
the class FxfWrapperPipe method doPipe.
@Override
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
if ("wrap".equalsIgnoreCase(getDirection())) {
XmlBuilder xmlStartTransfer_Action = new XmlBuilder("StartTransfer_Action");
xmlStartTransfer_Action.addAttribute("xmlns", "http://nn.nl/XSD/Infrastructure/Transfer/FileTransfer/1/StartTransfer/" + retrieveStartTransferVersion());
XmlBuilder xmlTransferDetails = new XmlBuilder("TransferDetails");
xmlStartTransfer_Action.addSubElement(xmlTransferDetails);
XmlBuilder xmlSenderApplication = new XmlBuilder("SenderApplication");
xmlSenderApplication.setValue(instanceName);
xmlTransferDetails.addSubElement(xmlSenderApplication);
XmlBuilder xmlRecipientApplication = new XmlBuilder("RecipientApplication");
xmlTransferDetails.addSubElement(xmlRecipientApplication);
XmlBuilder xmlFilename = new XmlBuilder("Filename");
if (input != null) {
String filename = input.toString();
if (isTransformFilename()) {
String filenameOnIufState = "/opt/data/FXF/" + instanceNameLowerCase + "/" + getFlowId() + "/out/" + new File(filename).getName();
xmlFilename.setValue(filenameOnIufState);
} else {
xmlFilename.setValue(filename);
}
}
xmlTransferDetails.addSubElement(xmlFilename);
XmlBuilder xmlTransferFlowId = new XmlBuilder("TransferFlowId");
String transferFlowId = getFlowId().substring(0, 2) + environment + getFlowId().substring(3);
xmlTransferFlowId.setValue(transferFlowId);
xmlTransferDetails.addSubElement(xmlTransferFlowId);
return super.doPipe(xmlStartTransfer_Action.toXML(), session);
} else {
String soapBody = (String) super.doPipe(input, session).getResult();
session.put(getSoapBodySessionKey(), soapBody);
String transferFlowId;
String clientFilename;
try {
transferFlowId = transferFlowIdTp.transform(soapBody, null);
session.put(getTransferFlowIdSessionKey(), transferFlowId);
clientFilename = clientFilenameTp.transform(soapBody, null);
session.put(getClientFilenameSessionKey(), clientFilename);
} catch (Throwable t) {
throw new PipeRunException(this, getLogPrefix(session) + " Unexpected exception during (un)wrapping ", t);
}
String flowId = transferFlowId.substring(0, 2) + "X" + transferFlowId.substring(3);
session.put(getFlowIdSessionKey(), flowId);
session.put(getFxfDirSessionKey(), fxfDir);
// Transform the filename as it is known locally on the IUF state
// machine to the filename as know on the application server (which
// has a mount to the IUF state machine).
String fxfFile = fxfDir + File.separator + flowId + File.separator + "in" + File.separator + new File(clientFilename).getName();
session.put(getFxfFileSessionKey(), fxfFile);
return new PipeRunResult(getForward(), fxfFile);
}
}
use of nl.nn.adapterframework.core.PipeRunException in project iaf by ibissource.
the class Adios2XmlPipe method makeAdios.
public String makeAdios(InputSource bericht, IPipeLineSession session) throws PipeRunException {
try {
// Parse the input
handler.clear();
saxParser.parse(bericht, handler);
return handler.getResult();
} catch (Throwable t) {
throw new PipeRunException(this, getLogPrefix(session) + "got error while transforming xml to adios, input [" + bericht + "]", t);
}
}
use of nl.nn.adapterframework.core.PipeRunException 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.PipeRunException in project iaf by ibissource.
the class ApiStreamPipe method adjustFirstStringPart.
@Override
protected String adjustFirstStringPart(String firstStringPart, IPipeLineSession session) throws PipeRunException {
if (firstStringPart == null) {
return "";
} else {
boolean retrieveMessage = false;
if (XmlUtils.isWellFormed(firstStringPart, "MessageID")) {
String rootNamespace = XmlUtils.getRootNamespace(firstStringPart);
if ("http://www.w3.org/2005/08/addressing".equals(rootNamespace)) {
retrieveMessage = true;
}
}
if (retrieveMessage) {
String messageId = null;
try {
messageId = XmlUtils.evaluateXPathNodeSetFirstElement(firstStringPart, "MessageID");
} catch (Exception e) {
throw new PipeRunException(this, "Exception getting MessageID", e);
}
if (StringUtils.isEmpty(messageId)) {
throw new PipeRunException(this, "Could not find messageId in request [" + firstStringPart + "]");
} else {
// TODO: create dummyQuerySender should be put in
// configure(), but gives an error
IbisContext ibisContext = getAdapter().getConfiguration().getIbisManager().getIbisContext();
dummyQuerySender = (FixedQuerySender) ibisContext.createBeanAutowireByName(FixedQuerySender.class);
dummyQuerySender.setJmsRealm(jmsRealm);
dummyQuerySender.setQuery("SELECT count(*) FROM ALL_TABLES");
try {
dummyQuerySender.configure();
} catch (ConfigurationException e) {
throw new PipeRunException(this, "Exception configuring dummy query sender", e);
}
ParameterResolutionContext prc = new ParameterResolutionContext("", session);
String slotId = AppConstants.getInstance().getResolvedProperty("instance.name") + "/" + session.get("operation");
String selectMessageKeyResult = null;
try {
selectMessageKeyResult = selectMessageKey(slotId, messageId);
} catch (Exception e) {
throw new PipeRunException(this, "Exception getting messageKey", e);
}
if (StringUtils.isEmpty(selectMessageKeyResult)) {
throw new PipeRunException(this, "Could not find message in MessageStore for slotId [" + slotId + "] and messageId [" + messageId + "]");
} else {
String selectMessageResult = null;
try {
selectMessageResult = selectMessage(selectMessageKeyResult);
} catch (Exception e) {
throw new PipeRunException(this, "Exception getting message", e);
}
if (StringUtils.isEmpty(selectMessageResult)) {
throw new PipeRunException(this, "Could not find message in MessageStore with messageKey [" + selectMessageKeyResult + "]");
} else {
try {
deleteMessage(selectMessageKeyResult);
} catch (Exception e) {
throw new PipeRunException(this, "Exception deleting message", e);
}
}
return selectMessageResult;
}
}
} else {
return firstStringPart;
}
}
}
Aggregations