Skip to content

Commit

Permalink
SHIBUI-2596
Browse files Browse the repository at this point in the history
Adjustments to the cron for sending
  • Loading branch information
chasegawa committed Jul 12, 2023
1 parent b15f0a2 commit 5991dba
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
5 changes: 2 additions & 3 deletions backend/src/main/app-resources/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<BeaconConfiguration> obc = repo.findById(1);
BeaconConfiguration bc;
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Transient;
import javax.persistence.Version;

@Data
@Entity
Expand All @@ -17,6 +18,9 @@ public class BeaconConfiguration {

private String sendCron;

@Version
private Long version;

// Comma separated list of the auth mechanisms used.
@Setter
@Transient
Expand Down
1 change: 1 addition & 0 deletions backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5991dba

Please sign in to comment.