Package org.frankframework.pipes
Class Json2XmlValidator
- All Implemented Interfaces:
FrankElement,HasApplicationContext,HasName,HasTransactionAttribute,IConfigurable,IDualModeValidator,IForwardTarget,IPipe,IScopeProvider,IValidator,IWithParameters,IXmlValidator,NameAware,EventThrowing,SchemasProvider,org.springframework.beans.factory.Aware,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware,org.springframework.context.Lifecycle
- Direct Known Subclasses:
SoapValidator
Pipe that validates the XML or JSON input message against a XML Schema and returns either XML or JSON.- Author:
- Gerrit van Brakel
-
Nested Class Summary
Nested classes/interfaces inherited from class org.frankframework.pipes.XmlValidator
XmlValidator.ResponseValidatorWrapper -
Field Summary
FieldsFields inherited from class org.frankframework.pipes.XmlValidator
configurationException, validatorFields inherited from class org.frankframework.pipes.AbstractPipe
parameterNamesMustBeUniqueFields inherited from class org.frankframework.core.TransactionAttributes
logFields inherited from interface org.frankframework.core.IPipe
LONG_DURATION_MONITORING_EVENT, MESSAGE_SIZE_MONITORING_EVENT, PIPE_EXCEPTION_MONITORING_EVENT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddNamespace(Message xml) protected PipeRunResultalignJson(Message messageToValidate, PipeLineSession session, boolean responseMode) protected PipeRunResultalignXml2Json(Message messageToValidate, PipeLineSession session, boolean responseMode) voidConfigure the XmlValidatorjakarta.json.JsonStructurecreateJsonSchema(String elementName) jakarta.json.JsonStructurecreateJsonSchema(String elementName, String namespace) doPipe(Message input, PipeLineSession session, boolean responseMode, String messageRoot) Validate the XML or JSON input, and align/convert it into JSON or XML according to a XML Schema.protected RootValidationsgetJsonRootValidations(boolean responseMode) getOutputFormat(PipeLineSession session, boolean responseMode) voidsetAcceptNamespacelessXml(boolean acceptNamespacelessXml) Iftrue, all XML is allowed to be without namespaces.voidsetAcceptNamespaceLessXml(boolean acceptNamespacelessXml) Deprecated.voidsetAllowJson(boolean allowJson) Allow JSON inputvoidsetAutoFormat(boolean autoFormat) Iftrue, the format on 'output' is set to the same as the format of the input message on 'input'.voidsetCompactJsonArrays(boolean compactJsonArrays) Iftrueassume arrays in JSON do not have the element containers like in XMLvoidsetDeepSearch(boolean deepSearch) Iftrue, and converting from JSON to XML, parameter substitutions are searched for optional sub elements too.voidsetFailOnWildcards(boolean failOnWildcards) Iftrue, an exception is thrown when a wildcard is found in the XML Schema when parsing an object.voidsetIgnoreUndeclaredElements(boolean ignoreUndeclaredElements) Iftrue, and converting from JSON to XML, elements in JSON that are not found in the XML Schema are ignoredvoidsetInputFormatSessionKey(String inputFormatSessionKey) Session key to store the inputFormat in, to be able to set the outputformat when autoFormat=true.voidsetJsonWithRootElements(boolean jsonWithRootElements) Iftrue, assume that JSON contains/must contain a root elementvoidsetOmitXmlDeclaration(boolean omitXmlDeclaration) Allow omitting the XML declaration from the output, if the output is in XML format.voidsetOutputFormat(DocumentFormat outputFormat) Default format of the result, that is used if the format cannot be found from outputFormatSessionKey or from inputFormatSessionKey (when validating responses and autoFormat=true)voidsetOutputFormatSessionKey(String outputFormatSessionKey) Session key to retrieve outputFormat fromvoidsetProduceNamespacelessXml(boolean produceNamespacelessXml) If true, all XML that is generated is without a namespace setvoidsetProduceNamespaceLessXml(boolean produceNamespacelessXml) Deprecated.voidsetStrictJsonArraySyntax(boolean strictJsonArraySyntax) Iftruecheck that incoming JSON adheres to the specified syntax (compact or full), otherwise both types are accepted for conversion from JSON to XMLvoidsetTargetNamespace(String targetNamespace) Only for JSON input: namespace of the resulting XML.voidsetValidateJsonToRootElementOnly(boolean validateJsonToRootElementOnly) Iftrue, and converting to or from JSON, then the message root is the only rootValidation, ignoring root validations like for SOAP envelope and header set by descender classes like SoapValidatorprotected voidstoreInputFormat(DocumentFormat format, Message input, PipeLineSession session, boolean responseMode) Methods inherited from class org.frankframework.pipes.XmlValidator
addInvalidRootNamespaces, addRequestRootValidation, addResponseRootValidation, afterPropertiesSet, checkSchemaSpecified, createRootValidation, determineForward, getCharset, getConfigurationException, getDocumentation, getErrorResult, getIgnoreUnknownNamespaces, getInvalidRootNamespaces, getMessageRoot, getMessageRoot, getReasonSessionKey, getRequestRootValidations, getResponseRootValidations, getResponseValidator, getRootValidations, getSchema, getSchemas, getSchemas, getSchemas, getSchemasId, getSchemasId, getSoapNamespace, getXmlReasonSessionKey, getXsds, getXSModels, isConfiguredForMixedValidation, isFullSchemaChecking, isThrowException, isValidateFile, setAddNamespaceToSchema, setCharset, setFullSchemaChecking, setIgnoreCaching, setIgnoreUnknownNamespaces, setImplementation, setImportedNamespacesToIgnore, setImportedSchemaLocationsToIgnore, setNoNamespaceSchemaLocation, setReasonSessionKey, setResponseRoot, setRoot, setRootElementSessionKey, setRootNamespaceSessionKey, setSchema, setSchemaLocation, setSoapNamespace, setThrowException, setUseBaseImportedSchemaLocationsToIgnore, setValidateFile, setWarn, setXmlReasonSessionKey, setXmlSchemaVersion, start, stop, validateMethods inherited from class org.frankframework.pipes.AbstractValidator
determineForward, doPipe, setForwardFailureToSuccess, setSchemaSessionKey, validate, validateMethods inherited from class org.frankframework.pipes.FixedForwardPipe
getParameterValue, setIfParam, setIfValue, setOnlyIfSessionKey, setOnlyIfValue, setSkipOnEmptyInput, setUnlessSessionKey, setUnlessValue, skipPipeMethods inherited from class org.frankframework.pipes.AbstractPipe
addForward, addParameter, consumesSessionVariable, createBean, findForward, getAdapter, getEventSourceName, getForwards, getParameterList, hasRegisteredForward, isRunning, registerEvent, setApplicationContext, setChompCharSize, setDurationThreshold, setElementToMove, setElementToMoveChain, setElementToMoveSessionKey, setEmptyInputReplacement, setGetInputFromFixedValue, setGetInputFromSessionKey, setHideRegex, setLocker, setLogIntermediaryResults, setMaxThreads, setName, setPreserveInput, setRemoveCompactMsgNamespaces, setRestoreMovedElements, setSecLogSessionKeys, setSizeStatistics, setStoreResultInSessionKey, setWriteToSecLog, sizeStatisticsEnabled, throwEventMethods inherited from class org.frankframework.core.TransactionAttributes
configureTransactionAttributes, isTransacted, isTransacted, setTransacted, setTransactionTimeoutMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContextMethods inherited from interface org.frankframework.core.FrankElement
addConfigWarningMethods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoaderMethods inherited from interface org.frankframework.core.HasTransactionAttribute
getTransactionAttribute, getTransactionTimeout, getTxDef, setTransactionAttributeMethods inherited from interface org.frankframework.core.IForwardTarget
getNameMethods inherited from interface org.frankframework.core.IPipe
addForward, consumesSessionVariable, doPipe, getChompCharSize, getDurationThreshold, getElementToMove, getElementToMoveChain, getElementToMoveSessionKey, getEmptyInputReplacement, getForwards, getGetInputFromFixedValue, getGetInputFromSessionKey, getHideRegex, getLocker, getLogIntermediaryResults, getMaxThreads, getSecLogSessionKeys, getStoreResultInSessionKey, isPreserveInput, isRemoveCompactMsgNamespaces, isRestoreMovedElements, isWriteToSecLog, registerEvent, setChompCharSize, setDurationThreshold, setElementToMove, setElementToMoveChain, setElementToMoveSessionKey, setEmptyInputReplacement, setGetInputFromFixedValue, setGetInputFromSessionKey, setHideRegex, setLocker, setLogIntermediaryResults, setPipeLine, setPreserveInput, setRemoveCompactMsgNamespaces, setRestoreMovedElements, setSecLogSessionKeys, setStoreResultInSessionKey, setWriteToSecLog, sizeStatisticsEnabled, throwEvent, throwEventMethods inherited from interface org.frankframework.core.IValidator
setName, validateMethods inherited from interface org.frankframework.core.IXmlValidator
getSchemaLocationMethods inherited from interface org.springframework.context.Lifecycle
isRunning
-
Field Details
-
READ_AHEAD_LIMIT
public static final int READ_AHEAD_LIMIT- See Also:
-
INPUT_FORMAT_SESSION_KEY_PREFIX
- See Also:
-
-
Constructor Details
-
Json2XmlValidator
public Json2XmlValidator()
-
-
Method Details
-
configure
Description copied from class:XmlValidatorConfigure the XmlValidator- Specified by:
configurein interfaceIConfigurable- Overrides:
configurein classXmlValidator- Throws:
ConfigurationException- when:- the schema cannot be found
XmlValidator.isThrowException()isfalseand there is no forward defined for "failure"- when the parser does not accept setting the properties for validating
-
getOutputFormat
-
storeInputFormat
protected void storeInputFormat(DocumentFormat format, Message input, PipeLineSession session, boolean responseMode) -
doPipe
public PipeRunResult doPipe(Message input, PipeLineSession session, boolean responseMode, String messageRoot) throws PipeRunException Validate the XML or JSON input, and align/convert it into JSON or XML according to a XML Schema. The format of the input message (XML or JSON) is automatically detected.- Overrides:
doPipein classXmlValidator- Throws:
PipeRunException- whenisThrowExceptionis true and a validationerror occurred.
-
getJsonRootValidations
-
alignXml2Json
protected PipeRunResult alignXml2Json(Message messageToValidate, PipeLineSession session, boolean responseMode) throws XmlValidatorException, PipeRunException, ConfigurationException -
alignJson
protected PipeRunResult alignJson(Message messageToValidate, PipeLineSession session, boolean responseMode) throws PipeRunException, XmlValidatorException -
addNamespace
- Throws:
IOException
-
createJsonSchema
-
createJsonSchema
-
setTargetNamespace
Only for JSON input: namespace of the resulting XML. Need only be specified when the namespace of root name is ambiguous in the schema -
setOutputFormat
Default format of the result, that is used if the format cannot be found from outputFormatSessionKey or from inputFormatSessionKey (when validating responses and autoFormat=true)- Default value
- XML
-
setOutputFormatSessionKey
Session key to retrieve outputFormat from- Default value
- outputFormat
-
setInputFormatSessionKey
Session key to store the inputFormat in, to be able to set the outputformat when autoFormat=true. Can also be used to pass the value of an HTTP Accept header, to obtain a properly formatted response- Default value
- "Json2XmlValidator.inputFormat "<name of the pipe>
-
setAutoFormat
public void setAutoFormat(boolean autoFormat) Iftrue, the format on 'output' is set to the same as the format of the input message on 'input'. The format of the input message is stored in and retrieved from the session variable specified by outputFormatSessionKey- Default value
- true
-
setCompactJsonArrays
public void setCompactJsonArrays(boolean compactJsonArrays) Iftrueassume arrays in JSON do not have the element containers like in XML- Default value
- true
-
setStrictJsonArraySyntax
public void setStrictJsonArraySyntax(boolean strictJsonArraySyntax) Iftruecheck that incoming JSON adheres to the specified syntax (compact or full), otherwise both types are accepted for conversion from JSON to XML- Default value
- false
-
setJsonWithRootElements
public void setJsonWithRootElements(boolean jsonWithRootElements) Iftrue, assume that JSON contains/must contain a root element- Default value
- false
-
setDeepSearch
public void setDeepSearch(boolean deepSearch) Iftrue, and converting from JSON to XML, parameter substitutions are searched for optional sub elements too. By default, only mandatory elements are searched for parameter substitutions. N.B. Currently this option might cause problems. Please try using more qualified parameters names (using '/') first- Default value
- false
-
setIgnoreUndeclaredElements
public void setIgnoreUndeclaredElements(boolean ignoreUndeclaredElements) Iftrue, and converting from JSON to XML, elements in JSON that are not found in the XML Schema are ignored- Default value
- false
-
setFailOnWildcards
public void setFailOnWildcards(boolean failOnWildcards) Iftrue, an exception is thrown when a wildcard is found in the XML Schema when parsing an object. This often indicates that an element is not properly typed in the XML Schema, and could lead to ambuigities.- Default value
- true
-
setAcceptNamespacelessXml
public void setAcceptNamespacelessXml(boolean acceptNamespacelessXml) Iftrue, all XML is allowed to be without namespaces. If no namespaces are detected (by the presence of the string 'xmlns') in the XML, the root namespace is added to the XML- Default value
- false
-
setAcceptNamespaceLessXml
@Deprecated @ConfigurationWarning("The attribute \'acceptNamespaceLessXml\' has been renamed \'acceptNamespacelessXml\'") public void setAcceptNamespaceLessXml(boolean acceptNamespacelessXml) Deprecated. -
setProduceNamespacelessXml
public void setProduceNamespacelessXml(boolean produceNamespacelessXml) If true, all XML that is generated is without a namespace set- Default value
- false
-
setProduceNamespaceLessXml
@Deprecated @ConfigurationWarning("The attribute \'produceNamespaceLessXml\' has been renamed \'produceNamespacelessXml\'") public void setProduceNamespaceLessXml(boolean produceNamespacelessXml) Deprecated. -
setValidateJsonToRootElementOnly
public void setValidateJsonToRootElementOnly(boolean validateJsonToRootElementOnly) Iftrue, and converting to or from JSON, then the message root is the only rootValidation, ignoring root validations like for SOAP envelope and header set by descender classes like SoapValidator- Default value
- true
-
setAllowJson
public void setAllowJson(boolean allowJson) Allow JSON input- Default value
- true
-
setOmitXmlDeclaration
public void setOmitXmlDeclaration(boolean omitXmlDeclaration) Allow omitting the XML declaration from the output, if the output is in XML format. This can be useful when the output needs to be combined with other XML documents.- Default value
- false
-