Search in sources :

Example 36 with ConfigurationException

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

the class BisWrapperPipe method configure.

public void configure() throws ConfigurationException {
    ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
    String msg = getLogPrefix(null) + "The class [" + getClass().getName() + "] has been deprecated. Please change to EsbSoapWrapperPipe (not 1:1)";
    configWarnings.add(log, msg);
    super.configure();
    if (StringUtils.isNotEmpty(getSoapHeaderSessionKey())) {
        throw new ConfigurationException(getLogPrefix(null) + "soapHeaderSessionKey is not allowed");
    }
    if (StringUtils.isEmpty(getBisMessageHeaderSessionKey())) {
        throw new ConfigurationException(getLogPrefix(null) + "messageHeaderSessionKey must be set");
    }
    if (isAddOutputNamespace() && StringUtils.isEmpty(outputNamespace)) {
        throw new ConfigurationException(getLogPrefix(null) + "outputNamespace must be set when addOutputnamespace=true");
    }
    try {
        if (StringUtils.isNotEmpty(getInputXPath())) {
            String bodyMessageNd = StringUtils.isNotEmpty(getInputNamespaceDefs()) ? soapNamespaceDefs + "\n" + getInputNamespaceDefs() : soapNamespaceDefs;
            String bodyMessageXe = StringUtils.isNotEmpty(getInputXPath()) ? soapBodyXPath + "/" + getInputXPath() : soapBodyXPath + "/*";
            bodyMessageTp = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(bodyMessageNd, bodyMessageXe, "xml"));
        }
        String bisMessageHeaderNd = soapNamespaceDefs + "\n" + bisNamespaceDefs;
        String bisMessageHeaderXe;
        if (isBisMessageHeaderInSoapBody()) {
            bisMessageHeaderXe = soapBodyXPath + "/" + bisMessageHeaderXPath;
        } else {
            bisMessageHeaderXe = soapHeaderXPath + "/" + bisMessageHeaderXPath;
        }
        bisMessageHeaderTp = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(bisMessageHeaderNd, bisMessageHeaderXe, "xml"));
        bisMessageHeaderConversationIdTp = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(bisNamespaceDefs, bisMessageHeaderConversationIdXPath, "text"));
        bisMessageHeaderExternalRefToMessageIdTp = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(bisNamespaceDefs, bisMessageHeaderExternalRefToMessageIdXPath, "text"));
        String bisErrorNd = soapNamespaceDefs + "\n" + bisNamespaceDefs;
        if (isBisResultInPayload()) {
            bisErrorXe = soapBodyXPath + "/*/" + bisErrorXPath;
        } else {
            bisErrorXe = soapBodyXPath + "/" + bisErrorXPath;
        }
        bisErrorXe = bisErrorXe + " or string-length(" + soapBodyXPath + "/" + soapErrorXPath + ")>0";
        bisErrorTp = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(bisErrorNd, bisErrorXe, "text"));
        if (isRemoveOutputNamespaces()) {
            String removeOutputNamespaces_xslt = XmlUtils.makeRemoveNamespacesXslt(true, false);
            removeOutputNamespacesTp = TransformerPool.getInstance(removeOutputNamespaces_xslt);
        }
        if (isAddOutputNamespace()) {
            String addOutputNamespace_xslt = XmlUtils.makeAddRootNamespaceXslt(getOutputNamespace(), true, false);
            addOutputNamespaceTp = TransformerPool.getInstance(addOutputNamespace_xslt);
        }
    } catch (TransformerConfigurationException e) {
        throw new ConfigurationException(getLogPrefix(null) + "cannot create transformer", e);
    }
}
Also used : ConfigurationWarnings(nl.nn.adapterframework.configuration.ConfigurationWarnings) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException)

Example 37 with ConfigurationException

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

the class EsbJmsListener method configure.

public void configure() throws ConfigurationException {
    if (getMessageProtocol() == null) {
        throw new ConfigurationException(getLogPrefix() + "messageProtocol must be set");
    }
    if (!getMessageProtocol().equalsIgnoreCase(REQUEST_REPLY) && !getMessageProtocol().equalsIgnoreCase(FIRE_AND_FORGET)) {
        throw new ConfigurationException(getLogPrefix() + "illegal value for messageProtocol [" + getMessageProtocol() + "], must be '" + REQUEST_REPLY + "' or '" + FIRE_AND_FORGET + "'");
    }
    if (getMessageProtocol().equalsIgnoreCase(REQUEST_REPLY)) {
        setForceMessageIdAsCorrelationId(true);
        if (CACHE_CONSUMER.equals(getCacheMode())) {
            boolean recovered = false;
            ReceiverBase receiverBase = getReceiverBase();
            if (receiverBase != null) {
                recovered = (receiverBase.isRecover() || receiverBase.isRecoverAdapter());
            }
            if (!recovered) {
                ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
                configWarnings.add(log, "attribute [cacheMode] already has a default value [" + CACHE_CONSUMER + "]");
            }
        }
        setCacheMode("CACHE_CONSUMER");
    } else {
        setUseReplyTo(false);
    }
    super.configure();
}
Also used : ReceiverBase(nl.nn.adapterframework.receivers.ReceiverBase) ConfigurationWarnings(nl.nn.adapterframework.configuration.ConfigurationWarnings) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException)

Example 38 with ConfigurationException

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

the class EsbSoapWrapperPipe method configure.

@Override
public void configure() throws ConfigurationException {
    if (mode == Mode.REG) {
        if (cmhVersion == 0) {
            cmhVersion = 1;
        } else if (cmhVersion < 0 || cmhVersion > 2) {
            ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
            String msg = getLogPrefix(null) + "cmhVersion [" + cmhVersion + "] for mode [" + mode.toString() + "] should be set to '1' or '2', assuming '1'";
            configWarnings.add(log, msg);
            cmhVersion = 1;
        }
    } else {
        if (cmhVersion != 0) {
            ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
            String msg = getLogPrefix(null) + "cmhVersion [" + cmhVersion + "] for mode [" + mode.toString() + "] should not be set, assuming '0'";
            configWarnings.add(log, msg);
            cmhVersion = 0;
        }
    }
    if ("wrap".equalsIgnoreCase(getDirection())) {
        if (StringUtils.isEmpty(getSoapHeaderSessionKey())) {
            setSoapHeaderSessionKey(DEFAULT_SOAP_HEADER_SESSION_KEY);
        }
        if (StringUtils.isEmpty(getSoapHeaderStyleSheet())) {
            if (mode == Mode.BIS) {
                setSoapHeaderStyleSheet("/xml/xsl/esb/bisSoapHeader.xsl");
            } else {
                setSoapHeaderStyleSheet("/xml/xsl/esb/soapHeader.xsl");
            }
        }
        if (StringUtils.isEmpty(getSoapBodyStyleSheet())) {
            if (mode == Mode.REG) {
                setSoapBodyStyleSheet("/xml/xsl/esb/soapBody.xsl");
            } else if (mode == Mode.BIS) {
                setSoapBodyStyleSheet("/xml/xsl/esb/bisSoapBody.xsl");
            }
        }
        stripDestination();
        if (isAddOutputNamespace()) {
            String ons = getOutputNamespaceBaseUri();
            if (getMessagingLayer().equals("P2P") || (StringUtils.isNotEmpty(p2pAlias) && getMessagingLayer().equalsIgnoreCase(p2pAlias))) {
                ons = ons + "/" + getBusinessDomain() + "/" + getApplicationName() + "/" + getApplicationFunction();
            } else {
                ons = ons + "/" + getBusinessDomain() + "/" + getServiceName() + (StringUtils.isEmpty(getServiceContext()) ? "" : "/" + getServiceContext()) + "/" + getServiceContextVersion() + "/" + getOperationName() + "/" + getOperationVersion();
            }
            setOutputNamespace(ons);
        }
        addParameters();
    }
    super.configure();
    if (isUseFixedValues()) {
        if (!ConfigurationUtils.stubConfiguration()) {
            throw new ConfigurationException(getLogPrefix(null) + "returnFixedDate only allowed in stub mode");
        }
    }
}
Also used : ConfigurationWarnings(nl.nn.adapterframework.configuration.ConfigurationWarnings) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException)

Example 39 with ConfigurationException

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

the class IbisWebServiceSender method configure.

public void configure() throws ConfigurationException {
    if (ibisInstance == null) {
        ibisInstance = AppConstants.getInstance().getResolvedProperty("instance.name");
    }
    try {
        proxy = new ServiceDispatcher_ServiceProxy();
        proxy.setEndPoint(new URL(getEndPoint()));
    } catch (MalformedURLException e) {
        throw new ConfigurationException("IbisWebServiceSender cannot find URL from [" + getEndPoint() + "]", e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) ServiceDispatcher_ServiceProxy(nl.nn.adapterframework.receivers.ServiceDispatcher_ServiceProxy) URL(java.net.URL)

Example 40 with ConfigurationException

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

the class JavaxValidationContext method getSchemaObject.

// protected String validate(Source source, IPipeLineSession session) throws XmlValidatorException, ConfigurationException, PipeRunException {
// init();
// String schemasId = schemasProvider.getSchemasId();
// if (schemasId == null) {
// schemasId = schemasProvider.getSchemasId(session);
// getSchemaObject(schemasId, schemasProvider.getSchemas(session));
// }
// Schema xsd = javaxSchemas.get(schemasId);
// try {
// Validator validator = xsd.newValidator();
// validator.setResourceResolver(new LSResourceResolver() {
// public LSInput resolveResource(String s, String s1, String s2, String s3, String s4) {
// System.out.println("--");
// return null;//To change body of implemented methods Settings | File Templates.
// }
// });
// validator.setErrorHandler(new ErrorHandler() {
// public void warning(SAXParseException e) throws SAXException {
// log.warn(e.getMessage());
// }
// 
// public void error(SAXParseException e) throws SAXException {
// log.error(e.getMessage());
// }
// 
// public void fatalError(SAXParseException e) throws SAXException {
// log.error(e.getMessage());
// }
// });
// //validator.setFeature("http://xml.org/sax/features/namespace-prefixes", true); /// DOESNT" WORK any more?
// validator.validate(source);
// } catch (SAXException e) {
// throw new XmlValidatorException(e.getClass() + " " + e.getMessage());
// } catch (IOException e) {
// throw new XmlValidatorException(e.getMessage(), e);
// }
// return XML_VALIDATOR_VALID_MONITOR_EVENT;
// }
/**
 * Returns the {@link Schema} associated with this validator. This ia an XSD schema containing knowledge about the
 * schema source as returned by {@link #getSchemaSources(List)}
 * @throws ConfigurationException
 */
protected synchronized Schema getSchemaObject(String schemasId, List<nl.nn.adapterframework.validation.Schema> schemas) throws ConfigurationException {
    Schema schema = javaxSchemas.get(schemasId);
    if (schema == null) {
        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        factory.setResourceResolver(new LSResourceResolver() {

            public LSInput resolveResource(String s, String s1, String s2, String s3, String s4) {
                return null;
            }
        });
        try {
            Collection<Source> sources = getSchemaSources(schemas);
            schema = factory.newSchema(sources.toArray(new Source[sources.size()]));
            javaxSchemas.put(schemasId, schema);
        } catch (Exception e) {
            throw new ConfigurationException("cannot read schema's [" + schemasId + "]", e);
        }
    }
    return schema;
}
Also used : SchemaFactory(javax.xml.validation.SchemaFactory) LSResourceResolver(org.w3c.dom.ls.LSResourceResolver) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Schema(javax.xml.validation.Schema) LSInput(org.w3c.dom.ls.LSInput) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) PipeRunException(nl.nn.adapterframework.core.PipeRunException) XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Aggregations

ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)113 IOException (java.io.IOException)26 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)20 PipeRunException (nl.nn.adapterframework.core.PipeRunException)17 ConfigurationWarnings (nl.nn.adapterframework.configuration.ConfigurationWarnings)16 URL (java.net.URL)13 ArrayList (java.util.ArrayList)12 Parameter (nl.nn.adapterframework.parameters.Parameter)12 ParameterList (nl.nn.adapterframework.parameters.ParameterList)11 File (java.io.File)7 Iterator (java.util.Iterator)6 ListenerException (nl.nn.adapterframework.core.ListenerException)6 PipeForward (nl.nn.adapterframework.core.PipeForward)6 PipeLineSessionBase (nl.nn.adapterframework.core.PipeLineSessionBase)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 StringTokenizer (java.util.StringTokenizer)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 FileNotFoundException (java.io.FileNotFoundException)4 LinkedList (java.util.LinkedList)4