Search in sources :

Example 6 with Parameter

use of nl.nn.adapterframework.parameters.Parameter 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 7 with Parameter

use of nl.nn.adapterframework.parameters.Parameter in project iaf by ibissource.

the class ConfigData method setAutoReload.

private FixedQuerySender setAutoReload(String autoReload, FixedQuerySender qs) {
    Parameter param = new Parameter();
    param.setName(AUTO_RELOAD);
    if ("on".equals(autoReload)) {
        param.setValue(qs.getDbmsSupport().getBooleanValue(true));
    } else {
        param.setValue(qs.getDbmsSupport().getBooleanValue(false));
    }
    qs.addParameter(param);
    return qs;
}
Also used : Parameter(nl.nn.adapterframework.parameters.Parameter)

Example 8 with Parameter

use of nl.nn.adapterframework.parameters.Parameter in project iaf by ibissource.

the class XQueryPipe method doPipe.

public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
    if (input == null) {
        throw new PipeRunException(this, getLogPrefix(session) + "got null input");
    }
    if (!(input instanceof String)) {
        throw new PipeRunException(this, getLogPrefix(session) + "got an invalid type as input, expected String, got " + input.getClass().getName());
    }
    try {
        String stringResult = (String) input;
        // We already specifically use Saxon in this pipe, hence set xslt2
        // to true to make XmlUtils use the Saxon
        // DocumentBuilderFactoryImpl.
        ParameterResolutionContext prc = new ParameterResolutionContext(stringResult, session, isNamespaceAware(), true);
        Map parametervalues = null;
        if (getParameterList() != null) {
            parametervalues = prc.getValueMap(getParameterList());
        }
        preparedExpression.bindDocument(XQConstants.CONTEXT_ITEM, stringResult, null, null);
        Iterator iterator = getParameterList().iterator();
        while (iterator.hasNext()) {
            Parameter parameter = (Parameter) iterator.next();
            preparedExpression.bindObject(new QName(parameter.getName()), parametervalues.get(parameter.getName()), null);
        }
        XQResultSequence resultSequence = preparedExpression.executeQuery();
        stringResult = resultSequence.getSequenceAsString(null);
        return new PipeRunResult(getForward(), stringResult);
    } catch (Exception e) {
        throw new PipeRunException(this, getLogPrefix(session) + " Exception on running xquery", e);
    }
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) QName(javax.xml.namespace.QName) PipeRunException(nl.nn.adapterframework.core.PipeRunException) Iterator(java.util.Iterator) Parameter(nl.nn.adapterframework.parameters.Parameter) ParameterResolutionContext(nl.nn.adapterframework.parameters.ParameterResolutionContext) Map(java.util.Map) PipeRunException(nl.nn.adapterframework.core.PipeRunException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) XQException(javax.xml.xquery.XQException) XQResultSequence(javax.xml.xquery.XQResultSequence)

Example 9 with Parameter

use of nl.nn.adapterframework.parameters.Parameter in project iaf by ibissource.

the class CompareStringPipe method configure.

@Override
public void configure() throws ConfigurationException {
    super.configure();
    if (null == findForward(LESSTHANFORWARD))
        throw new ConfigurationException(getLogPrefix(null) + "forward [" + LESSTHANFORWARD + "] is not defined");
    if (null == findForward(GREATERTHANFORWARD))
        throw new ConfigurationException(getLogPrefix(null) + "forward [" + GREATERTHANFORWARD + "] is not defined");
    if (null == findForward(EQUALSFORWARD))
        throw new ConfigurationException(getLogPrefix(null) + "forward [" + EQUALSFORWARD + "] is not defined");
    if (StringUtils.isEmpty(sessionKey1) && StringUtils.isEmpty(sessionKey2)) {
        boolean operand1Exists = false;
        boolean operand2Exists = false;
        ParameterList parameterList = getParameterList();
        for (int i = 0; i < parameterList.size(); i++) {
            Parameter parameter = parameterList.getParameter(i);
            if (parameter.getName().equalsIgnoreCase(OPERAND1)) {
                operand1Exists = true;
            } else {
                if (parameter.getName().equalsIgnoreCase(OPERAND2)) {
                    operand2Exists = true;
                }
            }
        }
        if (!operand1Exists && !operand2Exists) {
            throw new ConfigurationException(getLogPrefix(null) + "has neither parameter [" + OPERAND1 + "] nor parameter [" + OPERAND2 + "] specified");
        }
    }
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) ParameterList(nl.nn.adapterframework.parameters.ParameterList) Parameter(nl.nn.adapterframework.parameters.Parameter)

Example 10 with Parameter

use of nl.nn.adapterframework.parameters.Parameter in project iaf by ibissource.

the class EtagHandlerPipe method doPipe.

@Override
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
    if (input == null) {
        throw new PipeRunException(this, getLogPrefix(session) + "got null input");
    }
    if (!(input instanceof String)) {
        throw new PipeRunException(this, getLogPrefix(session) + "got an invalid type as input, expected String, got " + input.getClass().getName());
    }
    String uriPatternSessionKey = null;
    ParameterValueList pvl = null;
    ParameterList parameterList = getParameterList();
    if (parameterList != null) {
        ParameterResolutionContext prc = new ParameterResolutionContext((String) input, session);
        try {
            pvl = prc.getValues(getParameterList());
            if (pvl != null) {
                for (int i = 0; i < parameterList.size(); i++) {
                    Parameter parameter = parameterList.getParameter(i);
                    if ("uriPattern".equalsIgnoreCase(parameter.getName()))
                        uriPatternSessionKey = (String) parameter.getValue(pvl, prc);
                }
            }
        } catch (ParameterException e) {
            throw new PipeRunException(this, getLogPrefix(session) + "exception extracting parameters", e);
        }
    }
    // hash over data genereren, uit cache lezen en teruggeven, in cache updaten, verwijderen uit cache, cache naar disk wegschrijven, cache legen
    String cacheKey = null;
    if (uriPatternSessionKey != null && !uriPatternSessionKey.isEmpty())
        cacheKey = getRestPath() + "_" + uriPatternSessionKey.toLowerCase();
    else
        cacheKey = getRestPath() + "_" + getUriPattern();
    if (cache != null && cache.containsKey(cacheKey)) {
        Object returnCode = false;
        if (getAction().equalsIgnoreCase("generate")) {
            cache.put(cacheKey, RestListenerUtils.formatEtag(getRestPath(), getUriPattern(), input.hashCode()));
            returnCode = true;
        } else if (getAction().equalsIgnoreCase("get")) {
            returnCode = cache.get(cacheKey);
        } else if (getAction().equalsIgnoreCase("set")) {
            cache.put(cacheKey, input.toString());
            returnCode = true;
        } else if (getAction().equalsIgnoreCase("delete")) {
            returnCode = cache.remove(cacheKey);
        } else if (getAction().equalsIgnoreCase("flush")) {
            if (cache instanceof ApiEhcache) {
                ((ApiEhcache) cache).flush();
                returnCode = true;
            }
        } else if (getAction().equalsIgnoreCase("clear")) {
            cache.clear();
            returnCode = true;
        } else {
            throw new PipeRunException(this, getLogPrefix(session) + "action not found [" + getAction() + "]");
        }
        if (log.isDebugEnabled())
            log.debug("found eTag cacheKey [" + cacheKey + "] with action [" + getAction() + "]");
        return new PipeRunResult(getForward(), returnCode);
    } else {
        PipeForward pipeForward = findForward("exception");
        String msg;
        if (cache == null)
            msg = "failed to locate cache";
        else
            msg = "failed to locate eTag [" + cacheKey + "] in cache";
        if (pipeForward == null) {
            throw new PipeRunException(this, getLogPrefix(session) + msg);
        }
        return new PipeRunResult(pipeForward, "");
    }
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) ParameterValueList(nl.nn.adapterframework.parameters.ParameterValueList) PipeRunException(nl.nn.adapterframework.core.PipeRunException) ParameterList(nl.nn.adapterframework.parameters.ParameterList) Parameter(nl.nn.adapterframework.parameters.Parameter) ParameterException(nl.nn.adapterframework.core.ParameterException) ParameterResolutionContext(nl.nn.adapterframework.parameters.ParameterResolutionContext) ApiEhcache(nl.nn.adapterframework.http.rest.ApiEhcache) PipeForward(nl.nn.adapterframework.core.PipeForward)

Aggregations

Parameter (nl.nn.adapterframework.parameters.Parameter)41 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)19 ParameterResolutionContext (nl.nn.adapterframework.parameters.ParameterResolutionContext)15 ParameterList (nl.nn.adapterframework.parameters.ParameterList)13 PipeRunException (nl.nn.adapterframework.core.PipeRunException)12 IOException (java.io.IOException)7 FixedQuerySender (nl.nn.adapterframework.jdbc.FixedQuerySender)7 ParameterException (nl.nn.adapterframework.core.ParameterException)6 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)6 ParameterValueList (nl.nn.adapterframework.parameters.ParameterValueList)5 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)4 Map (java.util.Map)4 Test (org.junit.Test)3 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedList (java.util.LinkedList)2