From 5c3ef5f25b4610d76f1791becd02566c7672cc8e Mon Sep 17 00:00:00 2001 From: Enrico Ottonello Date: Fri, 24 Jul 2020 18:32:28 +0200 Subject: [PATCH] retrieved body from server response --- .../ariadneplus/workflows/nodes/IndexOnESJobNode.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dnet-ariadneplus/src/main/java/eu/dnetlib/ariadneplus/workflows/nodes/IndexOnESJobNode.java b/dnet-ariadneplus/src/main/java/eu/dnetlib/ariadneplus/workflows/nodes/IndexOnESJobNode.java index 5396ac3..74a0a3a 100644 --- a/dnet-ariadneplus/src/main/java/eu/dnetlib/ariadneplus/workflows/nodes/IndexOnESJobNode.java +++ b/dnet-ariadneplus/src/main/java/eu/dnetlib/ariadneplus/workflows/nodes/IndexOnESJobNode.java @@ -1,6 +1,8 @@ package eu.dnetlib.ariadneplus.workflows.nodes; import com.google.common.collect.Lists; +import com.google.gson.Gson; +import eu.dnetlib.enabling.resultset.ResultSetInfo; import eu.dnetlib.enabling.resultset.client.ResultSetClient; import eu.dnetlib.msro.workflows.graph.Arc; import eu.dnetlib.msro.workflows.nodes.AsyncJobNode; @@ -10,6 +12,7 @@ import eu.dnetlib.msro.workflows.util.ResultsetProgressProvider; import eu.dnetlib.msro.workflows.util.WorkflowsConstants; import eu.dnetlib.rmi.common.ResultSet; import eu.dnetlib.rmi.manager.MSROException; +import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.NameValuePair; @@ -24,6 +27,7 @@ import org.apache.http.message.BasicNameValuePair; import org.springframework.beans.factory.annotation.Autowired; import java.io.IOException; +import java.io.InputStream; import java.net.ConnectException; import java.util.List; @@ -69,9 +73,8 @@ public class IndexOnESJobNode extends AsyncJobNode { log.info("Calling IndexOnES endpoint with params: "+getDatasource()+" "+getDatasourceInterface()); responsePOST = client.execute(post); statusCode = responsePOST.getStatusLine().getStatusCode(); - try { - log.info(responsePOST.toString()); - indexOnESResult = responsePOST.getEntity().getContent().toString(); + try(InputStream responseBody = responsePOST.getEntity().getContent()) { + indexOnESResult = IOUtils.toString(responseBody, "UTF-8"); } catch (Exception e) {} switch (statusCode) { case 200: @@ -98,7 +101,6 @@ public class IndexOnESJobNode extends AsyncJobNode { env.setAttribute(WorkflowsConstants.MAIN_LOG_PREFIX + "statusCode", Integer.toString(statusCode)); env.setAttribute(WorkflowsConstants.MAIN_LOG_PREFIX + "indexResult", indexOnESResult); - log.info(indexOnESResult); if (statusCode!=200) { throw new MSROException("Error from Publisher endpoint [ status code: " + statusCode + " ]"); }