Search in sources :

Example 71 with PipeRunException

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

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

the class FxfWrapperPipe method doPipe.

@Override
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
    if ("wrap".equalsIgnoreCase(getDirection())) {
        XmlBuilder xmlStartTransfer_Action = new XmlBuilder("StartTransfer_Action");
        xmlStartTransfer_Action.addAttribute("xmlns", "http://nn.nl/XSD/Infrastructure/Transfer/FileTransfer/1/StartTransfer/" + retrieveStartTransferVersion());
        XmlBuilder xmlTransferDetails = new XmlBuilder("TransferDetails");
        xmlStartTransfer_Action.addSubElement(xmlTransferDetails);
        XmlBuilder xmlSenderApplication = new XmlBuilder("SenderApplication");
        xmlSenderApplication.setValue(instanceName);
        xmlTransferDetails.addSubElement(xmlSenderApplication);
        XmlBuilder xmlRecipientApplication = new XmlBuilder("RecipientApplication");
        xmlTransferDetails.addSubElement(xmlRecipientApplication);
        XmlBuilder xmlFilename = new XmlBuilder("Filename");
        if (input != null) {
            String filename = input.toString();
            if (isTransformFilename()) {
                String filenameOnIufState = "/opt/data/FXF/" + instanceNameLowerCase + "/" + getFlowId() + "/out/" + new File(filename).getName();
                xmlFilename.setValue(filenameOnIufState);
            } else {
                xmlFilename.setValue(filename);
            }
        }
        xmlTransferDetails.addSubElement(xmlFilename);
        XmlBuilder xmlTransferFlowId = new XmlBuilder("TransferFlowId");
        String transferFlowId = getFlowId().substring(0, 2) + environment + getFlowId().substring(3);
        xmlTransferFlowId.setValue(transferFlowId);
        xmlTransferDetails.addSubElement(xmlTransferFlowId);
        return super.doPipe(xmlStartTransfer_Action.toXML(), session);
    } else {
        String soapBody = (String) super.doPipe(input, session).getResult();
        session.put(getSoapBodySessionKey(), soapBody);
        String transferFlowId;
        String clientFilename;
        try {
            transferFlowId = transferFlowIdTp.transform(soapBody, null);
            session.put(getTransferFlowIdSessionKey(), transferFlowId);
            clientFilename = clientFilenameTp.transform(soapBody, null);
            session.put(getClientFilenameSessionKey(), clientFilename);
        } catch (Throwable t) {
            throw new PipeRunException(this, getLogPrefix(session) + " Unexpected exception during (un)wrapping ", t);
        }
        String flowId = transferFlowId.substring(0, 2) + "X" + transferFlowId.substring(3);
        session.put(getFlowIdSessionKey(), flowId);
        session.put(getFxfDirSessionKey(), fxfDir);
        // Transform the filename as it is known locally on the IUF state
        // machine to the filename as know on the application server (which
        // has a mount to the IUF state machine).
        String fxfFile = fxfDir + File.separator + flowId + File.separator + "in" + File.separator + new File(clientFilename).getName();
        session.put(getFxfFileSessionKey(), fxfFile);
        return new PipeRunResult(getForward(), fxfFile);
    }
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) PipeRunException(nl.nn.adapterframework.core.PipeRunException) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) File(java.io.File)

Example 73 with PipeRunException

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

the class Adios2XmlPipe method makeAdios.

public String makeAdios(InputSource bericht, IPipeLineSession session) throws PipeRunException {
    try {
        // Parse the input
        handler.clear();
        saxParser.parse(bericht, handler);
        return handler.getResult();
    } catch (Throwable t) {
        throw new PipeRunException(this, getLogPrefix(session) + "got error while transforming xml to adios, input [" + bericht + "]", t);
    }
}
Also used : PipeRunException(nl.nn.adapterframework.core.PipeRunException)

Example 74 with PipeRunException

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

the class ScanTibcoSolutionPipe method doPipe.

public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
    StringWriter stringWriter = new StringWriter();
    XMLStreamWriter xmlStreamWriter;
    try {
        xmlStreamWriter = XmlUtils.OUTPUT_FACTORY.createXMLStreamWriter(stringWriter);
        xmlStreamWriter.writeStartDocument();
        xmlStreamWriter.writeStartElement("root");
        xmlStreamWriter.writeAttribute("url", getUrl());
        // xmlStreamWriter.writeAttribute("level",
        // String.valueOf(getLevel()));
        process(xmlStreamWriter, getUrl(), getLevel());
        xmlStreamWriter.writeEndDocument();
        xmlStreamWriter.flush();
        xmlStreamWriter.close();
    } catch (XMLStreamException e) {
        throw new PipeRunException(this, "XMLStreamException", e);
    } catch (DomBuilderException e) {
        throw new PipeRunException(this, "DomBuilderException", e);
    } catch (XPathExpressionException e) {
        throw new PipeRunException(this, "XPathExpressionException", e);
    }
    return new PipeRunResult(getForward(), stringWriter.getBuffer().toString());
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) StringWriter(java.io.StringWriter) XMLStreamException(javax.xml.stream.XMLStreamException) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) XPathExpressionException(javax.xml.xpath.XPathExpressionException) PipeRunException(nl.nn.adapterframework.core.PipeRunException) DomBuilderException(nl.nn.adapterframework.util.DomBuilderException)

Example 75 with PipeRunException

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

the class ApiStreamPipe method adjustFirstStringPart.

@Override
protected String adjustFirstStringPart(String firstStringPart, IPipeLineSession session) throws PipeRunException {
    if (firstStringPart == null) {
        return "";
    } else {
        boolean retrieveMessage = false;
        if (XmlUtils.isWellFormed(firstStringPart, "MessageID")) {
            String rootNamespace = XmlUtils.getRootNamespace(firstStringPart);
            if ("http://www.w3.org/2005/08/addressing".equals(rootNamespace)) {
                retrieveMessage = true;
            }
        }
        if (retrieveMessage) {
            String messageId = null;
            try {
                messageId = XmlUtils.evaluateXPathNodeSetFirstElement(firstStringPart, "MessageID");
            } catch (Exception e) {
                throw new PipeRunException(this, "Exception getting MessageID", e);
            }
            if (StringUtils.isEmpty(messageId)) {
                throw new PipeRunException(this, "Could not find messageId in request [" + firstStringPart + "]");
            } else {
                // TODO: create dummyQuerySender should be put in
                // configure(), but gives an error
                IbisContext ibisContext = getAdapter().getConfiguration().getIbisManager().getIbisContext();
                dummyQuerySender = (FixedQuerySender) ibisContext.createBeanAutowireByName(FixedQuerySender.class);
                dummyQuerySender.setJmsRealm(jmsRealm);
                dummyQuerySender.setQuery("SELECT count(*) FROM ALL_TABLES");
                try {
                    dummyQuerySender.configure();
                } catch (ConfigurationException e) {
                    throw new PipeRunException(this, "Exception configuring dummy query sender", e);
                }
                ParameterResolutionContext prc = new ParameterResolutionContext("", session);
                String slotId = AppConstants.getInstance().getResolvedProperty("instance.name") + "/" + session.get("operation");
                String selectMessageKeyResult = null;
                try {
                    selectMessageKeyResult = selectMessageKey(slotId, messageId);
                } catch (Exception e) {
                    throw new PipeRunException(this, "Exception getting messageKey", e);
                }
                if (StringUtils.isEmpty(selectMessageKeyResult)) {
                    throw new PipeRunException(this, "Could not find message in MessageStore for slotId [" + slotId + "] and messageId [" + messageId + "]");
                } else {
                    String selectMessageResult = null;
                    try {
                        selectMessageResult = selectMessage(selectMessageKeyResult);
                    } catch (Exception e) {
                        throw new PipeRunException(this, "Exception getting message", e);
                    }
                    if (StringUtils.isEmpty(selectMessageResult)) {
                        throw new PipeRunException(this, "Could not find message in MessageStore with messageKey [" + selectMessageKeyResult + "]");
                    } else {
                        try {
                            deleteMessage(selectMessageKeyResult);
                        } catch (Exception e) {
                            throw new PipeRunException(this, "Exception deleting message", e);
                        }
                    }
                    return selectMessageResult;
                }
            }
        } else {
            return firstStringPart;
        }
    }
}
Also used : IbisContext(nl.nn.adapterframework.configuration.IbisContext) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) PipeRunException(nl.nn.adapterframework.core.PipeRunException) ParameterResolutionContext(nl.nn.adapterframework.parameters.ParameterResolutionContext) PipeRunException(nl.nn.adapterframework.core.PipeRunException) JdbcException(nl.nn.adapterframework.jdbc.JdbcException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) SQLException(java.sql.SQLException)

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