private PayloadTemplateMessageBuilder parsePayloadTemplateBuilder ( Element messageElement ) { PayloadTemplateMessageBuilder messageBuilder ; messageBuilder = parsePayloadElement ( messageElement ) ; Element xmlDataElement = DomUtils . getChildElementByTagName ( messageElement , "data" ) ; if ( xmlDataElement != null ) { messageBuilder = new PayloadTemplateMessageBuilder ( ) ; messageBuilder . setPayloadData ( DomUtils . getTextValue ( xmlDataElement ) . trim ( ) ) ; } Element xmlResourceElement = DomUtils . getChildElementByTagName ( messageElement , "resource" ) ; if ( xmlResourceElement != null ) { messageBuilder = new PayloadTemplateMessageBuilder ( ) ; messageBuilder . setPayloadResourcePath ( xmlResourceElement . getAttribute ( "file" ) ) ; if ( xmlResourceElement . hasAttribute ( "charset" ) ) { messageBuilder . setPayloadResourceCharset ( xmlResourceElement . getAttribute ( "charset" ) ) ; } } if ( messageBuilder != null ) { Map < String , String > overwriteXpath = new HashMap <> ( ) ; Map < String , String > overwriteJsonPath = new HashMap <> ( ) ; List < ? > messageValueElements = DomUtils . getChildElementsByTagName ( messageElement , "element" ) ; for ( Iterator < ? > iter = messageValueElements . iterator ( ) ; iter . hasNext ( ) ; ) { Element messageValue = ( Element ) iter . next ( ) ; String pathExpression = messageValue . getAttribute ( "path" ) ; if ( JsonPathMessageValidationContext . isJsonPathExpression ( pathExpression ) ) { overwriteJsonPath . put ( pathExpression , messageValue . getAttribute ( "value" ) ) ; } else { overwriteXpath . put ( pathExpression , messageValue . getAttribute ( "value" ) ) ; } } if ( ! overwriteXpath . isEmpty ( ) ) { XpathMessageConstructionInterceptor interceptor = new XpathMessageConstructionInterceptor ( overwriteXpath ) ; messageBuilder . add ( interceptor ) ; } if ( ! overwriteJsonPath . isEmpty ( ) ) { JsonPathMessageConstructionInterceptor interceptor = new JsonPathMessageConstructionInterceptor ( overwriteJsonPath ) ; messageBuilder . add ( interceptor ) ; } } return messageBuilder ; }
Parses message payload template information given in message element .