Loading Java_MarkLogic_Template/MarkLogic_Template/src/main/java/edu/psu/MarkLogic/demo/controller/MLRestController.java +7 −3 Original line number Diff line number Diff line Loading @@ -164,7 +164,7 @@ public class MLRestController { @GetMapping(value = "/restQueryDoc", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<ArrayList<ConfidenceFitness>> restQueryDoc(@RequestParam("query_string") String query_string) { byte[] ba = null; ArrayList<ConfidenceFitness> alcf = new ArrayList<>(); query_string = query_string.replace(" ", "%20"); // a space is changed to the HTML code %20 to prevent error JsonNode actualObj = null; Loading @@ -182,10 +182,13 @@ public class MLRestController { HttpResponse response = httpClient.execute(request); System.out.println(response.toString()); HttpEntity e = response.getEntity(); String content = IOUtils.toString(my_uri); // please provide code using IOUtils.toString method to get content (how?) ByteArrayOutputStream baos = new ByteArrayOutputStream(); response.getEntity().writeTo(baos); ba = baos.toByteArray(); // provide the code to get byte[] String content = IOUtils.toString(ba, "UTF-8"); // please provide code using IOUtils.toString method to get content (how?) System.out.println("content: " + content); ObjectMapper mapper = new ObjectMapper(); actualObj = mapper.readTree(content); Loading @@ -197,6 +200,7 @@ public class MLRestController { // provide code to complete the content for the cf object cf.setConfidence(jn.get("confidence").asDouble()); cf.setFitness(jn.get("fitness").asDouble()); //System.out.println(cf.getUri() + "\n" + cf.getConfidence() + "\n" + cf.getFitness()); alcf.add(cf); } } Loading Loading
Java_MarkLogic_Template/MarkLogic_Template/src/main/java/edu/psu/MarkLogic/demo/controller/MLRestController.java +7 −3 Original line number Diff line number Diff line Loading @@ -164,7 +164,7 @@ public class MLRestController { @GetMapping(value = "/restQueryDoc", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<ArrayList<ConfidenceFitness>> restQueryDoc(@RequestParam("query_string") String query_string) { byte[] ba = null; ArrayList<ConfidenceFitness> alcf = new ArrayList<>(); query_string = query_string.replace(" ", "%20"); // a space is changed to the HTML code %20 to prevent error JsonNode actualObj = null; Loading @@ -182,10 +182,13 @@ public class MLRestController { HttpResponse response = httpClient.execute(request); System.out.println(response.toString()); HttpEntity e = response.getEntity(); String content = IOUtils.toString(my_uri); // please provide code using IOUtils.toString method to get content (how?) ByteArrayOutputStream baos = new ByteArrayOutputStream(); response.getEntity().writeTo(baos); ba = baos.toByteArray(); // provide the code to get byte[] String content = IOUtils.toString(ba, "UTF-8"); // please provide code using IOUtils.toString method to get content (how?) System.out.println("content: " + content); ObjectMapper mapper = new ObjectMapper(); actualObj = mapper.readTree(content); Loading @@ -197,6 +200,7 @@ public class MLRestController { // provide code to complete the content for the cf object cf.setConfidence(jn.get("confidence").asDouble()); cf.setFitness(jn.get("fitness").asDouble()); //System.out.println(cf.getUri() + "\n" + cf.getConfidence() + "\n" + cf.getFitness()); alcf.add(cf); } } Loading