mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Change second-level domain name to fully-qualified domain name
Second-level domain name isn't accurate because we support multi-part TLDs, so standardize on the "fullyQualifiedDomainName" name that is used throughout the code base. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=122693009
This commit is contained in:
parent
ca0e546230
commit
a2d2764115
14 changed files with 58 additions and 49 deletions
|
@ -21,7 +21,7 @@ import static google.registry.dns.DnsConstants.DNS_TARGET_NAME_PARAM;
|
|||
import static google.registry.dns.DnsConstants.DNS_TARGET_TYPE_PARAM;
|
||||
import static google.registry.model.registry.Registries.assertTldExists;
|
||||
import static google.registry.request.RequestParameters.PARAM_TLD;
|
||||
import static google.registry.util.DomainNameUtils.getTldFromSld;
|
||||
import static google.registry.util.DomainNameUtils.getTldFromDomainName;
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
|
||||
import com.google.appengine.api.taskqueue.Queue;
|
||||
|
@ -91,7 +91,7 @@ public class DnsQueue {
|
|||
return addToQueue(
|
||||
TargetType.DOMAIN,
|
||||
fullyQualifiedDomainName,
|
||||
assertTldExists(getTldFromSld(fullyQualifiedDomainName)));
|
||||
assertTldExists(getTldFromDomainName(fullyQualifiedDomainName)));
|
||||
}
|
||||
|
||||
/** Adds a task to the queue to refresh the DNS information for the specified zone. */
|
||||
|
|
|
@ -20,7 +20,7 @@ import static google.registry.model.EppResourceUtils.checkResourcesExist;
|
|||
import static google.registry.model.registry.label.ReservationType.UNRESERVED;
|
||||
import static google.registry.pricing.PricingEngineProxy.isPremiumName;
|
||||
import static google.registry.util.CollectionUtils.nullToEmpty;
|
||||
import static google.registry.util.DomainNameUtils.getTldFromSld;
|
||||
import static google.registry.util.DomainNameUtils.getTldFromDomainName;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
|
@ -116,7 +116,7 @@ public class DomainCheckFlow extends BaseDomainCheckFlow {
|
|||
}
|
||||
FeeCheck.Builder builder = new FeeCheck.Builder();
|
||||
handleFeeRequest(
|
||||
domainCheck, builder, domainName, getTldFromSld(domainName), getClientId(), now);
|
||||
domainCheck, builder, domainName, getTldFromDomainName(domainName), getClientId(), now);
|
||||
feeChecksBuilder.add(builder.setName(domainName).build());
|
||||
}
|
||||
return ImmutableList.of(FeeCheckResponseExtension.create(feeChecksBuilder.build()));
|
||||
|
|
|
@ -23,7 +23,7 @@ import static google.registry.util.CollectionUtils.nullToEmpty;
|
|||
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
||||
import static google.registry.util.CollectionUtils.nullToEmptyImmutableSortedCopy;
|
||||
import static google.registry.util.CollectionUtils.union;
|
||||
import static google.registry.util.DomainNameUtils.getTldFromSld;
|
||||
import static google.registry.util.DomainNameUtils.getTldFromDomainName;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
@ -237,7 +237,7 @@ public abstract class DomainBase extends EppResource {
|
|||
checkArgumentNotNull(
|
||||
emptyToNull(instance.fullyQualifiedDomainName), "Missing fullyQualifiedDomainName");
|
||||
checkArgumentNotNull(instance.registrant, "Missing registrant");
|
||||
instance.tld = getTldFromSld(instance.fullyQualifiedDomainName);
|
||||
instance.tld = getTldFromDomainName(instance.fullyQualifiedDomainName);
|
||||
instance.allContacts = union(
|
||||
instance.getContacts(),
|
||||
DesignatedContact.create(REGISTRANT, instance.registrant.getLinked()));
|
||||
|
|
|
@ -23,9 +23,12 @@ import org.joda.time.DateTime;
|
|||
public interface PricingEngine {
|
||||
|
||||
/**
|
||||
* Returns the premium price for the given second-level domain name at the given time for the
|
||||
* given registrar, or absent if the domain name isn't premium.
|
||||
* Returns the premium price for the given domain name at the given time for the given registrar,
|
||||
* or absent if the domain name isn't premium.
|
||||
*
|
||||
* <p>Note that fullyQualifiedDomainName must not include any subdomains. It should be a single
|
||||
* level above the TLD (which may be multi-part).
|
||||
*/
|
||||
public Optional<Money> getPremiumPrice(
|
||||
String secondLevelDomainName, DateTime priceTime, String clientIdentifier);
|
||||
String fullyQualifiedDomainName, DateTime priceTime, String clientIdentifier);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.model.pricing;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static google.registry.util.DomainNameUtils.getTldFromSld;
|
||||
import static google.registry.util.DomainNameUtils.getTldFromDomainName;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
|
@ -36,10 +36,10 @@ public final class StaticPremiumListPricingEngine implements PricingEngine {
|
|||
|
||||
@Override
|
||||
public Optional<Money> getPremiumPrice(
|
||||
String secondLevelDomainName, DateTime priceTime, String clientIdentifier) {
|
||||
String fullyQualifiedDomainName, DateTime priceTime, String clientIdentifier) {
|
||||
// Note that clientIdentifier and priceTime are not used for determining premium pricing for
|
||||
// static premium lists.
|
||||
String tld = getTldFromSld(secondLevelDomainName);
|
||||
String tld = getTldFromDomainName(fullyQualifiedDomainName);
|
||||
Registry registry = Registry.get(checkNotNull(tld, "tld"));
|
||||
if (registry.getPremiumList() == null) {
|
||||
return Optional.<Money>absent();
|
||||
|
@ -47,7 +47,7 @@ public final class StaticPremiumListPricingEngine implements PricingEngine {
|
|||
String listName = registry.getPremiumList().getName();
|
||||
Optional<PremiumList> premiumList = PremiumList.get(listName);
|
||||
checkState(premiumList.isPresent(), "Could not load premium list: %s", listName);
|
||||
String label = InternetDomainName.from(secondLevelDomainName).parts().get(0);
|
||||
String label = InternetDomainName.from(fullyQualifiedDomainName).parts().get(0);
|
||||
return premiumList.get().getPremiumPrice(label);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import static com.google.common.collect.Maps.filterValues;
|
|||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.util.CacheUtils.memoizeWithShortExpiration;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Supplier;
|
||||
|
@ -92,7 +93,7 @@ public final class Registries {
|
|||
*
|
||||
* <p><b>Note:</b> This routine will only work on names under TLDs for which this registry is
|
||||
* authoritative. To extract TLDs from domains (not hosts) that other registries control, use
|
||||
* {@link google.registry.util.DomainNameUtils#getTldFromSld(String)
|
||||
* {@link google.registry.util.DomainNameUtils#getTldFromDomainName(String)
|
||||
* DomainNameUtils#getTldFromDomainName}.
|
||||
*
|
||||
* @param domainName domain name or host name (but not TLD) under an authoritative TLD
|
||||
|
@ -114,7 +115,7 @@ public final class Registries {
|
|||
* match exists.
|
||||
*/
|
||||
public static InternetDomainName findTldForNameOrThrow(InternetDomainName domainName) {
|
||||
return checkNotNull(
|
||||
return checkArgumentNotNull(
|
||||
findTldForName(domainName).orNull(),
|
||||
"Domain name is not under a recognized TLD: %s", domainName.toString());
|
||||
}
|
||||
|
|
|
@ -158,7 +158,10 @@ public class Registry extends ImmutableObject implements Buildable {
|
|||
*/
|
||||
QUIET_PERIOD,
|
||||
|
||||
/** The steady state of a TLD in which all SLDs are available via first-come, first-serve. */
|
||||
/**
|
||||
* The steady state of a TLD in which all domain names are available via first-come,
|
||||
* first-serve.
|
||||
*/
|
||||
GENERAL_AVAILABILITY,
|
||||
|
||||
/** A "fake" state for use in predelegation testing. Acts like {@link #GENERAL_AVAILABILITY}. */
|
||||
|
|
|
@ -17,7 +17,7 @@ package google.registry.pricing;
|
|||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static google.registry.model.registry.Registries.assertTldExists;
|
||||
import static google.registry.util.DomainNameUtils.getTldFromSld;
|
||||
import static google.registry.util.DomainNameUtils.getTldFromDomainName;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
|
@ -74,7 +74,7 @@ public final class PricingEngineProxy {
|
|||
getPremiumPriceForDomainName(
|
||||
InternetDomainName.from(domainName), priceTime, clientIdentifier);
|
||||
return annualCost
|
||||
.or(Registry.get(getTldFromSld(domainName)).getStandardCreateCost())
|
||||
.or(Registry.get(getTldFromDomainName(domainName)).getStandardCreateCost())
|
||||
.multipliedBy(years);
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ public final class PricingEngineProxy {
|
|||
getPremiumPriceForDomainName(
|
||||
InternetDomainName.from(domainName), priceTime, clientIdentifier);
|
||||
return annualCost
|
||||
.or(Registry.get(getTldFromSld(domainName)).getStandardRenewCost(priceTime))
|
||||
.or(Registry.get(getTldFromDomainName(domainName)).getStandardRenewCost(priceTime))
|
||||
.multipliedBy(years);
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ public final class PricingEngineProxy {
|
|||
*/
|
||||
private static Optional<Money> getPremiumPriceForDomainName(
|
||||
InternetDomainName domainName, DateTime priceTime, String clientIdentifier) {
|
||||
String tld = assertTldExists(getTldFromSld(domainName));
|
||||
String tld = assertTldExists(getTldFromDomainName(domainName));
|
||||
String clazz = Registry.get(tld).getPricingEngineClassName();
|
||||
PricingEngine engine = pricingEngines.get(clazz);
|
||||
checkState(engine != null, "Could not load pricing engine %s for TLD %s", clazz, tld);
|
||||
|
|
|
@ -18,15 +18,16 @@ import static com.google.common.base.MoreObjects.firstNonNull;
|
|||
import static com.google.common.base.Strings.nullToEmpty;
|
||||
import static com.google.common.net.HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN;
|
||||
import static google.registry.model.eppcommon.ProtocolDefinition.ServiceExtension.FEE_0_6;
|
||||
import static google.registry.model.registry.Registries.findTldForNameOrThrow;
|
||||
import static google.registry.ui.server.SoyTemplateUtils.createTofuSupplier;
|
||||
import static google.registry.util.DomainNameUtils.canonicalizeDomainName;
|
||||
import static google.registry.util.DomainNameUtils.getTldFromSld;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.json.simple.JSONValue.toJSONString;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
import com.google.common.net.MediaType;
|
||||
import com.google.template.soy.tofu.SoyTofu;
|
||||
|
||||
|
@ -89,9 +90,9 @@ public class CheckApiServlet extends HttpServlet {
|
|||
try {
|
||||
domainString = canonicalizeDomainName(nullToEmpty(domainString));
|
||||
// Validate the TLD.
|
||||
getTldFromSld(domainString);
|
||||
findTldForNameOrThrow(InternetDomainName.from(domainString));
|
||||
} catch (IllegalStateException | IllegalArgumentException e) {
|
||||
return fail("Must supply a valid second level domain name");
|
||||
return fail("Must supply a valid domain name on an authoritative TLD");
|
||||
}
|
||||
try {
|
||||
byte[] inputXmlBytes = TOFU_SUPPLIER.get()
|
||||
|
|
|
@ -43,8 +43,7 @@ public final class DomainNameUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the canonicalized TLD part of a valid second level domain name by stripping off the
|
||||
* leftmost part.
|
||||
* Returns the canonicalized TLD part of a valid domain name by stripping off the leftmost part.
|
||||
*
|
||||
* <p>This function is compatible with multi-part tlds, e.g. {@code co.uk}. This function will
|
||||
* also work on domains for which the registry is not authoritative. If you are certain that the
|
||||
|
@ -52,26 +51,28 @@ public final class DomainNameUtils {
|
|||
* {@link google.registry.model.registry.Registries#findTldForName(InternetDomainName)
|
||||
* Registries#findTldForName}, which will work on hostnames in addition to domains.
|
||||
*
|
||||
* @param sld must be a punycode SLD (not a host or unicode)
|
||||
* @param fullyQualifiedDomainName must be a puny-coded domain name (not a subdomain or Unicode)
|
||||
* @throws IllegalArgumentException if there is no TLD
|
||||
*/
|
||||
public static String getTldFromSld(String sld) {
|
||||
checkArgument(!Strings.isNullOrEmpty(sld), "secondLevelDomainName cannot be null or empty");
|
||||
return getTldFromSld(InternetDomainName.from(sld));
|
||||
public static String getTldFromDomainName(String fullyQualifiedDomainName) {
|
||||
checkArgument(
|
||||
!Strings.isNullOrEmpty(fullyQualifiedDomainName),
|
||||
"fullyQualifiedDomainName cannot be null or empty");
|
||||
return getTldFromDomainName(InternetDomainName.from(fullyQualifiedDomainName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the canonicalized TLD part of a valid second level domain name by stripping off the
|
||||
* leftmost part.
|
||||
* Returns the canonicalized TLD part of a valid domain name by stripping off the leftmost part.
|
||||
*
|
||||
* <p>This function is compatible with multi-part tlds.
|
||||
* <p>This function is compatible with multi-part TLDs and must not be called with subdomains.
|
||||
*
|
||||
* @throws IllegalArgumentException if there is no TLD
|
||||
*/
|
||||
public static String getTldFromSld(InternetDomainName sld) {
|
||||
checkArgumentNotNull(sld);
|
||||
checkArgument(sld.hasParent(), "secondLevelDomainName does not have a TLD");
|
||||
return sld.parent().toString();
|
||||
public static String getTldFromDomainName(InternetDomainName fullyQualifiedDomainName) {
|
||||
checkArgumentNotNull(fullyQualifiedDomainName);
|
||||
checkArgument(
|
||||
fullyQualifiedDomainName.hasParent(), "fullyQualifiedDomainName does not have a TLD");
|
||||
return fullyQualifiedDomainName.parent().toString();
|
||||
}
|
||||
|
||||
private DomainNameUtils() {}
|
||||
|
|
|
@ -31,7 +31,7 @@ import static google.registry.util.CollectionUtils.union;
|
|||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DomainNameUtils.ACE_PREFIX_REGEX;
|
||||
import static google.registry.util.DomainNameUtils.getTldFromSld;
|
||||
import static google.registry.util.DomainNameUtils.getTldFromDomainName;
|
||||
import static google.registry.util.ResourceUtils.readResourceUtf8;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
|
@ -120,13 +120,13 @@ public class DatastoreHelper {
|
|||
}
|
||||
|
||||
public static DomainResource newDomainResource(String domainName) {
|
||||
String repoId = generateNewDomainRoid(getTldFromSld(domainName));
|
||||
String repoId = generateNewDomainRoid(getTldFromDomainName(domainName));
|
||||
return newDomainResource(domainName, repoId, persistActiveContact("contact1234"));
|
||||
}
|
||||
|
||||
public static DomainResource newDomainResource(String domainName, ContactResource contact) {
|
||||
return newDomainResource(
|
||||
domainName, generateNewDomainRoid(getTldFromSld(domainName)), contact);
|
||||
domainName, generateNewDomainRoid(getTldFromDomainName(domainName)), contact);
|
||||
}
|
||||
|
||||
public static DomainResource newDomainResource(
|
||||
|
@ -152,7 +152,7 @@ public class DatastoreHelper {
|
|||
// contact does, which is usually the applicationId 1.
|
||||
return newDomainApplication(
|
||||
domainName,
|
||||
generateNewDomainRoid(getTldFromSld(domainName)),
|
||||
generateNewDomainRoid(getTldFromDomainName(domainName)),
|
||||
persistActiveContact("contact1234"),
|
||||
LaunchPhase.SUNRISE);
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ public class DatastoreHelper {
|
|||
String domainName, ContactResource contact, LaunchPhase phase) {
|
||||
return newDomainApplication(
|
||||
domainName,
|
||||
generateNewDomainRoid(getTldFromSld(domainName)),
|
||||
generateNewDomainRoid(getTldFromDomainName(domainName)),
|
||||
contact,
|
||||
phase);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ package google.registry.testing;
|
|||
import static google.registry.testing.DatastoreHelper.generateNewContactHostRoid;
|
||||
import static google.registry.testing.DatastoreHelper.generateNewDomainRoid;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.util.DomainNameUtils.getTldFromSld;
|
||||
import static google.registry.util.DomainNameUtils.getTldFromDomainName;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
@ -221,7 +221,7 @@ public final class FullFieldsTestEntityHelper {
|
|||
Registrar registrar) {
|
||||
DomainResource.Builder builder = new DomainResource.Builder()
|
||||
.setFullyQualifiedDomainName(Idn.toASCII(domain))
|
||||
.setRepoId(generateNewDomainRoid(getTldFromSld(Idn.toASCII(domain))))
|
||||
.setRepoId(generateNewDomainRoid(getTldFromDomainName(Idn.toASCII(domain))))
|
||||
.setLastEppUpdateTime(DateTime.parse("2009-05-29T20:13:00Z"))
|
||||
.setCreationTimeForTest(DateTime.parse("2000-10-08T00:45:00Z"))
|
||||
.setRegistrationExpirationTime(DateTime.parse("2110-10-08T00:44:59Z"))
|
||||
|
|
|
@ -62,7 +62,7 @@ public class GetApplicationIdsCommandTest extends CommandTestCase<GetApplication
|
|||
|
||||
@Test
|
||||
public void testFailure_tldDoesNotExist() throws Exception {
|
||||
thrown.expect(NullPointerException.class);
|
||||
thrown.expect(IllegalArgumentException.class, "Domain name is not under a recognized TLD");
|
||||
runCommand("example.foo");
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ public class CheckApiServletTest {
|
|||
public void testFailure_nullDomain() throws Exception {
|
||||
doTest(ImmutableMap.of(
|
||||
"status", "error",
|
||||
"reason", "Must supply a valid second level domain name"));
|
||||
"reason", "Must supply a valid domain name on an authoritative TLD"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -87,7 +87,7 @@ public class CheckApiServletTest {
|
|||
when(req.getParameter("domain")).thenReturn("");
|
||||
doTest(ImmutableMap.of(
|
||||
"status", "error",
|
||||
"reason", "Must supply a valid second level domain name"));
|
||||
"reason", "Must supply a valid domain name on an authoritative TLD"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -95,7 +95,7 @@ public class CheckApiServletTest {
|
|||
when(req.getParameter("domain")).thenReturn("@#$%^");
|
||||
doTest(ImmutableMap.of(
|
||||
"status", "error",
|
||||
"reason", "Must supply a valid second level domain name"));
|
||||
"reason", "Must supply a valid domain name on an authoritative TLD"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -103,7 +103,7 @@ public class CheckApiServletTest {
|
|||
when(req.getParameter("domain")).thenReturn("foo");
|
||||
doTest(ImmutableMap.of(
|
||||
"status", "error",
|
||||
"reason", "Must supply a valid second level domain name"));
|
||||
"reason", "Must supply a valid domain name on an authoritative TLD"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -111,7 +111,7 @@ public class CheckApiServletTest {
|
|||
when(req.getParameter("domain")).thenReturn("foo.bar");
|
||||
doTest(ImmutableMap.of(
|
||||
"status", "error",
|
||||
"reason", "Domain name is under tld bar which doesn't exist"));
|
||||
"reason", "Must supply a valid domain name on an authoritative TLD"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue