public JSONAware handlePostRequest ( String pUri , InputStream pInputStream , String pEncoding , Map < String , String [ ] > pParameterMap ) throws IOException { if ( backendManager . isDebug ( ) ) { logHandler . debug ( "URI: " + pUri ) ; } Object jsonRequest = extractJsonRequest ( pInputStream , pEncoding ) ; if ( jsonRequest instanceof JSONArray ) { List < JmxRequest > jmxRequests = JmxRequestFactory . createPostRequests ( ( List ) jsonRequest , getProcessingParameter ( pParameterMap ) ) ; JSONArray responseList = new JSONArray ( ) ; for ( JmxRequest jmxReq : jmxRequests ) { if ( backendManager . isDebug ( ) ) { logHandler . debug ( "Request: " + jmxReq . toString ( ) ) ; } // Call handler and retrieve return value JSONObject resp = executeRequest ( jmxReq ) ; responseList . add ( resp ) ; } return responseList ; } else if ( jsonRequest instanceof JSONObject ) { JmxRequest jmxReq = JmxRequestFactory . createPostRequest ( ( Map < String , ? > ) jsonRequest , getProcessingParameter ( pParameterMap ) ) ; return executeRequest ( jmxReq ) ; } else { throw new IllegalArgumentException ( "Invalid JSON Request " + jsonRequest ) ; } }
Handle the input stream as given by a POST request