Search in sources :

Example 6 with ConfigurationWarnings

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

the class ClassLoaderWSDLLocator method configure.

@Override
public void configure() throws ConfigurationException {
    addSoapEnvelopeToSchemaLocation = false;
    if (ConfigurationUtils.stubConfiguration()) {
        // warnings in IJA_API in DTAP
        if (StringUtils.isNotEmpty(getSchemaLocation()) && !isAddNamespaceToSchema()) {
            ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
            String msg = getLogPrefix(null) + "attribute [schemaLocation] for wsdl [" + getWsdl() + "] should only be set when addNamespaceToSchema=true";
            configWarnings.add(log, msg);
        }
    }
    if (StringUtils.isNotEmpty(getSoapBodyNamespace()) && StringUtils.isNotEmpty(getSchemaLocation())) {
        ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
        String msg = getLogPrefix(null) + "attribute [schemaLocation] for wsdl [" + getWsdl() + "] should only be set when attribute [soapBodyNamespace] is not set";
        configWarnings.add(log, msg);
    }
    if (StringUtils.isNotEmpty(getSoapBodyNamespace()) && !isAddNamespaceToSchema()) {
        ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
        String msg = getLogPrefix(null) + "attribute [soapBodyNamespace] for wsdl [" + getWsdl() + "] should only be set when addNamespaceToSchema=true";
        configWarnings.add(log, msg);
    }
    String wsdlSchemaLocation = null;
    StringBuilder sb = new StringBuilder();
    int counter = 0;
    boolean soapBodyFound = false;
    for (Object o : definition.getTypes().getExtensibilityElements()) {
        if (o instanceof Schema) {
            Schema schema = (Schema) o;
            String tns = schema.getElement().getAttribute("targetNamespace");
            if (StringUtils.isNotEmpty(getSoapBodyNamespace())) {
                NodeList childNodes = schema.getElement().getChildNodes();
                for (int i = 0; i < childNodes.getLength(); i++) {
                    Node n = childNodes.item(i);
                    if (n.getNodeType() == Node.ELEMENT_NODE && n.getLocalName().equals("element")) {
                        String name = n.getAttributes().getNamedItem("name").getNodeValue();
                        if (getSoapBody().equals(name)) {
                            if (soapBodyFound) {
                                throw new ConfigurationException(getLogPrefix(null) + "soapBody [" + getSoapBody() + "] exists multiple times, not possible to create schemaLocation from soapBodyNamespace");
                            }
                            tns = getSoapBodyNamespace();
                            soapBodyFound = true;
                        }
                    }
                }
            }
            if (sb.length() > 0) {
                sb.append(" ");
            }
            sb.append(tns);
            sb.append(" ");
            sb.append("schema" + ++counter);
        }
        if (sb.length() > 0) {
            wsdlSchemaLocation = sb.toString();
        }
        if (wsdlSchemaLocation != null) {
            if (ConfigurationUtils.stubConfiguration()) {
                // of warnings in IJA_API in DTAP
                if (StringUtils.isNotEmpty(getSchemaLocation()) && isAddNamespaceToSchema()) {
                    if (getSchemaLocation().replaceAll("\\s", " ").equals(wsdlSchemaLocation)) {
                        ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
                        String msg = getLogPrefix(null) + "attribute [schemaLocation] for wsdl [" + getWsdl() + "] already has a default value [" + wsdlSchemaLocation + "]";
                        configWarnings.add(log, msg);
                    }
                }
            }
            if (StringUtils.isNotEmpty(getSoapBodyNamespace())) {
                setSchemaLocation(wsdlSchemaLocation);
            }
        }
    }
    super.configure();
}
Also used : ConfigurationWarnings(nl.nn.adapterframework.configuration.ConfigurationWarnings) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) Schema(nl.nn.javax.wsdl.extensions.schema.Schema) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node)

Example 7 with ConfigurationWarnings

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

the class XmlValidator method configure.

/**
 * Configure the XmlValidator
 * @throws ConfigurationException when:
 * <ul><li>the schema cannot be found</li>
 * <ul><li><{@link #isThrowException()} is false and there is no forward defined
 * for "failure"</li>
 * <li>when the parser does not accept setting the properties for validating</li>
 * </ul>
 */
