mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +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
|
@ -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;
|
||||
|
@ -110,7 +109,7 @@ public abstract class DeleteEppResourceAction<T extends EppResource> implements
|
|||
"Resource %s is already deleted.", resource.getForeignKey());
|
||||
checkState(
|
||||
resource.getStatusValues().contains(StatusValue.PENDING_DELETE),
|
||||
"Resource %s is not set as PENDING_DELETE", resource.getForeignKey());
|
||||
"Resource %s is not set as PENDING_DELETE", resource.getForeignKey());
|
||||
mapper.setTargetResource(resourceKey);
|
||||
reducer.setClient(requestingClientId, isSuperuser);
|
||||
logger.infofmt("Executing Delete EPP resource mapreduce for %s", resourceKey);
|
||||
|
@ -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());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue