Search in sources :

Example 21 with ConfigurationException

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;
}
Also used : ValidatorHandler(javax.xml.validation.ValidatorHandler) PipeForward(nl.nn.adapterframework.core.PipeForward) Source(javax.xml.transform.Source) PipeRunException(nl.nn.adapterframework.core.PipeRunException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) XmlValidatorException(nl.nn.adapterframework.validation.XmlValidatorException) ValidationContext(nl.nn.adapterframework.validation.ValidationContext) PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) PipeRunException(nl.nn.adapterframework.core.PipeRunException) StringReader(java.io.StringReader) ParameterList(nl.nn.adapterframework.parameters.ParameterList) ParameterResolutionContext(nl.nn.adapterframework.parameters.ParameterResolutionContext) Xml2Json(nl.nn.adapterframework.align.Xml2Json) Json2Xml(nl.nn.adapterframework.align.Json2Xml) JsonStructure(javax.json.JsonStructure)

Example 22 with ConfigurationException

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();
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) ParameterList(nl.nn.adapterframework.parameters.ParameterList) Parameter(nl.nn.adapterframework.parameters.Parameter)

Example 23 with ConfigurationException

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 + "]");
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException)

Example 24 with ConfigurationException

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);
    }
}
Also used : Destination(javax.jms.Destination) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) IfsaException(nl.nn.adapterframework.extensions.ifsa.IfsaException) ListenerException(nl.nn.adapterframework.core.ListenerException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) JMSException(javax.jms.JMSException)

Example 25 with ConfigurationException

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;
}
Also used : AbstractXmlValidator(nl.nn.adapterframework.validation.AbstractXmlValidator) XercesXmlValidator(nl.nn.adapterframework.validation.XercesXmlValidator) JavaxXmlValidator(nl.nn.adapterframework.validation.JavaxXmlValidator) PipeRunException(nl.nn.adapterframework.core.PipeRunException) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) XmlValidatorException(nl.nn.adapterframework.validation.XmlValidatorException)

Aggregations

ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)113 IOException (java.io.IOException)26 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)20 PipeRunException (nl.nn.adapterframework.core.PipeRunException)17 ConfigurationWarnings (nl.nn.adapterframework.configuration.ConfigurationWarnings)16 URL (java.net.URL)13 ArrayList (java.util.ArrayList)12 Parameter (nl.nn.adapterframework.parameters.Parameter)12 ParameterList (nl.nn.adapterframework.parameters.ParameterList)11 File (java.io.File)7 Iterator (java.util.Iterator)6 ListenerException (nl.nn.adapterframework.core.ListenerException)6 PipeForward (nl.nn.adapterframework.core.PipeForward)6 PipeLineSessionBase (nl.nn.adapterframework.core.PipeLineSessionBase)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 StringTokenizer (java.util.StringTokenizer)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 FileNotFoundException (java.io.FileNotFoundException)4 LinkedList (java.util.LinkedList)4