@Override
public void configure() throws ConfigurationException {
    try {
        super.configure();
        if ((StringUtils.isNotEmpty(getNoNamespaceSchemaLocation()) || StringUtils.isNotEmpty(getSchemaLocation())) && StringUtils.isNotEmpty(getSchemaSessionKey())) {
            throw new ConfigurationException(getLogPrefix(null) + "cannot have schemaSessionKey together with schemaLocation or noNamespaceSchemaLocation");
        }
        checkSchemaSpecified();
        if (StringUtils.isNotEmpty(getSoapNamespace())) {
            // Don't use this warning yet as it is used for the IFSA to Tibco
            // migration where an adapter with Tibco listener (with SOAP
            // Envelope and an adapter with IFSA listener (without SOAP Envelop)
            // call an adapter with XmlValidator which should validate both.
            // ConfigurationWarnings.getInstance().add(log, "Using XmlValidator with soapNamespace for Soap validation is deprecated. Please use " + SoapValidator.class.getName());
            String extractNamespaceDefs = "soapenv=" + getSoapNamespace();
            String extractBodyXPath = "/soapenv:Envelope/soapenv:Body/*";
            try {
                transformerPoolExtractSoapBody = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(extractNamespaceDefs, extractBodyXPath, "xml"));
            } catch (TransformerConfigurationException te) {
                throw new ConfigurationException(getLogPrefix(null) + "got error creating transformer from getSoapBody", te);
            }
            String getRootNamespace_xslt = XmlUtils.makeGetRootNamespaceXslt();
            try {
                transformerPoolGetRootNamespace = TransformerPool.getInstance(getRootNamespace_xslt, true);
            } catch (TransformerConfigurationException te) {
                throw new ConfigurationException(getLogPrefix(null) + "got error creating transformer from getRootNamespace", te);
            }
            String removeNamespaces_xslt = XmlUtils.makeRemoveNamespacesXslt(true, false);
            try {
                transformerPoolRemoveNamespaces = TransformerPool.getInstance(removeNamespaces_xslt);
            } catch (TransformerConfigurationException te) {
                throw new ConfigurationException(getLogPrefix(null) + "got error creating transformer from removeNamespaces", te);
            }
        }
        if (!isForwardFailureToSuccess() && !isThrowException()) {
            if (findForward("failure") == null) {
                throw new ConfigurationException(getLogPrefix(null) + "must either set throwException true, forwardFailureToSuccess true or have a forward with name [failure]");
            }
        }
        // noNamespaceSchemaLocation.
        if (validator.getIgnoreUnknownNamespaces() == null) {
            if (StringUtils.isNotEmpty(getNoNamespaceSchemaLocation())) {
                validator.setIgnoreUnknownNamespaces(true);
            } else {
                validator.setIgnoreUnknownNamespaces(false);
            }
        }
        validator.setSchemasProvider(this);
        // do initial schema check
        if (getSchemasId() != null) {
            getSchemas(true);
        }
        if (isRecoverAdapter()) {
            validator.reset();
        }
        validator.configure(getLogPrefix(null));
        registerEvent(AbstractXmlValidator.XML_VALIDATOR_PARSER_ERROR_MONITOR_EVENT);
        registerEvent(AbstractXmlValidator.XML_VALIDATOR_NOT_VALID_MONITOR_EVENT);
        registerEvent(AbstractXmlValidator.XML_VALIDATOR_VALID_MONITOR_EVENT);
    } catch (ConfigurationException e) {
        configurationException = e;
        throw e;
    }
    if (getRoot() == null) {
        ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
        String msg = getLogPrefix(null) + "Root not specified";
        configWarnings.add(log, msg);
    }
}
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 8 with ConfigurationWarnings

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

the class XmlValidator method setSchemaSession.

/**
 * @deprecated attribute name changed to {@link #setSchemaSessionKey(String) schemaSessionKey}
 */
public void setSchemaSession(String schemaSessionKey) {
    ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
    String msg = getLogPrefix(null) + "attribute 'schemaSession' is deprecated. Please use 'schemaSessionKey' instead.";
    configWarnings.add(log, msg);
    setSchemaSessionKey(schemaSessionKey);
}
Also used : ConfigurationWarnings(nl.nn.adapterframework.configuration.ConfigurationWarnings)

Example 9 with ConfigurationWarnings

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

the class MessageSendingPipe method configure.

/**
 * Checks whether a sender is defined for this pipe.
 */
