From 553743327f983d0b7df29e775e326fab4e88833a Mon Sep 17 00:00:00 2001 From: Clemens Zagler Date: Wed, 18 Dec 2024 16:14:35 +0100 Subject: [PATCH 1/2] traffic-provbz: add logging for failed request --- .../java/it/bz/odh/trafficprovbz/FamasClient.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/data-collectors/traffic-provBZ/src/main/java/it/bz/odh/trafficprovbz/FamasClient.java b/data-collectors/traffic-provBZ/src/main/java/it/bz/odh/trafficprovbz/FamasClient.java index d920b1fd..41e9aa22 100644 --- a/data-collectors/traffic-provBZ/src/main/java/it/bz/odh/trafficprovbz/FamasClient.java +++ b/data-collectors/traffic-provBZ/src/main/java/it/bz/odh/trafficprovbz/FamasClient.java @@ -120,13 +120,19 @@ public AggregatedDataDto[] getAggregatedDataOnStations(String stationId, String payload.put("IdPostazioni", stationIdArray); payload.put("InizioPeriodo", startPeriod); payload.put("FinePeriodo", endPeriod); - StringEntity stringEntity = new StringEntity(String.valueOf(payload), + String payloadString = payload.toJSONString(); + StringEntity stringEntity = new StringEntity(payloadString, ContentType.APPLICATION_JSON); HttpPost request = new HttpPost(aggregatedDataOnStationsUrl); request.setEntity(stringEntity); - HttpEntity entity = client.execute(request).getEntity(); - String responseString = EntityUtils.toString(entity, RESPONSE_CHARSET); - return objectMapper.readValue(responseString, AggregatedDataDto[].class); + try { + HttpEntity entity = client.execute(request).getEntity(); + String responseString = EntityUtils.toString(entity, RESPONSE_CHARSET); + return objectMapper.readValue(responseString, AggregatedDataDto[].class); + } catch (Exception e) { + LOG.error("Dumping request object: " + payloadString); + throw e; + } } /** From f12a50376ffdccda95bc82b95352c426210985d7 Mon Sep 17 00:00:00 2001 From: Clemens Zagler Date: Thu, 19 Dec 2024 14:00:36 +0100 Subject: [PATCH 2/2] radelt: change cookie settings in API call to solve warnings --- .../main/java/com/opendatahub/bdp/radelt/RadeltAPIClient.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/data-collectors/radelt/src/main/java/com/opendatahub/bdp/radelt/RadeltAPIClient.java b/data-collectors/radelt/src/main/java/com/opendatahub/bdp/radelt/RadeltAPIClient.java index 0e8d9853..6d8ef091 100644 --- a/data-collectors/radelt/src/main/java/com/opendatahub/bdp/radelt/RadeltAPIClient.java +++ b/data-collectors/radelt/src/main/java/com/opendatahub/bdp/radelt/RadeltAPIClient.java @@ -9,6 +9,7 @@ import org.apache.http.HttpEntity; import org.apache.http.client.HttpClient; +import org.apache.http.client.config.CookieSpecs; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; @@ -49,6 +50,7 @@ public static CloseableHttpClient httpClient(){ .setConnectTimeout(timeout) .setSocketTimeout(timeout) .setConnectionRequestTimeout(timeout) + .setCookieSpec(CookieSpecs.STANDARD) .build(); return HttpClientBuilder.create().setDefaultRequestConfig(rc).build(); }