public static ConfigOverlay getConfigOverlay(SolrResourceLoader loader) { InputStream in = null; InputStreamReader isr = null; try { try { in = loader.openResource(ConfigOverlay.RESOURCE_NAME); } catch (IOException e) { // TODO: we should be explicitly looking for file not found exceptions // and logging if it's not the expected IOException // hopefully no problem, assume no overlay.json file return new ConfigOverlay(Collections.EMPTY_MAP, -1); } int version = 0; // will be always 0 for file based resourceLoader if (in instanceof ZkSolrResourceLoader.ZkByteArrayInputStream) { version = ((ZkSolrResourceLoader.ZkByteArrayInputStream) in).getStat().getVersion(); log.info("config overlay loaded . version : {} ", version); } isr = new InputStreamReader(in, StandardCharsets.UTF_8); Map m = (Map) ObjectBuilder.getVal(new JSONParser(isr)); return new ConfigOverlay(m, version); } catch (Exception e) { throw new SolrException(ErrorCode.SERVER_ERROR, "Error reading config overlay", e); } finally { IOUtils.closeQuietly(isr); IOUtils.closeQuietly(in); } }
public static void runConfigCommand(RestTestHarness harness, String uri, String payload) throws IOException { String json = SolrTestCaseJ4.json(payload); log.info("going to send config command. path {} , payload: {}", uri, payload); String response = harness.post(uri, json); Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response))); assertNull(response, map.get("errors")); }
public static Map getRespMap(String path, RestTestHarness restHarness) throws Exception { String response = restHarness.query(path); try { return (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response))); } catch (JSONParser.ParseException e) { log.error(response); return Collections.emptyMap(); } }
@Override protected Object parseText(Reader reader, String resourceId) throws IOException { return ObjectBuilder.getVal(new JSONParser(reader)); }