Search in sources :

Example 81 with ConfigurationException

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

the class Json2XmlValidatorTest method init.

protected void init() throws ConfigurationException {
    jsonPipe = new JsonPipe();
    jsonPipe.setName("xml2json");
    jsonPipe.registerForward(new PipeForward("success", null));
    jsonPipe.setDirection(Direction.XML2JSON);
    jsonPipe.configure();
    try {
        validator = implementation.newInstance();
    } catch (IllegalAccessException e) {
        throw new ConfigurationException(e);
    } catch (InstantiationException e) {
        throw new ConfigurationException(e);
    }
    validator.setThrowException(true);
    validator.setFullSchemaChecking(true);
    instance = new Json2XmlValidator();
    instance.registerForward(new PipeForward("success", null));
    instance.setSoapNamespace(null);
    instance.setFailOnWildcards(false);
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) Json2XmlValidator(nl.nn.adapterframework.pipes.Json2XmlValidator) JsonPipe(nl.nn.adapterframework.pipes.JsonPipe) PipeForward(nl.nn.adapterframework.core.PipeForward)

Example 82 with ConfigurationException

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

the class AbstractXmlValidatorTestBase method validate.

@Override
public String validate(String rootElement, String rootNamespace, String schemaLocation, boolean addNamespaceToSchema, boolean ignoreUnknownNamespaces, String inputfile, String[] expectedFailureReasons) throws ConfigurationException, InstantiationException, IllegalAccessException, XmlValidatorException, PipeRunException, IOException {
    AbstractXmlValidator instance = implementation.newInstance();
    instance.setSchemasProvider(getSchemasProvider(schemaLocation, addNamespaceToSchema));
    instance.setIgnoreUnknownNamespaces(ignoreUnknownNamespaces);
    // instance.registerForward("success");
    instance.setThrowException(true);
    instance.setFullSchemaChecking(true);
    String testXml = inputfile != null ? TestFileUtils.getTestFile(inputfile + ".xml") : null;
    PipeLineSession session = new PipeLineSession();
    try {
        instance.configure("init");
        instance.start();
        RootValidations rootvalidations = null;
        if (rootElement != null) {
            rootvalidations = new RootValidations("Envelope", "Body", rootElement);
        }
        String result = instance.validate(testXml, session, "test", rootvalidations, null);
        evaluateResult(result, session, null, expectedFailureReasons);
        return result;
    } catch (Exception e) {
        evaluateResult(null, session, e, expectedFailureReasons);
        return "Invalid XML";
    }
}
Also used : PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) PipeRunException(nl.nn.adapterframework.core.PipeRunException) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException)

Example 83 with ConfigurationException

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

the class BisWrapperPipe method configure.

@Override
public void configure() throws ConfigurationException {
    super.configure();
    if (StringUtils.isNotEmpty(getSoapHeaderSessionKey())) {
        throw new ConfigurationException("soapHeaderSessionKey is not allowed");
    }
    if (StringUtils.isEmpty(getBisMessageHeaderSessionKey())) {
        throw new ConfigurationException("messageHeaderSessionKey must be set");
    }
    if (isAddOutputNamespace() && StringUtils.isEmpty(outputNamespace)) {
        throw new ConfigurationException("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, OutputType.XML));
        }
        String bisMessageHeaderNd = soapNamespaceDefs + "\n" + bisNamespaceDefs;
        String bisMessageHeaderXe;
        if (isBisMessageHeaderInSoapBody()) {
            bisMessageHeaderXe = soapBodyXPath + "/" + bisMessageHeaderXPath;
        } else {
            bisMessageHeaderXe = soapHeaderXPath + "/" + bisMessageHeaderXPath;
        }
        bisMessageHeaderTp = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(bisMessageHeaderNd, bisMessageHeaderXe, OutputType.XML));
        bisMessageHeaderConversationIdTp = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(bisNamespaceDefs, bisMessageHeaderConversationIdXPath, OutputType.TEXT));
        bisMessageHeaderExternalRefToMessageIdTp = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(bisNamespaceDefs, bisMessageHeaderExternalRefToMessageIdXPath, OutputType.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, OutputType.TEXT));
        if (isRemoveOutputNamespaces()) {
            removeOutputNamespacesTp = XmlUtils.getRemoveNamespacesTransformerPool(true, false);
        }
        if (isAddOutputNamespace()) {
            addOutputNamespaceTp = XmlUtils.getAddRootNamespaceTransformerPool(getOutputNamespace(), true, false);
        }
    } catch (TransformerConfigurationException e) {
        throw new ConfigurationException(getLogPrefix(null) + "cannot create transformer", e);
    }
}
Also used : TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException)

