From db7c7dbff7812f52612d286e4e73a8cc44861fb2 Mon Sep 17 00:00:00 2001 From: Giuseppe La Scaleia Date: Tue, 12 Oct 2021 08:59:19 +0200 Subject: [PATCH] Added WebSocketBase Implementation --- .../downloader/DPCRadarDataStompSessionHandler.java | 5 +++-- .../radar/downloader/DPCWebsocketMessage.java | 10 ++++++---- .../protezionecivile/radar/downloader/StompClient.java | 5 +++-- java/src/main/resources/application.properties | 5 +++-- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/java/src/main/java/gov/protezionecivile/radar/downloader/DPCRadarDataStompSessionHandler.java b/java/src/main/java/gov/protezionecivile/radar/downloader/DPCRadarDataStompSessionHandler.java index 1a89967..2cfd8be 100644 --- a/java/src/main/java/gov/protezionecivile/radar/downloader/DPCRadarDataStompSessionHandler.java +++ b/java/src/main/java/gov/protezionecivile/radar/downloader/DPCRadarDataStompSessionHandler.java @@ -287,6 +287,7 @@ import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Profile; import org.springframework.messaging.simp.stomp.StompCommand; import org.springframework.messaging.simp.stomp.StompHeaders; import org.springframework.messaging.simp.stomp.StompSession; @@ -301,7 +302,7 @@ /** * @author Francesco Izzi @ CNR IMAA geoSDI */ - +@Profile(value = "stomp") @Component(value = "dpcSessionHandler") public class DPCRadarDataStompSessionHandler extends StompSessionHandlerAdapter implements InitializingBean { @@ -311,7 +312,7 @@ public class DPCRadarDataStompSessionHandler extends StompSessionHandlerAdapter public String productToDownload; @Value("${defaultSavePath}") public String defaultSavePath; - private final String DOWNLOAD_PRODUCT_URL = "https://radar.protezionecivile.gov.it/wide-api/wide/product/downloadProduct"; + private final String DOWNLOAD_PRODUCT_URL = "https://radar-api.protezionecivile.it/wide/product/downloadProduct"; private StompClient stompClient; @Override diff --git a/java/src/main/java/gov/protezionecivile/radar/downloader/DPCWebsocketMessage.java b/java/src/main/java/gov/protezionecivile/radar/downloader/DPCWebsocketMessage.java index 5622007..27599ac 100644 --- a/java/src/main/java/gov/protezionecivile/radar/downloader/DPCWebsocketMessage.java +++ b/java/src/main/java/gov/protezionecivile/radar/downloader/DPCWebsocketMessage.java @@ -276,6 +276,8 @@ */ package gov.protezionecivile.radar.downloader; +import java.util.Date; + /** * @author Francesco Izzi @ CNR IMAA geoSDI */ @@ -283,7 +285,7 @@ public class DPCWebsocketMessage { private String productType; - private String time; + private Date time; private String period; public String getProductType() { @@ -294,11 +296,11 @@ public void setProductType(String productType) { this.productType = productType; } - public String getTime() { + public Date getTime() { return time; } - public void setTime(String time) { + public void setTime(Date time) { this.time = time; } @@ -314,7 +316,7 @@ public String toJsonString(){ return "{" + "\"productType\":"+"\"" + getProductType() +"\"," + - "\"productDate\":"+ getTime() + + "\"productDate\":"+ getTime().getTime() + "}"; } diff --git a/java/src/main/java/gov/protezionecivile/radar/downloader/StompClient.java b/java/src/main/java/gov/protezionecivile/radar/downloader/StompClient.java index c60d27e..01002ab 100644 --- a/java/src/main/java/gov/protezionecivile/radar/downloader/StompClient.java +++ b/java/src/main/java/gov/protezionecivile/radar/downloader/StompClient.java @@ -281,6 +281,7 @@ import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Profile; import org.springframework.messaging.converter.MappingJackson2MessageConverter; import org.springframework.messaging.simp.stomp.StompSession; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; @@ -295,13 +296,13 @@ /** * @author Francesco Izzi @ CNR IMAA geoSDI */ - +@Profile(value = "stomp") @Component public class StompClient { private static final Logger logger = LogManager.getLogger(StompClient.class); // - private static String RADAR_WEBSOCKET_URL = "wss://radar.protezionecivile.gov.it/wide-websocket"; + protected static String RADAR_WEBSOCKET_URL = "wss://8ielgrmwo6.execute-api.eu-south-1.amazonaws.com/Prod"; @Autowired @Qualifier(value = "dpcSessionHandler") diff --git a/java/src/main/resources/application.properties b/java/src/main/resources/application.properties index 2e6a2ac..2e76cf3 100644 --- a/java/src/main/resources/application.properties +++ b/java/src/main/resources/application.properties @@ -1,2 +1,3 @@ -productToDownload = HRD,LTG -defaultSavePath = /Users/francescoizzi/Desktop/DATI_RADAR/ +productToDownload=HRD,LTG,SRI,SRT3,VMI,SRT1,IR108 +defaultSavePath=/Users/glascaleia/Desktop/DATI_RADAR/ +spring.profiles.active=without_stomp \ No newline at end of file