mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Remove nearly all uses of ReferenceUnion
ReferenceUnion is a hack to work around the mismatch between how we store references (by roid) and how they are represented in EPP (by foreign key). If it ever needed to exist (not entirely clear...) it should have remained tightly scoped within the domain commands and resources. Instead it has leaked everywhere in the project, causing lots of boilerplate. This CL hides all of that behind standard Refs, and should be followed by work to remove ReferenceUnion completely. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=122424416
This commit is contained in:
parent
56c8bb0f2a
commit
9a2afc7a9b
59 changed files with 448 additions and 454 deletions
|
@ -17,12 +17,12 @@ package google.registry.flows;
|
|||
import static google.registry.model.eppoutput.Result.Code.SuccessWithActionPending;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Work;
|
||||
|
||||
import google.registry.flows.EppException.AssociationProhibitsOperationException;
|
||||
import google.registry.model.EppResource;
|
||||
import google.registry.model.EppResource.Builder;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.eppinput.ResourceCommand.SingleResourceCommand;
|
||||
import google.registry.model.eppoutput.Result.Code;
|
||||
|
@ -51,7 +51,7 @@ public abstract class ResourceAsyncDeleteFlow
|
|||
// that would be hard to reason about, and there's no real gain in doing so.
|
||||
return false;
|
||||
}
|
||||
return isLinkedForFailfast(ReferenceUnion.create(fki.getReference()));
|
||||
return isLinkedForFailfast(fki.getReference());
|
||||
}
|
||||
});
|
||||
if (isLinked) {
|
||||
|
@ -60,7 +60,7 @@ public abstract class ResourceAsyncDeleteFlow
|
|||
}
|
||||
|
||||
/** Subclasses must override this to check if the supplied reference has incoming links. */
|
||||
protected abstract boolean isLinkedForFailfast(ReferenceUnion<R> ref);
|
||||
protected abstract boolean isLinkedForFailfast(Ref<R> ref);
|
||||
|
||||
@Override
|
||||
protected final R createOrMutateResource() {
|
||||
|
|
|
@ -16,9 +16,10 @@ package google.registry.flows.async;
|
|||
|
||||
import static google.registry.flows.ResourceFlowUtils.handlePendingTransferOnDelete;
|
||||
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.reporting.HistoryEntry.Type;
|
||||
import google.registry.request.Action;
|
||||
|
@ -48,7 +49,7 @@ public class DeleteContactResourceAction extends DeleteEppResourceAction<Contact
|
|||
|
||||
@Override
|
||||
protected boolean isLinked(
|
||||
DomainBase domain, ReferenceUnion<ContactResource> targetResourceRef) {
|
||||
DomainBase domain, Ref<ContactResource> targetResourceRef) {
|
||||
return domain.getReferencedContacts().contains(targetResourceRef);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ import google.registry.mapreduce.inputs.NullInput;
|
|||
import google.registry.model.EppResource;
|
||||
import google.registry.model.annotations.ExternalMessagingName;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.poll.PollMessage;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
|
@ -147,7 +146,7 @@ public abstract class DeleteEppResourceAction<T extends EppResource> implements
|
|||
}
|
||||
|
||||
/** Determine whether the target resource is a linked resource on the domain. */
|
||||
protected abstract boolean isLinked(DomainBase domain, ReferenceUnion<T> targetResourceRef);
|
||||
protected abstract boolean isLinked(DomainBase domain, Ref<T> targetResourceRef);
|
||||
|
||||
@Override
|
||||
public void map(DomainBase domain) {
|
||||
|
@ -159,12 +158,12 @@ public abstract class DeleteEppResourceAction<T extends EppResource> implements
|
|||
emit(targetEppResourceKey, false);
|
||||
return;
|
||||
}
|
||||
// The ReferenceUnion can't be a field on the Mapper, because when a Ref<?> is serialized
|
||||
// (required for each MapShardTask), it uses the DeadRef version, which contains the Ref's
|
||||
// value, which isn't serializable. Thankfully, this isn't expensive.
|
||||
// The Ref can't be a field on the Mapper, because when a Ref<?> is serialized (required for
|
||||
// each MapShardTask), it uses the DeadRef version, which contains the Ref's value, which
|
||||
// isn't serializable. Thankfully, this isn't expensive.
|
||||
// See: https://github.com/objectify/objectify/blob/master/src/main/java/com/googlecode/objectify/impl/ref/DeadRef.java
|
||||
if (isActive(domain, targetResourceUpdateTimestamp)
|
||||
&& isLinked(domain, ReferenceUnion.create(Ref.create(targetEppResourceKey)))) {
|
||||
&& isLinked(domain, Ref.create(targetEppResourceKey))) {
|
||||
emit(targetEppResourceKey, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,10 @@ package google.registry.flows.async;
|
|||
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.dns.DnsQueue;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.reporting.HistoryEntry.Type;
|
||||
|
@ -48,8 +49,7 @@ public class DeleteHostResourceAction extends DeleteEppResourceAction<HostResour
|
|||
private static final long serialVersionUID = 1941092742903217194L;
|
||||
|
||||
@Override
|
||||
protected boolean isLinked(
|
||||
DomainBase domain, ReferenceUnion<HostResource> targetResourceRef) {
|
||||
protected boolean isLinked(DomainBase domain, Ref<HostResource> targetResourceRef) {
|
||||
return domain.getNameservers().contains(targetResourceRef);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import google.registry.mapreduce.MapreduceAction;
|
|||
import google.registry.mapreduce.MapreduceRunner;
|
||||
import google.registry.mapreduce.inputs.EppResourceInputs;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.HttpException.BadRequestException;
|
||||
|
@ -98,7 +97,7 @@ public class DnsRefreshForHostRenameAction implements MapreduceAction {
|
|||
@Override
|
||||
public final void map(DomainResource domain) {
|
||||
if (isActive(domain, hostUpdateTime)
|
||||
&& domain.getNameservers().contains(ReferenceUnion.create(Ref.create(targetHostKey)))) {
|
||||
&& domain.getNameservers().contains(Ref.create(targetHostKey))) {
|
||||
try {
|
||||
dnsQueue.addDomainRefreshTask(domain.getFullyQualifiedDomainName());
|
||||
logger.infofmt("Enqueued refresh for domain %s", domain.getFullyQualifiedDomainName());
|
||||
|
|
|
@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.common.collect.Iterables;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.flows.EppException;
|
||||
|
@ -33,7 +34,6 @@ import google.registry.model.contact.ContactCommand.Delete;
|
|||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.contact.ContactResource.Builder;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
|
||||
/**
|
||||
|
@ -50,7 +50,7 @@ public class ContactDeleteFlow extends ResourceAsyncDeleteFlow<ContactResource,
|
|||
private static final int FAILFAST_CHECK_COUNT = 5;
|
||||
|
||||
@Override
|
||||
protected boolean isLinkedForFailfast(final ReferenceUnion<ContactResource> ref) {
|
||||
protected boolean isLinkedForFailfast(final Ref<ContactResource> ref) {
|
||||
// Query for the first few linked domains, and if found, actually load them. The query is
|
||||
// eventually consistent and so might be very stale, but the direct load will not be stale,
|
||||
// just non-transactional. If we find at least one actual reference then we can reliably
|
||||
|
@ -58,7 +58,7 @@ public class ContactDeleteFlow extends ResourceAsyncDeleteFlow<ContactResource,
|
|||
return Iterables.any(
|
||||
ofy().load().keys(
|
||||
queryDomainsUsingResource(
|
||||
ContactResource.class, ref.getLinked(), now, FAILFAST_CHECK_COUNT)).values(),
|
||||
ContactResource.class, ref, now, FAILFAST_CHECK_COUNT)).values(),
|
||||
new Predicate<DomainBase>() {
|
||||
@Override
|
||||
public boolean apply(DomainBase domain) {
|
||||
|
|
|
@ -20,7 +20,8 @@ import static google.registry.flows.domain.DomainFlowUtils.validateContactsHaveT
|
|||
import static google.registry.flows.domain.DomainFlowUtils.validateDomainName;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateDomainNameWithIdnTables;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateDsData;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateNameservers;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateNameserversAllowedOnTld;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateNameserversCount;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateNoDuplicateContacts;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateRegistrantAllowedOnTld;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateRequiredContactsPresent;
|
||||
|
@ -36,6 +37,7 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
|
|||
import static google.registry.model.registry.Registries.findTldForName;
|
||||
import static google.registry.model.registry.label.ReservedList.matchesAnchorTenantReservation;
|
||||
import static google.registry.pricing.PricingEngineProxy.getDomainCreateCost;
|
||||
import static google.registry.util.CollectionUtils.nullToEmpty;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
|
@ -67,6 +69,8 @@ import google.registry.model.tmch.ClaimsListShard;
|
|||
|
||||
import org.joda.money.Money;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
|
@ -210,10 +214,13 @@ public abstract class BaseDomainCreateFlow<R extends DomainBase, B extends Build
|
|||
command.getRegistrant(),
|
||||
command.getNameservers());
|
||||
validateContactsHaveTypes(command.getContacts());
|
||||
validateRegistrantAllowedOnTld(tld, command.getRegistrant());
|
||||
validateRegistrantAllowedOnTld(tld, command.getRegistrantContactId());
|
||||
validateNoDuplicateContacts(command.getContacts());
|
||||
validateRequiredContactsPresent(command.getRegistrant(), command.getContacts());
|
||||
validateNameservers(tld, command.getNameservers());
|
||||
Set<String> fullyQualifiedHostNames =
|
||||
nullToEmpty(command.getNameserverFullyQualifiedHostNames());
|
||||
validateNameserversCount(fullyQualifiedHostNames.size());
|
||||
validateNameserversAllowedOnTld(tld, fullyQualifiedHostNames);
|
||||
validateLaunchCreateExtension();
|
||||
// If a signed mark was provided, then it must match the desired domain label.
|
||||
// We do this after validating the launch create extension so that flows which don't allow any
|
||||
|
|
|
@ -20,7 +20,8 @@ import static google.registry.flows.domain.DomainFlowUtils.checkAllowedAccessToT
|
|||
import static google.registry.flows.domain.DomainFlowUtils.cloneAndLinkReferences;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateContactsHaveTypes;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateDsData;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateNameservers;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateNameserversAllowedOnTld;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateNameserversCount;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateNoDuplicateContacts;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateRegistrantAllowedOnTld;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateRequiredContactsPresent;
|
||||
|
@ -112,6 +113,10 @@ public abstract class BaseDomainUpdateFlow<R extends DomainBase, B extends Build
|
|||
command.getInnerAdd().getNameservers());
|
||||
validateContactsHaveTypes(command.getInnerAdd().getContacts());
|
||||
validateContactsHaveTypes(command.getInnerRemove().getContacts());
|
||||
validateRegistrantAllowedOnTld(
|
||||
existingResource.getTld(), command.getInnerChange().getRegistrantContactId());
|
||||
validateNameserversAllowedOnTld(
|
||||
existingResource.getTld(), command.getInnerAdd().getNameserverFullyQualifiedHostNames());
|
||||
}
|
||||
|
||||
/** Subclasses can override this to do more specific verification. */
|
||||
|
@ -123,8 +128,7 @@ public abstract class BaseDomainUpdateFlow<R extends DomainBase, B extends Build
|
|||
validateNoDuplicateContacts(newResource.getContacts());
|
||||
validateRequiredContactsPresent(newResource.getRegistrant(), newResource.getContacts());
|
||||
validateDsData(newResource.getDsData());
|
||||
validateRegistrantAllowedOnTld(newResource.getTld(), newResource.getRegistrant());
|
||||
validateNameservers(newResource.getTld(), newResource.getNameservers());
|
||||
validateNameserversCount(newResource.getNameservers().size());
|
||||
}
|
||||
|
||||
/** The secDNS:all element must have value 'true' if present. */
|
||||
|
|
|
@ -91,7 +91,7 @@ import java.util.List;
|
|||
* @error {@link DomainFlowUtils.LeadingDashException}
|
||||
* @error {@link DomainFlowUtils.LinkedResourceDoesNotExistException}
|
||||
* @error {@link DomainFlowUtils.MissingContactTypeException}
|
||||
* @error {@link DomainFlowUtils.NameserverNotAllowedException}
|
||||
* @error {@link DomainFlowUtils.NameserversNotAllowedException}
|
||||
* @error {@link DomainFlowUtils.NoMarksFoundMatchingDomainException}
|
||||
* @error {@link DomainFlowUtils.PremiumNameBlockedException}
|
||||
* @error {@link DomainFlowUtils.RegistrantNotAllowedException}
|
||||
|
|
|
@ -50,7 +50,7 @@ import google.registry.model.reporting.HistoryEntry;
|
|||
* @error {@link DomainFlowUtils.MissingAdminContactException}
|
||||
* @error {@link DomainFlowUtils.MissingContactTypeException}
|
||||
* @error {@link DomainFlowUtils.MissingTechnicalContactException}
|
||||
* @error {@link DomainFlowUtils.NameserverNotAllowedException}
|
||||
* @error {@link DomainFlowUtils.NameserversNotAllowedException}
|
||||
* @error {@link DomainFlowUtils.RegistrantNotAllowedException}
|
||||
* @error {@link DomainFlowUtils.TooManyDsRecordsException}
|
||||
* @error {@link DomainFlowUtils.TooManyNameserversException}
|
||||
|
|
|
@ -81,7 +81,7 @@ import java.util.Set;
|
|||
* @error {@link DomainFlowUtils.MissingContactTypeException}
|
||||
* @error {@link DomainFlowUtils.MissingRegistrantException}
|
||||
* @error {@link DomainFlowUtils.MissingTechnicalContactException}
|
||||
* @error {@link DomainFlowUtils.NameserverNotAllowedException}
|
||||
* @error {@link DomainFlowUtils.NameserversNotAllowedException}
|
||||
* @error {@link DomainFlowUtils.PremiumNameBlockedException}
|
||||
* @error {@link DomainFlowUtils.RegistrantNotAllowedException}
|
||||
* @error {@link DomainFlowUtils.TldDoesNotExistException}
|
||||
|
|
|
@ -20,6 +20,7 @@ import static com.google.common.base.Predicates.equalTo;
|
|||
import static com.google.common.base.Strings.emptyToNull;
|
||||
import static com.google.common.collect.Iterables.any;
|
||||
import static com.google.common.collect.Iterables.concat;
|
||||
import static com.google.common.collect.Sets.difference;
|
||||
import static google.registry.flows.EppXmlTransformer.unmarshal;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.registry.Registries.findTldForName;
|
||||
|
@ -43,6 +44,7 @@ import com.google.common.collect.Sets;
|
|||
import com.google.common.net.InternetDomainName;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.EppException.AuthorizationErrorException;
|
||||
|
@ -65,7 +67,6 @@ import google.registry.model.domain.DomainCommand.CreateOrUpdate;
|
|||
import google.registry.model.domain.DomainCommand.InvalidReferenceException;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.Period;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.domain.fee.BaseFeeCommand;
|
||||
import google.registry.model.domain.fee.BaseFeeRequest;
|
||||
import google.registry.model.domain.fee.BaseFeeResponse;
|
||||
|
@ -249,23 +250,23 @@ public class DomainFlowUtils {
|
|||
/** Verify that no linked resources have disallowed statuses. */
|
||||
static void verifyNotInPendingDelete(
|
||||
Set<DesignatedContact> contacts,
|
||||
ReferenceUnion<ContactResource> registrant,
|
||||
Set<ReferenceUnion<HostResource>> nameservers) throws EppException {
|
||||
Ref<ContactResource> registrant,
|
||||
Set<Ref<HostResource>> nameservers) throws EppException {
|
||||
for (DesignatedContact contact : nullToEmpty(contacts)) {
|
||||
verifyNotInPendingDelete(contact.getContactId());
|
||||
verifyNotInPendingDelete(contact.getContactRef());
|
||||
}
|
||||
if (registrant != null) {
|
||||
verifyNotInPendingDelete(registrant);
|
||||
}
|
||||
for (ReferenceUnion<HostResource> host : nullToEmpty(nameservers)) {
|
||||
for (Ref<HostResource> host : nullToEmpty(nameservers)) {
|
||||
verifyNotInPendingDelete(host);
|
||||
}
|
||||
}
|
||||
|
||||
private static void verifyNotInPendingDelete(
|
||||
ReferenceUnion<? extends EppResource> resourceRef) throws EppException {
|
||||
Ref<? extends EppResource> resourceRef) throws EppException {
|
||||
|
||||
EppResource resource = resourceRef.getLinked().get();
|
||||
EppResource resource = resourceRef.get();
|
||||
if (resource.getStatusValues().contains(StatusValue.PENDING_DELETE)) {
|
||||
throw new LinkedResourceInPendingDeleteProhibitsOperationException(resource.getForeignKey());
|
||||
}
|
||||
|
@ -280,28 +281,12 @@ public class DomainFlowUtils {
|
|||
}
|
||||
}
|
||||
|
||||
/** Return a foreign key for a {@link ReferenceUnion} from memory or datastore as needed. */
|
||||
private static String resolveForeignKey(ReferenceUnion<?> ref) {
|
||||
return ref.getForeignKey() != null
|
||||
? ref.getForeignKey()
|
||||
: ref.getLinked().get().getForeignKey();
|
||||
}
|
||||
static void validateNameserversCount(int count) throws EppException {
|
||||
if (count > MAX_NAMESERVERS_PER_DOMAIN) {
|
||||
throw new TooManyNameserversException(String.format(
|
||||
"Only %d nameservers are allowed per domain", MAX_NAMESERVERS_PER_DOMAIN));
|
||||
}
|
||||
|
||||
static void validateNameservers(String tld, Set<ReferenceUnion<HostResource>> nameservers)
|
||||
throws EppException {
|
||||
if (nameservers != null && nameservers.size() > MAX_NAMESERVERS_PER_DOMAIN) {
|
||||
throw new TooManyNameserversException(String.format(
|
||||
"Only %d nameservers are allowed per domain", MAX_NAMESERVERS_PER_DOMAIN));
|
||||
}
|
||||
ImmutableSet<String> whitelist = Registry.get(tld).getAllowedFullyQualifiedHostNames();
|
||||
if (!whitelist.isEmpty()) { // Empty whitelists are ignored.
|
||||
for (ReferenceUnion<HostResource> nameserver : nullToEmpty(nameservers)) {
|
||||
String foreignKey = resolveForeignKey(nameserver);
|
||||
if (!whitelist.contains(foreignKey)) {
|
||||
throw new NameserverNotAllowedException(foreignKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void validateNoDuplicateContacts(Set<DesignatedContact> contacts)
|
||||
|
@ -315,8 +300,8 @@ public class DomainFlowUtils {
|
|||
}
|
||||
|
||||
static void validateRequiredContactsPresent(
|
||||
ReferenceUnion<ContactResource> registrant, Set<DesignatedContact> contacts)
|
||||
throws RequiredParameterMissingException {
|
||||
Ref<ContactResource> registrant, Set<DesignatedContact> contacts)
|
||||
throws RequiredParameterMissingException {
|
||||
if (registrant == null) {
|
||||
throw new MissingRegistrantException();
|
||||
}
|
||||
|
@ -333,12 +318,24 @@ public class DomainFlowUtils {
|
|||
}
|
||||
}
|
||||
|
||||
static void validateRegistrantAllowedOnTld(String tld, ReferenceUnion<ContactResource> registrant)
|
||||
static void validateRegistrantAllowedOnTld(String tld, String registrantContactId)
|
||||
throws RegistrantNotAllowedException {
|
||||
ImmutableSet<String> whitelist = Registry.get(tld).getAllowedRegistrantContactIds();
|
||||
// Empty whitelists are ignored.
|
||||
if (!whitelist.isEmpty() && !whitelist.contains(resolveForeignKey(registrant))) {
|
||||
throw new RegistrantNotAllowedException(resolveForeignKey(registrant));
|
||||
if (!whitelist.isEmpty() && !whitelist.contains(registrantContactId)) {
|
||||
throw new RegistrantNotAllowedException(registrantContactId);
|
||||
}
|
||||
}
|
||||
|
||||
static void validateNameserversAllowedOnTld(String tld, Set<String> fullyQualifiedHostNames)
|
||||
throws EppException {
|
||||
ImmutableSet<String> whitelist = Registry.get(tld).getAllowedFullyQualifiedHostNames();
|
||||
if (whitelist.isEmpty()) { // Empty whitelists are ignored.
|
||||
return;
|
||||
}
|
||||
Set<String> disallowedNameservers = difference(nullToEmpty(fullyQualifiedHostNames), whitelist);
|
||||
if (!disallowedNameservers.isEmpty()) {
|
||||
throw new NameserversNotAllowedException(disallowedNameservers);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1015,10 +1012,13 @@ public class DomainFlowUtils {
|
|||
}
|
||||
}
|
||||
|
||||
/** Nameserver is not whitelisted for this TLD. */
|
||||
public static class NameserverNotAllowedException extends StatusProhibitsOperationException {
|
||||
public NameserverNotAllowedException(String fullyQualifiedHostName) {
|
||||
super(String.format("Nameserver %s is not whitelisted for this TLD", fullyQualifiedHostName));
|
||||
/** Nameserver are not whitelisted for this TLD. */
|
||||
public static class NameserversNotAllowedException extends StatusProhibitsOperationException {
|
||||
public NameserversNotAllowedException(Set<String> fullyQualifiedHostNames) {
|
||||
super(String.format(
|
||||
"Nameservers '%s' are not whitelisted for this TLD",
|
||||
Joiner.on(',').join(fullyQualifiedHostNames)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ import java.util.Set;
|
|||
* @error {@link DomainFlowUtils.MissingAdminContactException}
|
||||
* @error {@link DomainFlowUtils.MissingContactTypeException}
|
||||
* @error {@link DomainFlowUtils.MissingTechnicalContactException}
|
||||
* @error {@link DomainFlowUtils.NameserverNotAllowedException}
|
||||
* @error {@link DomainFlowUtils.NameserversNotAllowedException}
|
||||
* @error {@link DomainFlowUtils.RegistrantNotAllowedException}
|
||||
* @error {@link DomainFlowUtils.TooManyDsRecordsException}
|
||||
* @error {@link DomainFlowUtils.TooManyNameserversException}
|
||||
|
|
|
@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.common.collect.Iterables;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.flows.EppException;
|
||||
|
@ -30,7 +31,6 @@ import google.registry.flows.async.AsyncFlowUtils;
|
|||
import google.registry.flows.async.DeleteEppResourceAction;
|
||||
import google.registry.flows.async.DeleteHostResourceAction;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.host.HostCommand.Delete;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.host.HostResource.Builder;
|
||||
|
@ -50,7 +50,7 @@ public class HostDeleteFlow extends ResourceAsyncDeleteFlow<HostResource, Builde
|
|||
private static final int FAILFAST_CHECK_COUNT = 5;
|
||||
|
||||
@Override
|
||||
protected boolean isLinkedForFailfast(final ReferenceUnion<HostResource> ref) {
|
||||
protected boolean isLinkedForFailfast(final Ref<HostResource> ref) {
|
||||
// Query for the first few linked domains, and if found, actually load them. The query is
|
||||
// eventually consistent and so might be very stale, but the direct load will not be stale,
|
||||
// just non-transactional. If we find at least one actual reference then we can reliably
|
||||
|
@ -58,7 +58,7 @@ public class HostDeleteFlow extends ResourceAsyncDeleteFlow<HostResource, Builde
|
|||
return Iterables.any(
|
||||
ofy().load().keys(
|
||||
queryDomainsUsingResource(
|
||||
HostResource.class, ref.getLinked(), now, FAILFAST_CHECK_COUNT)).values(),
|
||||
HostResource.class, ref, now, FAILFAST_CHECK_COUNT)).values(),
|
||||
new Predicate<DomainBase>() {
|
||||
@Override
|
||||
public boolean apply(DomainBase domain) {
|
||||
|
|
|
@ -36,7 +36,6 @@ import google.registry.model.EppResource.Builder;
|
|||
import google.registry.model.EppResource.ForeignKeyedEppResource;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.index.ForeignKeyIndex;
|
||||
|
@ -139,12 +138,12 @@ public final class EppResourceUtils {
|
|||
latestOf(now, resource.getUpdateAutoTimestamp().getTimestamp()));
|
||||
}
|
||||
|
||||
/** Loads returns the hosts specified by the given ReferenceUnions. */
|
||||
/** Loads and returns the hosts specified by the given reference. */
|
||||
public static ImmutableSet<HostResource> loadReferencedNameservers(
|
||||
Set<ReferenceUnion<HostResource>> hostRefs) {
|
||||
Set<Ref<HostResource>> hostRefs) {
|
||||
ImmutableSet.Builder<HostResource> builder = new ImmutableSet.Builder<>();
|
||||
for (ReferenceUnion<HostResource> hostRef : hostRefs) {
|
||||
HostResource host = hostRef.getLinked().get();
|
||||
for (Ref<HostResource> hostRef : hostRefs) {
|
||||
HostResource host = hostRef.get();
|
||||
if (host != null) {
|
||||
builder.add(host);
|
||||
}
|
||||
|
@ -152,12 +151,12 @@ public final class EppResourceUtils {
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
/** Loads and returns the contacts specified by the given ReferenceUnions. */
|
||||
/** Loads and returns the contacts specified by the given references. */
|
||||
public static ImmutableSet<ContactResource> loadReferencedContacts(
|
||||
Set<ReferenceUnion<ContactResource>> contactRefs) {
|
||||
Set<Ref<ContactResource>> contactRefs) {
|
||||
ImmutableSet.Builder<ContactResource> builder = new ImmutableSet.Builder<>();
|
||||
for (ReferenceUnion<ContactResource> contactRef : contactRefs) {
|
||||
builder.add(contactRef.getLinked().get());
|
||||
for (Ref<ContactResource> contactRef : contactRefs) {
|
||||
builder.add(contactRef.get());
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ package google.registry.model.domain;
|
|||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.annotation.Embed;
|
||||
import com.googlecode.objectify.annotation.Index;
|
||||
|
||||
|
@ -50,10 +51,10 @@ public class DesignatedContact extends ImmutableObject {
|
|||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static DesignatedContact create(Type type, ReferenceUnion<ContactResource> contact) {
|
||||
public static DesignatedContact create(Type type, Ref<ContactResource> contact) {
|
||||
DesignatedContact instance = new DesignatedContact();
|
||||
instance.type = type;
|
||||
instance.contactId = contact;
|
||||
instance.contactId = ReferenceUnion.create(contact);
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
@ -62,13 +63,14 @@ public class DesignatedContact extends ImmutableObject {
|
|||
|
||||
@Index
|
||||
@XmlValue
|
||||
//TODO(b/28713909): Make this a Ref<ContactResource>.
|
||||
ReferenceUnion<ContactResource> contactId;
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public ReferenceUnion<ContactResource> getContactId() {
|
||||
return contactId;
|
||||
public Ref<ContactResource> getContactRef() {
|
||||
return contactId.getLinked();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ package google.registry.model.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.annotation.Embed;
|
||||
|
||||
import google.registry.model.EppResource;
|
||||
|
@ -38,9 +39,9 @@ public class DomainAuthInfo extends AuthInfo {
|
|||
checkNotNull(getPw());
|
||||
if (getRepoId() != null) {
|
||||
// Make sure the repo id matches one of the contacts on the domain.
|
||||
ReferenceUnion<ContactResource> foundContact = null;
|
||||
for (ReferenceUnion<ContactResource> contact : domain.getReferencedContacts()) {
|
||||
String contactRepoId = contact.getLinked().getKey().getName();
|
||||
Ref<ContactResource> foundContact = null;
|
||||
for (Ref<ContactResource> contact : domain.getReferencedContacts()) {
|
||||
String contactRepoId = contact.getKey().getName();
|
||||
if (getRepoId().equals(contactRepoId)) {
|
||||
foundContact = contact;
|
||||
break;
|
||||
|
@ -50,7 +51,7 @@ public class DomainAuthInfo extends AuthInfo {
|
|||
throw new BadAuthInfoException();
|
||||
}
|
||||
// Check if the password provided matches the password on the referenced contact.
|
||||
if (!foundContact.getLinked().get().getAuthInfo().getPw().getValue().equals(
|
||||
if (!foundContact.get().getAuthInfo().getPw().getValue().equals(
|
||||
getPw().getValue())) {
|
||||
throw new BadAuthInfoException();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import static com.google.common.base.Strings.isNullOrEmpty;
|
|||
import static com.google.common.collect.Sets.difference;
|
||||
import static com.google.common.collect.Sets.union;
|
||||
import static google.registry.model.domain.DesignatedContact.Type.REGISTRANT;
|
||||
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;
|
||||
|
@ -27,6 +28,7 @@ import static google.registry.util.DomainNameUtils.getTldFromSld;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.annotation.Entity;
|
||||
import com.googlecode.objectify.annotation.Ignore;
|
||||
import com.googlecode.objectify.annotation.IgnoreSave;
|
||||
|
@ -74,6 +76,7 @@ public abstract class DomainBase extends EppResource {
|
|||
/** References to hosts that are the nameservers for the domain. */
|
||||
@XmlElementWrapper(name = "ns")
|
||||
@XmlElement(name = "hostObj")
|
||||
//TODO(b/28713909): Make this a Set<Ref<HostResource>>.
|
||||
Set<ReferenceUnion<HostResource>> nameservers;
|
||||
|
||||
/**
|
||||
|
@ -102,6 +105,7 @@ public abstract class DomainBase extends EppResource {
|
|||
* both stored in {@link DomainBase#allContacts} to allow for more efficient queries.
|
||||
*/
|
||||
@Ignore
|
||||
//TODO(b/28713909): Make this a Ref<ContactResource>.
|
||||
ReferenceUnion<ContactResource> registrant;
|
||||
|
||||
/** Authorization info (aka transfer secret) of the domain. */
|
||||
|
@ -149,8 +153,12 @@ public abstract class DomainBase extends EppResource {
|
|||
return idnTableName;
|
||||
}
|
||||
|
||||
public ImmutableSet<ReferenceUnion<HostResource>> getNameservers() {
|
||||
return nullToEmptyImmutableCopy(nameservers);
|
||||
public ImmutableSet<Ref<HostResource>> getNameservers() {
|
||||
ImmutableSet.Builder<Ref<HostResource>> builder = new ImmutableSet.Builder<>();
|
||||
for (ReferenceUnion<HostResource> union : nullToEmptyImmutableCopy(nameservers)) {
|
||||
builder.add(union.getLinked());
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/** Loads and returns all linked nameservers. */
|
||||
|
@ -158,12 +166,12 @@ public abstract class DomainBase extends EppResource {
|
|||
return EppResourceUtils.loadReferencedNameservers(getNameservers());
|
||||
}
|
||||
|
||||
public ReferenceUnion<ContactResource> getRegistrant() {
|
||||
return registrant;
|
||||
public Ref<ContactResource> getRegistrant() {
|
||||
return registrant == null ? null : registrant.getLinked();
|
||||
}
|
||||
|
||||
public ContactResource loadRegistrant() {
|
||||
return registrant.getLinked().get();
|
||||
return getRegistrant().get();
|
||||
}
|
||||
|
||||
public ImmutableSet<DesignatedContact> getContacts() {
|
||||
|
@ -175,11 +183,11 @@ public abstract class DomainBase extends EppResource {
|
|||
}
|
||||
|
||||
/** Returns all referenced contacts from this domain or application. */
|
||||
public ImmutableSet<ReferenceUnion<ContactResource>> getReferencedContacts() {
|
||||
ImmutableSet.Builder<ReferenceUnion<ContactResource>> contactsBuilder =
|
||||
public ImmutableSet<Ref<ContactResource>> getReferencedContacts() {
|
||||
ImmutableSet.Builder<Ref<ContactResource>> contactsBuilder =
|
||||
new ImmutableSet.Builder<>();
|
||||
for (DesignatedContact designated : nullToEmptyImmutableCopy(allContacts)) {
|
||||
contactsBuilder.add(designated.getContactId());
|
||||
contactsBuilder.add(designated.getContactRef());
|
||||
}
|
||||
return contactsBuilder.build();
|
||||
}
|
||||
|
@ -202,7 +210,7 @@ public abstract class DomainBase extends EppResource {
|
|||
ImmutableSet.Builder<DesignatedContact> contactsBuilder = new ImmutableSet.Builder<>();
|
||||
for (DesignatedContact contact : nullToEmptyImmutableCopy(allContacts)) {
|
||||
if (REGISTRANT.equals(contact.getType())){
|
||||
registrant = contact.getContactId();
|
||||
registrant = ReferenceUnion.create(contact.getContactRef());
|
||||
} else {
|
||||
contactsBuilder.add(contact);
|
||||
}
|
||||
|
@ -229,8 +237,11 @@ public abstract class DomainBase extends EppResource {
|
|||
checkState(
|
||||
!isNullOrEmpty(instance.fullyQualifiedDomainName), "Missing fullyQualifiedDomainName");
|
||||
instance.tld = getTldFromSld(instance.fullyQualifiedDomainName);
|
||||
instance.allContacts = instance.registrant == null ? instance.contacts : union(
|
||||
instance.getContacts(), DesignatedContact.create(REGISTRANT, instance.registrant));
|
||||
instance.allContacts = instance.registrant == null
|
||||
? instance.contacts
|
||||
: union(
|
||||
instance.getContacts(),
|
||||
DesignatedContact.create(REGISTRANT, instance.registrant.getLinked()));
|
||||
return super.build();
|
||||
}
|
||||
|
||||
|
@ -244,8 +255,8 @@ public abstract class DomainBase extends EppResource {
|
|||
return thisCastToDerived();
|
||||
}
|
||||
|
||||
public B setRegistrant(ReferenceUnion<ContactResource> registrant) {
|
||||
getInstance().registrant = registrant;
|
||||
public B setRegistrant(Ref<ContactResource> registrant) {
|
||||
getInstance().registrant = ReferenceUnion.create(registrant);
|
||||
return thisCastToDerived();
|
||||
}
|
||||
|
||||
|
@ -254,17 +265,21 @@ public abstract class DomainBase extends EppResource {
|
|||
return thisCastToDerived();
|
||||
}
|
||||
|
||||
public B setNameservers(ImmutableSet<ReferenceUnion<HostResource>> nameservers) {
|
||||
getInstance().nameservers = nameservers;
|
||||
public B setNameservers(ImmutableSet<Ref<HostResource>> nameservers) {
|
||||
ImmutableSet.Builder<ReferenceUnion<HostResource>> builder = new ImmutableSet.Builder<>();
|
||||
for (Ref<HostResource> ref : nullToEmpty(nameservers)) {
|
||||
builder.add(ReferenceUnion.create(ref));
|
||||
}
|
||||
getInstance().nameservers = builder.build();
|
||||
return thisCastToDerived();
|
||||
}
|
||||
|
||||
public B addNameservers(ImmutableSet<ReferenceUnion<HostResource>> nameservers) {
|
||||
public B addNameservers(ImmutableSet<Ref<HostResource>> nameservers) {
|
||||
return setNameservers(
|
||||
ImmutableSet.copyOf(union(getInstance().getNameservers(), nameservers)));
|
||||
}
|
||||
|
||||
public B removeNameservers(ImmutableSet<ReferenceUnion<HostResource>> nameservers) {
|
||||
public B removeNameservers(ImmutableSet<Ref<HostResource>> nameservers) {
|
||||
return setNameservers(
|
||||
ImmutableSet.copyOf(difference(getInstance().getNameservers(), nameservers)));
|
||||
}
|
||||
|
|
|
@ -74,12 +74,25 @@ public class DomainCommand {
|
|||
public static class DomainCreateOrChange<B extends DomainBase.Builder<?, ?>>
|
||||
extends ImmutableObject implements ResourceCreateOrChange<B> {
|
||||
|
||||
/** A reference to the registrant who registered this domain. */
|
||||
ReferenceUnion<ContactResource> registrant;
|
||||
/** The contactId of the registrant who registered this domain. */
|
||||
@XmlElement(name = "registrant")
|
||||
String registrantContactId;
|
||||
|
||||
/** A resolved reference to the registrant who registered this domain. */
|
||||
@XmlTransient
|
||||
Ref<ContactResource> registrant;
|
||||
|
||||
/** Authorization info (aka transfer secret) of the domain. */
|
||||
DomainAuthInfo authInfo;
|
||||
|
||||
public String getRegistrantContactId() {
|
||||
return registrantContactId;
|
||||
}
|
||||
|
||||
public Ref<ContactResource> getRegistrant() {
|
||||
return registrant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(B builder) {
|
||||
if (registrant != null) {
|
||||
|
@ -97,7 +110,12 @@ public class DomainCommand {
|
|||
*/
|
||||
@XmlRootElement
|
||||
@XmlType(propOrder = {
|
||||
"fullyQualifiedDomainName", "period", "nameservers", "registrant", "contacts", "authInfo" })
|
||||
"fullyQualifiedDomainName",
|
||||
"period",
|
||||
"nameserverFullyQualifiedHostNames",
|
||||
"registrantContactId",
|
||||
"foreignKeyedDesignatedContacts",
|
||||
"authInfo"})
|
||||
public static class Create
|
||||
extends DomainCreateOrChange<DomainBase.Builder<?, ?>>
|
||||
implements CreateOrUpdate<Create> {
|
||||
|
@ -106,13 +124,21 @@ public class DomainCommand {
|
|||
@XmlElement(name = "name")
|
||||
String fullyQualifiedDomainName;
|
||||
|
||||
/** References to hosts that are the nameservers for the domain. */
|
||||
/** Fully qualified host names of the hosts that are the nameservers for the domain. */
|
||||
@XmlElementWrapper(name = "ns")
|
||||
@XmlElement(name = "hostObj")
|
||||
Set<ReferenceUnion<HostResource>> nameservers;
|
||||
Set<String> nameserverFullyQualifiedHostNames;
|
||||
|
||||
/** Associated contacts for the domain (other than registrant). */
|
||||
/** Resolved references to hosts that are the nameservers for the domain. */
|
||||
@XmlTransient
|
||||
Set<Ref<HostResource>> nameservers;
|
||||
|
||||
/** Foreign keyed associated contacts for the domain (other than registrant). */
|
||||
@XmlElement(name = "contact")
|
||||
Set<ForeignKeyedDesignatedContact> foreignKeyedDesignatedContacts;
|
||||
|
||||
/** Resolved references to associated contacts for the domain (other than registrant). */
|
||||
@XmlTransient
|
||||
Set<DesignatedContact> contacts;
|
||||
|
||||
/** The period that this domain's state was set to last for (e.g. 1-10 years). */
|
||||
|
@ -131,7 +157,11 @@ public class DomainCommand {
|
|||
return fullyQualifiedDomainName;
|
||||
}
|
||||
|
||||
public ImmutableSet<ReferenceUnion<HostResource>> getNameservers() {
|
||||
public ImmutableSet<String> getNameserverFullyQualifiedHostNames() {
|
||||
return nullSafeImmutableCopy(nameserverFullyQualifiedHostNames);
|
||||
}
|
||||
|
||||
public ImmutableSet<Ref<HostResource>> getNameservers() {
|
||||
return nullSafeImmutableCopy(nameservers);
|
||||
}
|
||||
|
||||
|
@ -139,11 +169,7 @@ public class DomainCommand {
|
|||
return nullSafeImmutableCopy(contacts);
|
||||
}
|
||||
|
||||
public ReferenceUnion<ContactResource> getRegistrant() {
|
||||
return registrant;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public AuthInfo getAuthInfo() {
|
||||
return authInfo;
|
||||
}
|
||||
|
@ -166,10 +192,10 @@ public class DomainCommand {
|
|||
@Override
|
||||
public Create cloneAndLinkReferences(DateTime now) throws InvalidReferenceException {
|
||||
Create clone = clone(this);
|
||||
clone.nameservers = linkHosts(clone.nameservers, now);
|
||||
clone.contacts = linkContacts(clone.contacts, now);
|
||||
clone.registrant = clone.registrant == null
|
||||
? null : linkReference(clone.registrant, ContactResource.class, now);
|
||||
clone.nameservers = linkHosts(clone.nameserverFullyQualifiedHostNames, now);
|
||||
clone.contacts = linkContacts(clone.foreignKeyedDesignatedContacts, now);
|
||||
clone.registrant = clone.registrantContactId == null
|
||||
? null : loadReference(clone.registrantContactId, ContactResource.class, now);
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
|
@ -317,18 +343,33 @@ public class DomainCommand {
|
|||
}
|
||||
|
||||
/** The inner change type on a domain update command. */
|
||||
@XmlType(propOrder = {"nameservers", "contacts", "statusValues"})
|
||||
@XmlType(propOrder = {
|
||||
"nameserverFullyQualifiedHostNames",
|
||||
"foreignKeyedDesignatedContacts",
|
||||
"statusValues"})
|
||||
public static class AddRemove extends ResourceUpdate.AddRemove {
|
||||
/** References to hosts that are the nameservers for the domain. */
|
||||
/** Fully qualified host names of the hosts that are the nameservers for the domain. */
|
||||
@XmlElementWrapper(name = "ns")
|
||||
@XmlElement(name = "hostObj")
|
||||
Set<ReferenceUnion<HostResource>> nameservers;
|
||||
Set<String> nameserverFullyQualifiedHostNames;
|
||||
|
||||
/** Associated contacts for the domain. */
|
||||
/** Resolved references to hosts that are the nameservers for the domain. */
|
||||
@XmlTransient
|
||||
Set<Ref<HostResource>> nameservers;
|
||||
|
||||
/** Foreign keyed associated contacts for the domain (other than registrant). */
|
||||
@XmlElement(name = "contact")
|
||||
Set<ForeignKeyedDesignatedContact> foreignKeyedDesignatedContacts;
|
||||
|
||||
/** Resolved references to associated contacts for the domain (other than registrant). */
|
||||
@XmlTransient
|
||||
Set<DesignatedContact> contacts;
|
||||
|
||||
public ImmutableSet<ReferenceUnion<HostResource>> getNameservers() {
|
||||
public ImmutableSet<String> getNameserverFullyQualifiedHostNames() {
|
||||
return nullSafeImmutableCopy(nameserverFullyQualifiedHostNames);
|
||||
}
|
||||
|
||||
public ImmutableSet<Ref<HostResource>> getNameservers() {
|
||||
return nullToEmptyImmutableCopy(nameservers);
|
||||
}
|
||||
|
||||
|
@ -339,25 +380,20 @@ public class DomainCommand {
|
|||
/** Creates a copy of this {@link AddRemove} with hard links to hosts and contacts. */
|
||||
private AddRemove cloneAndLinkReferences(DateTime now) throws InvalidReferenceException {
|
||||
AddRemove clone = clone(this);
|
||||
clone.nameservers = linkHosts(clone.nameservers, now);
|
||||
clone.contacts = linkContacts(clone.contacts, now);
|
||||
clone.nameservers = linkHosts(clone.nameserverFullyQualifiedHostNames, now);
|
||||
clone.contacts = linkContacts(clone.foreignKeyedDesignatedContacts, now);
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
|
||||
/** The inner change type on a domain update command. */
|
||||
@XmlType(propOrder = {"registrant", "authInfo"})
|
||||
@XmlType(propOrder = {"registrantContactId", "authInfo"})
|
||||
public static class Change extends DomainCreateOrChange<DomainBase.Builder<?, ?>> {
|
||||
|
||||
public ReferenceUnion<ContactResource> getRegistrant() {
|
||||
return registrant;
|
||||
}
|
||||
|
||||
/** Creates a copy of this {@link Change} with hard links to hosts and contacts. */
|
||||
Change cloneAndLinkReferences(DateTime now) throws InvalidReferenceException {
|
||||
Change clone = clone(this);
|
||||
clone.registrant = clone.registrant == null
|
||||
? null : linkReference(clone.registrant, ContactResource.class, now);
|
||||
clone.registrant = clone.registrantContactId == null
|
||||
? null : loadReference(clone.registrantContactId, ContactResource.class, now);
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
|
@ -396,50 +432,59 @@ public class DomainCommand {
|
|||
}
|
||||
}
|
||||
|
||||
private static Set<ReferenceUnion<HostResource>> linkHosts(
|
||||
Set<ReferenceUnion<HostResource>> hosts,
|
||||
DateTime now) throws InvalidReferenceException {
|
||||
if (hosts == null) {
|
||||
private static Set<Ref<HostResource>> linkHosts(
|
||||
Set<String> fullyQualifiedHostNames, DateTime now) throws InvalidReferenceException {
|
||||
if (fullyQualifiedHostNames == null) {
|
||||
return null;
|
||||
}
|
||||
ImmutableSet.Builder<ReferenceUnion<HostResource>> linked = new ImmutableSet.Builder<>();
|
||||
for (ReferenceUnion<HostResource> host : hosts) {
|
||||
linked.add(linkReference(host, HostResource.class, now));
|
||||
ImmutableSet.Builder<Ref<HostResource>> linked = new ImmutableSet.Builder<>();
|
||||
for (String fullyQualifiedHostName : fullyQualifiedHostNames) {
|
||||
linked.add(loadReference(fullyQualifiedHostName, HostResource.class, now));
|
||||
}
|
||||
return linked.build();
|
||||
}
|
||||
|
||||
private static Set<DesignatedContact> linkContacts(
|
||||
Set<DesignatedContact> contacts, DateTime now) throws InvalidReferenceException {
|
||||
Set<ForeignKeyedDesignatedContact> contacts, DateTime now) throws InvalidReferenceException {
|
||||
if (contacts == null) {
|
||||
return null;
|
||||
}
|
||||
ImmutableSet.Builder<DesignatedContact> linkedContacts = new ImmutableSet.Builder<>();
|
||||
for (DesignatedContact contact : contacts) {
|
||||
for (ForeignKeyedDesignatedContact contact : contacts) {
|
||||
linkedContacts.add(DesignatedContact.create(
|
||||
contact.getType(),
|
||||
linkReference(contact.getContactId(), ContactResource.class, now)));
|
||||
contact.type, loadReference(contact.contactId, ContactResource.class, now)));
|
||||
}
|
||||
return linkedContacts.build();
|
||||
}
|
||||
|
||||
/** Turn a foreign-keyed {@link ReferenceUnion} into a linked one. */
|
||||
private static <T extends EppResource> ReferenceUnion<T> linkReference(
|
||||
final ReferenceUnion<T> reference, final Class<T> clazz, final DateTime now)
|
||||
/** Load a reference to a resource by its foreign key. */
|
||||
private static <T extends EppResource> Ref<T> loadReference(
|
||||
final String foreignKey, final Class<T> clazz, final DateTime now)
|
||||
throws InvalidReferenceException {
|
||||
if (reference.getForeignKey() == null) {
|
||||
return reference;
|
||||
}
|
||||
Ref<T> ref = ofy().doTransactionless(new Work<Ref<T>>() {
|
||||
@Override
|
||||
public Ref<T> run() {
|
||||
return loadAndGetReference(clazz, reference.getForeignKey(), now);
|
||||
return loadAndGetReference(clazz, foreignKey, now);
|
||||
}
|
||||
});
|
||||
if (ref == null) {
|
||||
throw new InvalidReferenceException(clazz, reference.getForeignKey());
|
||||
throw new InvalidReferenceException(clazz, foreignKey);
|
||||
}
|
||||
return ReferenceUnion.create(ref);
|
||||
return ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* EPP-inputable version of XML type for contact identifiers associated with a domain, which can
|
||||
* be converted to a storable (and EPP-outputable) {@link DesignatedContact}.
|
||||
*
|
||||
* @see "http://tools.ietf.org/html/rfc5731#section-2.2"
|
||||
*/
|
||||
static class ForeignKeyedDesignatedContact extends ImmutableObject {
|
||||
@XmlAttribute(required = true)
|
||||
DesignatedContact.Type type;
|
||||
|
||||
@XmlValue
|
||||
String contactId;
|
||||
}
|
||||
|
||||
/** Exception to throw when a referenced object does not exist. */
|
||||
|
|
|
@ -16,7 +16,6 @@ package google.registry.model.domain;
|
|||
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.annotation.Embed;
|
||||
import com.googlecode.objectify.annotation.Ignore;
|
||||
import com.googlecode.objectify.annotation.Index;
|
||||
|
||||
import google.registry.model.EppResource;
|
||||
|
@ -24,81 +23,50 @@ import google.registry.model.ImmutableObject;
|
|||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.host.HostResource;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
|
||||
/**
|
||||
* A "union" type to represent referenced objects as either a foreign key or as a link to another
|
||||
* object in the datastore.
|
||||
* Legacy shell of a "union" type to represent referenced objects as either a foreign key or as a
|
||||
* link to another object in the datastore. In its current form it merely wraps a {@link Ref}.
|
||||
* <p>
|
||||
* This type always marshals as the "foreign key". When it is explicitly storing a foreign key it
|
||||
* gets the value from its own string field. When it is linked to another object, it gets the value
|
||||
* from the other object.
|
||||
* <p>
|
||||
* When a {@link ReferenceUnion} comes in from Epp, either in an update or a delete, it fills in the
|
||||
* "foreign key" string field, but as soon as the relevant Flow runs it deletes that field and
|
||||
* replaces it with a linked {@link Ref} to the object named by that string. We can't do this in a
|
||||
* {@code XmlJavaTypeAdapter} because failing a lookup is a business logic error, not a failure to
|
||||
* parse the XML.
|
||||
* This type always marshals as the "foreign key". We no longer use this type for unmarshalling.
|
||||
*
|
||||
* @param <T> the type being referenced
|
||||
*/
|
||||
@Embed
|
||||
public class ReferenceUnion<T extends EppResource> extends ImmutableObject implements Serializable {
|
||||
public class ReferenceUnion<T extends EppResource> extends ImmutableObject {
|
||||
|
||||
@Index
|
||||
Ref<T> linked;
|
||||
|
||||
/** This is never persisted, and only ever populated to marshal or unmarshal to or from XML. */
|
||||
@Ignore
|
||||
String foreignKey;
|
||||
|
||||
public Ref<T> getLinked() {
|
||||
return linked;
|
||||
}
|
||||
|
||||
public String getForeignKey() {
|
||||
return foreignKey;
|
||||
}
|
||||
|
||||
/** An adapter that is aware of the union inside {@link ReferenceUnion}. */
|
||||
/** An adapter that marshals the linked {@link Ref} as its loaded foreign key. */
|
||||
public static class Adapter<T extends EppResource>
|
||||
extends XmlAdapter<String, ReferenceUnion<T>> {
|
||||
|
||||
@Override
|
||||
public ReferenceUnion<T> unmarshal(String foreignKey) throws Exception {
|
||||
return ReferenceUnion.<T>create(foreignKey);
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String marshal(ReferenceUnion<T> reference) throws Exception {
|
||||
return reference.getForeignKey() == null
|
||||
? reference.getLinked().get().getForeignKey()
|
||||
: reference.getForeignKey();
|
||||
return reference.getLinked().get().getForeignKey();
|
||||
}
|
||||
}
|
||||
|
||||
/** An adapter for references to contacts. */
|
||||
static class ContactReferenceUnionAdapter extends ReferenceUnion.Adapter<ContactResource>{}
|
||||
static class ContactReferenceUnionAdapter extends Adapter<ContactResource>{}
|
||||
|
||||
/** An adapter for references to hosts. */
|
||||
static class HostReferenceUnionAdapter extends ReferenceUnion.Adapter<HostResource>{}
|
||||
|
||||
public static <T extends EppResource> ReferenceUnion<T> create(String foreignKey) {
|
||||
ReferenceUnion<T> instance = new ReferenceUnion<>();
|
||||
instance.foreignKey = foreignKey;
|
||||
return instance;
|
||||
}
|
||||
static class HostReferenceUnionAdapter extends Adapter<HostResource>{}
|
||||
|
||||
public static <T extends EppResource> ReferenceUnion<T> create(Ref<T> linked) {
|
||||
ReferenceUnion<T> instance = new ReferenceUnion<>();
|
||||
instance.linked = linked;
|
||||
return instance;
|
||||
}
|
||||
|
||||
/** Convenience method. */
|
||||
public static <T extends EppResource> ReferenceUnion<T> create(T resource) {
|
||||
return create(Ref.create(resource));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@ import google.registry.model.domain.DomainApplication;
|
|||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.GracePeriod;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.index.DomainApplicationIndex;
|
||||
import google.registry.model.index.EppResourceIndex;
|
||||
|
@ -246,8 +245,8 @@ public class VerifyEntityIntegrityAction implements Runnable {
|
|||
if (resource instanceof DomainBase) {
|
||||
DomainBase domainBase = (DomainBase) resource;
|
||||
Key<?> key = Key.create(domainBase);
|
||||
verifyExistence(key, bustUnions(domainBase.getReferencedContacts()));
|
||||
verifyExistence(key, bustUnions(domainBase.getNameservers()));
|
||||
verifyExistence(key, refsToKeys(domainBase.getReferencedContacts()));
|
||||
verifyExistence(key, refsToKeys(domainBase.getNameservers()));
|
||||
verifyExistence(key, domainBase.getTransferData().getServerApproveAutorenewEvent());
|
||||
verifyExistence(key, domainBase.getTransferData().getServerApproveAutorenewPollMessage());
|
||||
verifyExistence(key, domainBase.getTransferData().getServerApproveBillingEvent());
|
||||
|
@ -386,14 +385,13 @@ public class VerifyEntityIntegrityAction implements Runnable {
|
|||
return entity;
|
||||
}
|
||||
|
||||
private static <E extends EppResource> Set<Key<E>> bustUnions(
|
||||
Iterable<ReferenceUnion<E>> unions) {
|
||||
private static <E extends EppResource> ImmutableSet<Key<E>> refsToKeys(Iterable<Ref<E>> refs) {
|
||||
return FluentIterable
|
||||
.from(unions)
|
||||
.transform(new Function<ReferenceUnion<E>, Key<E>>() {
|
||||
.from(refs)
|
||||
.transform(new Function<Ref<E>, Key<E>>() {
|
||||
@Override
|
||||
public Key<E> apply(ReferenceUnion<E> union) {
|
||||
return union.getLinked().getKey();
|
||||
public Key<E> apply(Ref<E> ref) {
|
||||
return ref.getKey();
|
||||
}})
|
||||
.toSet();
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import google.registry.model.contact.PostalInfo;
|
|||
import google.registry.model.domain.DesignatedContact;
|
||||
import google.registry.model.domain.DesignatedContact.Type;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.eppcommon.Address;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
|
@ -398,11 +397,7 @@ public class RdapJsonFormatter {
|
|||
@Nullable String linkBase,
|
||||
@Nullable String whoisServer) {
|
||||
// Kick off the database loads of the nameservers that we will need.
|
||||
Set<Ref<HostResource>> hostRefs = new LinkedHashSet<>();
|
||||
for (ReferenceUnion<HostResource> hostReference : domainResource.getNameservers()) {
|
||||
hostRefs.add(hostReference.getLinked());
|
||||
}
|
||||
Map<Key<HostResource>, HostResource> loadedHosts = ofy().load().refs(hostRefs);
|
||||
ImmutableSet<HostResource> loadedHosts = domainResource.loadNameservers();
|
||||
// And the registrant and other contacts.
|
||||
List<DesignatedContact> allContacts = new ArrayList<>();
|
||||
if (domainResource.getRegistrant() != null) {
|
||||
|
@ -411,7 +406,7 @@ public class RdapJsonFormatter {
|
|||
allContacts.addAll(domainResource.getContacts());
|
||||
Set<Ref<ContactResource>> contactRefs = new LinkedHashSet<>();
|
||||
for (DesignatedContact designatedContact : allContacts) {
|
||||
contactRefs.add(designatedContact.getContactId().getLinked());
|
||||
contactRefs.add(designatedContact.getContactRef());
|
||||
}
|
||||
Map<Key<ContactResource>, ContactResource> loadedContacts = ofy().load().refs(contactRefs);
|
||||
// Now, assemble the results, using the loaded objects as needed.
|
||||
|
@ -432,8 +427,7 @@ public class RdapJsonFormatter {
|
|||
}
|
||||
// Nameservers
|
||||
ImmutableList.Builder<Object> nsBuilder = new ImmutableList.Builder<>();
|
||||
for (HostResource hostResource
|
||||
: HOST_RESOURCE_ORDERING.immutableSortedCopy(loadedHosts.values())) {
|
||||
for (HostResource hostResource : HOST_RESOURCE_ORDERING.immutableSortedCopy(loadedHosts)) {
|
||||
nsBuilder.add(makeRdapJsonForHost(hostResource, false, linkBase, null));
|
||||
}
|
||||
ImmutableList<Object> ns = nsBuilder.build();
|
||||
|
@ -445,7 +439,7 @@ public class RdapJsonFormatter {
|
|||
for (DesignatedContact designatedContact
|
||||
: DESIGNATED_CONTACT_ORDERING.immutableSortedCopy(allContacts)) {
|
||||
ContactResource loadedContact =
|
||||
loadedContacts.get(designatedContact.getContactId().getLinked().key());
|
||||
loadedContacts.get(designatedContact.getContactRef().key());
|
||||
entitiesBuilder.add(makeRdapJsonForContact(
|
||||
loadedContact, false, Optional.of(designatedContact.getType()), linkBase, null));
|
||||
}
|
||||
|
|
|
@ -17,10 +17,11 @@ package google.registry.rde;
|
|||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.domain.DesignatedContact;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
|
@ -163,9 +164,9 @@ final class DomainResourceToXjcConverter {
|
|||
// o An OPTIONAL <registrant> element that contain the identifier for
|
||||
// the human or organizational social information object associated
|
||||
// as the holder of the domain name object.
|
||||
ReferenceUnion<ContactResource> registrant = model.getRegistrant();
|
||||
Ref<ContactResource> registrant = model.getRegistrant();
|
||||
if (registrant != null) {
|
||||
bean.setRegistrant(registrant.getLinked().get().getContactId());
|
||||
bean.setRegistrant(registrant.get().getContactId());
|
||||
}
|
||||
|
||||
// o Zero or more OPTIONAL <contact> elements that contain identifiers
|
||||
|
@ -282,7 +283,7 @@ final class DomainResourceToXjcConverter {
|
|||
/** Converts {@link DesignatedContact} to {@link XjcDomainContactType}. */
|
||||
private static XjcDomainContactType convertDesignatedContact(DesignatedContact model) {
|
||||
XjcDomainContactType bean = new XjcDomainContactType();
|
||||
ContactResource contact = model.getContactId().getLinked().get();
|
||||
ContactResource contact = model.getContactRef().get();
|
||||
bean.setType(XjcDomainContactAttrType.fromValue(model.getType().toString().toLowerCase()));
|
||||
bean.setValue(contact.getContactId());
|
||||
return bean;
|
||||
|
|
|
@ -140,7 +140,7 @@ final class AllocateDomainCommand extends MutatingEppToolCommand {
|
|||
for (DesignatedContact contact : application.getContacts()) {
|
||||
contactsMapBuilder.put(
|
||||
contact.getType().toString().toLowerCase(),
|
||||
contact.getContactId().getLinked().get().getForeignKey());
|
||||
contact.getContactRef().get().getForeignKey());
|
||||
}
|
||||
LaunchNotice launchNotice = application.getLaunchNotice();
|
||||
addSoyRecord(application.getCurrentSponsorClientId(), new SoyMapData(
|
||||
|
|
|
@ -27,9 +27,9 @@ import com.google.template.soy.data.SoyMapData;
|
|||
|
||||
import com.beust.jcommander.Parameter;
|
||||
import com.beust.jcommander.Parameters;
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.tools.Command.GtechCommand;
|
||||
|
@ -113,8 +113,8 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand impleme
|
|||
|
||||
private ImmutableSortedSet<String> getExistingNameservers(DomainResource domain) {
|
||||
ImmutableSortedSet.Builder<String> nameservers = ImmutableSortedSet.naturalOrder();
|
||||
for (ReferenceUnion<HostResource> nameserverRef : domain.getNameservers()) {
|
||||
nameservers.add(nameserverRef.getLinked().get().getForeignKey());
|
||||
for (Ref<HostResource> nameserverRef : domain.getNameservers()) {
|
||||
nameservers.add(nameserverRef.get().getForeignKey());
|
||||
}
|
||||
return nameservers.build();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ package google.registry.tools.server;
|
|||
|
||||
import static com.google.appengine.tools.cloudstorage.GcsServiceFactory.createGcsService;
|
||||
import static com.google.common.base.Predicates.notNull;
|
||||
import static com.google.common.collect.Iterables.transform;
|
||||
import static com.google.common.collect.Iterators.filter;
|
||||
import static com.google.common.io.BaseEncoding.base16;
|
||||
import static google.registry.mapreduce.inputs.EppResourceInputs.createEntityInput;
|
||||
|
@ -38,15 +37,12 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.config.ConfigModule.Config;
|
||||
import google.registry.gcs.GcsUtils;
|
||||
import google.registry.mapreduce.MapreduceRunner;
|
||||
import google.registry.mapreduce.inputs.NullInput;
|
||||
import google.registry.model.EppResource;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.request.Action;
|
||||
|
@ -280,14 +276,7 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA
|
|||
*/
|
||||
private static String domainStanza(DomainResource domain, DateTime exportTime) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (HostResource nameserver : ofy().load().refs(
|
||||
transform(
|
||||
domain.getNameservers(),
|
||||
new Function<ReferenceUnion<HostResource>, Ref<HostResource>>() {
|
||||
@Override
|
||||
public Ref<HostResource> apply(ReferenceUnion<HostResource> referenceUnion) {
|
||||
return referenceUnion.getLinked();
|
||||
}})).values()) {
|
||||
for (HostResource nameserver : ofy().load().refs(domain.getNameservers()).values()) {
|
||||
result.append(String.format(
|
||||
NS_FORMAT,
|
||||
domain.getFullyQualifiedDomainName(),
|
||||
|
|
|
@ -24,6 +24,8 @@ import com.google.common.base.Optional;
|
|||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.model.contact.ContactPhoneNumber;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.contact.PostalInfo;
|
||||
|
@ -31,7 +33,6 @@ import google.registry.model.domain.DesignatedContact;
|
|||
import google.registry.model.domain.DesignatedContact.Type;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.GracePeriod;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
|
@ -103,14 +104,14 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
|
|||
|
||||
/** Returns the contact of the given type, or null if it does not exist. */
|
||||
@Nullable
|
||||
private ReferenceUnion<ContactResource> getContactReference(final Type type) {
|
||||
private Ref<ContactResource> getContactReference(final Type type) {
|
||||
Optional<DesignatedContact> contactOfType = tryFind(domain.getContacts(),
|
||||
new Predicate<DesignatedContact>() {
|
||||
@Override
|
||||
public boolean apply(DesignatedContact d) {
|
||||
return d.getType() == type;
|
||||
}});
|
||||
return contactOfType.isPresent() ? contactOfType.get().getContactId() : null;
|
||||
return contactOfType.isPresent() ? contactOfType.get().getContactRef() : null;
|
||||
}
|
||||
|
||||
/** Output emitter with logic for domains. */
|
||||
|
@ -126,7 +127,7 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
|
|||
/** Emit the contact entry of the given type. */
|
||||
DomainEmitter emitContact(
|
||||
String contactType,
|
||||
@Nullable ReferenceUnion<ContactResource> contact,
|
||||
@Nullable Ref<ContactResource> contact,
|
||||
boolean preferUnicode) {
|
||||
if (contact == null) {
|
||||
return this;
|
||||
|
@ -134,10 +135,10 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
|
|||
// If we refer to a contact that doesn't exist, that's a bug. It means referential integrity
|
||||
// has somehow been broken. We skip the rest of this contact, but log it to hopefully bring it
|
||||
// someone's attention.
|
||||
ContactResource contactResource = contact.getLinked().get();
|
||||
ContactResource contactResource = contact.get();
|
||||
if (contactResource == null) {
|
||||
logger.severefmt("(BUG) Broken reference found from domain %s to contact %s",
|
||||
domain.getFullyQualifiedDomainName(), contact.getLinked());
|
||||
domain.getFullyQualifiedDomainName(), contact);
|
||||
return this;
|
||||
}
|
||||
emitField(contactType, "ID", contactResource.getContactId());
|
||||
|
|
|
@ -32,8 +32,9 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.net.InetAddresses;
|
||||
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
|
@ -109,8 +110,7 @@ public class DnsUpdateWriterTest {
|
|||
DomainResource domain =
|
||||
persistActiveDomain("example.tld")
|
||||
.asBuilder()
|
||||
.setNameservers(
|
||||
ImmutableSet.of(ReferenceUnion.create(host1), ReferenceUnion.create(host2)))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(host1), Ref.create(host2)))
|
||||
.build();
|
||||
persistResource(domain);
|
||||
|
||||
|
@ -129,8 +129,7 @@ public class DnsUpdateWriterTest {
|
|||
DomainResource domain =
|
||||
persistActiveDomain("example.tld")
|
||||
.asBuilder()
|
||||
.setNameservers(
|
||||
ImmutableSet.of(ReferenceUnion.create(persistActiveHost("ns1.example.tld"))))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(persistActiveHost("ns1.example.tld"))))
|
||||
.setDsData(
|
||||
ImmutableSet.of(
|
||||
DelegationSignerData.create(1, 3, 1, base16().decode("0123456789ABCDEF"))))
|
||||
|
@ -154,8 +153,7 @@ public class DnsUpdateWriterTest {
|
|||
persistActiveDomain("example.tld")
|
||||
.asBuilder()
|
||||
.addStatusValue(StatusValue.SERVER_HOLD)
|
||||
.setNameservers(
|
||||
ImmutableSet.of(ReferenceUnion.create(persistActiveHost("ns1.example.tld"))))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(persistActiveHost("ns1.example.tld"))))
|
||||
.build();
|
||||
persistResource(domain);
|
||||
|
||||
|
@ -223,8 +221,7 @@ public class DnsUpdateWriterTest {
|
|||
DomainResource domain =
|
||||
persistActiveDomain("example.tld")
|
||||
.asBuilder()
|
||||
.setNameservers(
|
||||
ImmutableSet.of(ReferenceUnion.create(persistActiveHost("ns1.example.tld"))))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(persistActiveHost("ns1.example.tld"))))
|
||||
.build();
|
||||
persistResource(domain);
|
||||
when(mockResolver.send(any(Message.class))).thenReturn(messageWithResponseCode(Rcode.SERVFAIL));
|
||||
|
|
|
@ -40,7 +40,6 @@ import google.registry.model.contact.ContactPhoneNumber;
|
|||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.contact.PostalInfo;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.eppcommon.Trid;
|
||||
import google.registry.model.poll.PendingActionNotificationResponse;
|
||||
|
@ -79,8 +78,7 @@ public class DeleteContactResourceActionTest
|
|||
assertAboutContacts().that(contactUsed).doesNotHaveStatusValue(StatusValue.PENDING_DELETE)
|
||||
.and().hasDeletionTime(END_OF_TIME);
|
||||
domain = loadByUniqueId(DomainResource.class, "example.tld", now);
|
||||
assertThat(domain.getReferencedContacts())
|
||||
.contains(ReferenceUnion.<ContactResource>create(Ref.create(contactUsed)));
|
||||
assertThat(domain.getReferencedContacts()).contains(Ref.create(contactUsed));
|
||||
HistoryEntry historyEntry =
|
||||
getOnlyHistoryEntryOfType(contactUsed, HistoryEntry.Type.CONTACT_DELETE_FAILURE);
|
||||
assertPollMessageFor(
|
||||
|
|
|
@ -29,11 +29,11 @@ import com.google.common.base.Optional;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.mapreduce.MapreduceRunner;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.ofy.Ofy;
|
||||
import google.registry.model.poll.PollMessage;
|
||||
|
@ -84,7 +84,7 @@ public abstract class DeleteEppResourceActionTestCase<T extends DeleteEppResourc
|
|||
hostUsed = persistActiveHost("ns1.example.tld");
|
||||
domain = persistResource(
|
||||
newDomainResource("example.tld", contactUsed).asBuilder()
|
||||
.setNameservers(ImmutableSet.of(ReferenceUnion.create(hostUsed)))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(hostUsed)))
|
||||
.build());
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ import com.googlecode.objectify.Key;
|
|||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
|
@ -68,8 +67,7 @@ public class DeleteHostResourceActionTest
|
|||
assertAboutHosts().that(hostUsed).doesNotHaveStatusValue(StatusValue.PENDING_DELETE)
|
||||
.and().hasDeletionTime(END_OF_TIME);
|
||||
domain = loadByUniqueId(DomainResource.class, "example.tld", now);
|
||||
assertThat(domain.getNameservers())
|
||||
.contains(ReferenceUnion.<HostResource>create(Ref.create(hostUsed)));
|
||||
assertThat(domain.getNameservers()).contains(Ref.create(hostUsed));
|
||||
HistoryEntry historyEntry =
|
||||
getOnlyHistoryEntryOfType(hostUsed, HistoryEntry.Type.HOST_DELETE_FAILURE);
|
||||
assertPollMessageFor(
|
||||
|
|
|
@ -30,10 +30,10 @@ import com.google.common.base.Optional;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.dns.DnsQueue;
|
||||
import google.registry.mapreduce.MapreduceRunner;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.request.HttpException.BadRequestException;
|
||||
import google.registry.testing.ExceptionRule;
|
||||
|
@ -77,21 +77,21 @@ public class DnsRefreshForHostRenameActionTest
|
|||
@Test
|
||||
public void testSuccess_dnsUpdateEnqueued() throws Exception {
|
||||
createTld("tld");
|
||||
HostResource renamedHost = persistActiveHost("ns1.example.tld");
|
||||
HostResource otherHost = persistActiveHost("ns2.example.tld");
|
||||
Ref<HostResource> renamedHostRef = Ref.create(persistActiveHost("ns1.example.tld"));
|
||||
Ref<HostResource> otherHostRef = Ref.create(persistActiveHost("ns2.example.tld"));
|
||||
persistResource(newDomainApplication("notadomain.tld").asBuilder()
|
||||
.setNameservers(ImmutableSet.of(ReferenceUnion.create(renamedHost)))
|
||||
.setNameservers(ImmutableSet.of(renamedHostRef))
|
||||
.build());
|
||||
persistResource(newDomainResource("example.tld").asBuilder()
|
||||
.setNameservers(ImmutableSet.of(ReferenceUnion.create(renamedHost)))
|
||||
.setNameservers(ImmutableSet.of(renamedHostRef))
|
||||
.build());
|
||||
persistResource(newDomainResource("otherexample.tld").asBuilder()
|
||||
.setNameservers(ImmutableSet.of(ReferenceUnion.create(renamedHost)))
|
||||
.setNameservers(ImmutableSet.of(renamedHostRef))
|
||||
.build());
|
||||
persistResource(newDomainResource("untouched.tld").asBuilder()
|
||||
.setNameservers(ImmutableSet.of(ReferenceUnion.create(otherHost)))
|
||||
.setNameservers(ImmutableSet.of(otherHostRef))
|
||||
.build());
|
||||
runMapreduce(Key.create(renamedHost).getString());
|
||||
runMapreduce(renamedHostRef.getKey().getString());
|
||||
verify(dnsQueue).addDomainRefreshTask("example.tld");
|
||||
verify(dnsQueue).addDomainRefreshTask("otherexample.tld");
|
||||
verifyNoMoreInteractions(dnsQueue);
|
||||
|
@ -100,12 +100,12 @@ public class DnsRefreshForHostRenameActionTest
|
|||
@Test
|
||||
public void testSuccess_noDnsTasksForDeletedDomain() throws Exception {
|
||||
createTld("tld");
|
||||
HostResource renamedHost = persistActiveHost("ns1.example.tld");
|
||||
Ref<HostResource> renamedHostRef = Ref.create(persistActiveHost("ns1.example.tld"));
|
||||
persistResource(newDomainResource("example.tld").asBuilder()
|
||||
.setNameservers(ImmutableSet.of(ReferenceUnion.create(renamedHost)))
|
||||
.setNameservers(ImmutableSet.of(renamedHostRef))
|
||||
.setDeletionTime(START_OF_TIME)
|
||||
.build());
|
||||
runMapreduce(Key.create(renamedHost).getString());
|
||||
runMapreduce(renamedHostRef.getKey().getString());
|
||||
verifyZeroInteractions(dnsQueue);
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ import google.registry.flows.domain.DomainFlowUtils.LaunchPhaseMismatchException
|
|||
import google.registry.flows.domain.DomainFlowUtils.LeadingDashException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.LinkedResourceDoesNotExistException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.MissingContactTypeException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.NameserverNotAllowedException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.NameserversNotAllowedException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.NoMarksFoundMatchingDomainException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.PremiumNameBlockedException;
|
||||
|
@ -1191,7 +1191,7 @@ public class DomainApplicationCreateFlowTest
|
|||
persistResource(Registry.get("tld").asBuilder()
|
||||
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns2.example.net"))
|
||||
.build());
|
||||
thrown.expect(NameserverNotAllowedException.class, "ns1.example.net");
|
||||
thrown.expect(NameserversNotAllowedException.class, "ns1.example.net");
|
||||
runFlow();
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ import static google.registry.testing.GenericEppResourceSubject.assertAboutEppRe
|
|||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.flows.EppException.UnimplementedExtensionException;
|
||||
import google.registry.flows.FlowRunner.CommitMode;
|
||||
import google.registry.flows.FlowRunner.UserPrivileges;
|
||||
|
@ -41,7 +43,6 @@ import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException
|
|||
import google.registry.model.EppResource;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.domain.DomainApplication;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.domain.launch.LaunchPhase;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
|
@ -89,10 +90,10 @@ public class DomainApplicationDeleteFlowTest
|
|||
persistResource(newDomainApplication("example.tld").asBuilder()
|
||||
.setRepoId("1-TLD")
|
||||
.setRegistrant(
|
||||
ReferenceUnion.create(
|
||||
Ref.create(
|
||||
loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))
|
||||
.setNameservers(ImmutableSet.of(
|
||||
ReferenceUnion.create(
|
||||
Ref.create(
|
||||
loadByUniqueId(HostResource.class, "ns1.example.net", clock.nowUtc()))))
|
||||
.build());
|
||||
doSuccessfulTest();
|
||||
|
|
|
@ -26,6 +26,8 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||
import google.registry.flows.ResourceQueryFlow.ResourceToQueryDoesNotExistException;
|
||||
|
@ -37,7 +39,6 @@ import google.registry.model.domain.DesignatedContact;
|
|||
import google.registry.model.domain.DesignatedContact.Type;
|
||||
import google.registry.model.domain.DomainApplication;
|
||||
import google.registry.model.domain.DomainAuthInfo;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.domain.launch.ApplicationStatus;
|
||||
import google.registry.model.domain.launch.LaunchCreateExtension;
|
||||
import google.registry.model.domain.launch.LaunchPhase;
|
||||
|
@ -89,12 +90,12 @@ public class DomainApplicationInfoFlowTest
|
|||
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
|
||||
.setLastEppUpdateTime(DateTime.parse("1999-12-03T09:00:00.0Z"))
|
||||
.setLastTransferTime(DateTime.parse("2000-04-08T09:00:00.0Z"))
|
||||
.setRegistrant(ReferenceUnion.create(registrant))
|
||||
.setRegistrant(Ref.create(registrant))
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, ReferenceUnion.create(contact)),
|
||||
DesignatedContact.create(Type.TECH, ReferenceUnion.create(contact))))
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(contact)),
|
||||
DesignatedContact.create(Type.TECH, Ref.create(contact))))
|
||||
.setNameservers(hostsState.equals(HostsState.HOSTS_EXIST) ? ImmutableSet.of(
|
||||
ReferenceUnion.create(host1), ReferenceUnion.create(host2)) : null)
|
||||
Ref.create(host1), Ref.create(host2)) : null)
|
||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("2fooBAR")))
|
||||
.addStatusValue(StatusValue.PENDING_CREATE)
|
||||
.setApplicationStatus(ApplicationStatus.PENDING_VALIDATION)
|
||||
|
@ -244,7 +245,7 @@ public class DomainApplicationInfoFlowTest
|
|||
.setDsData(ImmutableSet.of(DelegationSignerData.create(
|
||||
12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC"))))
|
||||
.setNameservers(ImmutableSet.of(
|
||||
ReferenceUnion.create(host1), ReferenceUnion.create(host2)))
|
||||
Ref.create(host1), Ref.create(host2)))
|
||||
.build());
|
||||
doSuccessfulTest("domain_info_sunrise_response_dsdata.xml", HostsState.NO_HOSTS_EXIST);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
|||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.flows.EppException.UnimplementedExtensionException;
|
||||
import google.registry.flows.FlowRunner.CommitMode;
|
||||
import google.registry.flows.FlowRunner.UserPrivileges;
|
||||
|
@ -50,7 +52,7 @@ import google.registry.flows.domain.DomainFlowUtils.LinkedResourceDoesNotExistEx
|
|||
import google.registry.flows.domain.DomainFlowUtils.MissingAdminContactException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.MissingContactTypeException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.MissingTechnicalContactException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.NameserverNotAllowedException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.NameserversNotAllowedException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.RegistrantNotAllowedException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.TooManyDsRecordsException;
|
||||
|
@ -60,7 +62,6 @@ import google.registry.model.domain.DesignatedContact;
|
|||
import google.registry.model.domain.DesignatedContact.Type;
|
||||
import google.registry.model.domain.DomainApplication;
|
||||
import google.registry.model.domain.DomainApplication.Builder;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.domain.launch.ApplicationStatus;
|
||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
|
@ -108,9 +109,9 @@ public class DomainApplicationUpdateFlowTest
|
|||
private DomainApplication persistApplication() throws Exception {
|
||||
return persistResource(newApplicationBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.TECH, ReferenceUnion.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.ADMIN, ReferenceUnion.create(unusedContact))))
|
||||
.setNameservers(ImmutableSet.of(ReferenceUnion.create(
|
||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(unusedContact))))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(
|
||||
loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
|
||||
.build());
|
||||
}
|
||||
|
@ -174,7 +175,7 @@ public class DomainApplicationUpdateFlowTest
|
|||
persistReferencedEntities();
|
||||
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
||||
persistResource(
|
||||
newApplicationBuilder().setRegistrant(ReferenceUnion.create(sh8013)).build());
|
||||
newApplicationBuilder().setRegistrant(Ref.create(sh8013)).build());
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||
}
|
||||
|
@ -184,13 +185,13 @@ public class DomainApplicationUpdateFlowTest
|
|||
setEppInput("domain_update_sunrise_remove_multiple_contacts.xml");
|
||||
persistReferencedEntities();
|
||||
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
||||
ReferenceUnion<ContactResource> sh8013ReferenceUnion = ReferenceUnion.create(sh8013);
|
||||
Ref<ContactResource> sh8013Ref = Ref.create(sh8013);
|
||||
persistResource(newApplicationBuilder()
|
||||
.setRegistrant(sh8013ReferenceUnion)
|
||||
.setRegistrant(sh8013Ref)
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, sh8013ReferenceUnion),
|
||||
DesignatedContact.create(Type.BILLING, sh8013ReferenceUnion),
|
||||
DesignatedContact.create(Type.TECH, sh8013ReferenceUnion)))
|
||||
DesignatedContact.create(Type.ADMIN, sh8013Ref),
|
||||
DesignatedContact.create(Type.BILLING, sh8013Ref),
|
||||
DesignatedContact.create(Type.TECH, sh8013Ref)))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||
|
@ -373,10 +374,10 @@ public class DomainApplicationUpdateFlowTest
|
|||
}
|
||||
|
||||
private void modifyApplicationToHave13Nameservers() throws Exception {
|
||||
ImmutableSet.Builder<ReferenceUnion<HostResource>> nameservers = new ImmutableSet.Builder<>();
|
||||
ImmutableSet.Builder<Ref<HostResource>> nameservers = new ImmutableSet.Builder<>();
|
||||
for (int i = 1; i < 15; i++) {
|
||||
if (i != 2) { // Skip 2 since that's the one that the tests will add.
|
||||
nameservers.add(ReferenceUnion.create(loadByUniqueId(
|
||||
nameservers.add(Ref.create(loadByUniqueId(
|
||||
HostResource.class, String.format("ns%d.example.tld", i), clock.nowUtc())));
|
||||
}
|
||||
}
|
||||
|
@ -496,7 +497,7 @@ public class DomainApplicationUpdateFlowTest
|
|||
// Add a tech contact to the persisted entity, which should cause the flow to fail when it tries
|
||||
// to add "mak21" as a second tech contact.
|
||||
persistResource(reloadResourceByUniqueId().asBuilder().setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.TECH, ReferenceUnion.create(
|
||||
DesignatedContact.create(Type.TECH, Ref.create(
|
||||
loadByUniqueId(ContactResource.class, "foo", clock.nowUtc()))))).build());
|
||||
runFlow();
|
||||
}
|
||||
|
@ -581,7 +582,7 @@ public class DomainApplicationUpdateFlowTest
|
|||
setEppInput("domain_update_sunrise_add_remove_same_host.xml");
|
||||
persistReferencedEntities();
|
||||
persistResource(newApplicationBuilder()
|
||||
.setNameservers(ImmutableSet.of(ReferenceUnion.create(
|
||||
.setNameservers(ImmutableSet.of(Ref.create(
|
||||
loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
|
||||
.build());
|
||||
runFlow();
|
||||
|
@ -595,7 +596,7 @@ public class DomainApplicationUpdateFlowTest
|
|||
persistResource(newApplicationBuilder()
|
||||
.setContacts(ImmutableSet.of(DesignatedContact.create(
|
||||
Type.TECH,
|
||||
ReferenceUnion.create(
|
||||
Ref.create(
|
||||
loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))))
|
||||
.build());
|
||||
runFlow();
|
||||
|
@ -608,8 +609,8 @@ public class DomainApplicationUpdateFlowTest
|
|||
persistReferencedEntities();
|
||||
persistResource(newApplicationBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, ReferenceUnion.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, ReferenceUnion.create(sh8013Contact))))
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact))))
|
||||
.build());
|
||||
runFlow();
|
||||
}
|
||||
|
@ -621,8 +622,8 @@ public class DomainApplicationUpdateFlowTest
|
|||
persistReferencedEntities();
|
||||
persistResource(newApplicationBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, ReferenceUnion.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, ReferenceUnion.create(sh8013Contact))))
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact))))
|
||||
.build());
|
||||
runFlow();
|
||||
}
|
||||
|
@ -649,7 +650,7 @@ public class DomainApplicationUpdateFlowTest
|
|||
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns1.example.foo"))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
thrown.expect(NameserverNotAllowedException.class);
|
||||
thrown.expect(NameserversNotAllowedException.class);
|
||||
runFlow();
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ import google.registry.flows.domain.DomainFlowUtils.MissingAdminContactException
|
|||
import google.registry.flows.domain.DomainFlowUtils.MissingContactTypeException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.MissingRegistrantException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.MissingTechnicalContactException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.NameserverNotAllowedException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.NameserversNotAllowedException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.PremiumNameBlockedException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.RegistrantNotAllowedException;
|
||||
|
@ -1251,7 +1251,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
persistResource(Registry.get("tld").asBuilder()
|
||||
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns2.example.net"))
|
||||
.build());
|
||||
thrown.expect(NameserverNotAllowedException.class, "ns1.example.net");
|
||||
thrown.expect(NameserversNotAllowedException.class, "ns1.example.net");
|
||||
runFlow();
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@ import google.registry.model.billing.BillingEvent.Reason;
|
|||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.GracePeriod;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.eppcommon.Trid;
|
||||
|
@ -118,7 +117,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
ContactResource contact = persistActiveContact("sh8013");
|
||||
domain = newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setCreationTimeForTest(TIME_BEFORE_FLOW)
|
||||
.setRegistrant(ReferenceUnion.create(contact))
|
||||
.setRegistrant(Ref.create(contact))
|
||||
.setRegistrationExpirationTime(expirationTime)
|
||||
.build();
|
||||
earlierHistoryEntry = persistResource(
|
||||
|
@ -466,14 +465,12 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
persistResource(loadByUniqueId(
|
||||
DomainResource.class, getUniqueIdFromCommand(), clock.nowUtc())
|
||||
.asBuilder()
|
||||
.setNameservers(ImmutableSet.of(ReferenceUnion.create(host)))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(host)))
|
||||
.build());
|
||||
// Persist another domain that's already been deleted and references this contact and host.
|
||||
persistResource(newDomainResource("example1.tld").asBuilder()
|
||||
.setRegistrant(
|
||||
ReferenceUnion.create(loadByUniqueId(
|
||||
ContactResource.class, "sh8013", clock.nowUtc())))
|
||||
.setNameservers(ImmutableSet.of(ReferenceUnion.create(host)))
|
||||
.setRegistrant(Ref.create(loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(host)))
|
||||
.setDeletionTime(START_OF_TIME)
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
|
|
|
@ -44,7 +44,6 @@ import google.registry.model.domain.DesignatedContact.Type;
|
|||
import google.registry.model.domain.DomainAuthInfo;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.GracePeriod;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
||||
|
@ -91,12 +90,11 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
|
|||
.setLastEppUpdateTime(DateTime.parse("1999-12-03T09:00:00.0Z"))
|
||||
.setLastTransferTime(DateTime.parse("2000-04-08T09:00:00.0Z"))
|
||||
.setRegistrationExpirationTime(DateTime.parse("2005-04-03T22:00:00.0Z"))
|
||||
.setRegistrant(ReferenceUnion.create(registrant))
|
||||
.setRegistrant(Ref.create(registrant))
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, ReferenceUnion.create(contact)),
|
||||
DesignatedContact.create(Type.TECH, ReferenceUnion.create(contact))))
|
||||
.setNameservers(inactive ? null
|
||||
: ImmutableSet.of(ReferenceUnion.create(host1), ReferenceUnion.create(host2)))
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(contact)),
|
||||
DesignatedContact.create(Type.TECH, Ref.create(contact))))
|
||||
.setNameservers(inactive ? null : ImmutableSet.of(Ref.create(host1), Ref.create(host2)))
|
||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("2fooBAR")))
|
||||
.build());
|
||||
// Set the superordinate domain of ns1.example.com to example.com. In reality, this would have
|
||||
|
@ -243,8 +241,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
|
|||
persistResource(domain.asBuilder()
|
||||
.setDsData(ImmutableSet.of(DelegationSignerData.create(
|
||||
12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC"))))
|
||||
.setNameservers(ImmutableSet.of(
|
||||
ReferenceUnion.create(host1), ReferenceUnion.create(host3)))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(host1), Ref.create(host3)))
|
||||
.build());
|
||||
doSuccessfulTest("domain_info_response_dsdata.xml", false);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ import google.registry.model.domain.DesignatedContact.Type;
|
|||
import google.registry.model.domain.DomainAuthInfo;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.GracePeriod;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
|
@ -123,18 +122,14 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
|
|||
.setCreationClientId("TheRegistrar")
|
||||
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
|
||||
.setRegistrationExpirationTime(REGISTRATION_EXPIRATION_TIME)
|
||||
.setRegistrant(
|
||||
ReferenceUnion.create(loadByUniqueId(
|
||||
ContactResource.class, "jd1234", clock.nowUtc())))
|
||||
.setRegistrant(Ref.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc())))
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(
|
||||
Type.ADMIN,
|
||||
ReferenceUnion.create(
|
||||
loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc()))),
|
||||
Ref.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc()))),
|
||||
DesignatedContact.create(
|
||||
Type.TECH,
|
||||
ReferenceUnion.create(
|
||||
loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc())))))
|
||||
Ref.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc())))))
|
||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("fooBAR")))
|
||||
.addGracePeriod(GracePeriod.create(
|
||||
GracePeriodStatus.ADD, clock.nowUtc().plusDays(10), "foo", null))
|
||||
|
|
|
@ -62,7 +62,7 @@ import google.registry.flows.domain.DomainFlowUtils.LinkedResourceInPendingDelet
|
|||
import google.registry.flows.domain.DomainFlowUtils.MissingAdminContactException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.MissingContactTypeException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.MissingTechnicalContactException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.NameserverNotAllowedException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.NameserversNotAllowedException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.RegistrantNotAllowedException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.TooManyDsRecordsException;
|
||||
|
@ -74,7 +74,6 @@ import google.registry.model.domain.DesignatedContact;
|
|||
import google.registry.model.domain.DesignatedContact.Type;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.GracePeriod;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
|
@ -123,9 +122,9 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
DomainResource domain = persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.TECH, ReferenceUnion.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.ADMIN, ReferenceUnion.create(unusedContact))))
|
||||
.setNameservers(ImmutableSet.of(ReferenceUnion.create(host)))
|
||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(unusedContact))))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(host)))
|
||||
.build());
|
||||
historyEntryDomainCreate = persistResource(
|
||||
new HistoryEntry.Builder()
|
||||
|
@ -180,7 +179,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
HistoryEntry historyEntryDomainUpdate =
|
||||
getOnlyHistoryEntryOfType(resource, HistoryEntry.Type.DOMAIN_UPDATE);
|
||||
assertThat(resource.getNameservers()).containsExactly(
|
||||
ReferenceUnion.create(
|
||||
Ref.create(
|
||||
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc())));
|
||||
BillingEvent.OneTime regularAddBillingEvent = new BillingEvent.OneTime.Builder()
|
||||
.setReason(Reason.CREATE)
|
||||
|
@ -278,7 +277,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
// serverHold on it.
|
||||
persistResource(
|
||||
reloadResourceByUniqueId().asBuilder()
|
||||
.setNameservers(ImmutableSet.of(ReferenceUnion.create(
|
||||
.setNameservers(ImmutableSet.of(Ref.create(
|
||||
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
|
||||
.addGracePeriod(GracePeriod.forBillingEvent(
|
||||
GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
|
||||
|
@ -302,7 +301,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
// serverHold on it.
|
||||
persistResource(
|
||||
reloadResourceByUniqueId().asBuilder()
|
||||
.setNameservers(ImmutableSet.of(ReferenceUnion.create(
|
||||
.setNameservers(ImmutableSet.of(Ref.create(
|
||||
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
|
||||
.addGracePeriod(GracePeriod.forBillingEvent(
|
||||
GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
|
||||
|
@ -345,10 +344,10 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
private void modifyDomainToHave13Nameservers() throws Exception {
|
||||
ImmutableSet.Builder<ReferenceUnion<HostResource>> nameservers = new ImmutableSet.Builder<>();
|
||||
ImmutableSet.Builder<Ref<HostResource>> nameservers = new ImmutableSet.Builder<>();
|
||||
for (int i = 1; i < 15; i++) {
|
||||
if (i != 2) { // Skip 2 since that's the one that the tests will add.
|
||||
nameservers.add(ReferenceUnion.create(loadByUniqueId(
|
||||
nameservers.add(Ref.create(loadByUniqueId(
|
||||
HostResource.class, String.format("ns%d.example.foo", i), clock.nowUtc())));
|
||||
}
|
||||
}
|
||||
|
@ -374,11 +373,11 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistDomain();
|
||||
setEppInput("domain_update_max_everything.xml");
|
||||
// Create 26 hosts and 8 contacts. Start the domain with half of them.
|
||||
ImmutableSet.Builder<ReferenceUnion<HostResource>> nameservers = new ImmutableSet.Builder<>();
|
||||
ImmutableSet.Builder<Ref<HostResource>> nameservers = new ImmutableSet.Builder<>();
|
||||
for (int i = 0; i < 26; i++) {
|
||||
HostResource host = persistActiveHost(String.format("max_test_%d.example.tld", i));
|
||||
if (i < 13) {
|
||||
nameservers.add(ReferenceUnion.create(host));
|
||||
nameservers.add(Ref.create(host));
|
||||
}
|
||||
}
|
||||
ImmutableSet.Builder<DesignatedContact> contacts = new ImmutableSet.Builder<>();
|
||||
|
@ -388,7 +387,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
contacts.add(
|
||||
DesignatedContact.create(
|
||||
DesignatedContact.Type.values()[i],
|
||||
ReferenceUnion.create(contact)));
|
||||
Ref.create(contact)));
|
||||
}
|
||||
}
|
||||
persistResource(
|
||||
|
@ -407,7 +406,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
assertThat(domain.getNameservers()).hasSize(13);
|
||||
// getContacts does not return contacts of type REGISTRANT, so check these separately.
|
||||
assertThat(domain.getContacts()).hasSize(3);
|
||||
assertThat(domain.getRegistrant().getLinked().get().getContactId()).isEqualTo("max_test_7");
|
||||
assertThat(domain.getRegistrant().get().getContactId()).isEqualTo("max_test_7");
|
||||
assertNoBillingEvents();
|
||||
assertDnsTasksEnqueued("example.tld");
|
||||
}
|
||||
|
@ -459,14 +458,14 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
domain = persistResource(domain.asBuilder()
|
||||
.addSubordinateHost("ns1.example.tld")
|
||||
.addSubordinateHost("ns2.example.tld")
|
||||
.setNameservers(ImmutableSet.of(ReferenceUnion.create(
|
||||
.setNameservers(ImmutableSet.of(Ref.create(
|
||||
loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
assertTransactionalFlow(true);
|
||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||
domain = reloadResourceByUniqueId();
|
||||
assertThat(domain.getNameservers()).containsExactly(ReferenceUnion.create(addedHost));
|
||||
assertThat(domain.getNameservers()).containsExactly(Ref.create(addedHost));
|
||||
assertThat(domain.getSubordinateHosts()).containsExactly("ns1.example.tld", "ns2.example.tld");
|
||||
existingHost = loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc());
|
||||
addedHost = loadByUniqueId(HostResource.class, "ns2.example.tld", clock.nowUtc());
|
||||
|
@ -481,7 +480,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
||||
persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setRegistrant(ReferenceUnion.create(sh8013))
|
||||
.setRegistrant(Ref.create(sh8013))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||
|
@ -492,14 +491,14 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
setEppInput("domain_update_remove_multiple_contacts.xml");
|
||||
persistReferencedEntities();
|
||||
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
||||
ReferenceUnion<ContactResource> sh8013ReferenceUnion = ReferenceUnion.create(sh8013);
|
||||
Ref<ContactResource> sh8013Ref = Ref.create(sh8013);
|
||||
persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setRegistrant(sh8013ReferenceUnion)
|
||||
.setRegistrant(sh8013Ref)
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, sh8013ReferenceUnion),
|
||||
DesignatedContact.create(Type.BILLING, sh8013ReferenceUnion),
|
||||
DesignatedContact.create(Type.TECH, sh8013ReferenceUnion)))
|
||||
DesignatedContact.create(Type.ADMIN, sh8013Ref),
|
||||
DesignatedContact.create(Type.BILLING, sh8013Ref),
|
||||
DesignatedContact.create(Type.TECH, sh8013Ref)))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||
|
@ -891,7 +890,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistResource(
|
||||
reloadResourceByUniqueId().asBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.TECH, ReferenceUnion.create(
|
||||
DesignatedContact.create(Type.TECH, Ref.create(
|
||||
loadByUniqueId(ContactResource.class, "foo", clock.nowUtc())))))
|
||||
.build());
|
||||
runFlow();
|
||||
|
@ -988,7 +987,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistReferencedEntities();
|
||||
persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setNameservers(ImmutableSet.of(ReferenceUnion.create(
|
||||
.setNameservers(ImmutableSet.of(Ref.create(
|
||||
loadByUniqueId(HostResource.class, "ns1.example.foo", clock.nowUtc()))))
|
||||
.build());
|
||||
runFlow();
|
||||
|
@ -1003,7 +1002,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setContacts(ImmutableSet.of(DesignatedContact.create(
|
||||
Type.TECH,
|
||||
ReferenceUnion.create(
|
||||
Ref.create(
|
||||
loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))))
|
||||
.build());
|
||||
runFlow();
|
||||
|
@ -1017,8 +1016,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, ReferenceUnion.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, ReferenceUnion.create(sh8013Contact))))
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact))))
|
||||
.build());
|
||||
runFlow();
|
||||
}
|
||||
|
@ -1031,8 +1030,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, ReferenceUnion.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, ReferenceUnion.create(sh8013Contact))))
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact))))
|
||||
.build());
|
||||
runFlow();
|
||||
}
|
||||
|
@ -1094,7 +1093,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns1.example.foo"))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
thrown.expect(NameserverNotAllowedException.class);
|
||||
thrown.expect(NameserversNotAllowedException.class);
|
||||
runFlow();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.flows.FlowRunner.CommitMode;
|
||||
import google.registry.flows.FlowRunner.UserPrivileges;
|
||||
|
@ -41,7 +42,6 @@ import google.registry.flows.ResourceMutateFlow.ResourceToMutateDoesNotExistExce
|
|||
import google.registry.flows.SingleResourceFlow.ResourceStatusProhibitsOperationException;
|
||||
import google.registry.flows.async.DeleteEppResourceAction;
|
||||
import google.registry.flows.async.DeleteHostResourceAction;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
|
@ -179,7 +179,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
|
|||
createTld("tld");
|
||||
persistResource(newDomainResource("example.tld").asBuilder()
|
||||
.setNameservers(ImmutableSet.of(
|
||||
ReferenceUnion.create(persistActiveHost(getUniqueIdFromCommand()))))
|
||||
Ref.create(persistActiveHost(getUniqueIdFromCommand()))))
|
||||
.build());
|
||||
thrown.expect(ResourceToDeleteIsReferencedException.class);
|
||||
runFlow();
|
||||
|
@ -190,7 +190,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
|
|||
createTld("tld");
|
||||
persistResource(newDomainApplication("example.tld").asBuilder()
|
||||
.setNameservers(ImmutableSet.of(
|
||||
ReferenceUnion.create(persistActiveHost(getUniqueIdFromCommand()))))
|
||||
Ref.create(persistActiveHost(getUniqueIdFromCommand()))))
|
||||
.build());
|
||||
thrown.expect(ResourceToDeleteIsReferencedException.class);
|
||||
runFlow();
|
||||
|
|
|
@ -29,7 +29,6 @@ import com.googlecode.objectify.Ref;
|
|||
import google.registry.flows.ResourceFlowTestCase;
|
||||
import google.registry.flows.ResourceQueryFlow.ResourceToQueryDoesNotExistException;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
|
||||
|
@ -94,7 +93,7 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
|
|||
persistResource(
|
||||
newDomainResource("example.foobar").asBuilder()
|
||||
.addNameservers(
|
||||
ImmutableSet.of(ReferenceUnion.<HostResource>create(persistHostResource(true))))
|
||||
ImmutableSet.of(Ref.<HostResource>create(persistHostResource(true))))
|
||||
.build());
|
||||
assertTransactionalFlow(false);
|
||||
// Check that the persisted host info was returned.
|
||||
|
|
|
@ -58,7 +58,6 @@ import google.registry.flows.host.HostUpdateFlow.HostAlreadyExistsException;
|
|||
import google.registry.flows.host.HostUpdateFlow.RenameHostToExternalRemoveIpException;
|
||||
import google.registry.flows.host.HostUpdateFlow.RenameHostToSubordinateRequiresIpException;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.index.ForeignKeyIndex;
|
||||
|
@ -162,7 +161,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
persistResource(
|
||||
newDomainResource("test.xn--q9jyb4c").asBuilder()
|
||||
.setDeletionTime(END_OF_TIME)
|
||||
.setNameservers(ImmutableSet.of(ReferenceUnion.create(host)))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(host)))
|
||||
.build());
|
||||
HostResource renamedHost = doSuccessfulTest();
|
||||
assertThat(renamedHost.getSuperordinateDomain()).isNull();
|
||||
|
|
|
@ -19,6 +19,7 @@ import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
|||
import static google.registry.testing.DatastoreHelper.cloneAndSetAutoTimestamps;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.newDomainApplication;
|
||||
import static google.registry.testing.DatastoreHelper.newHostResource;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
|
@ -29,6 +30,7 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.model.EntityTestCase;
|
||||
import google.registry.model.billing.BillingEvent;
|
||||
|
@ -78,12 +80,12 @@ public class DomainApplicationTest extends EntityTestCase {
|
|||
StatusValue.SERVER_UPDATE_PROHIBITED,
|
||||
StatusValue.SERVER_RENEW_PROHIBITED,
|
||||
StatusValue.SERVER_HOLD))
|
||||
.setRegistrant(ReferenceUnion.create(persistActiveContact("contact_id1")))
|
||||
.setRegistrant(Ref.create(persistActiveContact("contact_id1")))
|
||||
.setContacts(ImmutableSet.of(DesignatedContact.create(
|
||||
DesignatedContact.Type.ADMIN,
|
||||
ReferenceUnion.create(persistActiveContact("contact_id2")))))
|
||||
Ref.create(persistActiveContact("contact_id2")))))
|
||||
.setNameservers(
|
||||
ImmutableSet.of(ReferenceUnion.create(persistActiveHost("ns1.example.com"))))
|
||||
ImmutableSet.of(Ref.create(persistActiveHost("ns1.example.com"))))
|
||||
.setCurrentSponsorClientId("a third registrar")
|
||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("password")))
|
||||
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
|
||||
|
@ -149,12 +151,12 @@ public class DomainApplicationTest extends EntityTestCase {
|
|||
public void testEmptySetsAndArraysBecomeNull() {
|
||||
assertThat(emptyBuilder().setNameservers(null).build().nameservers).isNull();
|
||||
assertThat(emptyBuilder()
|
||||
.setNameservers(ImmutableSet.<ReferenceUnion<HostResource>>of())
|
||||
.setNameservers(ImmutableSet.<Ref<HostResource>>of())
|
||||
.build()
|
||||
.nameservers)
|
||||
.isNull();
|
||||
assertThat(emptyBuilder()
|
||||
.setNameservers(ImmutableSet.of(ReferenceUnion.<HostResource>create("foo")))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(newHostResource("foo.example.tld"))))
|
||||
.build()
|
||||
.nameservers)
|
||||
.isNotNull();
|
||||
|
|
|
@ -20,6 +20,7 @@ import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
|||
import static google.registry.testing.DatastoreHelper.cloneAndSetAutoTimestamps;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
||||
import static google.registry.testing.DatastoreHelper.newHostResource;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
|
@ -103,11 +104,11 @@ public class DomainResourceTest extends EntityTestCase {
|
|||
StatusValue.SERVER_UPDATE_PROHIBITED,
|
||||
StatusValue.SERVER_RENEW_PROHIBITED,
|
||||
StatusValue.SERVER_HOLD))
|
||||
.setRegistrant(ReferenceUnion.create(contactResource1))
|
||||
.setRegistrant(Ref.create(contactResource1))
|
||||
.setContacts(ImmutableSet.of(DesignatedContact.create(
|
||||
DesignatedContact.Type.ADMIN,
|
||||
ReferenceUnion.create(contactResource2))))
|
||||
.setNameservers(ImmutableSet.of(ReferenceUnion.create(hostResource)))
|
||||
Ref.create(contactResource2))))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(hostResource)))
|
||||
.setSubordinateHosts(ImmutableSet.of("ns1.example.com"))
|
||||
.setCurrentSponsorClientId("a third registrar")
|
||||
.setRegistrationExpirationTime(clock.nowUtc().plusYears(1))
|
||||
|
@ -190,10 +191,10 @@ public class DomainResourceTest extends EntityTestCase {
|
|||
assertThat(newDomainResource("example.com").asBuilder()
|
||||
.setNameservers(null).build().nameservers).isNull();
|
||||
assertThat(newDomainResource("example.com").asBuilder()
|
||||
.setNameservers(ImmutableSet.<ReferenceUnion<HostResource>>of()).build().nameservers)
|
||||
.setNameservers(ImmutableSet.<Ref<HostResource>>of()).build().nameservers)
|
||||
.isNull();
|
||||
assertThat(newDomainResource("example.com").asBuilder()
|
||||
.setNameservers(ImmutableSet.of(ReferenceUnion.<HostResource>create("foo")))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(newHostResource("foo.example.tld"))))
|
||||
.build().nameservers)
|
||||
.isNotNull();
|
||||
// This behavior should also hold true for ImmutableObjects nested in collections.
|
||||
|
@ -222,8 +223,8 @@ public class DomainResourceTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testImplicitStatusValues() {
|
||||
ImmutableSet<ReferenceUnion<HostResource>> nameservers =
|
||||
ImmutableSet.of(ReferenceUnion.<HostResource>create("foo"));
|
||||
ImmutableSet<Ref<HostResource>> nameservers =
|
||||
ImmutableSet.of(Ref.create(newHostResource("foo.example.tld")));
|
||||
StatusValue[] statuses = {StatusValue.OK};
|
||||
// OK is implicit if there's no other statuses but there are nameservers.
|
||||
assertAboutDomains()
|
||||
|
|
|
@ -49,7 +49,6 @@ import google.registry.config.RegistryEnvironment;
|
|||
import google.registry.mapreduce.MapreduceRunner;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.index.EppResourceIndex;
|
||||
import google.registry.model.index.ForeignKeyIndex;
|
||||
|
@ -192,9 +191,9 @@ public class VerifyEntityIntegrityActionTest
|
|||
.asBuilder()
|
||||
.setNameservers(
|
||||
ImmutableSet.of(
|
||||
ReferenceUnion.create(Ref.create(missingHost1)),
|
||||
ReferenceUnion.create(Ref.create(missingHost2)),
|
||||
ReferenceUnion.create(Ref.create(missingHost3))))
|
||||
Ref.create(missingHost1),
|
||||
Ref.create(missingHost2),
|
||||
Ref.create(missingHost3)))
|
||||
.build());
|
||||
String source = Key.create(domain).toString();
|
||||
runMapreduce();
|
||||
|
|
|
@ -25,6 +25,7 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
|||
import static org.joda.money.CurrencyUnit.USD;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.registry.label.PremiumList;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
|
|
|
@ -46,7 +46,6 @@ import google.registry.model.domain.DesignatedContact;
|
|||
import google.registry.model.domain.DomainAuthInfo;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.GracePeriod;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
||||
|
@ -264,10 +263,10 @@ public class DomainResourceToXjcConverterTest {
|
|||
domain = domain.asBuilder()
|
||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("secret")))
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(DesignatedContact.Type.ADMIN, ReferenceUnion.create(
|
||||
DesignatedContact.create(DesignatedContact.Type.ADMIN, Ref.create(
|
||||
makeContactResource(clock, "10-Q9JYB4C", "5372808-IRL",
|
||||
"be that word our sign in parting", "BOFH@cat.みんな"))),
|
||||
DesignatedContact.create(DesignatedContact.Type.TECH, ReferenceUnion.create(
|
||||
DesignatedContact.create(DesignatedContact.Type.TECH, Ref.create(
|
||||
makeContactResource(clock, "11-Q9JYB4C", "5372808-TRL",
|
||||
"bird or fiend!? i shrieked upstarting", "bog@cat.みんな")))))
|
||||
.setCreationClientId("LawyerCat")
|
||||
|
@ -280,11 +279,11 @@ public class DomainResourceToXjcConverterTest {
|
|||
.setLastEppUpdateClientId("IntoTheTempest")
|
||||
.setLastEppUpdateTime(DateTime.parse("1920-01-01T00:00:00Z"))
|
||||
.setNameservers(ImmutableSet.of(
|
||||
ReferenceUnion.create(
|
||||
Ref.create(
|
||||
makeHostResource(clock, "3-Q9JYB4C", "bird.or.devil.みんな", "1.2.3.4")),
|
||||
ReferenceUnion.create(
|
||||
Ref.create(
|
||||
makeHostResource(clock, "4-Q9JYB4C", "ns2.cat.みんな", "bad:f00d:cafe::15:beef"))))
|
||||
.setRegistrant(ReferenceUnion.create(makeContactResource(
|
||||
.setRegistrant(Ref.create(makeContactResource(
|
||||
clock, "12-Q9JYB4C", "5372808-ERL", "(◕‿◕) nevermore", "prophet@evil.みんな")))
|
||||
.setRegistrationExpirationTime(DateTime.parse("1930-01-01T00:00:00Z"))
|
||||
.setGracePeriods(ImmutableSet.of(
|
||||
|
|
|
@ -41,7 +41,6 @@ import google.registry.model.domain.DesignatedContact;
|
|||
import google.registry.model.domain.DomainAuthInfo;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.GracePeriod;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
||||
|
@ -85,10 +84,10 @@ final class RdeFixtures {
|
|||
domain = domain.asBuilder()
|
||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("secret")))
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(DesignatedContact.Type.ADMIN, ReferenceUnion.create(
|
||||
DesignatedContact.create(DesignatedContact.Type.ADMIN, Ref.create(
|
||||
makeContactResource(clock, "5372808-IRL",
|
||||
"be that word our sign in parting", "BOFH@cat.みんな"))),
|
||||
DesignatedContact.create(DesignatedContact.Type.TECH, ReferenceUnion.create(
|
||||
DesignatedContact.create(DesignatedContact.Type.TECH, Ref.create(
|
||||
makeContactResource(clock, "5372808-TRL",
|
||||
"bird or fiend!? i shrieked upstarting", "bog@cat.みんな")))))
|
||||
.setCreationClientId("TheRegistrar")
|
||||
|
@ -102,12 +101,12 @@ final class RdeFixtures {
|
|||
.setLastEppUpdateTime(clock.nowUtc())
|
||||
.setIdnTableName("extended_latin")
|
||||
.setNameservers(ImmutableSet.of(
|
||||
ReferenceUnion.create(
|
||||
Ref.create(
|
||||
makeHostResource(clock, "bird.or.devil.みんな", "1.2.3.4")),
|
||||
ReferenceUnion.create(
|
||||
Ref.create(
|
||||
makeHostResource(
|
||||
clock, "ns2.cat.みんな", "bad:f00d:cafe::15:beef"))))
|
||||
.setRegistrant(ReferenceUnion.create(
|
||||
.setRegistrant(Ref.create(
|
||||
makeContactResource(clock,
|
||||
"5372808-ERL", "(◕‿◕) nevermore", "prophet@evil.みんな")))
|
||||
.setRegistrationExpirationTime(DateTime.parse("1930-01-01T00:00:00Z"))
|
||||
|
|
|
@ -38,6 +38,7 @@ java_library(
|
|||
"//java/com/google/common/collect",
|
||||
"//third_party/java/appengine:appengine-api",
|
||||
"//third_party/java/joda_time",
|
||||
"//third_party/java/objectify:objectify-v4_1",
|
||||
"//java/google/registry/model",
|
||||
"//javatests/google/registry/testing",
|
||||
],
|
||||
|
|
|
@ -26,11 +26,12 @@ import static google.registry.testing.DatastoreHelper.persistResource;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.model.contact.ContactAddress;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.contact.PostalInfo;
|
||||
import google.registry.model.domain.DesignatedContact;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.ofy.Ofy;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.testing.FakeClock;
|
||||
|
@ -114,28 +115,26 @@ public enum Fixture {
|
|||
persistResource(
|
||||
newDomainResource("love.xn--q9jyb4c", justine).asBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(ADMIN, ReferenceUnion.create(robert)),
|
||||
DesignatedContact.create(BILLING, ReferenceUnion.create(google)),
|
||||
DesignatedContact.create(TECH, ReferenceUnion.create(justine))))
|
||||
DesignatedContact.create(ADMIN, Ref.create(robert)),
|
||||
DesignatedContact.create(BILLING, Ref.create(google)),
|
||||
DesignatedContact.create(TECH, Ref.create(justine))))
|
||||
.setNameservers(ImmutableSet.of(
|
||||
ReferenceUnion.create(
|
||||
persistActiveHost("ns1.love.xn--q9jyb4c")),
|
||||
ReferenceUnion.create(
|
||||
persistActiveHost("ns2.love.xn--q9jyb4c"))))
|
||||
Ref.create(persistActiveHost("ns1.love.xn--q9jyb4c")),
|
||||
Ref.create(persistActiveHost("ns2.love.xn--q9jyb4c"))))
|
||||
.build());
|
||||
|
||||
persistResource(
|
||||
newDomainResource("moogle.example", justine).asBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(ADMIN, ReferenceUnion.create(robert)),
|
||||
DesignatedContact.create(BILLING, ReferenceUnion.create(google)),
|
||||
DesignatedContact.create(TECH, ReferenceUnion.create(justine))))
|
||||
DesignatedContact.create(ADMIN, Ref.create(robert)),
|
||||
DesignatedContact.create(BILLING, Ref.create(google)),
|
||||
DesignatedContact.create(TECH, Ref.create(justine))))
|
||||
.setNameservers(ImmutableSet.of(
|
||||
ReferenceUnion.create(persistActiveHost("ns1.linode.com")),
|
||||
ReferenceUnion.create(persistActiveHost("ns2.linode.com")),
|
||||
ReferenceUnion.create(persistActiveHost("ns3.linode.com")),
|
||||
ReferenceUnion.create(persistActiveHost("ns4.linode.com")),
|
||||
ReferenceUnion.create(persistActiveHost("ns5.linode.com"))))
|
||||
Ref.create(persistActiveHost("ns1.linode.com")),
|
||||
Ref.create(persistActiveHost("ns2.linode.com")),
|
||||
Ref.create(persistActiveHost("ns3.linode.com")),
|
||||
Ref.create(persistActiveHost("ns4.linode.com")),
|
||||
Ref.create(persistActiveHost("ns5.linode.com"))))
|
||||
.build());
|
||||
|
||||
persistResource(
|
||||
|
|
|
@ -68,7 +68,6 @@ import google.registry.model.domain.DesignatedContact.Type;
|
|||
import google.registry.model.domain.DomainApplication;
|
||||
import google.registry.model.domain.DomainAuthInfo;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.domain.launch.LaunchPhase;
|
||||
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
|
@ -132,6 +131,7 @@ public class DatastoreHelper {
|
|||
|
||||
public static DomainResource newDomainResource(
|
||||
String domainName, String repoId, ContactResource contact) {
|
||||
Ref<ContactResource> contactRef = Ref.create(contact);
|
||||
return new DomainResource.Builder()
|
||||
.setRepoId(repoId)
|
||||
.setFullyQualifiedDomainName(domainName)
|
||||
|
@ -139,10 +139,10 @@ public class DatastoreHelper {
|
|||
.setCurrentSponsorClientId("TheRegistrar")
|
||||
.setCreationTimeForTest(START_OF_TIME)
|
||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("2fooBAR")))
|
||||
.setRegistrant(ReferenceUnion.create(contact))
|
||||
.setRegistrant(contactRef)
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, ReferenceUnion.create(contact)),
|
||||
DesignatedContact.create(Type.TECH, ReferenceUnion.create(contact))))
|
||||
DesignatedContact.create(Type.ADMIN, contactRef),
|
||||
DesignatedContact.create(Type.TECH, contactRef)))
|
||||
.setRegistrationExpirationTime(END_OF_TIME)
|
||||
.build();
|
||||
}
|
||||
|
@ -172,15 +172,16 @@ public class DatastoreHelper {
|
|||
|
||||
public static DomainApplication newDomainApplication(
|
||||
String domainName, String repoId, ContactResource contact, LaunchPhase phase) {
|
||||
Ref<ContactResource> contactRef = Ref.create(contact);
|
||||
return new DomainApplication.Builder()
|
||||
.setRepoId(repoId)
|
||||
.setFullyQualifiedDomainName(domainName)
|
||||
.setCurrentSponsorClientId("TheRegistrar")
|
||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("2fooBAR")))
|
||||
.setRegistrant(ReferenceUnion.create(contact))
|
||||
.setRegistrant(contactRef)
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, ReferenceUnion.create(contact)),
|
||||
DesignatedContact.create(Type.TECH, ReferenceUnion.create(contact))))
|
||||
DesignatedContact.create(Type.ADMIN, contactRef),
|
||||
DesignatedContact.create(Type.TECH, contactRef)))
|
||||
.setPhase(phase)
|
||||
.setApplicationStatus(VALIDATED)
|
||||
.addStatusValue(StatusValue.PENDING_CREATE)
|
||||
|
|
|
@ -24,6 +24,8 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.net.InetAddresses;
|
||||
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.model.EppResource;
|
||||
import google.registry.model.contact.ContactAddress;
|
||||
import google.registry.model.contact.ContactPhoneNumber;
|
||||
|
@ -32,7 +34,6 @@ import google.registry.model.contact.PostalInfo;
|
|||
import google.registry.model.domain.DesignatedContact;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.Period;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.eppcommon.Trid;
|
||||
|
@ -232,27 +233,27 @@ public final class FullFieldsTestEntityHelper {
|
|||
StatusValue.SERVER_UPDATE_PROHIBITED))
|
||||
.setDsData(ImmutableSet.of(new DelegationSignerData()));
|
||||
if (registrant != null) {
|
||||
builder.setRegistrant(ReferenceUnion.create(registrant));
|
||||
builder.setRegistrant(Ref.create(registrant));
|
||||
}
|
||||
if ((admin != null) || (tech != null)) {
|
||||
ImmutableSet.Builder<DesignatedContact> contactsBuilder = new ImmutableSet.Builder<>();
|
||||
if (admin != null) {
|
||||
contactsBuilder.add(DesignatedContact.create(
|
||||
DesignatedContact.Type.ADMIN, ReferenceUnion.create(admin)));
|
||||
DesignatedContact.Type.ADMIN, Ref.create(admin)));
|
||||
}
|
||||
if (tech != null) {
|
||||
contactsBuilder.add(DesignatedContact.create(
|
||||
DesignatedContact.Type.TECH, ReferenceUnion.create(tech)));
|
||||
DesignatedContact.Type.TECH, Ref.create(tech)));
|
||||
}
|
||||
builder.setContacts(contactsBuilder.build());
|
||||
}
|
||||
if ((ns1 != null) || (ns2 != null)) {
|
||||
ImmutableSet.Builder<ReferenceUnion<HostResource>> nsBuilder = new ImmutableSet.Builder<>();
|
||||
ImmutableSet.Builder<Ref<HostResource>> nsBuilder = new ImmutableSet.Builder<>();
|
||||
if (ns1 != null) {
|
||||
nsBuilder.add(ReferenceUnion.create(ns1));
|
||||
nsBuilder.add(Ref.create(ns1));
|
||||
}
|
||||
if (ns2 != null) {
|
||||
nsBuilder.add(ReferenceUnion.create(ns2));
|
||||
nsBuilder.add(Ref.create(ns2));
|
||||
}
|
||||
builder.setNameservers(nsBuilder.build());
|
||||
}
|
||||
|
|
|
@ -42,12 +42,12 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.flows.EppXmlTransformer;
|
||||
import google.registry.flows.domain.DomainAllocateFlow;
|
||||
import google.registry.model.domain.DesignatedContact;
|
||||
import google.registry.model.domain.DomainApplication;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.domain.launch.LaunchNotice;
|
||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.eppcommon.Trid;
|
||||
|
@ -93,20 +93,20 @@ public class AllocateDomainCommandTest extends CommandTestCase<AllocateDomainCom
|
|||
.asBuilder()
|
||||
.setRepoId(repoId)
|
||||
.setCreationTimeForTest(START_OF_TIME)
|
||||
.setRegistrant(ReferenceUnion.create(persistActiveContact("registrant")))
|
||||
.setRegistrant(Ref.create(persistActiveContact("registrant")))
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(
|
||||
ADMIN,
|
||||
ReferenceUnion.create(persistActiveContact("adminContact"))),
|
||||
Ref.create(persistActiveContact("adminContact"))),
|
||||
DesignatedContact.create(
|
||||
BILLING,
|
||||
ReferenceUnion.create(persistActiveContact("billingContact"))),
|
||||
Ref.create(persistActiveContact("billingContact"))),
|
||||
DesignatedContact.create(
|
||||
TECH,
|
||||
ReferenceUnion.create(persistActiveContact("techContact")))))
|
||||
Ref.create(persistActiveContact("techContact")))))
|
||||
.setNameservers(ImmutableSet.of(
|
||||
ReferenceUnion.create(persistActiveHost("ns1.example.com")),
|
||||
ReferenceUnion.create(persistActiveHost("ns2.example.com"))))
|
||||
Ref.create(persistActiveHost("ns1.example.com")),
|
||||
Ref.create(persistActiveHost("ns2.example.com"))))
|
||||
.setApplicationStatus(VALIDATED)
|
||||
.setDsData(ImmutableSet.of(
|
||||
DelegationSignerData.create(
|
||||
|
|
|
@ -34,7 +34,6 @@ import com.beust.jcommander.ParameterException;
|
|||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
|
@ -135,17 +134,13 @@ public class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsRep
|
|||
nameserver3 = persistActiveHost("ns1.google.com");
|
||||
nameserver4 = persistActiveHost("ns2.google.com");
|
||||
domain1 = persistResource(newDomainResource("example.xn--q9jyb4c").asBuilder()
|
||||
.setNameservers(ImmutableSet.of(
|
||||
ReferenceUnion.create(Ref.create(nameserver1)),
|
||||
ReferenceUnion.create(Ref.create(nameserver2))))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(nameserver1), Ref.create(nameserver2)))
|
||||
.setDsData(ImmutableSet.of(
|
||||
DelegationSignerData.create(12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC")),
|
||||
DelegationSignerData.create(56789, 2, 4, base16().decode("69FD46E6C4A45C55D4AC"))))
|
||||
.build());
|
||||
persistResource(newDomainResource("foobar.xn--q9jyb4c").asBuilder()
|
||||
.setNameservers(ImmutableSet.of(
|
||||
ReferenceUnion.create(Ref.create(nameserver3)),
|
||||
ReferenceUnion.create(Ref.create(nameserver4))))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(nameserver3), Ref.create(nameserver4)))
|
||||
.build());
|
||||
// Persist a domain in a different tld that should be ignored.
|
||||
persistActiveDomain("should-be-ignored.example");
|
||||
|
|
|
@ -24,7 +24,6 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.beust.jcommander.ParameterException;
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
|
@ -45,9 +44,9 @@ public class UniformRapidSuspensionCommandTest
|
|||
}
|
||||
|
||||
private void persistDomainWithHosts(HostResource... hosts) {
|
||||
ImmutableSet.Builder<ReferenceUnion<HostResource>> hostRefs = new ImmutableSet.Builder<>();
|
||||
ImmutableSet.Builder<Ref<HostResource>> hostRefs = new ImmutableSet.Builder<>();
|
||||
for (HostResource host : hosts) {
|
||||
hostRefs.add(ReferenceUnion.create(Ref.create(host)));
|
||||
hostRefs.add(Ref.create(host));
|
||||
}
|
||||
persistResource(newDomainResource("evil.tld").asBuilder()
|
||||
.setNameservers(hostRefs.build())
|
||||
|
|
|
@ -37,8 +37,9 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.mapreduce.MapreduceRunner;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.testing.FakeClock;
|
||||
|
@ -73,10 +74,8 @@ public class GenerateZoneFilesActionTest extends MapreduceTestCase<GenerateZoneF
|
|||
HostResource host2 =
|
||||
persistResource(newHostResource("ns.bar.tld").asBuilder().addInetAddresses(ips).build());
|
||||
|
||||
ImmutableSet<ReferenceUnion<HostResource>> nameservers =
|
||||
ImmutableSet.of(
|
||||
ReferenceUnion.<HostResource>create(host1),
|
||||
ReferenceUnion.<HostResource>create(host2));
|
||||
ImmutableSet<Ref<HostResource>> nameservers =
|
||||
ImmutableSet.of(Ref.create(host1), Ref.create(host2));
|
||||
persistResource(newDomainResource("ns-and-ds.tld").asBuilder()
|
||||
.addNameservers(nameservers)
|
||||
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
|
||||
|
|
|
@ -32,7 +32,6 @@ import google.registry.model.contact.PostalInfo;
|
|||
import google.registry.model.domain.DesignatedContact;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.GracePeriod;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
|
@ -227,17 +226,11 @@ public class DomainWhoisResponseTest {
|
|||
StatusValue.CLIENT_RENEW_PROHIBITED,
|
||||
StatusValue.CLIENT_TRANSFER_PROHIBITED,
|
||||
StatusValue.SERVER_UPDATE_PROHIBITED))
|
||||
.setRegistrant(ReferenceUnion.create(registrantResourceRef))
|
||||
.setRegistrant(registrantResourceRef)
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(
|
||||
DesignatedContact.Type.ADMIN,
|
||||
ReferenceUnion.create(adminResourceRef)),
|
||||
DesignatedContact.create(
|
||||
DesignatedContact.Type.TECH,
|
||||
ReferenceUnion.create(techResourceRef))))
|
||||
.setNameservers(ImmutableSet.of(
|
||||
ReferenceUnion.create(hostResource1Ref),
|
||||
ReferenceUnion.create(hostResource2Ref)))
|
||||
DesignatedContact.create(DesignatedContact.Type.ADMIN, adminResourceRef),
|
||||
DesignatedContact.create(DesignatedContact.Type.TECH, techResourceRef)))
|
||||
.setNameservers(ImmutableSet.of(hostResource1Ref, hostResource2Ref))
|
||||
.setDsData(ImmutableSet.of(new DelegationSignerData()))
|
||||
.setGracePeriods(ImmutableSet.of(
|
||||
GracePeriod.create(GracePeriodStatus.ADD, END_OF_TIME, "", null),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue