mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 08:27:14 +02:00
Add utility methods for copying time transition maps and filtering grace periods
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=130281141
This commit is contained in:
parent
19da9a1531
commit
57ec8b3ae3
2 changed files with 42 additions and 0 deletions
|
@ -125,6 +125,17 @@ public class TimedTransitionProperty<V, T extends TimedTransitionProperty.TimedT
|
||||||
makeTransitionMap(valueMap, timedTransitionSubclass)));
|
makeTransitionMap(valueMap, timedTransitionSubclass)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new immutable {@code TimedTransitionProperty} containing the same transitions as the
|
||||||
|
* current object, up to but not including the desired date. All transitions on or after that date
|
||||||
|
* will be deleted.
|
||||||
|
*
|
||||||
|
* @param asOfDate the date before which transitions should be retained
|
||||||
|
*/
|
||||||
|
public TimedTransitionProperty<V, T> copyUntilJustBefore(DateTime asOfDate) {
|
||||||
|
return new TimedTransitionProperty<>(backingMap.headMap(asOfDate, false));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new mutable {@code TimedTransitionProperty} representing the given map of DateTime
|
* Returns a new mutable {@code TimedTransitionProperty} representing the given map of DateTime
|
||||||
* to value, with transitions constructed using the given {@code TimedTransition} subclass.
|
* to value, with transitions constructed using the given {@code TimedTransition} subclass.
|
||||||
|
|
|
@ -217,6 +217,37 @@ public class DomainResource extends DomainBase implements ForeignKeyedEppResourc
|
||||||
return ImmutableSet.copyOf(gracePeriodStatuses);
|
return ImmutableSet.copyOf(gracePeriodStatuses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Registry Grace Period expiration date for the specified type of grace period for
|
||||||
|
* this domain, or null if there is no grace period of the specified type.
|
||||||
|
*/
|
||||||
|
public Optional<DateTime> getGracePeriodExpirationTime(GracePeriodStatus gracePeriodType) {
|
||||||
|
for (GracePeriod gracePeriod : getGracePeriods()) {
|
||||||
|
if (gracePeriod.getType() == gracePeriodType) {
|
||||||
|
return Optional.of(gracePeriod.getExpirationTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Optional.absent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks to see if the domain is in a particular type of grace period at the specified time. We
|
||||||
|
* only check the expiration time, because grace periods are always assumed to start at the
|
||||||
|
* beginning of time. This could be confusing if asOfDate is in the past. For instance, the Add
|
||||||
|
* Grace Period will appear to last from the beginning of time until 5 days after the domain is
|
||||||
|
* created.
|
||||||
|
*/
|
||||||
|
public boolean doesAnyGracePeriodOfTypeExpireAfter(
|
||||||
|
GracePeriodStatus gracePeriodType, DateTime asOfDate) {
|
||||||
|
for (GracePeriod gracePeriod : getGracePeriods()) {
|
||||||
|
if ((gracePeriod.getType() == gracePeriodType)
|
||||||
|
&& gracePeriod.getExpirationTime().isAfter(asOfDate)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The logic in this method, which handles implicit server approval of transfers, very closely
|
* The logic in this method, which handles implicit server approval of transfers, very closely
|
||||||
* parallels the logic in {@code DomainTransferApproveFlow} which handles explicit client
|
* parallels the logic in {@code DomainTransferApproveFlow} which handles explicit client
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue