Search in sources :

Example 91 with ConfigurationException

use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.

the class FixedForwardPipe method configure.

/**
 * checks for correct configuration of forward
 */
@Override
public void configure() throws ConfigurationException {
    super.configure();
    successForward = findForward(PipeForward.SUCCESS_FORWARD_NAME);
    if (successForward == null)
        throw new ConfigurationException("has no forward with name [" + PipeForward.SUCCESS_FORWARD_NAME + "]");
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException)

Example 92 with ConfigurationException

use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.

the class EtagHandlerPipe method configure.

@Override
public void configure() throws ConfigurationException {
    super.configure();
    EtagAction action = getAction();
    if (action == null) {
        throw new ConfigurationException("action must be set");
    }
    boolean hasUriPatternParameter = false;
    ParameterList parameterList = getParameterList();
    for (int i = 0; i < parameterList.size(); i++) {
        Parameter parameter = parameterList.getParameter(i);
        if ("uriPattern".equalsIgnoreCase(parameter.getName()))
            hasUriPatternParameter = true;
    }
    if (getUriPattern() == null && !hasUriPatternParameter) {
        throw new ConfigurationException("no uriPattern found!");
    }
    cache = ApiCacheManager.getInstance();
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) ParameterList(nl.nn.adapterframework.parameters.ParameterList) Parameter(nl.nn.adapterframework.parameters.Parameter)

Example 93 with ConfigurationException

use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.

the class AbstractPipe method configure.

/**
 * <code>configure()</code> is called after the {@link PipeLine Pipeline} is registered
 * at the {@link Adapter Adapter}. Purpose of this method is to reduce
 * creating connections to databases etc. in the {@link #doPipe(Message, PipeLineSession) doPipe()} method.
 * As much as possible class-instantiating should take place in the
 * <code>configure()</code> method, to improve performance.
 */
// For testing purposes the configure method should not require the PipeLine to be present.
@Override
public void configure() throws ConfigurationException {
    ParameterList params = getParameterList();
    if (params != null) {
        try {
            params.configure();
        } catch (ConfigurationException e) {
            throw new ConfigurationException(getLogPrefix(null) + "while configuring parameters", e);
        }
    }
    if (!StringUtils.isEmpty(getElementToMove()) && !StringUtils.isEmpty(getElementToMoveChain())) {
        throw new ConfigurationException("cannot have both an elementToMove and an elementToMoveChain specified");
    }
    if (pipeForwards.isEmpty()) {
        // In the case of a NON-FixedForwardPipe (default success/exception forwards) || no global forwards
        ConfigurationWarnings.add(this, log, "has no pipe forwards defined");
    }
    if (getLocker() != null) {
        getLocker().configure();
    }
    super.configure();
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) ParameterList(nl.nn.adapterframework.parameters.ParameterList)

Example 94 with ConfigurationException

use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.

the class ParameterList method getValues.

/**
 * Returns a List of <link>ParameterValue<link> objects
 */
public ParameterValueList getValues(Message message, PipeLineSession session, boolean namespaceAware) throws ParameterException {
    if (inputValueRequiredForResolution && message != null) {
        try {
            message.preserve();
        } catch (IOException e) {
            throw new ParameterException("Cannot preserve message for parameter resolution", e);
        }
    }
    ParameterValueList result = new ParameterValueList();
    for (Parameter parm : this) {
        String parmSessionKey = parm.getSessionKey();
        // each session variable whose name starts with the name of the original parameter
        if ("*".equals(parmSessionKey)) {
            String parmName = parm.getName();
            for (String sessionKey : session.keySet()) {
                if (!PipeLineSession.TS_RECEIVED_KEY.equals(sessionKey) && !PipeLineSession.TS_SENT_KEY.equals(sessionKey)) {
                    if ((sessionKey.startsWith(parmName) || "*".equals(parmName))) {
                        Parameter newParm = new Parameter();
                        newParm.setName(sessionKey);
                        // TODO: Should also set the parameter.type, based on the type of the session key.
                        newParm.setSessionKey(sessionKey);
                        try {
                            newParm.configure();
                        } catch (ConfigurationException e) {
                            throw new ParameterException(e);
                        }
                        result.add(getValue(result, newParm, message, session, namespaceAware));
                    }
                }
            }
        } else {
            result.add(getValue(result, parm, message, session, namespaceAware));
        }
    }
    return result;
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) ParameterException(nl.nn.adapterframework.core.ParameterException) IOException(java.io.IOException)

Example 95 with ConfigurationException

use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.

the class SchemaLocation method getXsds.

@Override
public Set<XSD> getXsds() throws ConfigurationException {
    Set<XSD> xsds = new HashSet<XSD>();
    SoapVersion soapVersion = getSoapVersion();
    if (soapVersion == null || soapVersion == SoapVersion.SOAP11 || soapVersion == SoapVersion.AUTO) {
        XSD xsd = new XSD();
        xsd.initNamespace(SoapVersion.SOAP11.namespace, this, SoapVersion.SOAP11.location);
        xsds.add(xsd);
    }
    if (soapVersion == SoapVersion.SOAP12 || soapVersion == SoapVersion.AUTO) {
        XSD xsd = new XSD();
        xsd.initNamespace(SoapVersion.SOAP12.namespace, this, SoapVersion.SOAP12.location);
        xsds.add(xsd);
    }
    if (StringUtils.isNotEmpty(getSchemaLocationToAdd())) {
        StringTokenizer st = new StringTokenizer(getSchemaLocationToAdd(), ", \t\r\n\f");
        while (st.hasMoreTokens()) {
            XSD xsd = new XSD();
            xsd.initNamespace(st.nextToken(), this, st.hasMoreTokens() ? st.nextToken() : null);
            xsds.add(xsd);
        }
    }
    List<Schema> schemas = new ArrayList<Schema>();
    List<ExtensibilityElement> types = definition.getTypes().getExtensibilityElements();
    for (Iterator<ExtensibilityElement> i = types.iterator(); i.hasNext(); ) {
        ExtensibilityElement type = i.next();
        QName qn = type.getElementType();
        if (SchemaUtils.WSDL_SCHEMA.equals(qn)) {
            final Schema schema = (Schema) type;
            addNamespaces(schema, definition.getNamespaces());
            schemas.add(schema);
        }
    }
    List<Schema> filteredSchemas;
    Map<Schema, String> filteredReferences = null;
    Map<Schema, String> filteredNamespaces = null;
    if (StringUtils.isEmpty(getSchemaLocation())) {
        filteredSchemas = schemas;
    } else {
        filteredSchemas = new ArrayList<Schema>();
        filteredReferences = new HashMap<Schema, String>();
        filteredNamespaces = new HashMap<Schema, String>();
        String[] split = getSchemaLocation().trim().split("\\s+");
        if (split.length % 2 != 0)
            throw new ConfigurationException("The schema must exist from an even number of strings, but it is [" + getSchemaLocation() + "]");
        for (int i = 0; i < split.length; i += 2) {
            if (!split[i + 1].startsWith(RESOURCE_INTERNAL_REFERENCE_PREFIX)) {
                throw new ConfigurationException("Schema reference " + split[i + 1] + " should start with '" + RESOURCE_INTERNAL_REFERENCE_PREFIX + "'");
            }
            try {
                int j = Integer.parseInt(split[i + 1].substring(RESOURCE_INTERNAL_REFERENCE_PREFIX.length())) - 1;
                filteredSchemas.add(schemas.get(j));
                filteredReferences.put(schemas.get(j), RESOURCE_INTERNAL_REFERENCE_PREFIX + (j + 1));
                filteredNamespaces.put(schemas.get(j), split[i]);
            } catch (Exception e) {
                throw new ConfigurationException("Schema reference " + split[i + 1] + " not valid or not found");
            }
        }
    }
    for (Schema schema : filteredSchemas) {
        XSD xsd = new XSD();
        xsd.setWsdlSchema(definition, schema);
        if (StringUtils.isNotEmpty(getSchemaLocation())) {
            xsd.setResourceInternalReference(filteredReferences.get(schema));
        // xsd.setNamespace(filteredNamespaces.get(schema));
        } else {
            xsd.setResourceInternalReference(RESOURCE_INTERNAL_REFERENCE_PREFIX + (filteredSchemas.indexOf(schema) + 1));
        }
        xsd.setAddNamespaceToSchema(isAddNamespaceToSchema());
        xsd.setImportedSchemaLocationsToIgnore(getImportedSchemaLocationsToIgnore());
        xsd.setUseBaseImportedSchemaLocationsToIgnore(isUseBaseImportedSchemaLocationsToIgnore());
        xsd.setImportedNamespacesToIgnore(getImportedNamespacesToIgnore());
        xsd.initNamespace(StringUtils.isNotEmpty(getSchemaLocation()) ? filteredNamespaces.get(schema) : null, this, getWsdl());
        xsds.add(xsd);
    }
    return xsds;
}
Also used : QName(javax.xml.namespace.QName) Schema(javax.wsdl.extensions.schema.Schema) XSD(nl.nn.adapterframework.validation.XSD) ArrayList(java.util.ArrayList) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) WSDLException(javax.wsdl.WSDLException) SoapVersion(nl.nn.adapterframework.soap.SoapVersion) StringTokenizer(java.util.StringTokenizer) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) HashSet(java.util.HashSet)

Aggregations

ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)187 IOException (java.io.IOException)52 PipeRunException (nl.nn.adapterframework.core.PipeRunException)25 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)24 Parameter (nl.nn.adapterframework.parameters.Parameter)20 ArrayList (java.util.ArrayList)19 URL (java.net.URL)17 ParameterList (nl.nn.adapterframework.parameters.ParameterList)16 SAXException (org.xml.sax.SAXException)14 TransformerException (javax.xml.transform.TransformerException)12 Test (org.junit.Test)12 CredentialFactory (nl.nn.adapterframework.util.CredentialFactory)11 HashMap (java.util.HashMap)10 File (java.io.File)9 StringTokenizer (java.util.StringTokenizer)8 Connection (java.sql.Connection)7 Map (java.util.Map)7 ListenerException (nl.nn.adapterframework.core.ListenerException)7 ParameterException (nl.nn.adapterframework.core.ParameterException)7 JdbcException (nl.nn.adapterframework.jdbc.JdbcException)7