Search in sources :

Example 66 with ConfigurationException

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

the class XsltSender method configure.

/**
 * The <code>configure()</code> method instantiates a transformer for the specified
 * XSL. If the stylesheetName cannot be accessed, a ConfigurationException is thrown.
 */
@Override
public void configure() throws ConfigurationException {
    super.configure();
    streamingXslt = AppConstants.getInstance(getConfigurationClassLoader()).getBoolean(XmlUtils.XSLT_STREAMING_BY_DEFAULT_KEY, false);
    dynamicTransformerPoolMap = Collections.synchronizedMap(new LRUMap(transformerPoolMapSize));
    if (StringUtils.isNotEmpty(getXpathExpression()) && getOutputType() == null) {
        setOutputType(DEFAULT_XPATH_OUTPUT_METHOD);
    }
    if (StringUtils.isNotEmpty(getStyleSheetName()) || StringUtils.isNotEmpty(getXpathExpression())) {
        Boolean omitXmlDeclaration = getOmitXmlDeclaration();
        if (omitXmlDeclaration == null) {
            omitXmlDeclaration = true;
        }
        transformerPool = TransformerPool.configureTransformer0(getLogPrefix(), this, getNamespaceDefs(), getXpathExpression(), getStyleSheetName(), getOutputType(), !omitXmlDeclaration, getParameterList(), getXsltVersion());
    } else if (StringUtils.isEmpty(getStyleSheetNameSessionKey())) {
        throw new ConfigurationException(getLogPrefix() + " one of xpathExpression, styleSheetName or styleSheetNameSessionKey must be specified");
    }
    if (getXsltVersion() >= 2) {
        ParameterList parameterList = getParameterList();
        if (parameterList != null) {
            for (int i = 0; i < parameterList.size(); i++) {
                Parameter parameter = parameterList.getParameter(i);
                if (parameter.getType() == ParameterType.NODE) {
                    throw new ConfigurationException(getLogPrefix() + "type '" + ParameterType.NODE + " is not permitted in combination with XSLT 2.0, use type '" + ParameterType.DOMDOC + "'");
                }
            }
        }
    }
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) LRUMap(org.apache.commons.collections.map.LRUMap) ParameterList(nl.nn.adapterframework.parameters.ParameterList) Parameter(nl.nn.adapterframework.parameters.Parameter)

Example 67 with ConfigurationException

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

the class SoapValidator method configure.

@Override
public void configure() throws ConfigurationException {
    setSoapNamespace("");
    if (isAllowPlainXml()) {
        // super.setRoot("Envelope,"+soapBody);
        addRequestRootValidation(new RootValidation(SOAP_ENVELOPE + "," + soapBody));
    } else {
        super.setRoot(getRoot());
    }
    if (addSoapEnvelopeToSchemaLocation) {
        if (StringUtils.isEmpty(getSchemaLocation())) {
            throw new ConfigurationException("schemaLocation must be specified");
        }
        super.setSchemaLocation(getSchemaLocation() + (getSchemaLocation().length() > 0 ? " " : "") + soapVersion.getSchemaLocation());
    }
    if (StringUtils.isEmpty(soapBody)) {
        ConfigurationWarnings.add(this, log, "soapBody not specified");
    }
    if (!isAllowPlainXml()) {
        addRequestRootValidation(new RootValidation(SOAP_ENVELOPE, SOAP_BODY, soapBody));
        if (StringUtils.isNotEmpty(outputSoapBody)) {
            addResponseRootValidation(new RootValidation(SOAP_ENVELOPE, SOAP_BODY, outputSoapBody));
        }
        addRequestRootValidation(new RootValidation(SOAP_ENVELOPE, SOAP_HEADER, soapHeader));
        List<String> invalidRootNamespaces = new ArrayList<String>();
        for (String namespace : soapVersion.getNamespaces()) {
            invalidRootNamespaces.add(namespace);
        }
        addInvalidRootNamespaces(Arrays.asList(SOAP_ENVELOPE, SOAP_BODY, soapBody), invalidRootNamespaces);
        addInvalidRootNamespaces(Arrays.asList(SOAP_ENVELOPE, SOAP_HEADER, soapHeader), invalidRootNamespaces);
    }
    super.configure();
}
Also used : RootValidation(nl.nn.adapterframework.validation.RootValidation) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) ArrayList(java.util.ArrayList)

Example 68 with ConfigurationException

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

the class SoapWrapper method init.

private void init() throws ConfigurationException {
    try {
        extractBodySoap11 = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(NAMESPACE_DEFS_SOAP11, EXTRACT_BODY_XPATH, OutputType.XML, false, null, false));
        extractBodySoap12 = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(NAMESPACE_DEFS_SOAP12, EXTRACT_BODY_XPATH, OutputType.XML, false, null, false));
        extractHeader = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(NAMESPACE_DEFS_SOAP11, EXTRACT_HEADER_XPATH, OutputType.XML));
        extractFaultCount = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(NAMESPACE_DEFS_SOAP11, EXTRACT_FAULTCOUNTER_XPATH, OutputType.TEXT));
        extractFaultCode = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(NAMESPACE_DEFS_SOAP11, EXTRACT_FAULTCODE_XPATH, OutputType.TEXT));
        extractFaultString = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(NAMESPACE_DEFS_SOAP11, EXTRACT_FAULTSTRING_XPATH, OutputType.TEXT));
    } catch (TransformerConfigurationException e) {
        throw new ConfigurationException("cannot create SOAP transformer", e);
    }
}
Also used : TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException)

