Search in sources :

Example 36 with PipeForward

use of nl.nn.adapterframework.core.PipeForward 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 37 with PipeForward

use of nl.nn.adapterframework.core.PipeForward 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 38 with PipeForward

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

Example 39 with PipeForward

use of nl.nn.adapterframework.core.PipeForward in project iaf by ibissource.

the class PasswordHashPipe method doPipe.

public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
    Object result;
    PipeForward pipeForward;
    if (StringUtils.isEmpty(getHashSessionKey())) {
        try {
            if (getRoundsSessionKey() == null) {
                result = PasswordHash.createHash(input.toString().toCharArray(), getRounds());
            } else {
                result = PasswordHash.createHash(input.toString().toCharArray(), Integer.valueOf(session.get(getRoundsSessionKey()).toString()));
            }
            pipeForward = getForward();
        } catch (Exception e) {
            throw new PipeRunException(this, "Could not hash password", e);
        }
    } else {
        try {
            result = input;
            if (PasswordHash.validatePassword(input.toString(), (String) session.get(getHashSessionKey()))) {
                pipeForward = getForward();
            } else {
                pipeForward = findForward(FAILURE_FORWARD_NAME);
            }
        } catch (Exception e) {
            throw new PipeRunException(this, "Could not validate password", e);
        }
    }
    return new PipeRunResult(pipeForward, result);
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) PipeRunException(nl.nn.adapterframework.core.PipeRunException) PipeForward(nl.nn.adapterframework.core.PipeForward) PipeRunException(nl.nn.adapterframework.core.PipeRunException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException)

Example 40 with PipeForward

use of nl.nn.adapterframework.core.PipeForward in project iaf by ibissource.

the class XmlValidator method determineForward.

protected PipeForward determineForward(String resultEvent, IPipeLineSession session, boolean responseMode) throws PipeRunException {
    throwEvent(resultEvent);
    if (AbstractXmlValidator.XML_VALIDATOR_VALID_MONITOR_EVENT.equals(resultEvent)) {
        return getForward();
    }
    PipeForward forward = null;
    if (AbstractXmlValidator.XML_VALIDATOR_PARSER_ERROR_MONITOR_EVENT.equals(resultEvent)) {
        if (responseMode) {
            forward = findForward("outputParserError");
        }
        if (forward == null) {
            forward = findForward("parserError");
        }
    }
    if (forward == null) {
        if (responseMode) {
            forward = findForward("outputFailure");
        }
        if (forward == null) {
            forward = findForward("failure");
        }
    }
    if (forward == null) {
        if (isForwardFailureToSuccess()) {
            forward = findForward("success");
        } else {
            throw new PipeRunException(this, "not implemented: should get reason from validator");
        }
    }
    return forward;
}
Also used : PipeRunException(nl.nn.adapterframework.core.PipeRunException) PipeForward(nl.nn.adapterframework.core.PipeForward)

Aggregations

PipeForward (nl.nn.adapterframework.core.PipeForward)49 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)23 PipeRunException (nl.nn.adapterframework.core.PipeRunException)21 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)10 Test (org.junit.Test)8 IOException (java.io.IOException)7 ParameterResolutionContext (nl.nn.adapterframework.parameters.ParameterResolutionContext)7 ParameterException (nl.nn.adapterframework.core.ParameterException)6 ParameterList (nl.nn.adapterframework.parameters.ParameterList)6 IPipe (nl.nn.adapterframework.core.IPipe)4 Map (java.util.Map)3 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)3 ConfigurationWarnings (nl.nn.adapterframework.configuration.ConfigurationWarnings)3 IPipeLineSession (nl.nn.adapterframework.core.IPipeLineSession)3 ITransactionalStorage (nl.nn.adapterframework.core.ITransactionalStorage)3 PipeLineSessionBase (nl.nn.adapterframework.core.PipeLineSessionBase)3 ApiWsdlXmlValidator (nl.nn.adapterframework.extensions.api.ApiWsdlXmlValidator)3 ParameterValueList (nl.nn.adapterframework.parameters.ParameterValueList)3 StatisticsKeeper (nl.nn.adapterframework.statistics.StatisticsKeeper)3 InputStream (java.io.InputStream)2