use of nl.nn.adapterframework.core.PipeRunException in project iaf by ibissource.
the class IfMultipart method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
String forward;
PipeForward pipeForward = null;
if (input == null) {
forward = elseForwardName;
} else {
if (!(input instanceof HttpServletRequest)) {
throw new PipeRunException(this, getLogPrefix(null) + "expected HttpServletRequest as input, got [" + ClassUtils.nameOf(input) + "]");
}
HttpServletRequest request = (HttpServletRequest) input;
String contentType = request.getContentType();
if (StringUtils.isNotEmpty(contentType) && contentType.startsWith("multipart")) {
forward = thenForwardName;
} else {
forward = elseForwardName;
}
}
log.debug(getLogPrefix(session) + "determined forward [" + forward + "]");
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.PipeRunException in project iaf by ibissource.
the class IsUserInRolePipe method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
try {
if (StringUtils.isEmpty(getRole())) {
String inputString = (String) input;
if (StringUtils.isEmpty(inputString)) {
throw new PipeRunException(this, "role cannot be empty");
}
assertUserIsInRole(session, inputString);
} else {
assertUserIsInRole(session, getRole());
}
} catch (SecurityException e) {
if (notInRoleForward != null) {
return new PipeRunResult(notInRoleForward, input);
} else {
throw new PipeRunException(this, "", e);
}
}
return new PipeRunResult(getForward(), input);
}
use of nl.nn.adapterframework.core.PipeRunException 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.PipeRunException 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.PipeRunException 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);
}
Aggregations