@Override
public void configure() throws ConfigurationException {
    super.configure();
    if (StringUtils.isNotEmpty(getStubFileName())) {
        URL stubUrl;
        try {
            stubUrl = ClassUtils.getResourceURL(classLoader, getStubFileName());
        } catch (Throwable e) {
            throw new ConfigurationException(getLogPrefix(null) + "got exception finding resource for stubfile [" + getStubFileName() + "]", e);
        }
        if (stubUrl == null) {
            throw new ConfigurationException(getLogPrefix(null) + "could not find resource for stubfile [" + getStubFileName() + "]");
        }
        try {
            returnString = Misc.resourceToString(stubUrl, SystemUtils.LINE_SEPARATOR);
        } catch (Throwable e) {
            throw new ConfigurationException(getLogPrefix(null) + "got exception loading stubfile [" + getStubFileName() + "] from resource [" + stubUrl.toExternalForm() + "]", e);
        }
    } else {
        propagateName();
        if (getSender() == null) {
            throw new ConfigurationException(getLogPrefix(null) + "no sender defined ");
        }
        try {
            if (getSender() instanceof PipeAware) {
                ((PipeAware) getSender()).setPipe(this);
            }
            getSender().configure();
        } catch (ConfigurationException e) {
            throw new ConfigurationException(getLogPrefix(null) + "while configuring sender", e);
        }
        if (getSender() instanceof HasPhysicalDestination) {
            log.info(getLogPrefix(null) + "has sender on " + ((HasPhysicalDestination) getSender()).getPhysicalDestinationName());
        }
        if (getListener() != null) {
            if (getSender().isSynchronous()) {
                throw new ConfigurationException(getLogPrefix(null) + "cannot have listener with synchronous sender");
            }
            try {
                getListener().configure();
            } catch (ConfigurationException e) {
                throw new ConfigurationException(getLogPrefix(null) + "while configuring listener", e);
            }
            if (getListener() instanceof HasPhysicalDestination) {
                log.info(getLogPrefix(null) + "has listener on " + ((HasPhysicalDestination) getListener()).getPhysicalDestinationName());
            }
        }
        if (!(getLinkMethod().equalsIgnoreCase("MESSAGEID")) && (!(getLinkMethod().equalsIgnoreCase("CORRELATIONID")))) {
            throw new ConfigurationException(getLogPrefix(null) + "Invalid argument for property LinkMethod [" + getLinkMethod() + "]. it should be either MESSAGEID or CORRELATIONID");
        }
        if (!(getHideMethod().equalsIgnoreCase("all")) && (!(getHideMethod().equalsIgnoreCase("firstHalf")))) {
            throw new ConfigurationException(getLogPrefix(null) + "invalid value for hideMethod [" + getHideMethod() + "], must be 'all' or 'firstHalf'");
        }
        if (isCheckXmlWellFormed() || StringUtils.isNotEmpty(getCheckRootTag())) {
            if (findForward(ILLEGAL_RESULT_FORWARD) == null)
                throw new ConfigurationException(getLogPrefix(null) + "has no forward with name [illegalResult]");
        }
        if (!ConfigurationUtils.stubConfiguration()) {
            if (StringUtils.isNotEmpty(getTimeOutOnResult())) {
                throw new ConfigurationException(getLogPrefix(null) + "timeOutOnResult only allowed in stub mode");
            }
            if (StringUtils.isNotEmpty(getExceptionOnResult())) {
                throw new ConfigurationException(getLogPrefix(null) + "exceptionOnResult only allowed in stub mode");
            }
        }
        if (getMaxRetries() > 0) {
            ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
            if (getRetryMinInterval() < MIN_RETRY_INTERVAL) {
                String msg = "retryMinInterval [" + getRetryMinInterval() + "] should be greater than or equal to [" + MIN_RETRY_INTERVAL + "], assuming the lower limit";
                configWarnings.add(log, msg);
                setRetryMinInterval(MIN_RETRY_INTERVAL);
            }
            if (getRetryMaxInterval() > MAX_RETRY_INTERVAL) {
                String msg = "retryMaxInterval [" + getRetryMaxInterval() + "] should be less than or equal to [" + MAX_RETRY_INTERVAL + "], assuming the upper limit";
                configWarnings.add(log, msg);
                setRetryMaxInterval(MAX_RETRY_INTERVAL);
            }
            if (getRetryMaxInterval() < getRetryMinInterval()) {
                String msg = "retryMaxInterval [" + getRetryMaxInterval() + "] should be greater than or equal to [" + getRetryMinInterval() + "], assuming the lower limit";
                configWarnings.add(log, msg);
                setRetryMaxInterval(getRetryMinInterval());
            }
        }
    }
    ITransactionalStorage messageLog = getMessageLog();
    if (checkMessageLog) {
        if (!getSender().isSynchronous() && getListener() == null && !(getSender() instanceof nl.nn.adapterframework.senders.IbisLocalSender)) {
            if (messageLog == null) {
                ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
                String msg = "asynchronous sender [" + getSender().getName() + "] without sibling listener has no messageLog. Integrity check not possible";
                configWarnings.add(log, msg);
            }
        }
    }
    if (messageLog != null) {
        messageLog.configure();
        if (messageLog instanceof HasPhysicalDestination) {
            String msg = getLogPrefix(null) + "has messageLog in " + ((HasPhysicalDestination) messageLog).getPhysicalDestinationName();
            log.info(msg);
            if (getAdapter() != null)
                getAdapter().getMessageKeeper().add(msg);
        }
        if (StringUtils.isNotEmpty(getAuditTrailXPath())) {
            auditTrailTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getAuditTrailNamespaceDefs(), getAuditTrailXPath(), null, "text", false, null);
        }
        if (StringUtils.isNotEmpty(getCorrelationIDXPath()) || StringUtils.isNotEmpty(getCorrelationIDStyleSheet())) {
            correlationIDTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getCorrelationIDNamespaceDefs(), getCorrelationIDXPath(), getCorrelationIDStyleSheet(), "text", false, null);
        }
        if (StringUtils.isNotEmpty(getLabelXPath()) || StringUtils.isNotEmpty(getLabelStyleSheet())) {
            labelTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getLabelNamespaceDefs(), getLabelXPath(), getLabelStyleSheet(), "text", false, null);
        }
    }
    if (StringUtils.isNotEmpty(getRetryXPath())) {
        retryTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getRetryNamespaceDefs(), getRetryXPath(), null, "text", false, null);
    }
    IPipe inputValidator = getInputValidator();
    IPipe outputValidator = getOutputValidator();
    if (inputValidator != null && outputValidator == null && inputValidator instanceof IDualModeValidator) {
        outputValidator = ((IDualModeValidator) inputValidator).getResponseValidator();
        setOutputValidator(outputValidator);
    }
    if (inputValidator != null) {
        PipeForward pf = new PipeForward();
        pf.setName(SUCCESS_FORWARD);
        inputValidator.registerForward(pf);
    // inputValidator.configure(); // configure is handled in PipeLine.configure()
    }
    if (outputValidator != null) {
        PipeForward pf = new PipeForward();
        pf.setName(SUCCESS_FORWARD);
        outputValidator.registerForward(pf);
    // outputValidator.configure(); // configure is handled in PipeLine.configure()
    }
    if (getInputWrapper() != null) {
        PipeForward pf = new PipeForward();
        pf.setName(SUCCESS_FORWARD);
        getInputWrapper().registerForward(pf);
        if (getInputWrapper() instanceof EsbSoapWrapperPipe) {
            EsbSoapWrapperPipe eswPipe = (EsbSoapWrapperPipe) getInputWrapper();
            ISender sender = getSender();
            eswPipe.retrievePhysicalDestinationFromSender(sender);
        }
    }
    if (getOutputWrapper() != null) {
        PipeForward pf = new PipeForward();
        pf.setName(SUCCESS_FORWARD);
        getOutputWrapper().registerForward(pf);
    }
    registerEvent(PIPE_TIMEOUT_MONITOR_EVENT);
    registerEvent(PIPE_CLEAR_TIMEOUT_MONITOR_EVENT);
    registerEvent(PIPE_EXCEPTION_MONITOR_EVENT);
}
Also used : ConfigurationWarnings(nl.nn.adapterframework.configuration.ConfigurationWarnings) EsbSoapWrapperPipe(nl.nn.adapterframework.extensions.esb.EsbSoapWrapperPipe) IDualModeValidator(nl.nn.adapterframework.core.IDualModeValidator) PipeForward(nl.nn.adapterframework.core.PipeForward) URL(java.net.URL) ITransactionalStorage(nl.nn.adapterframework.core.ITransactionalStorage) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) ISender(nl.nn.adapterframework.core.ISender) IPipe(nl.nn.adapterframework.core.IPipe) HasPhysicalDestination(nl.nn.adapterframework.core.HasPhysicalDestination)

