public static String getRequestPayloadOutput ( Request params , File file ) { StringBuilder payload = new StringBuilder ( ) ; String uuid = getUUID ( ) ; payload . append ( ONCLICK_TOGGLE ) . append ( uuid ) . append ( "\")'>Toggle Payload</a> " ) ; payload . append ( SPAN_ID ) . append ( uuid ) . append ( DISPLAY_NONE ) ; if ( params != null && params . getJsonPayload ( ) != null ) { Gson gson = new GsonBuilder ( ) . setPrettyPrinting ( ) . create ( ) ; payload . append ( DIV ) ; payload . append ( formatHTML ( gson . toJson ( params . getJsonPayload ( ) ) ) ) ; payload . append ( END_DIV ) ; } if ( params != null && params . getMultipartData ( ) != null ) { for ( Map . Entry < String , Object > entry : params . getMultipartData ( ) . entrySet ( ) ) { payload . append ( DIV ) ; payload . append ( entry . getKey ( ) ) ; payload . append ( " : " ) ; payload . append ( entry . getValue ( ) ) ; payload . append ( END_DIV ) ; } } if ( file != null ) { payload . append ( "<div> with file: <a href='file:///" ) . append ( file . getAbsoluteFile ( ) ) . append ( "'>" ) . append ( file . getName ( ) ) . append ( "</a></div>" ) ; } payload . append ( END_SPAN ) ; if ( payload . toString ( ) . equals ( ONCLICK_TOGGLE + uuid + "\")'>Toggle Payload</a> " + SPAN_ID + uuid + DISPLAY_NONE + END_SPAN ) ) { return "" ; } else { return payload . toString ( ) ; } }
Formats the request parameters to be prettily printed out in HTML