mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 17:07:15 +02:00
Return all applicable reserved list entries associated with a label
Instead of only returning the most severe one, return all applicable ones. This is because the reserved list has grown to a list of types that are not strictly comparable but orthogonal to each other. We can no longer depend on the fact that the most severe type incorporates all properties of those beneath it. Therefore returning all of them and treat them one by one in the calling site is the correct behavior. Due to constraint imposed in eppcom.xsd, during domain checks the response can only contain a reservation reason of fewer than 32 characters, therefore we are returning the message for the type with highest severity, in case of multiple reservation types for a label. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=149776106
This commit is contained in:
parent
9a11f125ff
commit
ebcdae7361
8 changed files with 199 additions and 86 deletions
|
@ -21,7 +21,7 @@ import static google.registry.flows.ResourceFlowUtils.verifyResourceDoesNotExist
|
|||
import static google.registry.flows.domain.DomainFlowUtils.cloneAndLinkReferences;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.createFeeCreateResponse;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.failfastForCreate;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.getReservationType;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.getReservationTypes;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.prepareMarkedLrpTokenEntity;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateCreateCommandContactsAndNameservers;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateDomainName;
|
||||
|
@ -85,6 +85,7 @@ import google.registry.model.registry.Registry;
|
|||
import google.registry.model.registry.label.ReservationType;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.tmch.LordnTask;
|
||||
import java.util.Set;
|
||||
import javax.inject.Inject;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
|
@ -169,7 +170,7 @@ public class DomainAllocateFlow implements TransactionalFlow {
|
|||
.addGracePeriod(createGracePeriod(
|
||||
isSunrushAddGracePeriod, getOnly(billsAndPolls, BillingEvent.OneTime.class)))
|
||||
// Names on the collision list will not be delegated. Set server hold.
|
||||
.setStatusValues(ReservationType.NAME_COLLISION == getReservationType(domainName)
|
||||
.setStatusValues(getReservationTypes(domainName).contains(ReservationType.NAME_COLLISION)
|
||||
? ImmutableSet.of(StatusValue.SERVER_HOLD)
|
||||
: ImmutableSet.<StatusValue>of())
|
||||
.setRegistrant(command.getRegistrant())
|
||||
|
@ -241,7 +242,7 @@ public class DomainAllocateFlow implements TransactionalFlow {
|
|||
BillingEvent.OneTime oneTimeBillingEvent = createOneTimeBillingEvent(
|
||||
application, historyEntry, isSunrushAddGracePeriod, registry, now, years);
|
||||
PollMessage.OneTime oneTimePollMessage =
|
||||
createOneTimePollMessage(application, historyEntry, getReservationType(domainName), now);
|
||||
createOneTimePollMessage(application, historyEntry, getReservationTypes(domainName), now);
|
||||
// Create a new autorenew billing event and poll message starting at the expiration time.
|
||||
BillingEvent.Recurring autorenewBillingEvent =
|
||||
createAutorenewBillingEvent(historyEntry, registrationExpirationTime);
|
||||
|
@ -336,23 +337,26 @@ public class DomainAllocateFlow implements TransactionalFlow {
|
|||
private PollMessage.OneTime createOneTimePollMessage(
|
||||
DomainApplication application,
|
||||
HistoryEntry historyEntry,
|
||||
ReservationType reservationType,
|
||||
Set<ReservationType> reservationTypes,
|
||||
DateTime now) {
|
||||
return new PollMessage.OneTime.Builder()
|
||||
.setClientId(historyEntry.getClientId())
|
||||
.setEventTime(now)
|
||||
.setMsg(reservationType == ReservationType.NAME_COLLISION
|
||||
? COLLISION_MESSAGE // Remind the registrar of the name collision policy.
|
||||
: "Domain was allocated")
|
||||
.setResponseData(ImmutableList.of(
|
||||
DomainPendingActionNotificationResponse.create(
|
||||
targetId, true, application.getCreationTrid(), now)))
|
||||
.setResponseExtensions(ImmutableList.of(
|
||||
new LaunchInfoResponseExtension.Builder()
|
||||
.setApplicationId(application.getForeignKey())
|
||||
.setPhase(application.getPhase())
|
||||
.setApplicationStatus(ApplicationStatus.ALLOCATED)
|
||||
.build()))
|
||||
.setMsg(
|
||||
reservationTypes.contains(ReservationType.NAME_COLLISION)
|
||||
? COLLISION_MESSAGE // Remind the registrar of the name collision policy.
|
||||
: "Domain was allocated")
|
||||
.setResponseData(
|
||||
ImmutableList.of(
|
||||
DomainPendingActionNotificationResponse.create(
|
||||
targetId, true, application.getCreationTrid(), now)))
|
||||
.setResponseExtensions(
|
||||
ImmutableList.of(
|
||||
new LaunchInfoResponseExtension.Builder()
|
||||
.setApplicationId(application.getForeignKey())
|
||||
.setPhase(application.getPhase())
|
||||
.setApplicationStatus(ApplicationStatus.ALLOCATED)
|
||||
.build()))
|
||||
.setParent(historyEntry)
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ package google.registry.flows.domain;
|
|||
import static google.registry.flows.FlowUtils.validateClientIsLoggedIn;
|
||||
import static google.registry.flows.ResourceFlowUtils.verifyTargetIdCount;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.checkAllowedAccessToTld;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.getReservationType;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.getReservationTypes;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.handleFeeRequest;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateDomainName;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateDomainNameWithIdnTables;
|
||||
|
@ -25,6 +25,7 @@ import static google.registry.flows.domain.DomainFlowUtils.verifyNotInPredelegat
|
|||
import static google.registry.model.EppResourceUtils.checkResourcesExist;
|
||||
import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
|
||||
import static google.registry.model.registry.label.ReservationType.UNRESERVED;
|
||||
import static google.registry.model.registry.label.ReservationType.getTypeOfHighestSeverity;
|
||||
import static google.registry.pricing.PricingEngineProxy.isDomainPremium;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
@ -179,14 +180,15 @@ public final class DomainCheckFlow implements Flow {
|
|||
}})) {
|
||||
return "Pending allocation";
|
||||
}
|
||||
ReservationType reservationType = getReservationType(domainName);
|
||||
if (reservationType == UNRESERVED
|
||||
ImmutableSet<ReservationType> reservationTypes = getReservationTypes(domainName);
|
||||
if (reservationTypes.equals(ImmutableSet.of(UNRESERVED))
|
||||
&& isDomainPremium(domainName.toString(), now)
|
||||
&& registry.getPremiumPriceAckRequired()
|
||||
&& eppInput.getSingleExtension(FeeCheckCommandExtension.class) == null) {
|
||||
return "Premium names require EPP ext.";
|
||||
}
|
||||
return reservationType.getMessageForCheck();
|
||||
|
||||
return getTypeOfHighestSeverity(reservationTypes).getMessageForCheck();
|
||||
}
|
||||
|
||||
/** Handle the fee check extension. */
|
||||
|
|
|
@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkState;
|
|||
import static com.google.common.base.Predicates.equalTo;
|
||||
import static com.google.common.collect.Iterables.any;
|
||||
import static com.google.common.collect.Sets.difference;
|
||||
import static com.google.common.collect.Sets.intersection;
|
||||
import static com.google.common.collect.Sets.union;
|
||||
import static google.registry.flows.domain.DomainPricingLogic.getMatchingLrpToken;
|
||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||
|
@ -26,7 +27,6 @@ import static google.registry.model.domain.DomainResource.MAX_REGISTRATION_YEARS
|
|||
import static google.registry.model.domain.DomainResource.extendRegistrationWithCap;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.registry.Registries.findTldForName;
|
||||
import static google.registry.model.registry.label.ReservedList.getReservation;
|
||||
import static google.registry.pricing.PricingEngineProxy.isDomainPremium;
|
||||
import static google.registry.tldconfig.idn.IdnLabelValidator.findValidIdnTableForTld;
|
||||
import static google.registry.util.CollectionUtils.nullToEmpty;
|
||||
|
@ -102,6 +102,7 @@ import google.registry.model.registrar.Registrar;
|
|||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.registry.Registry.TldState;
|
||||
import google.registry.model.registry.label.ReservationType;
|
||||
import google.registry.model.registry.label.ReservedList;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.tmch.ClaimsListShard;
|
||||
import google.registry.util.Idn;
|
||||
|
@ -351,16 +352,17 @@ public class DomainFlowUtils {
|
|||
}
|
||||
|
||||
private static boolean isReserved(InternetDomainName domainName, boolean isSunrise) {
|
||||
ReservationType type = getReservationType(domainName);
|
||||
return type == ReservationType.FULLY_BLOCKED
|
||||
|| type == ReservationType.RESERVED_FOR_ANCHOR_TENANT
|
||||
|| (TYPES_ALLOWED_FOR_CREATE_ONLY_IN_SUNRISE.contains(type) && !isSunrise);
|
||||
ImmutableSet<ReservationType> types = getReservationTypes(domainName);
|
||||
return types.contains(ReservationType.FULLY_BLOCKED)
|
||||
|| types.contains(ReservationType.RESERVED_FOR_ANCHOR_TENANT)
|
||||
|| !(isSunrise || intersection(TYPES_ALLOWED_FOR_CREATE_ONLY_IN_SUNRISE, types).isEmpty());
|
||||
}
|
||||
|
||||
/** Returns an enum that encodes how and when this name is reserved in the current tld. */
|
||||
static ReservationType getReservationType(InternetDomainName domainName) {
|
||||
/** Returns a set of {@link ReservationType}s for the given domain name. */
|
||||
static ImmutableSet<ReservationType> getReservationTypes(InternetDomainName domainName) {
|
||||
// The TLD should always be the parent of the requested domain name.
|
||||
return getReservation(domainName.parts().get(0), domainName.parent().toString());
|
||||
return ReservedList.getReservationTypes(
|
||||
domainName.parts().get(0), domainName.parent().toString());
|
||||
}
|
||||
|
||||
/** Verifies that a launch extension's specified phase matches the specified registry's phase. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue