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);
}
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";
}
}
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);
}
}
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);
}
}
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();
}
Aggregations