Search in sources :

Example 66 with PipeRunException

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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) PipeRunException(nl.nn.adapterframework.core.PipeRunException) PipeForward(nl.nn.adapterframework.core.PipeForward)

Example 67 with PipeRunException

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);
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) PipeRunException(nl.nn.adapterframework.core.PipeRunException)

Example 68 with PipeRunException

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);
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) PipeRunException(nl.nn.adapterframework.core.PipeRunException) PipeForward(nl.nn.adapterframework.core.PipeForward)

Example 69 with PipeRunException

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);
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) PipeRunException(nl.nn.adapterframework.core.PipeRunException) PipeRunException(nl.nn.adapterframework.core.PipeRunException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException)

Example 70 with PipeRunException

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);
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) PipeRunException(nl.nn.adapterframework.core.PipeRunException) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Aggregations

PipeRunException (nl.nn.adapterframework.core.PipeRunException)101 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)65 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)40 IOException (java.io.IOException)34 ParameterResolutionContext (nl.nn.adapterframework.parameters.ParameterResolutionContext)32 PipeForward (nl.nn.adapterframework.core.PipeForward)20 ParameterException (nl.nn.adapterframework.core.ParameterException)16 ParameterValueList (nl.nn.adapterframework.parameters.ParameterValueList)13 Parameter (nl.nn.adapterframework.parameters.Parameter)12 InputStream (java.io.InputStream)10 File (java.io.File)9 Map (java.util.Map)9 ParameterList (nl.nn.adapterframework.parameters.ParameterList)8 FixedQuerySender (nl.nn.adapterframework.jdbc.FixedQuerySender)7 DomBuilderException (nl.nn.adapterframework.util.DomBuilderException)7 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)6 PipeStartException (nl.nn.adapterframework.core.PipeStartException)6 ArrayList (java.util.ArrayList)5 ZipInputStream (java.util.zip.ZipInputStream)5 IAdapter (nl.nn.adapterframework.core.IAdapter)5