Search in sources :

Example 6 with PipeRunException

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

the class ConfigData method processJarFile.

private String processJarFile(IPipeLineSession session, String name, String version, String fileName, String fileNameSessionKey) throws PipeRunException {
    String formJmsRealm = (String) session.get("jmsRealm");
    String activeConfig = (String) session.get(ACTIVE_CONFIG);
    String autoReload = (String) session.get(AUTO_RELOAD);
    String result = selectConfigQuery(session, name);
    if ("on".equals(activeConfig)) {
        activeConfigQuery(session, name, formJmsRealm, result);
    }
    if (Integer.parseInt(result) > 0) {
        deleteConfigQuery(session, name, formJmsRealm, version);
    }
    String remoteUser = (String) session.get("principal");
    FixedQuerySender qs = (FixedQuerySender) ibisContext.createBeanAutowireByName(FixedQuerySender.class);
    try {
        qs.setName("QuerySender");
        qs.setJmsRealm(formJmsRealm);
        qs.setQueryType("insert");
        if (StringUtils.isEmpty(remoteUser)) {
            qs.setQuery("INSERT INTO IBISCONFIG (NAME, VERSION, FILENAME, CONFIG, CRE_TYDST, ACTIVECONFIG, AUTORELOAD) VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP, ?, ?)");
        } else {
            qs.setQuery("INSERT INTO IBISCONFIG (NAME, VERSION, FILENAME, CONFIG, CRE_TYDST, RUSER, ACTIVECONFIG, AUTORELOAD) VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP, ?, ?, ?)");
        }
        Parameter param = new Parameter();
        param.setName("name");
        param.setValue(name);
        qs.addParameter(param);
        param = new Parameter();
        param.setName("version");
        param.setValue(version);
        qs.addParameter(param);
        param = new Parameter();
        param.setName("fileName");
        param.setValue(fileName);
        qs.addParameter(param);
        param = new Parameter();
        param.setName("config");
        param.setSessionKey(fileNameSessionKey);
        param.setType(Parameter.TYPE_INPUTSTREAM);
        qs.addParameter(param);
        if (StringUtils.isNotEmpty(remoteUser)) {
            param = new Parameter();
            param.setName("ruser");
            param.setValue(remoteUser);
            qs.addParameter(param);
        }
        setActiveConfig(activeConfig, qs);
        setAutoReload(autoReload, qs);
        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 7 with PipeRunException

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

the class ConfigData method doPost.

private String doPost(IPipeLineSession session) throws PipeRunException {
    String multipleConfigs = (String) session.get("multipleConfigs");
    String fileName = (String) session.get("fileName");
    String name = (String) session.get("name");
    String version = (String) session.get("version");
    ConfigData configData = new ConfigData(multipleConfigs, fileName, name, version);
    String result;
    if (!"on".equals(multipleConfigs)) {
        processMultipleConfigs(configData, session);
    }
    Object file = session.get("file");
    if (file == null) {
        throw new PipeRunException(this, getLogPrefix(session) + "Nothing to send or test");
    }
    if ("on".equals(multipleConfigs)) {
        try {
            result = processZipFile(session);
        } catch (IOException e) {
            throw new PipeRunException(this, getLogPrefix(session) + "Error while processing zip file", e);
        }
    } else {
        result = processJarFile(session, name, version, fileName, "file");
    }
    session.put("result", result);
    return "<dummy/>";
}
Also used : PipeRunException(nl.nn.adapterframework.core.PipeRunException) IOException(java.io.IOException)

Example 8 with PipeRunException

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

the class ConfigData method deleteConfigQuery.

private String deleteConfigQuery(IPipeLineSession session, String name, String formJmsRealm, String version) throws PipeRunException {
    FixedQuerySender qs = (FixedQuerySender) ibisContext.createBeanAutowireByName(FixedQuerySender.class);
    String result = "";
    try {
        qs.setName("QuerySender");
        qs.setJmsRealm(formJmsRealm);
        qs.setQuery("DELETE FROM IBISCONFIG WHERE NAME = ? AND VERSION = ?");
        Parameter param = new Parameter();
        param.setName("name");
        param.setValue(name);
        qs.addParameter(param);
        param = new Parameter();
        param.setName("version");
        param.setValue(version);
        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 9 with PipeRunException

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

the class ConfigData method selectConfigQuery.

private String selectConfigQuery(IPipeLineSession session, String name) throws PipeRunException {
    String formJmsRealm = (String) session.get("jmsRealm");
    String result = "";
    FixedQuerySender qs = (FixedQuerySender) ibisContext.createBeanAutowireByName(FixedQuerySender.class);
    try {
        qs.setName("QuerySender");
        qs.setJmsRealm(formJmsRealm);
        qs.setQueryType("select");
        qs.setQuery("SELECT COUNT(*) FROM IBISCONFIG 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 10 with PipeRunException

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

the class CoolGenWrapperPipe method doPipe.

/**
 * Transform the input (optionally), check the conformance to the schema (optionally),
 * call the required proxy, transform the output (optionally)
 */
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
    Writer proxyResult;
    String proxypreProc = null;
    Variant inputVar;
    String wrapperResult = "";
    CoolGenXMLProxy proxy;
    ActionListener actionListener = new ActionListener() {

        /**
         * @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
         */
        public String errorMessage;

        public void actionPerformed(ActionEvent e) {
            errorMessage = e.toString();
        }

        public String toString() {
            return errorMessage;
        }
    };
    Source in;
    try {
        log.info(getLogPrefix(session) + "instantiating proxy [" + proxyClassName + "] as a temporary fix for broken comm-bridge connections");
        proxy = createProxy(proxyClassName);
    } catch (ConfigurationException ce) {
        String msg = getLogPrefix(session) + "cannot recreate proxy after exception";
        log.error(msg, ce);
        throw new PipeRunException(this, msg, ce);
    }
    proxy.addExceptionListener(actionListener);
    try {
        inputVar = new Variant(input);
        in = inputVar.asXmlSource();
        if (preProcTransformer != null) {
            proxypreProc = XmlUtils.transformXml(preProcTransformer, in);
            log.debug(getLogPrefix(session) + "] preprocessing transformed message into [" + proxypreProc + "]");
        } else
            proxypreProc = inputVar.asString();
        if (proxyInputFixTransformer != null)
            proxypreProc = XmlUtils.transformXml(proxyInputFixTransformer, proxypreProc);
        proxyResult = new StringWriter(10 * 1024);
        try {
            proxy.clear();
        } catch (PropertyVetoException e) {
            throw new PipeRunException(this, getLogPrefix(session) + "cannot clear CoolGen proxy", e);
        }
        try {
            proxy.executeXML(new StringReader(proxypreProc), proxyResult);
            proxy.removeExceptionListener(actionListener);
            String err = actionListener.toString();
            if (err != null) {
                // if an error occurs, recreate the proxy and throw an exception
                log.debug(getLogPrefix(session) + "got error, recreating proxy with class [" + proxyClassName + "]");
                try {
                    proxy = createProxy(proxyClassName);
                } catch (ConfigurationException e) {
                    throw new PipeRunException(this, getLogPrefix(session) + "cannot recreate proxy [" + proxyClassName + "]", e);
                }
                throw new PipeRunException(this, getLogPrefix(session) + "error excuting proxy [" + proxyClassName + "]:" + err);
            }
        } catch (XmlProxyException xpe) {
            try {
                proxy = createProxy(proxyClassName);
            } catch (ConfigurationException ce) {
                log.error(getLogPrefix(session) + "cannot recreate proxy", xpe);
            }
            throw new PipeRunException(this, getLogPrefix(session) + "error excecuting proxy", xpe);
        }
        if (postProcTransformer != null) {
            log.debug(getLogPrefix(session) + " CoolGen proxy returned: [" + proxyResult.toString() + "]");
            wrapperResult = XmlUtils.transformXml(postProcTransformer, proxyResult.toString());
        } else
            wrapperResult = proxyResult.toString();
    } catch (DomBuilderException e) {
        throw new PipeRunException(this, getLogPrefix(session) + "DomBuilderException excecuting proxy", e);
    } catch (IOException e) {
        throw new PipeRunException(this, getLogPrefix(session) + "IOException excecuting proxy", e);
    } catch (TransformerException e) {
        throw new PipeRunException(this, getLogPrefix(session) + "TransformerException excecuting proxy", e);
    }
    return new PipeRunResult(getForward(), wrapperResult);
}
Also used : CoolGenXMLProxy(nl.nn.coolgen.proxy.CoolGenXMLProxy) ActionEvent(java.awt.event.ActionEvent) IOException(java.io.IOException) Source(javax.xml.transform.Source) Variant(nl.nn.adapterframework.util.Variant) PropertyVetoException(java.beans.PropertyVetoException) PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) XmlProxyException(nl.nn.coolgen.proxy.XmlProxyException) ActionListener(java.awt.event.ActionListener) StringWriter(java.io.StringWriter) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) PipeRunException(nl.nn.adapterframework.core.PipeRunException) StringReader(java.io.StringReader) DomBuilderException(nl.nn.adapterframework.util.DomBuilderException) StringWriter(java.io.StringWriter) Writer(java.io.Writer) TransformerException(javax.xml.transform.TransformerException)

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