/** * Call executor and parse the JSON response as an instance of the class given as an argument. */ <T> T callForJsonType(final String host, final int port, final String path, final List<Pair<String, String>> paramList, final Class<T> valueType) throws IOException { final String responseString = callForJsonString(host, port, path, paramList); if (null == responseString || responseString.length() == 0) { return null; } return new ObjectMapper().readValue(responseString, valueType); }
Map<String, Object> callForJsonObjectMap(final String host, final int port, final String path, final List<Pair<String, String>> paramList) throws IOException { final String responseString = callForJsonString(host, port, path, paramList); @SuppressWarnings("unchecked") final Map<String, Object> jsonResponse = (Map<String, Object>) JSONUtils.parseJSONFromString(responseString); final String error = (String) jsonResponse.get(ConnectorParams.RESPONSE_ERROR); if (error != null) { throw new IOException(error); } return jsonResponse; }
/** * Call executor and parse the JSON response as an instance of the class given as an argument. */ <T> T callForJsonType(final String host, final int port, final String path, final List<Pair<String, String>> paramList, final Class<T> valueType) throws IOException { final String responseString = callForJsonString(host, port, path, paramList); if (null == responseString || responseString.length() == 0) { return null; } return new ObjectMapper().readValue(responseString, valueType); }
Map<String, Object> callForJsonObjectMap(final String host, final int port, final String path, final List<Pair<String, String>> paramList) throws IOException { final String responseString = callForJsonString(host, port, path, paramList); @SuppressWarnings("unchecked") final Map<String, Object> jsonResponse = (Map<String, Object>) JSONUtils.parseJSONFromString(responseString); final String error = (String) jsonResponse.get(ConnectorParams.RESPONSE_ERROR); if (error != null) { throw new IOException(error); } return jsonResponse; }