Search in sources :

Example 11 with ParameterList

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

the class TransformerPool method configureTransformer0.

public static TransformerPool configureTransformer0(String logPrefix, ClassLoader classLoader, String namespaceDefs, String xPathExpression, String styleSheetName, String outputType, boolean includeXmlDeclaration, ParameterList params, boolean xslt2) throws ConfigurationException {
    TransformerPool result;
    if (logPrefix == null) {
        logPrefix = "";
    }
    if (StringUtils.isNotEmpty(xPathExpression)) {
        if (StringUtils.isNotEmpty(styleSheetName)) {
            throw new ConfigurationException(logPrefix + " cannot have both an xpathExpression and a styleSheetName specified");
        }
        try {
            List paramNames = null;
            if (params != null) {
                paramNames = new ArrayList();
                Iterator iterator = params.iterator();
                while (iterator.hasNext()) {
                    paramNames.add(((Parameter) iterator.next()).getName());
                }
            }
            result = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(namespaceDefs, xPathExpression, outputType, includeXmlDeclaration, paramNames), xslt2);
        } catch (TransformerConfigurationException te) {
            throw new ConfigurationException(logPrefix + " got error creating transformer from xpathExpression [" + xPathExpression + "] namespaceDefs [" + namespaceDefs + "]", te);
        }
    } else {
        if (StringUtils.isNotEmpty(namespaceDefs)) {
            throw new ConfigurationException(logPrefix + " cannot have namespaceDefs specified for a styleSheetName");
        }
        if (!StringUtils.isEmpty(styleSheetName)) {
            URL resource = ClassUtils.getResourceURL(classLoader, styleSheetName);
            if (resource == null) {
                throw new ConfigurationException(logPrefix + " cannot find [" + styleSheetName + "]");
            }
            try {
                result = TransformerPool.getInstance(resource, xslt2);
            } catch (IOException e) {
                throw new ConfigurationException(logPrefix + "cannot retrieve [" + styleSheetName + "], resource [" + resource.toString() + "]", e);
            } catch (TransformerConfigurationException te) {
                throw new ConfigurationException(logPrefix + " got error creating transformer from file [" + styleSheetName + "]", te);
            }
            if (XmlUtils.isAutoReload()) {
                result.reloadURL = resource;
            }
        } else {
            throw new ConfigurationException(logPrefix + " either xpathExpression or styleSheetName must be specified");
        }
    }
    return result;
}
Also used : TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) ParameterList(nl.nn.adapterframework.parameters.ParameterList) LinkedList(java.util.LinkedList) List(java.util.List) IOException(java.io.IOException) URL(java.net.URL)

Example 12 with ParameterList

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

the class CreateRestViewPipe method configure.

public void configure() throws ConfigurationException {
    ParameterList parameterList = getParameterList();
    if (parameterList.findParameter(SRCPREFIX) == null) {
        Parameter p = new Parameter();
        p.setName(SRCPREFIX);
        p.setSessionKey(SRCPREFIX);
        addParameter(p);
    }
    appConstants = AppConstants.getInstance(classLoader);
    super.configure();
}
Also used : ParameterList(nl.nn.adapterframework.parameters.ParameterList) Parameter(nl.nn.adapterframework.parameters.Parameter)

Example 13 with ParameterList

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

the class HashPipe method doPipe.

public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
    String message = (String) input;
    String authAlias = getAuthAlias();
    String secret = getSecret();
    try {
        ParameterList parameterList = getParameterList();
        ParameterResolutionContext prc = new ParameterResolutionContext(message, session);
        ParameterValueList pvl = prc.getValues(parameterList);
        if (pvl != null) {
            Parameter authAliasParam = parameterList.findParameter("authAlias");
            if (authAliasParam != null)
                authAlias = (String) authAliasParam.getValue(pvl, prc);
            Parameter secretParam = parameterList.findParameter("secret");
            if (secretParam != null)
                secret = (String) secretParam.getValue(pvl, prc);
        }
    } catch (Exception e) {
        throw new PipeRunException(this, getLogPrefix(session) + "exception extracting authAlias", e);
    }
    CredentialFactory accessTokenCf = new CredentialFactory(authAlias, "", secret);
    String cfSecret = accessTokenCf.getPassword();
    if (cfSecret == null || cfSecret.isEmpty())
        throw new PipeRunException(this, getLogPrefix(session) + "empty secret, unable to hash");
    try {
        Mac mac = Mac.getInstance(getAlgorithm());
        SecretKeySpec secretkey = new SecretKeySpec(cfSecret.getBytes(getEncoding()), "algorithm");
        mac.init(secretkey);
        String hash = Base64.encodeBase64String(mac.doFinal(message.getBytes()));
        return new PipeRunResult(getForward(), hash);
    } catch (Exception e) {
        throw new PipeRunException(this, getLogPrefix(session) + "error creating hash", e);
    }
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) ParameterValueList(nl.nn.adapterframework.parameters.ParameterValueList) CredentialFactory(nl.nn.adapterframework.util.CredentialFactory) SecretKeySpec(javax.crypto.spec.SecretKeySpec) PipeRunException(nl.nn.adapterframework.core.PipeRunException) ParameterList(nl.nn.adapterframework.parameters.ParameterList) Parameter(nl.nn.adapterframework.parameters.Parameter) ParameterResolutionContext(nl.nn.adapterframework.parameters.ParameterResolutionContext) PipeRunException(nl.nn.adapterframework.core.PipeRunException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) Mac(javax.crypto.Mac)

Example 14 with ParameterList

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

the class EsbSoapWrapperPipe method stripDestination.

private void stripDestination() throws ConfigurationException {
    ParameterList parameterList = getParameterList();
    Parameter pd = parameterList.findParameter(DESTINATION);
    Parameter ppd = parameterList.findParameter(PHYSICALDESTINATION);
    String destination = null;
    if (isRetrievePhysicalDestination()) {
        if (ppd != null) {
            destination = ppd.getValue();
        } else if (pd != null) {
            destination = pd.getValue();
        }
    } else {
        if (pd != null) {
            destination = pd.getValue();
        }
    }
    Parameter p;
    if (StringUtils.isNotEmpty(destination)) {
        if (destination.startsWith("ESB.") || destination.startsWith("P2P.") || (StringUtils.isNotEmpty(esbAlias) && destination.startsWith(esbAlias + ".")) || (StringUtils.isNotEmpty(p2pAlias) && destination.startsWith(p2pAlias + "."))) {
            // In case the messaging layer is ESB, the destination syntax is:
            // Destination = [MessagingLayer].[BusinessDomain].[ServiceLayer].[ServiceName].[ServiceContext].[ServiceContextVersion].[OperationName].[OperationVersion].[Paradigm]
            // In case the messaging layer is P2P, the destination syntax is:
            // Destination = [MessagingLayer].[BusinessDomain].[ApplicationName].[ApplicationFunction].[Paradigm]
            boolean p2p = false;
            boolean esbDestinationWithoutServiceContext = false;
            StringTokenizer st = new StringTokenizer(destination, ".");
            int count = 0;
            while (st.hasMoreTokens()) {
                count++;
                String str = st.nextToken();
                p = new Parameter();
                switch(count) {
                    case 1:
                        if (str.equals("P2P") || (StringUtils.isNotEmpty(p2pAlias) && str.equalsIgnoreCase(p2pAlias))) {
                            p2p = true;
                        } else {
                            esbDestinationWithoutServiceContext = isEsbDestinationWithoutServiceContext(destination);
                        }
                        p.setName(MESSAGINGLAYER);
                        break;
                    case 2:
                        p.setName(BUSINESSDOMAIN);
                        break;
                    case 3:
                        if (p2p) {
                            p.setName(APPLICATIONNAME);
                        } else {
                            p.setName(SERVICELAYER);
                        }
                        break;
                    case 4:
                        if (p2p) {
                            p.setName(APPLICATIONFUNCTION);
                        } else {
                            p.setName(SERVICENAME);
                        }
                        break;
                    case 5:
                        if (p2p) {
                            p.setName(PARADIGM);
                        } else {
                            if (esbDestinationWithoutServiceContext) {
                                p.setName(SERVICECONTEXTVERSION);
                            } else {
                                p.setName(SERVICECONTEXT);
                            }
                        }
                        break;
                    case 6:
                        if (esbDestinationWithoutServiceContext) {
                            p.setName(OPERATIONNAME);
                        } else {
                            p.setName(SERVICECONTEXTVERSION);
                        }
                        break;
                    case 7:
                        if (esbDestinationWithoutServiceContext) {
                            p.setName(OPERATIONVERSION);
                        } else {
                            p.setName(OPERATIONNAME);
                        }
                        break;
                    case 8:
                        if (esbDestinationWithoutServiceContext) {
                            p.setName(PARADIGM);
                        } else {
                            p.setName(OPERATIONVERSION);
                        }
                        break;
                    case 9:
                        if (esbDestinationWithoutServiceContext) {
                        // not possible
                        } else {
                            p.setName(PARADIGM);
                        }
                        break;
                    default:
                }
                p.setValue(str);
                addParameter(p);
            }
        } else {
            p = new Parameter();
            p.setName(MESSAGINGLAYER);
            p.setValue("P2P");
            addParameter(p);
            // 
            p = new Parameter();
            p.setName(BUSINESSDOMAIN);
            p.setValue("?");
            addParameter(p);
            // 
            p = new Parameter();
            p.setName(APPLICATIONNAME);
            p.setValue("?");
            addParameter(p);
            // 
            p = new Parameter();
            p.setName(APPLICATIONFUNCTION);
            p.setValue(destination.replaceAll("\\W", "_"));
            addParameter(p);
            // 
            p = new Parameter();
            p.setName(PARADIGM);
            p.setValue("?");
            addParameter(p);
        }
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) ParameterList(nl.nn.adapterframework.parameters.ParameterList) Parameter(nl.nn.adapterframework.parameters.Parameter)

Example 15 with ParameterList

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

the class EsbSoapWrapperPipe method addParameters.

private void addParameters() {
    ParameterList parameterList = getParameterList();
    Parameter p;
    String paradigm = null;
    p = parameterList.findParameter(PARADIGM);
    if (p != null) {
        paradigm = p.getValue();
    }
    if (parameterList.findParameter(FROMID) == null) {
        p = new Parameter();
        p.setName(FROMID);
        p.setValue(AppConstants.getInstance().getProperty("instance.name", ""));
        addParameter(p);
    }
    if (mode != Mode.BIS) {
        if (parameterList.findParameter(CPAID) == null) {
            p = new Parameter();
            p.setName(CPAID);
            p.setSessionKey(getSoapHeaderSessionKey());
            p.setXpathExpression("MessageHeader/HeaderFields/CPAId");
            p.setRemoveNamespaces(true);
            p.setDefaultValue("n/a");
            addParameter(p);
        }
    }
    if (parameterList.findParameter(CONVERSATIONID) == null) {
        p = new Parameter();
        p.setName(CONVERSATIONID);
        p.setSessionKey(getSoapHeaderSessionKey());
        p.setXpathExpression("MessageHeader/HeaderFields/ConversationId");
        p.setRemoveNamespaces(true);
        if (isUseFixedValues()) {
            p.setPattern("{fixedhostname}_{fixeduid}");
        } else {
            p.setPattern("{hostname}_{uid}");
        }
        p.setDefaultValueMethods("pattern");
        addParameter(p);
    }
    if (parameterList.findParameter(MESSAGEID) == null) {
        p = new Parameter();
        p.setName(MESSAGEID);
        if (isUseFixedValues()) {
            p.setPattern("{fixedhostname}_{fixeduid}");
        } else {
            p.setPattern("{hostname}_{uid}");
        }
        addParameter(p);
    }
    if (parameterList.findParameter(EXTERNALREFTOMESSAGEID) == null) {
        p = new Parameter();
        p.setName(EXTERNALREFTOMESSAGEID);
        p.setSessionKey(getSoapHeaderSessionKey());
        if (mode == Mode.BIS) {
            p.setXpathExpression("MessageHeader/HeaderFields/MessageId");
        } else {
            p.setXpathExpression("MessageHeader/HeaderFields/ExternalRefToMessageId");
        }
        p.setRemoveNamespaces(true);
        addParameter(p);
    }
    if (mode != Mode.BIS) {
        if (parameterList.findParameter(CORRELATIONID) == null) {
            if (paradigm != null && paradigm.equals("Response")) {
                p = new Parameter();
                p.setName(CORRELATIONID);
                p.setSessionKey(getSoapHeaderSessionKey());
                p.setXpathExpression("MessageHeader/HeaderFields/MessageId");
                p.setRemoveNamespaces(true);
                addParameter(p);
            }
        }
    }
    if (parameterList.findParameter(TIMESTAMP) == null) {
        p = new Parameter();
        p.setName(TIMESTAMP);
        if (isUseFixedValues()) {
            p.setPattern("{fixeddate,date,yyyy-MM-dd'T'HH:mm:ss}");
        } else {
            p.setPattern("{now,date,yyyy-MM-dd'T'HH:mm:ss}");
        }
        addParameter(p);
    }
    if (parameterList.findParameter(FIXRESULTNAMESPACE) == null) {
        p = new Parameter();
        p.setName(FIXRESULTNAMESPACE);
        p.setValue(String.valueOf(isFixResultNamespace()));
        addParameter(p);
    }
    if (parameterList.findParameter(TRANSACTIONID) == null) {
        p = new Parameter();
        p.setName(TRANSACTIONID);
        p.setSessionKey(getSoapHeaderSessionKey());
        p.setXpathExpression("MessageHeader/HeaderFields/TransactionId");
        p.setRemoveNamespaces(true);
        addParameter(p);
    }
    p = new Parameter();
    p.setName(MODE);
    p.setValue(getMode());
    addParameter(p);
    p = new Parameter();
    p.setName(CMHVERSION);
    p.setValue(String.valueOf(getCmhVersion()));
    addParameter(p);
}
Also used : ParameterList(nl.nn.adapterframework.parameters.ParameterList) Parameter(nl.nn.adapterframework.parameters.Parameter)

Aggregations

ParameterList (nl.nn.adapterframework.parameters.ParameterList)24 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)14 Parameter (nl.nn.adapterframework.parameters.Parameter)13 ParameterResolutionContext (nl.nn.adapterframework.parameters.ParameterResolutionContext)10 PipeRunException (nl.nn.adapterframework.core.PipeRunException)8 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)8 ParameterException (nl.nn.adapterframework.core.ParameterException)7 IOException (java.io.IOException)6 PipeForward (nl.nn.adapterframework.core.PipeForward)6 Map (java.util.Map)4 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)3 ParameterValueList (nl.nn.adapterframework.parameters.ParameterValueList)3 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 SenderException (nl.nn.adapterframework.core.SenderException)2 TimeOutException (nl.nn.adapterframework.core.TimeOutException)2 File (java.io.File)1 OutputStream (java.io.OutputStream)1