Search in sources :

Example 1 with PipeForward

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

the class ShowConfigurationStatus method mapAdapterPipes.

private ArrayList<Object> mapAdapterPipes(Adapter adapter) {
    if (!adapter.configurationSucceeded())
        return null;
    PipeLine pipeline = adapter.getPipeLine();
    int totalPipes = pipeline.getPipes().size();
    ArrayList<Object> pipes = new ArrayList<Object>(totalPipes);
    for (int i = 0; i < totalPipes; i++) {
        Map<String, Object> pipesInfo = new HashMap<String, Object>();
        IPipe pipe = pipeline.getPipe(i);
        Map<String, PipeForward> pipeForwards = pipe.getForwards();
        String pipename = pipe.getName();
        Map<String, String> forwards = new HashMap<String, String>();
        for (PipeForward fwrd : pipeForwards.values()) {
            forwards.put(fwrd.getName(), fwrd.getPath());
        }
        pipesInfo.put("name", pipename);
        pipesInfo.put("type", pipe.getType());
        pipesInfo.put("forwards", forwards);
        if (pipe instanceof MessageSendingPipe) {
            MessageSendingPipe msp = (MessageSendingPipe) pipe;
            ISender sender = msp.getSender();
            pipesInfo.put("sender", ClassUtils.nameOf(sender));
            if (sender instanceof WebServiceSender) {
                WebServiceSender s = (WebServiceSender) sender;
                Map<String, Object> certInfo = addCertificateInfo(s);
                if (certInfo != null)
                    pipesInfo.put("certificate", certInfo);
            }
            if (sender instanceof HttpSender) {
                HttpSender s = (HttpSender) sender;
                Map<String, Object> certInfo = addCertificateInfo(s);
                if (certInfo != null)
                    pipesInfo.put("certificate", certInfo);
            }
            if (sender instanceof FtpSender) {
                FtpSender s = (FtpSender) sender;
                Map<String, Object> certInfo = addCertificateInfo(s);
                if (certInfo != null)
                    pipesInfo.put("certificate", certInfo);
            }
            if (sender instanceof HasPhysicalDestination) {
                pipesInfo.put("destination", ((HasPhysicalDestination) sender).getPhysicalDestinationName());
            }
            if (sender instanceof JdbcSenderBase) {
                pipesInfo.put("isJdbcSender", true);
            }
            IListener listener = msp.getListener();
            if (listener != null) {
                pipesInfo.put("listenerName", listener.getName());
                pipesInfo.put("listenerClass", ClassUtils.nameOf(listener));
                if (listener instanceof HasPhysicalDestination) {
                    String pd = ((HasPhysicalDestination) listener).getPhysicalDestinationName();
                    pipesInfo.put("listenerDestination", pd);
                }
            }
            ITransactionalStorage messageLog = msp.getMessageLog();
            if (messageLog != null) {
                pipesInfo.put("hasMessageLog", true);
                String messageLogCount;
                try {
                    if (showCountMessageLog) {
                        messageLogCount = "" + messageLog.getMessageCount();
                    } else {
                        messageLogCount = "?";
                    }
                } catch (Exception e) {
                    log.warn(e);
                    messageLogCount = "error";
                }
                pipesInfo.put("messageLogCount", messageLogCount);
                Map<String, Object> message = new HashMap<String, Object>();
                message.put("name", messageLog.getName());
                message.put("type", "log");
                message.put("slotId", messageLog.getSlotId());
                message.put("count", messageLogCount);
                pipesInfo.put("message", message);
            }
        }
        pipes.add(pipesInfo);
    }
    return pipes;
}
Also used : MessageSendingPipe(nl.nn.adapterframework.pipes.MessageSendingPipe) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IListener(nl.nn.adapterframework.core.IListener) ArrayList(java.util.ArrayList) FtpSender(nl.nn.adapterframework.ftp.FtpSender) HttpSender(nl.nn.adapterframework.http.HttpSender) PipeForward(nl.nn.adapterframework.core.PipeForward) ITransactionalStorage(nl.nn.adapterframework.core.ITransactionalStorage) ISender(nl.nn.adapterframework.core.ISender) WebServiceSender(nl.nn.adapterframework.http.WebServiceSender) PipeLine(nl.nn.adapterframework.core.PipeLine) IPipe(nl.nn.adapterframework.core.IPipe) JdbcSenderBase(nl.nn.adapterframework.jdbc.JdbcSenderBase) HasPhysicalDestination(nl.nn.adapterframework.core.HasPhysicalDestination)

Example 2 with PipeForward

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

the class XmlIf method doPipe.

public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
    String forward = "";
    PipeForward pipeForward = null;
    String sInput;
    if (StringUtils.isEmpty(getSessionKey())) {
        if (input == null) {
            sInput = "";
        } else {
            sInput = input.toString();
        }
    } else {
        log.debug(getLogPrefix(session) + "taking input from sessionKey [" + getSessionKey() + "]");
        sInput = (String) session.get(getSessionKey());
    }
    if (tp != null) {
        try {
            forward = tp.transform(sInput, null, isNamespaceAware());
        } catch (Exception e) {
            throw new PipeRunException(this, getLogPrefix(session) + "cannot evaluate expression", e);
        }
    } else {
        if (StringUtils.isEmpty(expressionValue)) {
            if (StringUtils.isEmpty(sInput)) {
                forward = elseForwardName;
            } else {
                forward = thenForwardName;
            }
        } else {
            if (sInput.equals(expressionValue)) {
                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 : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) PipeRunException(nl.nn.adapterframework.core.PipeRunException) PipeForward(nl.nn.adapterframework.core.PipeForward) PipeRunException(nl.nn.adapterframework.core.PipeRunException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException)

Example 3 with PipeForward

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

the class XmlSwitch method doPipe.

/**
 * This is where the action takes place, the switching is done. Pipes may only throw a PipeRunException,
 * to be handled by the caller of this object.<br/>
 * As WebLogic has the problem that when an non-well formed XML stream is given to
 * weblogic.xerces the transformer gets corrupt, on an exception the configuration is done again, so that the
 * transformer is re-initialized.
 */
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
    String forward = "";
    String sInput = (String) input;
    PipeForward pipeForward = null;
    if (StringUtils.isNotEmpty(getSessionKey())) {
        sInput = (String) session.get(sessionKey);
    }
    if (transformerPool != null) {
        ParameterList parameterList = null;
        ParameterResolutionContext prc = new ParameterResolutionContext(sInput, session, isNamespaceAware());
        ;
        try {
            Map parametervalues = null;
            if (getParameterList() != null) {
                parameterList = getParameterList();
                parametervalues = prc.getValueMap(parameterList);
            }
            forward = transformerPool.transform(prc.getInputSource(), parametervalues);
        } catch (Throwable e) {
            throw new PipeRunException(this, getLogPrefix(session) + "got exception on transformation", e);
        }
    } else {
        forward = sInput;
    }
    log.debug(getLogPrefix(session) + "determined forward [" + forward + "]");
    if (StringUtils.isEmpty(forward) && getEmptyForwardName() != null) {
        throwEvent(XML_SWITCH_FORWARD_FOUND_MONITOR_EVENT);
        pipeForward = findForward(getEmptyForwardName());
    } else {
        if (findForward(forward) != null) {
            throwEvent(XML_SWITCH_FORWARD_FOUND_MONITOR_EVENT);
            pipeForward = findForward(forward);
        } else {
            log.info(getLogPrefix(session) + "determined forward [" + forward + "], which is not defined. Will use [" + getNotFoundForwardName() + "] instead");
            throwEvent(XML_SWITCH_FORWARD_NOT_FOUND_MONITOR_EVENT);
            pipeForward = findForward(getNotFoundForwardName());
        }
    }
    if (pipeForward == null) {
        throw new PipeRunException(this, getLogPrefix(session) + "cannot find forward or pipe named [" + forward + "]");
    }
    return new PipeRunResult(pipeForward, input);
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) PipeRunException(nl.nn.adapterframework.core.PipeRunException) ParameterList(nl.nn.adapterframework.parameters.ParameterList) PipeForward(nl.nn.adapterframework.core.PipeForward) ParameterResolutionContext(nl.nn.adapterframework.parameters.ParameterResolutionContext) Map(java.util.Map)

Example 4 with PipeForward

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

the class CorePipeLineProcessor method processPipeLine.

public PipeLineResult processPipeLine(PipeLine pipeLine, String messageId, String message, IPipeLineSession pipeLineSession, String firstPipe) throws PipeRunException {
    // Object is the object that is passed to and returned from Pipes
    Object object = (Object) message;
    PipeRunResult pipeRunResult;
    // the PipeLineResult
    PipeLineResult pipeLineResult = new PipeLineResult();
    if (object == null || (object instanceof String && StringUtils.isEmpty(object.toString()))) {
        if (StringUtils.isNotEmpty(pipeLine.getAdapterToRunBeforeOnEmptyInput())) {
            log.debug("running adapterBeforeOnEmptyInput");
            IAdapter adapter = pipeLine.getAdapter().getConfiguration().getIbisManager().getRegisteredAdapter(pipeLine.getAdapterToRunBeforeOnEmptyInput());
            if (adapter == null) {
                log.warn("adapterToRunBefore with specified name [" + pipeLine.getAdapterToRunBeforeOnEmptyInput() + "] could not be retrieved");
            } else {
                PipeLineResult plr = adapter.processMessage(messageId, message, pipeLineSession);
                if (plr == null || !plr.getState().equals("success")) {
                    throw new PipeRunException(null, "adapterToRunBefore [" + pipeLine.getAdapterToRunBeforeOnEmptyInput() + "] ended with state [" + plr.getState() + "]");
                }
                message = plr.getResult();
                log.debug("input after running adapterBeforeOnEmptyInput [" + message + "]");
                object = (Object) message;
            }
        }
    }
    // ready indicates wether the pipeline processing is complete
    boolean ready = false;
    // get the first pipe to run
    IPipe pipeToRun = pipeLine.getPipe(pipeLine.getFirstPipe());
    boolean inputValidateError = false;
    IPipe inputValidator = pipeLine.getInputValidator();
    if (inputValidator != null) {
        log.debug("validating input");
        PipeRunResult validationResult = pipeProcessor.processPipe(pipeLine, inputValidator, messageId, message, pipeLineSession);
        if (validationResult != null) {
            if (!validationResult.getPipeForward().getName().equals("success")) {
                PipeForward validationForward = validationResult.getPipeForward();
                if (validationForward.getPath() == null) {
                    throw new PipeRunException(pipeToRun, "forward [" + validationForward.getName() + "] of inputValidator has emtpy forward path");
                }
                log.warn("setting first pipe to [" + validationForward.getPath() + "] due to validation fault");
                inputValidateError = true;
                pipeToRun = pipeLine.getPipe(validationForward.getPath());
                if (pipeToRun == null) {
                    throw new PipeRunException(pipeToRun, "forward [" + validationForward.getName() + "], path [" + validationForward.getPath() + "] does not correspond to a pipe");
                }
            }
            Object validatedMessage = validationResult.getResult();
            if (validatedMessage != null) {
                object = validatedMessage;
                message = validatedMessage.toString();
            }
        }
    }
    if (!inputValidateError) {
        IPipe inputWrapper = pipeLine.getInputWrapper();
        if (inputWrapper != null) {
            log.debug("wrapping input");
            PipeRunResult wrapResult = pipeProcessor.processPipe(pipeLine, inputWrapper, messageId, message, pipeLineSession);
            if (wrapResult != null && !wrapResult.getPipeForward().getName().equals("success")) {
                PipeForward wrapForward = wrapResult.getPipeForward();
                if (wrapForward.getPath() == null) {
                    throw new PipeRunException(pipeToRun, "forward [" + wrapForward.getName() + "] of inputWrapper has emtpy forward path");
                }
                log.warn("setting first pipe to [" + wrapForward.getPath() + "] due to wrap fault");
                pipeToRun = pipeLine.getPipe(wrapForward.getPath());
                if (pipeToRun == null) {
                    throw new PipeRunException(pipeToRun, "forward [" + wrapForward.getName() + "], path [" + wrapForward.getPath() + "] does not correspond to a pipe");
                }
            } else {
                message = wrapResult.getResult().toString();
            }
            log.debug("input after wrapping [" + message + "]");
            object = (Object) message;
        }
    }
    pipeLine.getRequestSizeStats().addValue(message.length());
    if (pipeLine.isStoreOriginalMessageWithoutNamespaces()) {
        if (XmlUtils.isWellFormed(message)) {
            String removeNamespaces_xslt = XmlUtils.makeRemoveNamespacesXslt(true, true);
            try {
                String xsltResult = null;
                Transformer transformer = XmlUtils.createTransformer(removeNamespaces_xslt);
                xsltResult = XmlUtils.transformXml(transformer, message);
                pipeLineSession.put("originalMessageWithoutNamespaces", xsltResult);
            } catch (IOException e) {
                throw new PipeRunException(pipeToRun, "cannot retrieve removeNamespaces", e);
            } catch (TransformerConfigurationException te) {
                throw new PipeRunException(pipeToRun, "got error creating transformer from removeNamespaces", te);
            } catch (TransformerException te) {
                throw new PipeRunException(pipeToRun, "got error transforming removeNamespaces", te);
            } catch (DomBuilderException te) {
                throw new PipeRunException(pipeToRun, "caught DomBuilderException", te);
            }
        } else {
            log.warn("original message is not well-formed");
            pipeLineSession.put("originalMessageWithoutNamespaces", message);
        }
    }
    boolean outputValidated = false;
    try {
        while (!ready) {
            pipeRunResult = pipeProcessor.processPipe(pipeLine, pipeToRun, messageId, object, pipeLineSession);
            object = pipeRunResult.getResult();
            if (!(pipeToRun instanceof AbstractPipe)) {
                if (object != null && object instanceof String) {
                    StatisticsKeeper sizeStat = pipeLine.getPipeSizeStatistics(pipeToRun);
                    if (sizeStat != null) {
                        sizeStat.addValue(((String) object).length());
                    }
                }
            }
            PipeForward pipeForward = pipeRunResult.getPipeForward();
            if (pipeForward == null) {
                throw new PipeRunException(pipeToRun, "Pipeline of [" + pipeLine.getOwner().getName() + "] received result from pipe [" + pipeToRun.getName() + "] without a pipeForward");
            }
            // get the next pipe to run
            String nextPath = pipeForward.getPath();
            if ((null == nextPath) || (nextPath.length() == 0)) {
                throw new PipeRunException(pipeToRun, "Pipeline of [" + pipeLine.getOwner().getName() + "] got an path that equals null or has a zero-length value from pipe [" + pipeToRun.getName() + "]. Check the configuration, probably forwards are not defined for this pipe.");
            }
            PipeLineExit plExit = pipeLine.getPipeLineExits().get(nextPath);
            if (null != plExit) {
                boolean outputWrapError = false;
                IPipe outputWrapper = pipeLine.getOutputWrapper();
                if (outputWrapper != null) {
                    log.debug("wrapping PipeLineResult");
                    PipeRunResult wrapResult = pipeProcessor.processPipe(pipeLine, outputWrapper, messageId, object, pipeLineSession);
                    if (wrapResult != null && !wrapResult.getPipeForward().getName().equals("success")) {
                        PipeForward wrapForward = wrapResult.getPipeForward();
                        if (wrapForward.getPath() == null) {
                            throw new PipeRunException(pipeToRun, "forward [" + wrapForward.getName() + "] of outputWrapper has emtpy forward path");
                        }
                        log.warn("setting next pipe to [" + wrapForward.getPath() + "] due to wrap fault");
                        outputWrapError = true;
                        pipeToRun = pipeLine.getPipe(wrapForward.getPath());
                        if (pipeToRun == null) {
                            throw new PipeRunException(pipeToRun, "forward [" + wrapForward.getName() + "], path [" + wrapForward.getPath() + "] does not correspond to a pipe");
                        }
                    } else {
                        log.debug("wrap succeeded");
                        object = wrapResult.getResult();
                    }
                    log.debug("PipeLineResult after wrapping [" + object.toString() + "]");
                }
                if (!outputWrapError) {
                    IPipe outputValidator = pipeLine.getOutputValidator();
                    if ((outputValidator != null) && !outputValidated) {
                        outputValidated = true;
                        log.debug("validating PipeLineResult");
                        PipeRunResult validationResult;
                        validationResult = pipeProcessor.processPipe(pipeLine, outputValidator, messageId, object, pipeLineSession);
                        if (validationResult != null && !validationResult.getPipeForward().getName().equals("success")) {
                            PipeForward validationForward = validationResult.getPipeForward();
                            if (validationForward.getPath() == null) {
                                throw new PipeRunException(pipeToRun, "forward [" + validationForward.getName() + "] of outputValidator has emtpy forward path");
                            }
                            log.warn("setting next pipe to [" + validationForward.getPath() + "] due to validation fault");
                            pipeToRun = pipeLine.getPipe(validationForward.getPath());
                            if (pipeToRun == null) {
                                throw new PipeRunException(pipeToRun, "forward [" + validationForward.getName() + "], path [" + validationForward.getPath() + "] does not correspond to a pipe");
                            }
                        } else {
                            log.debug("validation succeeded");
                            object = validationResult.getResult();
                            ready = true;
                        }
                    } else {
                        ready = true;
                    }
                } else {
                    ready = true;
                }
                if (ready) {
                    String state = plExit.getState();
                    pipeLineResult.setState(state);
                    pipeLineResult.setExitCode(plExit.getExitCode());
                    if (object != null && !plExit.getEmptyResult()) {
                        pipeLineResult.setResult(object.toString());
                    } else {
                        pipeLineResult.setResult(null);
                    }
                    ready = true;
                    if (log.isDebugEnabled()) {
                        // for performance reasons
                        String skString = "";
                        for (Iterator it = pipeLineSession.keySet().iterator(); it.hasNext(); ) {
                            String key = (String) it.next();
                            Object value = pipeLineSession.get(key);
                            skString = skString + "\n " + key + "=[" + value + "]";
                        }
                        log.debug("Available session keys at finishing pipeline of adapter [" + pipeLine.getOwner().getName() + "]:" + skString);
                        log.debug("Pipeline of adapter [" + pipeLine.getOwner().getName() + "] finished processing messageId [" + messageId + "] result: [" + object + "] with exit-state [" + state + "]");
                    }
                }
            } else {
                pipeToRun = pipeLine.getPipe(pipeForward.getPath());
                if (pipeToRun == null) {
                    throw new PipeRunException(null, "Pipeline of adapter [" + pipeLine.getOwner().getName() + "] got an erroneous definition. Pipe to execute [" + pipeForward.getPath() + "] is not defined.");
                }
            }
        }
    } finally {
        for (int i = 0; i < pipeLine.getExitHandlers().size(); i++) {
            IPipeLineExitHandler exitHandler = pipeLine.getExitHandlers().get(i);
            try {
                if (log.isDebugEnabled())
                    log.debug("processing ExitHandler [" + exitHandler.getName() + "]");
                exitHandler.atEndOfPipeLine(messageId, pipeLineResult, pipeLineSession);
            } catch (Throwable t) {
                log.warn("Caught Exception processing ExitHandler [" + exitHandler.getName() + "]", t);
            }
        }
    }
    return pipeLineResult;
}
Also used : Transformer(javax.xml.transform.Transformer) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IPipeLineExitHandler(nl.nn.adapterframework.core.IPipeLineExitHandler) IOException(java.io.IOException) PipeForward(nl.nn.adapterframework.core.PipeForward) PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) AbstractPipe(nl.nn.adapterframework.pipes.AbstractPipe) PipeLineResult(nl.nn.adapterframework.core.PipeLineResult) PipeRunException(nl.nn.adapterframework.core.PipeRunException) Iterator(java.util.Iterator) StatisticsKeeper(nl.nn.adapterframework.statistics.StatisticsKeeper) DomBuilderException(nl.nn.adapterframework.util.DomBuilderException) IAdapter(nl.nn.adapterframework.core.IAdapter) IPipe(nl.nn.adapterframework.core.IPipe) TransformerException(javax.xml.transform.TransformerException) PipeLineExit(nl.nn.adapterframework.core.PipeLineExit)

