Java Code Examples for org.noggit.JSONParser#ParseException
The following examples show how to use
org.noggit.JSONParser#ParseException .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SolrCLI.java From lucene-solr with Apache License 2.0 | 6 votes |
public Map<String,Object> handleResponse(HttpResponse response) throws ClientProtocolException, IOException { HttpEntity entity = response.getEntity(); if (entity != null) { String respBody = EntityUtils.toString(entity); Object resp = null; try { resp = fromJSONString(respBody); } catch (JSONParser.ParseException pe) { throw new ClientProtocolException("Expected JSON response from server but received: "+respBody+ "\nTypically, this indicates a problem with the Solr server; check the Solr server logs for more information."); } if (resp != null && resp instanceof Map) { return (Map<String,Object>)resp; } else { throw new ClientProtocolException("Expected JSON object in response but received "+ resp); } } else { StatusLine statusLine = response.getStatusLine(); throw new HttpResponseException(statusLine.getStatusCode(), statusLine.getReasonPhrase()); } }
Example 2
Source File: TestSolrConfigHandlerConcurrent.java From lucene-solr with Apache License 2.0 | 6 votes |
@SuppressWarnings({"rawtypes"}) public static LinkedHashMapWriter getAsMap(String uri, CloudSolrClient cloudClient) throws Exception { HttpGet get = new HttpGet(uri) ; HttpEntity entity = null; try { entity = cloudClient.getLbClient().getHttpClient().execute(get).getEntity(); String response = EntityUtils.toString(entity, StandardCharsets.UTF_8); try { return (LinkedHashMapWriter) Utils.MAPWRITEROBJBUILDER.apply(new JSONParser(new StringReader(response))).getVal(); } catch (JSONParser.ParseException e) { log.error(response,e); throw e; } } finally { EntityUtils.consumeQuietly(entity); get.releaseConnection(); } }
Example 3
Source File: TestSolrConfigHandler.java From lucene-solr with Apache License 2.0 | 5 votes |
@SuppressWarnings({"rawtypes"}) public static LinkedHashMapWriter getRespMap(String path, RestTestHarness restHarness) throws Exception { String response = restHarness.query(path); try { return (LinkedHashMapWriter) Utils.MAPWRITEROBJBUILDER.apply(Utils.getJSONParser(new StringReader(response))).getVal(); } catch (JSONParser.ParseException e) { log.error(response); return new LinkedHashMapWriter(); } }
Example 4
Source File: RecordingJSONParser.java From lucene-solr with Apache License 2.0 | 4 votes |
public JSONParser.ParseException error(String msg) { return err(msg); }