public JSONObject invokeJson ( ) throws InternalException , CloudException { ClientAndResponse clientAndResponse = null ; String content ; try { clientAndResponse = invokeInternal ( ) ; Header contentType = clientAndResponse . response . getFirstHeader ( "content-type" ) ; if ( ! "application/json" . equalsIgnoreCase ( contentType . getValue ( ) ) ) { throw new CloudException ( "Invalid Glacier response: expected JSON" ) ; } final HttpEntity entity = clientAndResponse . response . getEntity ( ) ; content = EntityUtils . toString ( entity ) ; if ( content == null ) { return null ; } return new JSONObject ( content ) ; } catch ( IOException e ) { throw new CloudException ( e ) ; } catch ( JSONException e ) { throw new CloudException ( e ) ; } finally { if ( clientAndResponse != null ) { clientAndResponse . client . getConnectionManager ( ) . shutdown ( ) ; } } }
Invokes the method and returns the response body as a JSON object