print logs

This commit is contained in:
Alessia Bardi 2020-06-23 11:52:19 +02:00
parent fcabee9242
commit 743d948d1c
1 changed files with 11 additions and 3 deletions

View File

@ -2,6 +2,7 @@
package eu.dnetlib.dhp.oa.graph.dump.gcat;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.List;
@ -53,7 +54,9 @@ public class GCatAPIClient {
public int publish(final String jsonMetadata) throws IOException, URISyntaxException {
try (CloseableHttpClient client = HttpClients.createDefault()) {
URIBuilder builder = new URIBuilder(getGcatBaseURL() + itemPath);
HttpPost post = new HttpPost(builder.build());
URI uri = builder.build();
System.out.println(uri.toString());
HttpPost post = new HttpPost(uri);
post.setHeader("gcube-token", getApplicationToken());
post.addHeader("Content-Type", "application/json");
post.addHeader("Accept", "application/json");
@ -62,6 +65,7 @@ public class GCatAPIClient {
HttpResponse response = client.execute(post);
if (log.isDebugEnabled()) {
log.debug(response.getStatusLine());
System.out.println(response.getStatusLine());
log.debug(IOUtils.toString(response.getEntity().getContent()));
}
return response.getStatusLine().getStatusCode();
@ -82,7 +86,9 @@ public class GCatAPIClient {
URIBuilder builder = new URIBuilder(getGcatBaseURL() + itemPath)
.addParameter("offset", String.valueOf(offset))
.addParameter("limit", String.valueOf(limit));
HttpGet get = new HttpGet(builder.build());
URI uri = builder.build();
System.out.println(uri.toString());
HttpGet get = new HttpGet(uri);
get.setHeader("gcube-token", getApplicationToken());
get.addHeader("Content-Type", "application/json");
get.addHeader("Accept", "application/json");
@ -112,7 +118,9 @@ public class GCatAPIClient {
try (CloseableHttpClient client = HttpClients.createDefault()) {
URIBuilder builder = new URIBuilder(getGcatBaseURL() + itemPath + "/" + resCatName)
.addParameter("purge", "true");
HttpDelete del = new HttpDelete(builder.build());
URI uri = builder.build();
System.out.println(uri.toString());
HttpDelete del = new HttpDelete(uri);
del.setHeader("gcube-token", getApplicationToken());
del.addHeader("Content-Type", "application/json");
del.addHeader("Accept", "application/json");