Example 10 with ConfigurationWarnings

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

the class CompareStringPipe method setSessionKey1.

public void setSessionKey1(String string) {
    ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
    String msg = getLogPrefix(null) + "The attribute sessionKey1 has been deprecated. Please use the parameter operand1";
    configWarnings.add(log, msg);
    sessionKey1 = string;
}
Also used : ConfigurationWarnings(nl.nn.adapterframework.configuration.ConfigurationWarnings)

Aggregations

ConfigurationWarnings (nl.nn.adapterframework.configuration.ConfigurationWarnings)58 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)16 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)5 ArrayList (java.util.ArrayList)4 ITransactionalStorage (nl.nn.adapterframework.core.ITransactionalStorage)3 PipeForward (nl.nn.adapterframework.core.PipeForward)3 ReceiverBase (nl.nn.adapterframework.receivers.ReceiverBase)3 URL (java.net.URL)2 BaseConfigurationWarnings (nl.nn.adapterframework.configuration.BaseConfigurationWarnings)2 Configuration (nl.nn.adapterframework.configuration.Configuration)2 HasPhysicalDestination (nl.nn.adapterframework.core.HasPhysicalDestination)2 ISender (nl.nn.adapterframework.core.ISender)2 EsbSoapWrapperPipe (nl.nn.adapterframework.extensions.esb.EsbSoapWrapperPipe)2 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Connection (java.sql.Connection)1 DatabaseMetaData (java.sql.DatabaseMetaData)1 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1