use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class IsXmlIfPipe method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
String forward = "";
if (input == null) {
if (isElseForwardOnEmptyInput()) {
forward = elseForwardName;
} else {
forward = thenForwardName;
}
} else {
String sInput = input.toString();
if (StringUtils.isEmpty(sInput)) {
if (isElseForwardOnEmptyInput()) {
forward = elseForwardName;
} else {
forward = thenForwardName;
}
} else {
String firstChar = sInput.replaceAll("^\\s+", "").substring(0, 1);
if (firstChar.equals("<")) {
forward = thenForwardName;
} else {
forward = elseForwardName;
}
}
}
log.debug(getLogPrefix(session) + "determined forward [" + forward + "]");
PipeForward pipeForward = findForward(forward);
if (pipeForward == null) {
throw new PipeRunException(this, getLogPrefix(null) + "cannot find forward or pipe named [" + forward + "]");
}
log.debug(getLogPrefix(session) + "resolved forward [" + forward + "] to path [" + pipeForward.getPath() + "]");
return new PipeRunResult(pipeForward, input);
}
use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class CompareIntegerPipe method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
String sessionKey1StringValue = (String) session.get(sessionKey1);
String sessionKey2StringValue = (String) session.get(sessionKey2);
if (log.isDebugEnabled()) {
log.debug("sessionKey1StringValue [" + sessionKey1StringValue + "]");
log.debug("sessionKey2StringValue [" + sessionKey2StringValue + "]");
}
Integer sessionKey1IntegerValue;
Integer sessionKey2IntegerValue;
try {
sessionKey1IntegerValue = new Integer(sessionKey1StringValue);
sessionKey2IntegerValue = new Integer(sessionKey2StringValue);
} catch (Exception e) {
PipeRunException prei = new PipeRunException(this, "Exception while comparing integers", e);
throw prei;
}
int comparison = sessionKey1IntegerValue.compareTo(sessionKey2IntegerValue);
if (comparison == 0)
return new PipeRunResult(findForward(EQUALSFORWARD), input);
else if (comparison < 0)
return new PipeRunResult(findForward(LESSTHANFORWARD), input);
else
return new PipeRunResult(findForward(GREATERTHANFORWARD), input);
}
use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class BisWrapperPipe method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
String result;
try {
if ("wrap".equalsIgnoreCase(getDirection())) {
String originalBisMessageHeader = (String) session.get(getBisMessageHeaderSessionKey());
String bisConversationId = null;
String bisExternalRefToMessageId = null;
if (originalBisMessageHeader == null) {
if (StringUtils.isNotEmpty(getBisConversationIdSessionKey())) {
bisConversationId = (String) session.get(getBisConversationIdSessionKey());
}
if (StringUtils.isNotEmpty(getBisExternalRefToMessageIdSessionKey())) {
bisExternalRefToMessageId = (String) session.get(getBisExternalRefToMessageIdSessionKey());
}
}
String messageHeader = prepareMessageHeader(originalBisMessageHeader, bisConversationId, bisExternalRefToMessageId);
String bisErrorCode = null;
if (StringUtils.isNotEmpty(getBisErrorCodeSessionKey())) {
bisErrorCode = (String) session.get(getBisErrorCodeSessionKey());
}
String bisErrorText = null;
String bisDetailText = null;
if (bisErrorCode != null) {
if (StringUtils.isNotEmpty(getBisErrorTextSessionKey())) {
bisErrorText = (String) session.get(getBisErrorTextSessionKey());
}
if (bisErrorText == null) {
bisErrorText = errorCodeToText(bisErrorCode);
}
if (StringUtils.isNotEmpty(getBisErrorReasonSessionKey())) {
bisDetailText = (String) session.get(getBisErrorReasonSessionKey());
}
if (isOmitResult()) {
throw new PipeRunException(this, getLogPrefix(session) + "bisError occured: errorCode [" + bisErrorCode + "], errorText [" + bisErrorText + "]");
}
}
String bisResult = prepareResult(bisErrorCode, bisErrorText, getBisServiceName(), getBisActionName(), bisDetailText);
String payload;
if (bisErrorCode == null || StringUtils.isEmpty(getOutputRoot())) {
if (addOutputNamespaceTp != null) {
payload = addOutputNamespaceTp.transform(input.toString(), null, true);
} else {
payload = input.toString();
}
payload = prepareReply(payload, isBisMessageHeaderInSoapBody() ? messageHeader : null, bisResult, isBisResultInPayload());
} else {
XmlBuilder outputElement = new XmlBuilder(getOutputRoot());
if (StringUtils.isNotEmpty(getOutputNamespace())) {
outputElement.addAttribute("xmlns", getOutputNamespace());
}
payload = prepareReply(outputElement.toXML(), isBisMessageHeaderInSoapBody() ? messageHeader : null, bisResult, isBisResultInPayload());
}
result = wrapMessage(payload, isBisMessageHeaderInSoapBody() ? null : messageHeader);
} else {
String body = unwrapMessage(input.toString());
if (StringUtils.isEmpty(body)) {
throw new PipeRunException(this, getLogPrefix(session) + "SOAP body is empty or message is not a SOAP message");
}
if (bisMessageHeaderTp != null) {
String messageHeader = bisMessageHeaderTp.transform(input.toString(), null, true);
if (messageHeader != null) {
session.put(getBisMessageHeaderSessionKey(), messageHeader);
log.debug(getLogPrefix(session) + "stored [" + messageHeader + "] in pipeLineSession under key [" + getBisMessageHeaderSessionKey() + "]");
}
}
if (bisErrorTp != null) {
String bisError = bisErrorTp.transform(input.toString(), null, true);
if (Boolean.valueOf(bisError).booleanValue()) {
throw new PipeRunException(this, getLogPrefix(session) + "bisErrorXPath [" + bisErrorXe + "] returns true");
}
}
if (bodyMessageTp != null) {
result = bodyMessageTp.transform(input.toString(), null, true);
} else {
result = body;
}
if (removeOutputNamespacesTp != null) {
result = removeOutputNamespacesTp.transform(result, null, true);
}
}
} catch (Throwable t) {
throw new PipeRunException(this, getLogPrefix(session) + " Unexpected exception during (un)wrapping ", t);
}
return new PipeRunResult(getForward(), result);
}
use of nl.nn.adapterframework.core.PipeRunResult 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.PipeRunResult 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);
}
}
Aggregations