Skip to content

Commit

Permalink
SHIBUI-2586
Browse files Browse the repository at this point in the history
Added logging output when data is sent to beacon
  • Loading branch information
chasegawa committed Jul 7, 2023
1 parent 90997b0 commit 8066653
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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();
}
});
Expand Down

0 comments on commit 8066653

Please sign in to comment.