Merge "Issue #2459 - Add unscheduled as a slot attribute" into omaha_14.2.1
Former-commit-id:a35da2dc28
[formerlyad8125bdfc
] [formerlyc4fd162842
] [formerlyc4fd162842
[formerlyf599d2582f
]] [formerlya35da2dc28
[formerlyad8125bdfc
] [formerlyc4fd162842
] [formerlyc4fd162842
[formerlyf599d2582f
]] [formerly8c993338bb
[formerlyc4fd162842
[formerlyf599d2582f
] [formerly8c993338bb
[formerly 1f8e60301301e4be3186ce09e569e7117a350a6d]]]]] Former-commit-id:8c993338bb
Former-commit-id:9a90123085
[formerly80f7874733
] [formerlye45d202e2c
] [formerly efc8d0510810c588d0650512abed62e06a0eb613 [formerly a80a249535a0ac50d506b7844b830a62dd6df906] [formerlye45d202e2c
[formerlyce4b2e6941
]]] Former-commit-id: d11324faf753c2fdb447952c67e5ce8527386a9d [formerly 73983dca0e8790272f4c99908c3bbca4da409b57] [formerly938f0c0b07
[formerlyc64d313a32
]] Former-commit-id:938f0c0b07
Former-commit-id:31a50f45aa
This commit is contained in:
commit
90e108f4a4
1 changed files with 20 additions and 8 deletions
|
@ -216,6 +216,7 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
|||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@SlotAttribute
|
||||
private boolean unscheduled;
|
||||
|
||||
@XmlAttribute
|
||||
|
@ -267,6 +268,9 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
|||
@SlotAttribute(Subscription.SUBSCRIPTION_STATE_SLOT)
|
||||
private SubscriptionState subscriptionState;
|
||||
|
||||
/** Flag stating if the object should be updated */
|
||||
private boolean shouldUpdate = false;
|
||||
|
||||
/**
|
||||
* Get subscription name.
|
||||
*
|
||||
|
@ -878,18 +882,18 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
|||
}
|
||||
|
||||
/**
|
||||
* Determine if subscription status is expired.
|
||||
* Determine if subscription status is expired and set subscription to off
|
||||
* if it is expired.
|
||||
*
|
||||
* @return true if status is expired
|
||||
*/
|
||||
private boolean isExpired() {
|
||||
private boolean checkAndSetExpiration() {
|
||||
Calendar cal = TimeUtil.newGmtCalendar();
|
||||
Date today = cal.getTime();
|
||||
boolean expired = false;
|
||||
if (this.getSubscriptionEnd() != null
|
||||
&& today.after(this.getSubscriptionEnd())) {
|
||||
if (subscriptionEnd != null && cal.getTime().after(subscriptionEnd)) {
|
||||
expired = true;
|
||||
this.subscriptionState = SubscriptionState.OFF;
|
||||
this.shouldUpdate = true;
|
||||
}
|
||||
|
||||
return expired;
|
||||
|
@ -904,7 +908,7 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
|||
public SubscriptionStatus getStatus() {
|
||||
if (!isValid()) {
|
||||
return SubscriptionStatus.INVALID;
|
||||
} else if (isExpired()) {
|
||||
} else if (checkAndSetExpiration()) {
|
||||
return SubscriptionStatus.EXPIRED;
|
||||
} else if (subscriptionState == SubscriptionState.OFF) {
|
||||
return SubscriptionStatus.DEACTIVATED;
|
||||
|
@ -931,7 +935,8 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
|||
* @return true if this subscription should be scheduled
|
||||
*/
|
||||
public boolean shouldSchedule() {
|
||||
return subscriptionState == SubscriptionState.ON && !isExpired();
|
||||
return subscriptionState == SubscriptionState.ON
|
||||
&& !checkAndSetExpiration();
|
||||
}
|
||||
|
||||
private boolean inWindow(Date checkDate) {
|
||||
|
@ -1065,7 +1070,7 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
|||
*/
|
||||
@Override
|
||||
public void activate() {
|
||||
if (valid && !isExpired()) {
|
||||
if (valid && !checkAndSetExpiration()) {
|
||||
this.setSubscriptionState(SubscriptionState.ON);
|
||||
}
|
||||
}
|
||||
|
@ -1077,4 +1082,11 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
|||
public void deactivate() {
|
||||
this.setSubscriptionState(SubscriptionState.OFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the shouldUpdate
|
||||
*/
|
||||
public boolean shouldUpdate() {
|
||||
return shouldUpdate;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue