Search in sources :

Example 51 with TimeOutException

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

the class CmisHttpSender method invoke.

public Response invoke(HttpMethod method, String url, Map<String, String> headers, Output writer, BindingSession session) throws SenderException, TimeoutException {
    // Prepare the message. We will overwrite things later...
    int responseCode = -1;
    PipeLineSession pls = new PipeLineSession();
    pls.put("writer", writer);
    pls.put("url", url);
    pls.put("method", method);
    pls.put("headers", headers);
    try {
        // Message is unused, we use 'Output writer' instead
        sendMessage(new Message(""), pls);
        return (Response) pls.get("response");
    } catch (Exception e) {
        throw new CmisConnectionException(getUrl(), responseCode, e);
    }
}
Also used : Response(org.apache.chemistry.opencmis.client.bindings.spi.http.Response) Message(nl.nn.adapterframework.stream.Message) CmisConnectionException(org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) TimeoutException(nl.nn.adapterframework.core.TimeoutException) CmisConnectionException(org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException) MethodNotSupportedException(org.apache.http.MethodNotSupportedException) IOException(java.io.IOException) SenderException(nl.nn.adapterframework.core.SenderException)

Example 52 with TimeOutException

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

the class BisJmsSender method sendMessage.

@Override
public Message sendMessage(Message input, PipeLineSession session) throws SenderException, TimeoutException {
    String messageHeader;
    try {
        messageHeader = bisUtils.prepareMessageHeader(null, isMessageHeaderInSoapBody(), (String) session.get(getConversationIdSessionKey()), (String) session.get(getExternalRefToMessageIdSessionKey()));
    } catch (Exception e) {
        throw new SenderException(e);
    }
    String replyMessage;
    try {
        Message payload = bisUtils.prepareReply(input, isMessageHeaderInSoapBody() ? messageHeader : null, null, false);
        if (StringUtils.isNotEmpty(getRequestNamespace())) {
            payload = new Message(XmlUtils.addRootNamespace(payload.asString(), getRequestNamespace()));
        }
        replyMessage = super.sendMessage(payload, session, isMessageHeaderInSoapBody() ? null : messageHeader).asString();
    } catch (Exception e) {
        throw new SenderException(e);
    }
    if (isSynchronous()) {
        String bisError;
        String bisErrorList;
        try {
            bisError = bisErrorTp.transform(replyMessage, null, true);
            bisErrorList = bisErrorListTp.transform(replyMessage, null, true);
        } catch (Exception e) {
            throw new SenderException(e);
        }
        if (Boolean.valueOf(bisError).booleanValue()) {
            log.debug("put in session [" + getErrorListSessionKey() + "] [" + bisErrorList + "]");
            session.put(getErrorListSessionKey(), bisErrorList);
            throw new SenderException("bisErrorXPath [" + (isResultInPayload() ? bisUtils.getBisErrorXPath() : bisUtils.getOldBisErrorXPath()) + "] returns true");
        }
        try {
            replyMessage = responseTp.transform(replyMessage, null, true);
            if (isRemoveResponseNamespaces()) {
                replyMessage = XmlUtils.removeNamespaces(replyMessage);
            }
            if (isResultInPayload()) {
                Element soapBodyElement = XmlUtils.buildElement(replyMessage, true);
                Element resultElement = XmlUtils.getFirstChildTag(soapBodyElement, "Result");
                if (resultElement != null) {
                    soapBodyElement.removeChild(resultElement);
                }
                replyMessage = XmlUtils.nodeToString(soapBodyElement);
            }
            return new Message(replyMessage);
        } catch (Exception e) {
            throw new SenderException(e);
        }
    } else {
        return new Message(replyMessage);
    }
}
Also used : Message(nl.nn.adapterframework.stream.Message) Element(org.w3c.dom.Element) SenderException(nl.nn.adapterframework.core.SenderException) TransformerException(javax.xml.transform.TransformerException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) SenderException(nl.nn.adapterframework.core.SenderException) TimeoutException(nl.nn.adapterframework.core.TimeoutException)

Example 53 with TimeOutException

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

the class XmlFileElementIteratorPipe method iterateOverInput.

@Override
protected StopReason iterateOverInput(Message input, PipeLineSession session, Map<String, Object> threadContext, ItemCallback callback) throws SenderException, TimeoutException {
    InputStream xmlInput;
    try {
        xmlInput = new FileInputStream(input.asString());
    } catch (IOException e) {
        throw new SenderException("could not find file [" + input + "]", e);
    }
    ItemCallbackCallingHandler handler = new ItemCallbackCallingHandler(callback);
    log.debug("obtaining list of elements [" + getElementName() + "] using sax parser");
    try {
        SAXParserFactory parserFactory = XmlUtils.getSAXParserFactory();
        parserFactory.setNamespaceAware(true);
        SAXParser saxParser = parserFactory.newSAXParser();
        saxParser.parse(xmlInput, handler);
    } catch (Exception e) {
        if (handler.getTimeOutException() != null) {
            throw handler.getTimeOutException();
        }
        if (!handler.isStopRequested()) {
            throw new SenderException("Could not extract list of elements [" + getElementName() + "] using sax parser", e);
        }
        try {
            handler.endDocument();
        } catch (SAXException e1) {
            throw new SenderException("could not endDocument after stop was requested", e1);
        }
    }
    return handler.stopReason;
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) SAXParser(javax.xml.parsers.SAXParser) IOException(java.io.IOException) SenderException(nl.nn.adapterframework.core.SenderException) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) SaxException(nl.nn.adapterframework.xml.SaxException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) SAXException(org.xml.sax.SAXException) SenderException(nl.nn.adapterframework.core.SenderException) TimeoutException(nl.nn.adapterframework.core.TimeoutException) SAXParserFactory(javax.xml.parsers.SAXParserFactory) SAXException(org.xml.sax.SAXException)

Example 54 with TimeOutException

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

the class IteratingPipe method sendMessage.

@Override
protected PipeRunResult sendMessage(Message input, PipeLineSession session, ISender sender, Map<String, Object> threadContext) throws SenderException, TimeoutException, IOException {
    // sendResult has a messageID for async senders, the result for sync senders
    StopReason stopReason = null;
    try (MessageOutputStream target = getTargetStream(session)) {
        try (Writer resultWriter = target.asWriter()) {
            ItemCallback callback = createItemCallBack(session, sender, resultWriter);
            stopReason = iterateOverInput(input, session, threadContext, callback);
        }
        PipeRunResult prr = target.getPipeRunResult();
        if (stopReason != null) {
            PipeForward forward = getForwards().get(stopReason.getForwardName());
            if (forward != null) {
                prr.setPipeForward(forward);
            }
        }
        return prr;
    } catch (SenderException | TimeoutException | IOException e) {
        throw e;
    } catch (Exception e) {
        throw new SenderException(getLogPrefix(session) + "Exception on transforming input", e);
    }
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) MessageOutputStream(nl.nn.adapterframework.stream.MessageOutputStream) IOException(java.io.IOException) SenderException(nl.nn.adapterframework.core.SenderException) PipeForward(nl.nn.adapterframework.core.PipeForward) Writer(java.io.Writer) TransformerException(javax.xml.transform.TransformerException) TimeoutException(nl.nn.adapterframework.core.TimeoutException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IOException(java.io.IOException) StreamingException(nl.nn.adapterframework.stream.StreamingException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) SAXException(org.xml.sax.SAXException) SenderException(nl.nn.adapterframework.core.SenderException) TimeoutException(nl.nn.adapterframework.core.TimeoutException)

Example 55 with TimeOutException

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

the class XmlValidatorSender method sendMessage.

@Override
public Message sendMessage(Message message, PipeLineSession session) throws SenderException, TimeoutException {
    String fullReasons = "tja";
    try {
        String resultEvent = validate(message, session, getLogPrefix(), null, null);
        if (AbstractXmlValidator.XML_VALIDATOR_VALID_MONITOR_EVENT.equals(resultEvent)) {
            return message;
        }
        // TODO: find real fullReasons
        fullReasons = resultEvent;
        if (isThrowException()) {
            throw new SenderException(fullReasons);
        }
        log.warn(fullReasons);
        return message;
    } catch (Exception e) {
        if (isThrowException()) {
            throw new SenderException(e);
        }
        log.warn(fullReasons, e);
        return message;
    }
}
Also used : SenderException(nl.nn.adapterframework.core.SenderException) SenderException(nl.nn.adapterframework.core.SenderException) TimeoutException(nl.nn.adapterframework.core.TimeoutException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException)

Aggregations

SenderException (nl.nn.adapterframework.core.SenderException)68 TimeoutException (nl.nn.adapterframework.core.TimeoutException)45 IOException (java.io.IOException)40 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)34 TimeOutException (nl.nn.adapterframework.core.TimeOutException)28 Message (nl.nn.adapterframework.stream.Message)26 ParameterException (nl.nn.adapterframework.core.ParameterException)24 HashMap (java.util.HashMap)20 ParameterValueList (nl.nn.adapterframework.parameters.ParameterValueList)18 Map (java.util.Map)16 LinkedHashMap (java.util.LinkedHashMap)12 ListenerException (nl.nn.adapterframework.core.ListenerException)10 PipeLineSession (nl.nn.adapterframework.core.PipeLineSession)9 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)9 JMSException (javax.jms.JMSException)8 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)8 FileNotFoundException (java.io.FileNotFoundException)7 InputStream (java.io.InputStream)7 SAXException (org.xml.sax.SAXException)7 FixedQuerySender (nl.nn.adapterframework.jdbc.FixedQuerySender)6