Merge "Issue #2469 Refined deletion of adhoc subs." into development
Former-commit-id:f5208d359a
[formerly6cdbad069a
] [formerly1d85220363
] [formerly1b7b6f0134
[formerly1d85220363
[formerly 2ff6d9a5e793e7673ddf8d5e5c5b25cf3235e12e]]] Former-commit-id:1b7b6f0134
Former-commit-id: 0cd653cbbf4d6de4d91974c87380cb964aeb3f6f [formerlyc27c764c61
] Former-commit-id:4b612a3fa0
This commit is contained in:
commit
e5ae2ac89f
1 changed files with 24 additions and 9 deletions
|
@ -52,6 +52,7 @@ import com.raytheon.uf.edex.database.purge.PurgeRuleSet;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 11, 2013 2460 dhladky Initial creation
|
||||
* Oct 23, 2013 2469 dhladky Refined the time check and accommodation for lack of purge rules.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -63,6 +64,8 @@ public class AdhocSubscriptionCleaner {
|
|||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(AdhocSubscriptionCleaner.class);
|
||||
|
||||
private static final String DEFAULT_RULE = "00-12:00:00";
|
||||
|
||||
public AdhocSubscriptionCleaner() {
|
||||
|
||||
|
@ -150,17 +153,29 @@ public class AdhocSubscriptionCleaner {
|
|||
if (purgeRuleSet != null) {
|
||||
|
||||
List<PurgeRule> rules = purgeRuleSet.getRules();
|
||||
// if no rules exist, create a default, 12 hours
|
||||
if (rules.isEmpty()) {
|
||||
rules = new ArrayList<PurgeRule>();
|
||||
PurgeRule rule = new PurgeRule();
|
||||
rule.setPeriod(DEFAULT_RULE);
|
||||
rules.add(rule);
|
||||
}
|
||||
|
||||
// Go over all of the purge rules for each sub
|
||||
for (PurgeRule rule: rules) {
|
||||
// use current system date/time
|
||||
long timeCheck = TimeUtil.newDate().getTime();
|
||||
Date expireDate = new Date(timeCheck + rule.getPeriodInMillis());
|
||||
|
||||
// check rule against creation time of this sub
|
||||
if (adhoc.getTime().getEnd().before(expireDate)) {
|
||||
if (!subsToDelete.contains(adhoc)) {
|
||||
subsToDelete.add(adhoc);
|
||||
for (PurgeRule rule : rules) {
|
||||
// use a valid rule
|
||||
if (rule.getPeriodInMillis() != 0) {
|
||||
// use current system date/time
|
||||
Date compareTime = TimeUtil.newDate();
|
||||
Date expireDate = new Date(adhoc.getTime()
|
||||
.getStart().getTime()
|
||||
+ rule.getPeriodInMillis());
|
||||
|
||||
if (expireDate.before(compareTime)) {
|
||||
if (!subsToDelete.contains(adhoc)) {
|
||||
subsToDelete.add(adhoc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue