From 8066653bff5e3cc0d125f30099dd048334c58e7c Mon Sep 17 00:00:00 2001 From: chasegawa Date: Wed, 21 Jun 2023 10:55:15 -0700 Subject: [PATCH] SHIBUI-2586 Added logging output when data is sent to beacon --- .../admin/ui/scheduled/BeaconReportingTask.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/scheduled/BeaconReportingTask.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/scheduled/BeaconReportingTask.java index 5c25c8603..65d430b40 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/scheduled/BeaconReportingTask.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/scheduled/BeaconReportingTask.java @@ -1,6 +1,7 @@ package edu.internet2.tier.shibboleth.admin.ui.scheduled; import edu.internet2.tier.shibboleth.admin.ui.service.IBeaconDataService; +import lombok.extern.slf4j.Slf4j; import net.javacrumbs.shedlock.spring.annotation.EnableSchedulerLock; import net.javacrumbs.shedlock.spring.annotation.SchedulerLock; import org.springframework.beans.factory.annotation.Autowired; @@ -14,11 +15,13 @@ import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.List; @Configuration @ConditionalOnProperty(name = "shibui.beacon.enabled", matchIfMissing=true) @EnableSchedulerLock(defaultLockAtMostFor = "${shibui.maxTask.lockTime:30m}") +@Slf4j public class BeaconReportingTask { @Autowired IBeaconDataService dataService; @@ -38,11 +41,13 @@ public void sendBeaconData() { con.setRequestProperty("Content-Type", "application/json; utf-8"); con.setRequestProperty("Accept", "application/json"); con.setDoOutput(true); - try(OutputStream os = con.getOutputStream()){ - byte[] input = dataService.getBeaconData().getBytes("utf-8"); + try (OutputStream os = con.getOutputStream()) { + byte[] input = dataService.getBeaconData().getBytes(StandardCharsets.UTF_8); os.write(input, 0, input.length); } - } catch (IOException e) { + log.info("TIER Beacon data sent to {} with response code: {}", url, con.getResponseCode()); + } + catch (IOException e) { e.printStackTrace(); } });