mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 00:47:11 +02:00
Get rid of ReferenceUnions entirely
This is the third and final phase in the migration away from ReferenceUnions. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=138778148
This commit is contained in:
parent
8d97fa5858
commit
780a5add78
14 changed files with 5 additions and 148 deletions
|
@ -36,33 +36,17 @@
|
|||
<property name="allContacts.contact" direction="asc"/>
|
||||
<property name="deletionTime" direction="asc"/>
|
||||
</datastore-index>
|
||||
<!-- TODO(b/28713909): Remove this index along with ReferenceUnions. -->
|
||||
<datastore-index kind="DomainBase" ancestor="false" source="manual">
|
||||
<property name="allContacts.contactId.linked" direction="asc"/>
|
||||
<property name="deletionTime" direction="asc"/>
|
||||
</datastore-index>
|
||||
<!-- For determining the active domains linked to a given host. -->
|
||||
<datastore-index kind="DomainBase" ancestor="false" source="manual">
|
||||
<property name="nsHosts" direction="asc"/>
|
||||
<property name="deletionTime" direction="asc"/>
|
||||
</datastore-index>
|
||||
<!-- TODO(b/28713909): Remove this index along with ReferenceUnions. -->
|
||||
<datastore-index kind="DomainBase" ancestor="false" source="manual">
|
||||
<property name="nameservers.linked" direction="asc"/>
|
||||
<property name="deletionTime" direction="asc"/>
|
||||
</datastore-index>
|
||||
<!-- For RDAP searches by linked nameserver. -->
|
||||
<datastore-index kind="DomainBase" ancestor="false" source="manual">
|
||||
<property name="^i" direction="asc"/>
|
||||
<property name="nsHosts" direction="asc"/>
|
||||
<property name="deletionTime" direction="asc"/>
|
||||
</datastore-index>
|
||||
<!-- TODO(b/28713909): Remove this index along with ReferenceUnions. -->
|
||||
<datastore-index kind="DomainBase" ancestor="false" source="manual">
|
||||
<property name="^i" direction="asc"/>
|
||||
<property name="nameservers.linked" direction="asc"/>
|
||||
<property name="deletionTime" direction="asc"/>
|
||||
</datastore-index>
|
||||
<!-- For WHOIS IP address lookup -->
|
||||
<datastore-index kind="HostResource" ancestor="false" source="manual">
|
||||
<property name="inetAddresses" direction="asc"/>
|
||||
|
|
|
@ -26,7 +26,6 @@ import com.google.common.collect.FluentIterable;
|
|||
import com.google.common.collect.Maps;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.annotation.Ignore;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
@ -145,9 +144,7 @@ public abstract class ImmutableObject implements Cloneable {
|
|||
new Function<Object, Object>() {
|
||||
@Override
|
||||
public Object apply(Object value) {
|
||||
if (value instanceof ReferenceUnion) {
|
||||
return apply(((ReferenceUnion<?>) value).getLinked());
|
||||
} else if (value instanceof Key) {
|
||||
if (value instanceof Key) {
|
||||
return apply(ofy().load().key((Key<?>) value).now());
|
||||
} else if (value instanceof Map) {
|
||||
return transformValues((Map<?, ?>) value, this);
|
||||
|
|
|
@ -22,7 +22,6 @@ import google.registry.model.ImmutableObject;
|
|||
import google.registry.model.contact.ContactResource;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlEnumValue;
|
||||
import javax.xml.bind.annotation.XmlValue;
|
||||
|
||||
/**
|
||||
* XML type for contact identifiers associated with a domain.
|
||||
|
@ -52,7 +51,6 @@ public class DesignatedContact extends ImmutableObject {
|
|||
public static DesignatedContact create(Type type, Key<ContactResource> contact) {
|
||||
DesignatedContact instance = new DesignatedContact();
|
||||
instance.type = type;
|
||||
instance.contactId = ReferenceUnion.create(contact);
|
||||
instance.contact = contact;
|
||||
return instance;
|
||||
}
|
||||
|
@ -60,11 +58,6 @@ public class DesignatedContact extends ImmutableObject {
|
|||
@XmlAttribute(required = true)
|
||||
Type type;
|
||||
|
||||
@Index
|
||||
@XmlValue
|
||||
//TODO(b/28713909): Remove contactId and replace with contact.
|
||||
ReferenceUnion<ContactResource> contactId;
|
||||
|
||||
@Index
|
||||
Key<ContactResource> contact;
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ import com.googlecode.objectify.Key;
|
|||
import com.googlecode.objectify.annotation.Entity;
|
||||
import com.googlecode.objectify.annotation.IgnoreSave;
|
||||
import com.googlecode.objectify.annotation.Index;
|
||||
import com.googlecode.objectify.annotation.OnSave;
|
||||
import com.googlecode.objectify.condition.IfNull;
|
||||
import google.registry.model.EppResource;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
|
@ -77,10 +76,6 @@ public abstract class DomainBase extends EppResource {
|
|||
String tld;
|
||||
|
||||
/** References to hosts that are the nameservers for the domain. */
|
||||
@XmlTransient
|
||||
//TODO(b/28713909): Delete this once migration away from ReferenceUnions is complete.
|
||||
Set<ReferenceUnion<HostResource>> nameservers;
|
||||
|
||||
@Index
|
||||
@XmlTransient
|
||||
Set<Key<HostResource>> nsHosts;
|
||||
|
@ -234,18 +229,6 @@ public abstract class DomainBase extends EppResource {
|
|||
return tld;
|
||||
}
|
||||
|
||||
@OnSave
|
||||
void dualSaveReferenceUnions() {
|
||||
for (DesignatedContact contact : nullToEmptyImmutableCopy(allContacts)) {
|
||||
contact.contactId = ReferenceUnion.create(contact.contact);
|
||||
}
|
||||
ImmutableSet.Builder<ReferenceUnion<HostResource>> hosts = new ImmutableSet.Builder<>();
|
||||
for (Key<HostResource> hostKey : nullToEmptyImmutableCopy(nsHosts)) {
|
||||
hosts.add(ReferenceUnion.create(hostKey));
|
||||
}
|
||||
nameservers = hosts.build();
|
||||
}
|
||||
|
||||
/** Predicate to determine if a given {@link DesignatedContact} is the registrant. */
|
||||
private static final Predicate<DesignatedContact> IS_REGISTRANT =
|
||||
new Predicate<DesignatedContact>() {
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
// Copyright 2016 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.model.domain;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.annotation.Embed;
|
||||
import com.googlecode.objectify.annotation.Index;
|
||||
import google.registry.model.EppResource;
|
||||
import google.registry.model.ImmutableObject;
|
||||
|
||||
/**
|
||||
* 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 Key}.
|
||||
*
|
||||
* @param <T> the type being referenced
|
||||
*/
|
||||
// TODO(b/28713909): Delete ReferenceUnion entirely.
|
||||
@Embed
|
||||
@Deprecated
|
||||
public class ReferenceUnion<T extends EppResource> extends ImmutableObject {
|
||||
|
||||
@Index
|
||||
Key<T> linked;
|
||||
|
||||
public Key<T> getLinked() {
|
||||
return linked;
|
||||
}
|
||||
|
||||
public static <T extends EppResource> ReferenceUnion<T> create(Key<T> linked) {
|
||||
ReferenceUnion<T> instance = new ReferenceUnion<>();
|
||||
instance.linked = linked;
|
||||
return instance;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue