Search in sources :

Example 96 with PipeRunException

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

the class TestPipeLine method doPost.

private String doPost(IPipeLineSession session) throws PipeRunException {
    Object form_file = session.get("file");
    String form_message = null;
    form_message = (String) session.get("message");
    if (form_file == null && (StringUtils.isEmpty(form_message))) {
        throw new PipeRunException(this, getLogPrefix(session) + "Nothing to send or test");
    }
    String form_adapterName = (String) session.get("adapterName");
    if (StringUtils.isEmpty(form_adapterName)) {
        throw new PipeRunException(this, getLogPrefix(session) + "No adapter selected");
    }
    IAdapter adapter = RestListenerUtils.retrieveIbisManager(session).getRegisteredAdapter(form_adapterName);
    if (adapter == null) {
        throw new PipeRunException(this, getLogPrefix(session) + "Adapter with specified name [" + form_adapterName + "] could not be retrieved");
    }
    boolean writeSecLogMessage = false;
    if (secLogMessage) {
        writeSecLogMessage = (Boolean) session.get("writeSecLogMessage");
    }
    if (form_file != null) {
        if (form_file instanceof InputStream) {
            InputStream inputStream = (InputStream) form_file;
            String form_fileName = (String) session.get("fileName");
            String form_fileEncoding = (String) session.get("fileEncoding");
            try {
                if (inputStream.available() > 0) {
                    String fileEncoding;
                    if (StringUtils.isNotEmpty(form_fileEncoding)) {
                        fileEncoding = form_fileEncoding;
                    } else {
                        fileEncoding = Misc.DEFAULT_INPUT_STREAM_ENCODING;
                    }
                    if (StringUtils.endsWithIgnoreCase(form_fileName, ".zip")) {
                        try {
                            form_message = processZipFile(session, inputStream, fileEncoding, adapter, writeSecLogMessage);
                        } catch (Exception e) {
                            throw new PipeRunException(this, getLogPrefix(session) + "exception on processing zip file", e);
                        }
                    } else {
                        form_message = Misc.streamToString(inputStream, "\n", fileEncoding, false);
                    }
                }
            } catch (IOException e) {
                throw new PipeRunException(this, getLogPrefix(session) + "exception on converting stream to string", e);
            }
        } else {
            form_message = form_file.toString();
        }
        session.put("message", form_message);
    }
    if (StringUtils.isNotEmpty(form_message)) {
        try {
            PipeLineResult plr = processMessage(adapter, form_message, writeSecLogMessage);
            session.put("state", plr.getState());
            session.put("result", plr.getResult());
        } catch (Exception e) {
            throw new PipeRunException(this, getLogPrefix(session) + "exception on sending message", e);
        }
    }
    return "<dummy/>";
}
Also used : ZipInputStream(java.util.zip.ZipInputStream) InputStream(java.io.InputStream) PipeLineResult(nl.nn.adapterframework.core.PipeLineResult) PipeRunException(nl.nn.adapterframework.core.PipeRunException) IOException(java.io.IOException) IAdapter(nl.nn.adapterframework.core.IAdapter) PipeRunException(nl.nn.adapterframework.core.PipeRunException) IOException(java.io.IOException)

Example 97 with PipeRunException

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

the class XmlValidatorTest2 method validate.

@Override
public String validate(String rootNamespace, String schemaLocation, boolean addNamespaceToSchema, boolean ignoreUnknownNamespaces, String inputfile, String[] expectedFailureReasons) throws ConfigurationException, InstantiationException, IllegalAccessException, XmlValidatorException, PipeRunException, IOException {
    String testXml = inputfile != null ? getTestXml(inputfile + ".xml") : null;
    IPipeLineSession session = new PipeLineSessionBase();
    try {
        XmlValidator validator = getValidator(schemaLocation, addNamespaceToSchema, implementation);
        validator.setIgnoreUnknownNamespaces(ignoreUnknownNamespaces);
        PipeForward forward = validator.validate(testXml, session);
        evaluateResult(forward.getName(), session, null, expectedFailureReasons);
    } catch (Exception e) {
        evaluateResult(null, session, e, expectedFailureReasons);
        return "Invalid XML";
    }
    return null;
}
Also used : AbstractXmlValidator(nl.nn.adapterframework.validation.AbstractXmlValidator) XercesXmlValidator(nl.nn.adapterframework.validation.XercesXmlValidator) JavaxXmlValidator(nl.nn.adapterframework.validation.JavaxXmlValidator) IPipeLineSession(nl.nn.adapterframework.core.IPipeLineSession) PipeForward(nl.nn.adapterframework.core.PipeForward) PipeRunException(nl.nn.adapterframework.core.PipeRunException) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) XmlValidatorException(nl.nn.adapterframework.validation.XmlValidatorException) PipeLineSessionBase(nl.nn.adapterframework.core.PipeLineSessionBase)

Example 98 with PipeRunException

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

the class XsltPipeErrorTest method documentNotFound2.

@Test
public void documentNotFound2() throws Exception {
    // error not during configure(), but during doPipe()
    ErrorOutputStream errorOutputStream = new ErrorOutputStream();
    System.setErr(new PrintStream(errorOutputStream));
    XsltPipe xsltPipe = new XsltPipe();
    xsltPipe.registerForward(createPipeSuccessForward());
    xsltPipe.setStyleSheetName("/Xslt/documentNotFound/root2.xsl");
    xsltPipe.setXslt2(true);
    xsltPipe.configure();
    xsltPipe.start();
    String input = getFile("/Xslt/documentNotFound/in.xml");
    String errorMessage = null;
    try {
        xsltPipe.doPipe(input, session);
    } catch (PipeRunException e) {
        errorMessage = e.getMessage();
    }
    assertEquals(true, errorOutputStream.isEmpty());
    assertEquals(0, testAppender.getNumberOfAlerts());
    assertEquals(true, errorMessage.contains("java.io.FileNotFoundException"));
}
Also used : PrintStream(java.io.PrintStream) PipeRunException(nl.nn.adapterframework.core.PipeRunException) Test(org.junit.Test)

Example 99 with PipeRunException

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

the class ConfigData method activeConfigQuery.

private String activeConfigQuery(IPipeLineSession session, String name, String formJmsRealm, String result) throws PipeRunException {
    FixedQuerySender qs = (FixedQuerySender) ibisContext.createBeanAutowireByName(FixedQuerySender.class);
    try {
        qs.setName("QuerySender");
        qs.setJmsRealm(formJmsRealm);
        qs.setQueryType("update");
        qs.setQuery("UPDATE IBISCONFIG SET ACTIVECONFIG = '" + qs.getDbmsSupport().getBooleanValue(false) + "' WHERE NAME=?");
        Parameter param = new Parameter();
        param.setName("name");
        param.setValue(name);
        qs.addParameter(param);
        qs.setScalar(true);
        qs.configure();
        qs.open();
        ParameterResolutionContext prc = new ParameterResolutionContext(DUMMY, session);
        result = qs.sendMessage(DUMMY, DUMMY, prc);
    } catch (Exception t) {
        throw new PipeRunException(this, getLogPrefix(session) + "Error occured on executing jdbc query", t);
    } finally {
        qs.close();
    }
    return result;
}
Also used : PipeRunException(nl.nn.adapterframework.core.PipeRunException) Parameter(nl.nn.adapterframework.parameters.Parameter) ParameterResolutionContext(nl.nn.adapterframework.parameters.ParameterResolutionContext) FixedQuerySender(nl.nn.adapterframework.jdbc.FixedQuerySender) PipeRunException(nl.nn.adapterframework.core.PipeRunException) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException)

Example 100 with PipeRunException

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

the class Webservices method doGet.

private String doGet(IPipeLineSession session) throws PipeRunException {
    IbisManager ibisManager = RestListenerUtils.retrieveIbisManager(session);
    String uri = (String) session.get("uri");
    String indent = (String) session.get("indent");
    String useIncludes = (String) session.get("useIncludes");
    if (StringUtils.isNotEmpty(uri) && (uri.endsWith(getWsdlExtention()) || uri.endsWith(".zip"))) {
        String adapterName = StringUtils.substringBeforeLast(StringUtils.substringAfterLast(uri, "/"), ".");
        IAdapter adapter = ibisManager.getRegisteredAdapter(adapterName);
        if (adapter == null) {
            throw new PipeRunException(this, getLogPrefix(session) + "adapter [" + adapterName + "] doesn't exist");
        }
        try {
            if (uri.endsWith(getWsdlExtention())) {
                RestListenerUtils.setResponseContentType(session, "application/xml");
                wsdl((Adapter) adapter, session, indent, useIncludes);
            } else {
                RestListenerUtils.setResponseContentType(session, "application/octet-stream");
                zip((Adapter) adapter, session);
            }
        } catch (Exception e) {
            throw new PipeRunException(this, getLogPrefix(session) + "exception on retrieving wsdl", e);
        }
        return "";
    } else {
        return list(ibisManager);
    }
}
Also used : IbisManager(nl.nn.adapterframework.configuration.IbisManager) PipeRunException(nl.nn.adapterframework.core.PipeRunException) IAdapter(nl.nn.adapterframework.core.IAdapter) PipeRunException(nl.nn.adapterframework.core.PipeRunException) NamingException(javax.naming.NamingException) XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException)

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