Example 84 with ConfigurationException

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

the class MqttFacade method configure.

@Override
public void configure() throws ConfigurationException {
    if (StringUtils.isEmpty(getClientId())) {
        throw new ConfigurationException("clientId must be specified");
    }
    if (StringUtils.isEmpty(getBrokerUrl())) {
        throw new ConfigurationException("brokerUrl must be specified");
    }
    if (StringUtils.isEmpty(getTopic())) {
        throw new ConfigurationException("topic must be specified");
    }
    if (StringUtils.isEmpty(getPersistenceDirectory())) {
        throw new ConfigurationException("persistenceDirectory must be specified");
    }
    connectOptions = new MqttConnectOptions();
    connectOptions.setCleanSession(isCleanSession());
    connectOptions.setAutomaticReconnect(isAutomaticReconnect());
    connectOptions.setConnectionTimeout(getTimeout());
    connectOptions.setKeepAliveInterval(getKeepAliveInterval());
    // Default: 0, V3.1: 3, V3.1.1: 4
    connectOptions.setMqttVersion(MqttConnectOptions.MQTT_VERSION_DEFAULT);
    if (!StringUtils.isEmpty(getAuthAlias()) || (!StringUtils.isEmpty(getUsername()) && !StringUtils.isEmpty(getPassword()))) {
        CredentialFactory credentialFactory = new CredentialFactory(getAuthAlias(), getUsername(), getPassword());
        connectOptions.setUserName(credentialFactory.getUsername());
        connectOptions.setPassword(credentialFactory.getPassword().toCharArray());
    }
    MqttDefaultFilePersistence dataStore = new MqttDefaultFilePersistence(getPersistenceDirectory());
    try {
        client = new MqttClient(brokerUrl, clientId, dataStore);
    } catch (MqttException e) {
        throw new ConfigurationException("Could not create client", e);
    }
}
Also used : MqttClient(org.eclipse.paho.client.mqttv3.MqttClient) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) MqttConnectOptions(org.eclipse.paho.client.mqttv3.MqttConnectOptions) CredentialFactory(nl.nn.adapterframework.util.CredentialFactory) MqttException(org.eclipse.paho.client.mqttv3.MqttException) MqttDefaultFilePersistence(org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence)

Example 85 with ConfigurationException

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

the class RekenBoxCaller method configure.

public void configure() throws ConfigurationException {
    super.configure();
    if (StringUtils.isEmpty(getCommandLineType()) || !(getCommandLineType().equals("straight") || getCommandLineType().equals("switches") || getCommandLineType().equals("redirected"))) {
        throw new ConfigurationException("commandLineType [" + getCommandLineType() + "] must be one of 'straigth', 'switches' or 'redirected'");
    }
    inputOutputDir = new File(getInputOutputDirectory());
    if (!inputOutputDir.exists()) {
        throw new ConfigurationException("inputOutputDirectory [" + getInputOutputDirectory() + "] does not exist");
    }
    if (!inputOutputDir.isDirectory()) {
        throw new ConfigurationException("inputOutputDirectory [" + getInputOutputDirectory() + "] is not a directory");
    }
    formatter = new DecimalFormat("000000000000".substring(0, Long.toString(getMaxRequestNumber()).length()));
    String baseFileName = getBaseFileName();
    log.debug(getLogPrefix(null) + "first filename will be [" + baseFileName + "]");
    requestCounter.decrease();
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) DecimalFormat(java.text.DecimalFormat) File(java.io.File)

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