Skip to content

Commit d21714e

Browse files
Add codeUpdateTime to config
1 parent 630b4d2 commit d21714e

File tree

5 files changed

+49
-7
lines changed

5 files changed

+49
-7
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ARG CI_COMMIT_SHA
2727
LABEL git-commit=$CI_COMMIT_SHA
2828
COPY --from=build /app/proxyserver/target/efspserver-with-deps.jar /app/
2929
COPY config /app/
30-
COPY LICENSE config/client_sign.propertie[s] config/quartz.properties config/Suffolk.pf[x] /app/
30+
COPY LICENSE /app/
3131
COPY Docker/docker_run_script.sh Docker/fly_startup_script.sh /app/
3232

3333
EXPOSE 9000

config/application.prod.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
edu.suffolk.litlab.efsp.codeUpdateTime = 02:13
2+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
edu.suffolk.litlab.efsp.codeUpdateTime = 19:35
2+

proxyserver/src/main/java/edu/suffolk/litlab/efsp/server/EfspServer.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,17 @@
3131
import edu.suffolk.litlab.efsp.tyler.TylerEnv;
3232
import edu.suffolk.litlab.efsp.utils.InterviewToFilingInformationConverter;
3333
import jakarta.ws.rs.core.MediaType;
34+
import java.io.FileInputStream;
3435
import java.security.NoSuchAlgorithmException;
3536
import java.sql.Connection;
3637
import java.sql.SQLException;
38+
import java.time.LocalTime;
3739
import java.util.ArrayList;
3840
import java.util.HashMap;
3941
import java.util.List;
4042
import java.util.Map;
4143
import java.util.Optional;
44+
import java.util.Properties;
4245
import java.util.function.Supplier;
4346
import javax.sql.DataSource;
4447
import org.apache.cxf.endpoint.Server;
@@ -50,7 +53,9 @@
5053
import org.slf4j.LoggerFactory;
5154

5255
public class EfspServer {
53-
private static Logger log = LoggerFactory.getLogger(EfspServer.class);
56+
private static final Logger log = LoggerFactory.getLogger(EfspServer.class);
57+
58+
private static final String CODES_UPDATE_TIME_PROP = "edu.suffolk.litlab.efsp.codeUpdateTime";
5459

5560
private JAXRSServerFactoryBean sf;
5661
private Server server;
@@ -220,13 +225,32 @@ public static void main(String[] args) throws Exception {
220225
throw new RuntimeException("TOGA_CLIENT_KEYS and TYLER_JURISDICTION mismatch");
221226
}
222227

228+
LocalTime codesUpdateTime = LocalTime.of(2, 13);
229+
if (tylerEnv.isPresent()) {
230+
var propertiesFile = "application." + tylerEnv.get().getName() + ".properties";
231+
log.info("Loading {}", propertiesFile);
232+
try (var is = new FileInputStream(propertiesFile)) {
233+
Properties properties = new Properties();
234+
properties.load(is);
235+
String time = properties.getProperty(CODES_UPDATE_TIME_PROP);
236+
codesUpdateTime = LocalTime.parse(time);
237+
}
238+
}
239+
223240
List<EfmModuleSetup> modules = new ArrayList<>();
224241
for (int idx = 0; idx < jurisdictions.size(); idx++) {
225242
String jurisdiction = jurisdictions.get(idx);
226243
if (jurisdiction.isBlank()) {
227244
continue;
228245
}
229-
TylerModuleSetup.create(jurisdiction, togaKeys.get(idx), converterMap, codeDs, userDs, sender)
246+
TylerModuleSetup.create(
247+
jurisdiction,
248+
togaKeys.get(idx),
249+
codesUpdateTime,
250+
converterMap,
251+
codeDs,
252+
userDs,
253+
sender)
230254
.ifPresent(mod -> modules.add(mod));
231255
}
232256
JeffNetModuleSetup.create(converterMap, userDs, sender).ifPresent(mod -> modules.add(mod));

proxyserver/src/main/java/edu/suffolk/litlab/efsp/server/setup/tyler/TylerModuleSetup.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import edu.suffolk.litlab.efsp.tyler.TylerEnv;
2929
import edu.suffolk.litlab.efsp.utils.InterviewToFilingInformationConverter;
3030
import java.sql.SQLException;
31+
import java.time.LocalTime;
3132
import java.util.HashMap;
3233
import java.util.HashSet;
3334
import java.util.List;
@@ -62,13 +63,14 @@ public class TylerModuleSetup implements EfmModuleSetup {
6263
private final DataSource codeDs;
6364
private final DataSource userDs;
6465
private final Map<String, InterviewToFilingInformationConverter> converterMap;
66+
private final TylerEnv tylerEnv;
67+
private final LocalTime codesDbUpdateTime;
6568

6669
// Payments Stuff
6770
private final String togaKey;
6871
private final String togaUrl;
6972
private OrgMessageSender sender;
7073
private Scheduler scheduler;
71-
private TylerEnv tylerEnv;
7274

7375
public static class CreationArgs {
7476
public String pgUrl;
@@ -84,6 +86,7 @@ public static class CreationArgs {
8486
public static Optional<TylerModuleSetup> create(
8587
String jurisdiction,
8688
String togaKey,
89+
LocalTime codesDbUpdateTime,
8790
Map<String, InterviewToFilingInformationConverter> converterMap,
8891
DataSource codeDs,
8992
DataSource userDs,
@@ -95,13 +98,21 @@ public static Optional<TylerModuleSetup> create(
9598

9699
return Optional.of(
97100
new TylerModuleSetup(
98-
args.get(), jurisdiction, togaKey, converterMap, codeDs, userDs, sender));
101+
args.get(),
102+
jurisdiction,
103+
togaKey,
104+
codesDbUpdateTime,
105+
converterMap,
106+
codeDs,
107+
userDs,
108+
sender));
99109
}
100110

101111
private TylerModuleSetup(
102112
CreationArgs args,
103113
String jurisdiction,
104114
String togaKey,
115+
LocalTime codesDbUpdateTime,
105116
Map<String, InterviewToFilingInformationConverter> converterMap,
106117
DataSource codeDs,
107118
DataSource userDs,
@@ -119,6 +130,7 @@ private TylerModuleSetup(
119130
this.togaKey = togaKey;
120131
this.togaUrl = args.togaUrl;
121132
this.sender = sender;
133+
this.codesDbUpdateTime = codesDbUpdateTime;
122134
}
123135

124136
private static Optional<CreationArgs> createFromEnvVars() {
@@ -215,16 +227,18 @@ public void preSetup() {
215227
scheduler.start();
216228

217229
// Always schedule daily codes update.
230+
int hour = codesDbUpdateTime.getHour();
231+
int min = codesDbUpdateTime.getMinute();
218232
var r = new Random();
219233
String triggerName = "trigger-" + this.tylerJurisdiction + "-" + this.tylerEnv;
220234
Trigger trigger =
221235
TriggerBuilder.newTrigger()
222236
.withIdentity(triggerName, "codesdb-group")
223237
.startNow()
224-
.withSchedule(CronScheduleBuilder.dailyAtHourAndMinute(2, 13 + r.nextInt(4)))
238+
.withSchedule(CronScheduleBuilder.dailyAtHourAndMinute(hour, min + r.nextInt(4)))
225239
.build();
226240

227-
log.info("Scheduling daily Tyler EFM code update job.");
241+
log.info("Scheduling daily Tyler EFM code update job around {}", codesDbUpdateTime);
228242
scheduler.scheduleJob(
229243
buildJob("job-" + this.tylerJurisdiction + "-" + this.tylerEnv), trigger);
230244

0 commit comments

Comments
 (0)