Example 69 with ConfigurationException

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

the class IbisActionJob method configure.

@Override
public void configure() throws ConfigurationException {
    super.configure();
    // Try and parse the JobDefFunction as an IbisAction
    this.ibisAction = EnumUtils.parse(IbisAction.class, "function", jobAction.name());
    if (StringUtils.isEmpty(getAdapterName())) {
        throw new ConfigurationException("a adapterName must be specified");
    }
    Adapter adapter = adapterManager.getAdapter(getAdapterName());
    if (adapter == null) {
        // Make sure the adapter is registered in this configuration
        String msg = "Jobdef [" + getName() + "] got error: adapter [" + getAdapterName() + "] not registered.";
        throw new ConfigurationException(msg);
    }
    if (jobAction == Action.STOPRECEIVER || jobAction == Action.STARTRECEIVER) {
        if (StringUtils.isEmpty(getReceiverName())) {
            throw new ConfigurationException("a receiverName must be specified");
        }
        if (adapter.getReceiverByName(getReceiverName()) == null) {
            String msg = "Jobdef [" + getName() + "] got error: adapter [" + getAdapterName() + "] receiver [" + getReceiverName() + "] not registered.";
            throw new ConfigurationException(msg);
        }
    }
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) IbisAction(nl.nn.adapterframework.configuration.IbisManager.IbisAction) Adapter(nl.nn.adapterframework.core.Adapter)

Example 70 with ConfigurationException

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

the class RecoverAdaptersJob method execute.

@Override
public void execute(IbisManager ibisManager) {
    int countAdapter = 0;
    int countAdapterStateStarted = 0;
    int countReceiver = 0;
    int countReceiverStateStarted = 0;
    for (Adapter adapter : ibisManager.getRegisteredAdapters()) {
        countAdapter++;
        RunState adapterRunState = adapter.getRunState();
        boolean startAdapter = false;
        if (adapterRunState == RunState.ERROR) {
            // if not previously configured, there is no point in trying to do this again.
            log.debug("trying to recover adapter [" + adapter.getName() + "]");
            if (!adapter.configurationSucceeded()) {
                // This should only happen once, so only try to (re-)configure if it failed in the first place!
                try {
                    adapter.configure();
                } catch (ConfigurationException e) {
                    // log the warning and do nothing, it couldn't configure before, it still can't...
                    log.warn("error configuring adapter [" + adapter.getName() + "] while trying to recover", e);
                }
            }
            if (adapter.configurationSucceeded()) {
                // if configure has succeeded and adapter was in state ERROR try to auto (re-)start the adapter
                startAdapter = adapter.isAutoStart();
            }
            log.debug("finished recovering adapter [" + adapter.getName() + "]");
        }
        String message = "adapter [" + adapter.getName() + "] has state [" + adapterRunState + "]";
        if (adapterRunState == RunState.STARTED) {
            countAdapterStateStarted++;
            heartbeatLog.info(message);
        } else if (adapterRunState == RunState.ERROR) {
            heartbeatLog.error(message);
        } else {
            heartbeatLog.warn(message);
        }
        for (Receiver<?> receiver : adapter.getReceivers()) {
            countReceiver++;
            RunState receiverRunState = receiver.getRunState();
            if (adapterRunState == RunState.STARTED && receiverRunState == RunState.ERROR && receiver.configurationSucceeded()) {
                // Only try to (re-)start receivers in a running adapter. Receiver configure is done in Adapter.configure
                log.debug("trying to recover receiver [" + receiver.getName() + "] of adapter [" + adapter.getName() + "]");
                receiver.startRunning();
                log.debug("finished recovering receiver [" + receiver.getName() + "] of adapter [" + adapter.getName() + "]");
            }
            receiverRunState = receiver.getRunState();
            message = "receiver [" + receiver.getName() + "] of adapter [" + adapter.getName() + "] has state [" + receiverRunState + "]";
            if (receiverRunState == RunState.STARTED) {
                countReceiverStateStarted++;
                heartbeatLog.info(message);
            } else if (receiverRunState == RunState.ERROR) {
                heartbeatLog.error(message);
            } else {
                heartbeatLog.warn(message);
            }
        }
        if (startAdapter) {
            // can only be true if adapter was in error before and AutoStart is enabled
            // ASync startup can still cause the Adapter to end up in an ERROR state
            adapter.startRunning();
        }
    }
    heartbeatLog.info("[" + countAdapterStateStarted + "/" + countAdapter + "] adapters and [" + countReceiverStateStarted + "/" + countReceiver + "] receivers have state [" + RunState.STARTED + "]");
}
Also used : RunState(nl.nn.adapterframework.util.RunState) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) Adapter(nl.nn.adapterframework.core.Adapter)

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