diff --git a/backend/src/main/app-resources/default.yml b/backend/src/main/app-resources/default.yml index 5ba247176..aa73f8627 100644 --- a/backend/src/main/app-resources/default.yml +++ b/backend/src/main/app-resources/default.yml @@ -24,14 +24,13 @@ ## Only set the installationID if you wish to define the ID used by the beacon. RECOMMENDED: ignore - a default random value will be used ## Only change the urls if instructed or if you wish to redirect for testing (if multiple, separate list with commas ## Only change the productName for testing purposes -## Set the cron time to send the beacon data at a specific time - if unset, the system will send at a random time between 12AM and 4AM once per day +## Set the cron time to send the beacon data at a specific time - if unset, the system will send at a random time between 12AM and 4AM once per day (random preferred) # beacon: # enabled: ture # installationID: [user-defined value] # urls: http://collector.testbed.tier.internet2.edu:5001 # productName: ShibUI -# send: -# cron: 0 4 * * * * +# cron: 0 59 3 * * ? # pac4j-enabled: true # pac4j: diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/configuration/CoreShibUiConfiguration.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/configuration/CoreShibUiConfiguration.java index 1e5582651..8e746bbf1 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/configuration/CoreShibUiConfiguration.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/configuration/CoreShibUiConfiguration.java @@ -277,7 +277,7 @@ public LockProvider lockProvider(DataSource dataSource) { } @Bean - public String getBeaconCronValue(BeaconConfigurationRepository repo) + public String getBeaconCronValue(BeaconConfigurationRepository repo, @Value("${shibui.beacon.cron}") String valueFromConfig) { Optional obc = repo.findById(1); BeaconConfiguration bc; @@ -286,8 +286,16 @@ public String getBeaconCronValue(BeaconConfigurationRepository repo) BeaconConfiguration newbc = new BeaconConfiguration(); Random rand = new Random(); String cron = "0 " + rand.nextInt(60) + " " + rand.nextInt(4) + " * * ?"; + if (valueFromConfig.endsWith("?")) { + cron = valueFromConfig; + } newbc.setSendCron(cron); - repo.save(newbc); + try { + repo.save(newbc); + } + catch(Exception e) { + log.debug("Error trying to create new BEACON CRON - should be ok"); + } bc = repo.findById(1).get(); } else { bc = obc.get(); diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/domain/BeaconConfiguration.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/domain/BeaconConfiguration.java index c3b263c77..b78034dbf 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/domain/BeaconConfiguration.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/domain/BeaconConfiguration.java @@ -6,6 +6,7 @@ import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Transient; +import javax.persistence.Version; @Data @Entity @@ -17,6 +18,9 @@ public class BeaconConfiguration { private String sendCron; + @Version + private Long version; + // Comma separated list of the auth mechanisms used. @Setter @Transient diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 14f726125..e46938360 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -123,6 +123,7 @@ shibui.beacon.enabled=true shibui.beacon.productName=ShibUi shibui.beacon.installationID=UNICON-SHIBUI-TESTING shibui.beacon.url=http://collector.testbed.tier.internet2.edu:5001 +#shibui.beacon.cron=0 59 3 * * ? ### Swagger/Springdoc patterns springdoc.use-management-port=true