Example 5 with PipeForward

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

the class MessageSendingPipe method configure.

/**
 * Checks whether a sender is defined for this pipe.
 */
@Override
public void configure() throws ConfigurationException {
    super.configure();
    if (StringUtils.isNotEmpty(getStubFileName())) {
        URL stubUrl;
        try {
            stubUrl = ClassUtils.getResourceURL(classLoader, getStubFileName());
        } catch (Throwable e) {
            throw new ConfigurationException(getLogPrefix(null) + "got exception finding resource for stubfile [" + getStubFileName() + "]", e);
        }
        if (stubUrl == null) {
            throw new ConfigurationException(getLogPrefix(null) + "could not find resource for stubfile [" + getStubFileName() + "]");
        }
        try {
            returnString = Misc.resourceToString(stubUrl, SystemUtils.LINE_SEPARATOR);
        } catch (Throwable e) {
            throw new ConfigurationException(getLogPrefix(null) + "got exception loading stubfile [" + getStubFileName() + "] from resource [" + stubUrl.toExternalForm() + "]", e);
        }
    } else {
        propagateName();
        if (getSender() == null) {
            throw new ConfigurationException(getLogPrefix(null) + "no sender defined ");
        }
        try {
            if (getSender() instanceof PipeAware) {
                ((PipeAware) getSender()).setPipe(this);
            }
            getSender().configure();
        } catch (ConfigurationException e) {
            throw new ConfigurationException(getLogPrefix(null) + "while configuring sender", e);
        }
        if (getSender() instanceof HasPhysicalDestination) {
            log.info(getLogPrefix(null) + "has sender on " + ((HasPhysicalDestination) getSender()).getPhysicalDestinationName());
        }
        if (getListener() != null) {
            if (getSender().isSynchronous()) {
                throw new ConfigurationException(getLogPrefix(null) + "cannot have listener with synchronous sender");
            }
            try {
                getListener().configure();
            } catch (ConfigurationException e) {
                throw new ConfigurationException(getLogPrefix(null) + "while configuring listener", e);
            }
            if (getListener() instanceof HasPhysicalDestination) {
                log.info(getLogPrefix(null) + "has listener on " + ((HasPhysicalDestination) getListener()).getPhysicalDestinationName());
            }
        }
        if (!(getLinkMethod().equalsIgnoreCase("MESSAGEID")) && (!(getLinkMethod().equalsIgnoreCase("CORRELATIONID")))) {
            throw new ConfigurationException(getLogPrefix(null) + "Invalid argument for property LinkMethod [" + getLinkMethod() + "]. it should be either MESSAGEID or CORRELATIONID");
        }
        if (!(getHideMethod().equalsIgnoreCase("all")) && (!(getHideMethod().equalsIgnoreCase("firstHalf")))) {
            throw new ConfigurationException(getLogPrefix(null) + "invalid value for hideMethod [" + getHideMethod() + "], must be 'all' or 'firstHalf'");
        }
        if (isCheckXmlWellFormed() || StringUtils.isNotEmpty(getCheckRootTag())) {
            if (findForward(ILLEGAL_RESULT_FORWARD) == null)
                throw new ConfigurationException(getLogPrefix(null) + "has no forward with name [illegalResult]");
        }
        if (!ConfigurationUtils.stubConfiguration()) {
            if (StringUtils.isNotEmpty(getTimeOutOnResult())) {
                throw new ConfigurationException(getLogPrefix(null) + "timeOutOnResult only allowed in stub mode");
            }
            if (StringUtils.isNotEmpty(getExceptionOnResult())) {
                throw new ConfigurationException(getLogPrefix(null) + "exceptionOnResult only allowed in stub mode");
            }
        }
        if (getMaxRetries() > 0) {
            ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
            if (getRetryMinInterval() < MIN_RETRY_INTERVAL) {
                String msg = "retryMinInterval [" + getRetryMinInterval() + "] should be greater than or equal to [" + MIN_RETRY_INTERVAL + "], assuming the lower limit";
                configWarnings.add(log, msg);
                setRetryMinInterval(MIN_RETRY_INTERVAL);
            }
            if (getRetryMaxInterval() > MAX_RETRY_INTERVAL) {
                String msg = "retryMaxInterval [" + getRetryMaxInterval() + "] should be less than or equal to [" + MAX_RETRY_INTERVAL + "], assuming the upper limit";
                configWarnings.add(log, msg);
                setRetryMaxInterval(MAX_RETRY_INTERVAL);
            }
            if (getRetryMaxInterval() < getRetryMinInterval()) {
                String msg = "retryMaxInterval [" + getRetryMaxInterval() + "] should be greater than or equal to [" + getRetryMinInterval() + "], assuming the lower limit";
                configWarnings.add(log, msg);
                setRetryMaxInterval(getRetryMinInterval());
            }
        }
    }
    ITransactionalStorage messageLog = getMessageLog();
    if (checkMessageLog) {
        if (!getSender().isSynchronous() && getListener() == null && !(getSender() instanceof nl.nn.adapterframework.senders.IbisLocalSender)) {
            if (messageLog == null) {
                ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
                String msg = "asynchronous sender [" + getSender().getName() + "] without sibling listener has no messageLog. Integrity check not possible";
                configWarnings.add(log, msg);
            }
        }
    }
    if (messageLog != null) {
        messageLog.configure();
        if (messageLog instanceof HasPhysicalDestination) {
            String msg = getLogPrefix(null) + "has messageLog in " + ((HasPhysicalDestination) messageLog).getPhysicalDestinationName();
            log.info(msg);
            if (getAdapter() != null)
                getAdapter().getMessageKeeper().add(msg);
        }
        if (StringUtils.isNotEmpty(getAuditTrailXPath())) {
            auditTrailTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getAuditTrailNamespaceDefs(), getAuditTrailXPath(), null, "text", false, null);
        }
        if (StringUtils.isNotEmpty(getCorrelationIDXPath()) || StringUtils.isNotEmpty(getCorrelationIDStyleSheet())) {
            correlationIDTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getCorrelationIDNamespaceDefs(), getCorrelationIDXPath(), getCorrelationIDStyleSheet(), "text", false, null);
        }
        if (StringUtils.isNotEmpty(getLabelXPath()) || StringUtils.isNotEmpty(getLabelStyleSheet())) {
            labelTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getLabelNamespaceDefs(), getLabelXPath(), getLabelStyleSheet(), "text", false, null);
        }
    }
    if (StringUtils.isNotEmpty(getRetryXPath())) {
        retryTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getRetryNamespaceDefs(), getRetryXPath(), null, "text", false, null);
    }
    IPipe inputValidator = getInputValidator();
    IPipe outputValidator = getOutputValidator();
    if (inputValidator != null && outputValidator == null && inputValidator instanceof IDualModeValidator) {
        outputValidator = ((IDualModeValidator) inputValidator).getResponseValidator();
        setOutputValidator(outputValidator);
    }
    if (inputValidator != null) {
        PipeForward pf = new PipeForward();
        pf.setName(SUCCESS_FORWARD);
        inputValidator.registerForward(pf);
    // inputValidator.configure(); // configure is handled in PipeLine.configure()
    }
    if (outputValidator != null) {
        PipeForward pf = new PipeForward();
        pf.setName(SUCCESS_FORWARD);
        outputValidator.registerForward(pf);
    // outputValidator.configure(); // configure is handled in PipeLine.configure()
    }
    if (getInputWrapper() != null) {
        PipeForward pf = new PipeForward();
        pf.setName(SUCCESS_FORWARD);
        getInputWrapper().registerForward(pf);
        if (getInputWrapper() instanceof EsbSoapWrapperPipe) {
            EsbSoapWrapperPipe eswPipe = (EsbSoapWrapperPipe) getInputWrapper();
            ISender sender = getSender();
            eswPipe.retrievePhysicalDestinationFromSender(sender);
        }
    }
    if (getOutputWrapper() != null) {
        PipeForward pf = new PipeForward();
        pf.setName(SUCCESS_FORWARD);
        getOutputWrapper().registerForward(pf);
    }
    registerEvent(PIPE_TIMEOUT_MONITOR_EVENT);
    registerEvent(PIPE_CLEAR_TIMEOUT_MONITOR_EVENT);
    registerEvent(PIPE_EXCEPTION_MONITOR_EVENT);
}
Also used : ConfigurationWarnings(nl.nn.adapterframework.configuration.ConfigurationWarnings) EsbSoapWrapperPipe(nl.nn.adapterframework.extensions.esb.EsbSoapWrapperPipe) IDualModeValidator(nl.nn.adapterframework.core.IDualModeValidator) PipeForward(nl.nn.adapterframework.core.PipeForward) URL(java.net.URL) ITransactionalStorage(nl.nn.adapterframework.core.ITransactionalStorage) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) ISender(nl.nn.adapterframework.core.ISender) IPipe(nl.nn.adapterframework.core.IPipe) HasPhysicalDestination(nl.nn.adapterframework.core.HasPhysicalDestination)

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