use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class Json2XmlValidator method alignJson.
protected PipeRunResult alignJson(String messageToValidate, IPipeLineSession session, boolean responseMode) throws PipeRunException, XmlValidatorException {
ValidationContext context;
ValidatorHandler validatorHandler;
try {
context = validator.createValidationContext(session, getRootValidations(responseMode), getInvalidRootNamespaces());
validatorHandler = validator.getValidatorHandler(session, context);
} catch (ConfigurationException e) {
throw new PipeRunException(this, "Cannot create ValidationContext", e);
}
String resultEvent;
String out = null;
try {
Json2Xml aligner = new Json2Xml(validatorHandler, context.getXsModels(), isCompactJsonArrays(), getMessageRoot(responseMode), isStrictJsonArraySyntax());
if (StringUtils.isNotEmpty(getTargetNamespace())) {
aligner.setTargetNamespace(getTargetNamespace());
}
aligner.setDeepSearch(isDeepSearch());
aligner.setErrorHandler(context.getErrorHandler());
aligner.setFailOnWildcards(isFailOnWildcards());
ParameterList parameterList = getParameterList();
if (parameterList != null) {
ParameterResolutionContext prc = new ParameterResolutionContext(messageToValidate, session, isNamespaceAware(), false);
Map<String, Object> parametervalues = null;
parametervalues = prc.getValueMap(parameterList);
aligner.setOverrideValues(parametervalues);
}
JsonStructure jsonStructure = Json.createReader(new StringReader(messageToValidate)).read();
if (getOutputFormat(session, responseMode).equalsIgnoreCase(FORMAT_JSON)) {
Xml2Json xml2json = new Xml2Json(aligner, isCompactJsonArrays(), !isJsonWithRootElements());
aligner.setContentHandler(xml2json);
aligner.startParse(jsonStructure);
out = xml2json.toString();
} else {
Source source = aligner.asSource(jsonStructure);
out = XmlUtils.source2String(source, isProduceNamespaceLessXml());
}
} catch (Exception e) {
resultEvent = validator.finalizeValidation(context, session, e);
}
resultEvent = validator.finalizeValidation(context, session, null);
PipeForward forward = determineForward(resultEvent, session, responseMode);
PipeRunResult result = new PipeRunResult(forward, out);
return result;
}
use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class EtagHandlerPipe method configure.
@Override
public void configure() throws ConfigurationException {
super.configure();
String action = getAction();
if (action == null) {
throw new ConfigurationException(getLogPrefix(null) + "action must be set");
}
if (!actions.contains(action)) {
throw new ConfigurationException(getLogPrefix(null) + "illegal value for action [" + action + "], must be one of " + actions.toString());
}
boolean hasUriPatternParameter = false;
ParameterList parameterList = getParameterList();
for (int i = 0; i < parameterList.size(); i++) {
Parameter parameter = parameterList.getParameter(i);
if ("uriPattern".equalsIgnoreCase(parameter.getName()))
hasUriPatternParameter = true;
}
if (getUriPattern() == null && !hasUriPatternParameter) {
throw new ConfigurationException(getLogPrefix(null) + "no uriPattern found!");
}
cache = ApiCacheManager.getInstance();
}
use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class FixedForwardPipe method configure.
/**
* checks for correct configuration of forward
*/
@Override
public void configure() throws ConfigurationException {
super.configure();
forward = findForward(forwardName);
if (forward == null)
throw new ConfigurationException(getLogPrefix(null) + "has no forward with name [" + forwardName + "]");
}
use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class PushingIfsaProviderListener method configure.
public void configure() throws ConfigurationException {
super.configure();
if (jmsConnector == null) {
throw new ConfigurationException(getLogPrefix() + " has no jmsConnector. It should be configured via springContext.xml");
}
if (StringUtils.isNotEmpty(getCacheMode())) {
if (!getCacheMode().equals("CACHE_NONE") && !getCacheMode().equals("CACHE_CONNECTION") && !getCacheMode().equals("CACHE_SESSION") && !getCacheMode().equals("CACHE_CONSUMER")) {
throw new ConfigurationException(getLogPrefix() + "cacheMode [" + getCacheMode() + "] must be one of CACHE_NONE, CACHE_CONNECTION, CACHE_SESSION or CACHE_CONSUMER");
}
}
Destination destination = null;
try {
destination = getServiceQueue();
} catch (Exception e) {
throw new ConfigurationException(getLogPrefix() + "could not get Destination", e);
}
try {
jmsConnector.configureEndpointConnection(this, getMessagingSource().getConnectionFactory(), destination, getExceptionListener(), getCacheMode(), getAckMode(), isJmsTransacted(), getProviderSelector());
} catch (Exception e) {
throw new ConfigurationException(e);
}
}
use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class XmlValidatorTest2 method getValidator.
public static XmlValidator getValidator(String schemaLocation, boolean addNamespaceToSchema, Class<AbstractXmlValidator> implementation) throws ConfigurationException {
XmlValidator validator = new XmlValidator();
try {
validator.setImplementation(implementation);
} catch (Exception e) {
throw new RuntimeException(e);
}
validator.setSchemaLocation(schemaLocation);
if (addNamespaceToSchema) {
validator.setAddNamespaceToSchema(addNamespaceToSchema);
}
validator.registerForward(getSuccess());
validator.setThrowException(true);
validator.setFullSchemaChecking(true);
validator.configure();
return validator;
}
Aggregations