diff options
author | Thomas <> | 2021-04-30 08:11:11 +0200 |
---|---|---|
committer | Thomas <> | 2021-04-30 08:11:11 +0200 |
commit | e106b43bcd3dd5a9ac04c389fe2cbbb814874b87 (patch) | |
tree | 179207afbcb6ad61860029237d79e10c376cf765 /moaSig | |
parent | 38c3a15d00414fb3967555481131e55e6a21fbd1 (diff) | |
download | moa-sig-e106b43bcd3dd5a9ac04c389fe2cbbb814874b87.tar.gz moa-sig-e106b43bcd3dd5a9ac04c389fe2cbbb814874b87.tar.bz2 moa-sig-e106b43bcd3dd5a9ac04c389fe2cbbb814874b87.zip |
update TSL update mechanism to check every 5 minutes if EU TSL is loaded. Start a reloading operation if not.
Diffstat (limited to 'moaSig')
3 files changed, 65 insertions, 8 deletions
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java index 28231e6..7cb23df 100644 --- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java +++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java @@ -59,6 +59,14 @@ import iaik.utils.RFC2253NameParser; * @version $Id$ */ public class SystemInitializer { + + /** + * 15 min TSL reload scheduler interval. + */ + private static final long TSL_SCHEDULE_INTERVAL = 5*60*1000; + + + /** Interval between archive cleanups in seconds */ private static final long ARCHIVE_CLEANUP_INTERVAL = 60 * 60; // 1h /** The MOA SP/SS logging hierarchy. */ @@ -254,12 +262,14 @@ public class SystemInitializer { if (start.before(now)) { start = new Date(start.getTime() + 86400000); } - + Logger.debug(new LogMsg(msg.getMessage("config.46", new String[] { start.toString(), "" + period }))); // start TSL updater task final Timer timer = new Timer("TSL_DB_Updater"); - timer.schedule(new TSLUpdaterTimerTask(), start, period); + timer.schedule(new TSLUpdaterTimerTask(start, period), + new Date(now.getTime() + TSL_SCHEDULE_INTERVAL), TSL_SCHEDULE_INTERVAL); + } } diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/monitoring/ServiceStatusContainer.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/monitoring/ServiceStatusContainer.java index 9c5bef3..6c05a99 100644 --- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/monitoring/ServiceStatusContainer.java +++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/monitoring/ServiceStatusContainer.java @@ -9,7 +9,8 @@ public class ServiceStatusContainer { public static final String STATUS_NOT_SET = "no status message"; public static final String STATUS_OK = "ok"; - + public static final String STATUS_ERROR_EUTSL = "EU TSL failed"; + private static boolean TSLStatusValid = false; private static String TSLStatusMsg = STATUS_NOT_SET; private static List<TSLProcessingResultElement> tslDetailStatus = null; diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/tsl/timer/TSLUpdaterTimerTask.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/tsl/timer/TSLUpdaterTimerTask.java index 1a377b6..b5303fd 100644 --- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/tsl/timer/TSLUpdaterTimerTask.java +++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/tsl/timer/TSLUpdaterTimerTask.java @@ -1,5 +1,6 @@ package at.gv.egovernment.moa.spss.tsl.timer;
+import java.util.Date;
import java.util.TimerTask;
import at.gv.egovernment.moa.sig.tsl.exception.TslException;
@@ -12,17 +13,63 @@ import at.gv.egovernment.moaspss.logging.Logger; public class TSLUpdaterTimerTask extends TimerTask {
+ private static final String COUNTRY_CODE_EU = "EU";
+
+ private Date configuratedTslUpdateDate;
+ private final long configuratedTslUpdateInterval;
+
+
+ /**
+ * Create a TSL Update Task for scheduler.
+ *
+ * @param start Date when TSL should forced to reloaded first time
+ * @param period TSL force reload interval
+ */
+ public TSLUpdaterTimerTask(Date start, long period) {
+ this.configuratedTslUpdateDate = start;
+ this.configuratedTslUpdateInterval = period;
+
+ }
+
@Override
public void run() {
+
+ Date now = new Date();
+
+ if (!ServiceStatusContainer.getStatus()) {
+ Logger.info("EU TSL is not loaded. Starting TSL reload process ... ");
+ performTslUpdate();
+
+ } else if (this.configuratedTslUpdateDate.before(now)) {
+ performTslUpdate();
+ this.configuratedTslUpdateDate = new Date(now.getTime() + this.configuratedTslUpdateInterval);
+
+ } else {
+ Logger.trace("EU TSL is loaded and next TSL force update is at: " + this.configuratedTslUpdateDate);
+
+ }
+
+ }
+ private void performTslUpdate() {
try {
Logger.info("Start TSL Update");
TSLServiceFactory.getTSLServiceClient().updateTSLInformation();
Logger.info("Finished TSL Update");
+ boolean isEuTslLoaded = TSLServiceFactory.getTSLServiceClient().getCurrentTSLClientStatus().stream()
+ .filter(el -> COUNTRY_CODE_EU.equalsIgnoreCase(el.getCountryCode()))
+ .findFirst()
+ .map(el -> el.isProcessed() && el.isVerified())
+ .orElse(false);
+
+ Logger.debug("Current EU-TSL status is: "
+ + (isEuTslLoaded ? ServiceStatusContainer.STATUS_OK : ServiceStatusContainer.STATUS_ERROR_EUTSL));
+
// set global TSL client status
- ServiceStatusContainer.setStatus(true);
- ServiceStatusContainer.setStatusMsg(ServiceStatusContainer.STATUS_OK);
+ ServiceStatusContainer.setStatus(isEuTslLoaded);
+ ServiceStatusContainer.setStatusMsg(
+ isEuTslLoaded ? ServiceStatusContainer.STATUS_OK : ServiceStatusContainer.STATUS_ERROR_EUTSL);
} catch (final TslUpdateException e) {
final MessageProvider msg = MessageProvider.getInstance();
@@ -42,8 +89,7 @@ public class TSLUpdaterTimerTask extends TimerTask { ServiceStatusContainer.setStatusMsg(
new LogMsg(msg.getMessage("tsl.00", null)).toString());
- }
-
+ }
}
-
+
}
|