Package org.frankframework.pipes
Class Json2XmlValidator
- All Implemented Interfaces:
HasSpecialDefaultValues
,HasPhysicalDestination
,HasTransactionAttribute
,IConfigurable
,IConfigurationAware
,IDualModeValidator
,IForwardTarget
,INamedObject
,IPipe
,IScopeProvider
,IValidator
,IWithParameters
,IXmlValidator
,EventThrowing
,HasStatistics
,SchemasProvider
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.InitializingBean
,org.springframework.context.ApplicationContextAware
- 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
Fields inherited from class org.frankframework.pipes.XmlValidator
configurationException, validator
Fields inherited from class org.frankframework.pipes.AbstractPipe
parameterNamesMustBeUnique
Fields inherited from class org.frankframework.core.TransactionAttributes
log
Fields inherited from interface org.frankframework.core.IPipe
LONG_DURATION_MONITORING_EVENT, MESSAGE_SIZE_MONITORING_EVENT, PIPE_EXCEPTION_MONITORING_EVENT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddNamespace
(String xml) protected PipeRunResult
alignJson
(String messageToValidate, PipeLineSession session, boolean responseMode) protected PipeRunResult
alignXml2Json
(String messageToValidate, PipeLineSession session, boolean responseMode) void
Configure the XmlValidatorjakarta.json.JsonStructure
createJsonSchema
(String elementName) jakarta.json.JsonStructure
createJsonSchema
(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 RootValidations
getJsonRootValidations
(boolean responseMode) getOutputFormat
(PipeLineSession session, boolean responseMode) boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
void
setAcceptNamespacelessXml
(boolean acceptNamespacelessXml) If true, all XML is allowed to be without namespaces.void
setAcceptNamespaceLessXml
(boolean acceptNamespacelessXml) Deprecated.void
setAllowJson
(boolean allowJson) Allow JSON inputvoid
setAutoFormat
(boolean autoFormat) If true, the format on 'output' is set to the same as the format of the input message on 'input'.void
setCompactJsonArrays
(boolean compactJsonArrays) If true assume arrays in JSON do not have the element containers like in XMLvoid
setDeepSearch
(boolean deepSearch) If true, and converting from JSON to XML, parameter substitutions are searched for optional sub elements too.void
setFailOnWildcards
(boolean failOnWildcards) If true, an exception is thrown when a wildcard is found in the XML Schema when parsing an object.void
setIgnoreUndeclaredElements
(boolean ignoreUndeclaredElements) If true, and converting from JSON to XML, elements in JSON that are not found in the XML Schema are ignoredvoid
setInputFormatSessionKey
(String inputFormatSessionKey) Session key to store the inputFormat in, to be able to set the outputformat when autoFormat=true.void
setJsonWithRootElements
(boolean jsonWithRootElements) If true, assume that JSON contains/must contain a root elementvoid
setOutputFormat
(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)void
setOutputFormatSessionKey
(String outputFormatSessionKey) Session key to retrieve outputFormat fromvoid
setProduceNamespacelessXml
(boolean produceNamespacelessXml) If true, all XML that is generated is without a namespace setvoid
setProduceNamespaceLessXml
(boolean produceNamespacelessXml) Deprecated.void
setStrictJsonArraySyntax
(boolean strictJsonArraySyntax) If true check that incoming JSON adheres to the specified syntax (compact or full), otherwise both types are accepted for conversion from JSON to XMLvoid
setTargetNamespace
(String targetNamespace) Only for JSON input: namespace of the resulting XML.void
setValidateJsonToRootElementOnly
(boolean validateJsonToRootElementOnly) If true, 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 void
storeInputFormat
(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, getImportedNamespacesToIgnore, getImportedSchemaLocationsToIgnore, getInvalidRootNamespaces, getMessageRoot, getMessageRoot, getNoNamespaceSchemaLocation, getReasonSessionKey, getRequestRootValidations, getResponseRootValidations, getResponseValidator, getRootElementSessionKey, getRootNamespaceSessionKey, getRootValidations, getSchema, getSchemaLocation, getSchemas, getSchemas, getSchemas, getSchemasId, getSchemasId, getSoapNamespace, getSpecialDefaultValue, getXmlReasonSessionKey, getXsds, getXSModels, isAddNamespaceToSchema, isConfiguredForMixedValidation, isFullSchemaChecking, isThrowException, isUseBaseImportedSchemaLocationsToIgnore, 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, validate
Methods inherited from class org.frankframework.pipes.AbstractValidator
determineForward, doPipe, getResponseRoot, getRoot, getSchemaSessionKey, isForwardFailureToSuccess, setForwardFailureToSuccess, setSchemaSessionKey, validate, validate
Methods inherited from class org.frankframework.pipes.FixedForwardPipe
getIfParam, getIfValue, getOnlyIfSessionKey, getOnlyIfValue, getParameterValue, getSuccessForward, getUnlessSessionKey, getUnlessValue, isSkipOnEmptyInput, setIfParam, setIfValue, setOnlyIfSessionKey, setOnlyIfValue, setSkipOnEmptyInput, setUnlessSessionKey, setUnlessValue, skipPipe
Methods inherited from class org.frankframework.pipes.AbstractPipe
addForward, addParameter, consumesSessionVariable, createBean, findForward, getAdapter, getApplicationContext, getChompCharSize, getConfigurationClassLoader, getDurationThreshold, getElementToMove, getElementToMoveChain, getElementToMoveSessionKey, getEmptyInputReplacement, getEventSourceName, getForwards, getGetInputFromFixedValue, getGetInputFromSessionKey, getHideRegex, getLocker, getLogIntermediaryResults, getMaxThreads, getName, getParameterList, getPipeLine, getSecLogSessionKeys, getStoreResultInSessionKey, hasRegisteredForward, isPreserveInput, isRemoveCompactMsgNamespaces, isRestoreMovedElements, isWriteToSecLog, registerEvent, setApplicationContext, setChompCharSize, setDurationThreshold, setElementToMove, setElementToMoveChain, setElementToMoveSessionKey, setEmptyInputReplacement, setEventPublisher, setGetInputFromFixedValue, setGetInputFromSessionKey, setHideRegex, setLocker, setLogIntermediaryResults, setMaxThreads, setName, setPipeLine, setPreserveInput, setRemoveCompactMsgNamespaces, setRestoreMovedElements, setSecLogSessionKeys, setSizeStatistics, setStoreResultInSessionKey, setWriteToSecLog, sizeStatisticsEnabled, throwEvent
Methods inherited from class org.frankframework.core.TransactionAttributes
configureTransactionAttributes, getTransactionAttribute, getTransactionTimeout, getTxDef, isTransacted, isTransacted, setTransacted, setTransactionAttribute, setTransactionTimeout
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContext
Methods inherited from interface org.frankframework.core.IConfigurationAware
getApplicationContext, getName
Methods inherited from interface org.frankframework.core.IForwardTarget
getName
Methods inherited from interface org.frankframework.core.INamedObject
getName
Methods 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, throwEvent
Methods inherited from interface org.frankframework.core.IScopeProvider
getConfigurationClassLoader
Methods inherited from interface org.frankframework.core.IValidator
setName, validate
-
Field Details
-
INPUT_FORMAT_SESSION_KEY_PREFIX
- See Also:
-
-
Constructor Details
-
Json2XmlValidator
public Json2XmlValidator()
-
-
Method Details
-
configure
Description copied from class:XmlValidator
Configure the XmlValidator- Specified by:
configure
in interfaceIConfigurable
- Specified by:
configure
in interfaceIPipe
- Overrides:
configure
in classXmlValidator
- Throws:
ConfigurationException
- when:- the schema cannot be found
- <
XmlValidator.isThrowException()
is false and 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:
doPipe
in classXmlValidator
- Throws:
PipeRunException
- whenisThrowException
is true and a validationerror occurred.
-
getJsonRootValidations
-
alignXml2Json
protected PipeRunResult alignXml2Json(String messageToValidate, PipeLineSession session, boolean responseMode) throws XmlValidatorException, PipeRunException, ConfigurationException -
alignJson
protected PipeRunResult alignJson(String messageToValidate, PipeLineSession session, boolean responseMode) throws PipeRunException, XmlValidatorException -
addNamespace
-
createJsonSchema
-
createJsonSchema
-
getPhysicalDestinationName
- Specified by:
getPhysicalDestinationName
in interfaceHasPhysicalDestination
-
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) If true, 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) If true assume arrays in JSON do not have the element containers like in XML- Default value
- true
-
setStrictJsonArraySyntax
public void setStrictJsonArraySyntax(boolean strictJsonArraySyntax) If true check 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) If true, assume that JSON contains/must contain a root element- Default value
- false
-
setDeepSearch
public void setDeepSearch(boolean deepSearch) If true, 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) If true, 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) If true, 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) If true, 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) If true, 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
-
getDomain
- Specified by:
getDomain
in interfaceHasPhysicalDestination
-
isCompactJsonArrays
public boolean isCompactJsonArrays() -
isStrictJsonArraySyntax
public boolean isStrictJsonArraySyntax() -
isJsonWithRootElements
public boolean isJsonWithRootElements() -
isDeepSearch
public boolean isDeepSearch() -
isIgnoreUndeclaredElements
public boolean isIgnoreUndeclaredElements() -
getTargetNamespace
-
getOutputFormat
-
isAutoFormat
public boolean isAutoFormat() -
getInputFormatSessionKey
-
getOutputFormatSessionKey
-
isFailOnWildcards
public boolean isFailOnWildcards() -
isAcceptNamespacelessXml
public boolean isAcceptNamespacelessXml() -
isProduceNamespacelessXml
public boolean isProduceNamespacelessXml() -
isValidateJsonToRootElementOnly
public boolean isValidateJsonToRootElementOnly() -
isAllowJson
public boolean isAllowJson()
-