diff --git a/java/google/registry/env/common/default/WEB-INF/datastore-indexes.xml b/java/google/registry/env/common/default/WEB-INF/datastore-indexes.xml index 45656832d..fee7c0dfe 100644 --- a/java/google/registry/env/common/default/WEB-INF/datastore-indexes.xml +++ b/java/google/registry/env/common/default/WEB-INF/datastore-indexes.xml @@ -36,33 +36,17 @@ - - - - - - - - - - - - - - - - diff --git a/java/google/registry/model/ImmutableObject.java b/java/google/registry/model/ImmutableObject.java index d8ff8fbc4..0ce694a7d 100644 --- a/java/google/registry/model/ImmutableObject.java +++ b/java/google/registry/model/ImmutableObject.java @@ -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() { @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); diff --git a/java/google/registry/model/domain/DesignatedContact.java b/java/google/registry/model/domain/DesignatedContact.java index cb176d4be..50b517db1 100644 --- a/java/google/registry/model/domain/DesignatedContact.java +++ b/java/google/registry/model/domain/DesignatedContact.java @@ -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 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 contactId; - @Index Key contact; diff --git a/java/google/registry/model/domain/DomainBase.java b/java/google/registry/model/domain/DomainBase.java index bf1d43bfa..fb54c7449 100644 --- a/java/google/registry/model/domain/DomainBase.java +++ b/java/google/registry/model/domain/DomainBase.java @@ -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> nameservers; - @Index @XmlTransient Set> 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> hosts = new ImmutableSet.Builder<>(); - for (Key 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 IS_REGISTRANT = new Predicate() { diff --git a/java/google/registry/model/domain/ReferenceUnion.java b/java/google/registry/model/domain/ReferenceUnion.java deleted file mode 100644 index 88a7a9395..000000000 --- a/java/google/registry/model/domain/ReferenceUnion.java +++ /dev/null @@ -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 the type being referenced - */ -// TODO(b/28713909): Delete ReferenceUnion entirely. -@Embed -@Deprecated -public class ReferenceUnion extends ImmutableObject { - - @Index - Key linked; - - public Key getLinked() { - return linked; - } - - public static ReferenceUnion create(Key linked) { - ReferenceUnion instance = new ReferenceUnion<>(); - instance.linked = linked; - return instance; - } -} diff --git a/javatests/google/registry/model/ImmutableObjectTest.java b/javatests/google/registry/model/ImmutableObjectTest.java index e94cecdba..2cf764c9f 100644 --- a/javatests/google/registry/model/ImmutableObjectTest.java +++ b/javatests/google/registry/model/ImmutableObjectTest.java @@ -19,7 +19,6 @@ import static com.google.common.collect.Maps.newHashMap; import static com.google.common.collect.Sets.newHashSet; import static com.google.common.truth.Truth.assertThat; import static google.registry.model.ImmutableObject.cloneEmptyToNull; -import static google.registry.testing.DatastoreHelper.persistActiveContact; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.util.DateTimeUtils.START_OF_TIME; @@ -31,7 +30,6 @@ import com.googlecode.objectify.Key; import com.googlecode.objectify.ObjectifyService; import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Id; -import google.registry.model.domain.ReferenceUnion; import google.registry.testing.AppEngineRule; import google.registry.util.CidrAddressBlock; import java.util.ArrayDeque; @@ -255,6 +253,7 @@ public class ImmutableObjectTest { /** Subclass of ImmutableObject with keys to other objects. */ public static class RootObject extends ImmutableObject { + Key hydrateMe; @DoNotHydrate @@ -263,8 +262,6 @@ public class ImmutableObjectTest { Map> map; Set> set; - - ReferenceUnion referenceUnion; } /** Simple subclass of ImmutableObject. */ @@ -308,11 +305,4 @@ public class ImmutableObjectTest { root.set = ImmutableSet.of(Key.create(persistResource(ValueObject.create(1, "foo")))); assertThat(root.toHydratedString()).contains("foo"); } - - @Test - public void testToHydratedString_expandsReferenceUnions() { - RootObject root = new RootObject(); - root.referenceUnion = ReferenceUnion.create(Key.create(persistActiveContact("foo"))); - assertThat(root.toHydratedString()).contains("foo"); - } } diff --git a/javatests/google/registry/model/domain/DomainApplicationTest.java b/javatests/google/registry/model/domain/DomainApplicationTest.java index 988cca4d4..8f66b1b6f 100644 --- a/javatests/google/registry/model/domain/DomainApplicationTest.java +++ b/javatests/google/registry/model/domain/DomainApplicationTest.java @@ -130,10 +130,8 @@ public class DomainApplicationTest extends EntityTestCase { domainApplication.asBuilder().setPeriod(Period.create(5, Period.Unit.YEARS)).build()); verifyIndexing( domainApplication, - "allContacts.contactId.linked", "allContacts.contact", "fullyQualifiedDomainName", - "nameservers.linked", "nsHosts", "deletionTime", "currentSponsorClientId", diff --git a/javatests/google/registry/model/domain/DomainResourceTest.java b/javatests/google/registry/model/domain/DomainResourceTest.java index a624ed03b..dce820bf4 100644 --- a/javatests/google/registry/model/domain/DomainResourceTest.java +++ b/javatests/google/registry/model/domain/DomainResourceTest.java @@ -23,8 +23,6 @@ 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.persistActiveContact; -import static google.registry.testing.DatastoreHelper.persistActiveHost; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DomainResourceSubject.assertAboutDomains; import static google.registry.util.DateTimeUtils.START_OF_TIME; @@ -174,10 +172,8 @@ public class DomainResourceTest extends EntityTestCase { public void testIndexing() throws Exception { verifyIndexing( domain, - "allContacts.contactId.linked", "allContacts.contact", "fullyQualifiedDomainName", - "nameservers.linked", "nsHosts", "currentSponsorClientId", "deletionTime", @@ -455,28 +451,4 @@ public class DomainResourceTest extends EntityTestCase { public void testToHydratedString_notCircular() { domain.toHydratedString(); // If there are circular references, this will overflow the stack. } - - // TODO(b/28713909): Remove these tests once ReferenceUnion migration is complete. - @Test - public void testDualSavingOfDesignatedContact() { - ContactResource contact = persistActiveContact("time1006"); - DesignatedContact designatedContact = new DesignatedContact(); - designatedContact.contact = Key.create(contact); - designatedContact.type = Type.ADMIN; - DomainResource domainWithContact = - domain.asBuilder().setContacts(ImmutableSet.of(designatedContact)).build(); - assertThat(getOnlyElement(domainWithContact.getContacts()).contactId).isNull(); - DomainResource reloadedDomain = persistResource(domainWithContact); - assertThat(getOnlyElement(reloadedDomain.getContacts()).contactId) - .isEqualTo(ReferenceUnion.create(Key.create(contact))); - } - - @Test - public void testDualSavingOfNameservers() { - HostResource host = persistActiveHost("zzz.xxx.yyy"); - DomainResource domain = newDomainResource("python-django-unchained.com", host); - assertThat(domain.nameservers).isNull(); - DomainResource djangoReloaded = persistResource(domain); - assertThat(djangoReloaded.nameservers).containsExactly(ReferenceUnion.create(Key.create(host))); - } } diff --git a/javatests/google/registry/model/schema.txt b/javatests/google/registry/model/schema.txt index 3155a9711..3d292b97e 100644 --- a/javatests/google/registry/model/schema.txt +++ b/javatests/google/registry/model/schema.txt @@ -189,7 +189,6 @@ enum google.registry.model.contact.PostalInfo$Type { class google.registry.model.domain.DesignatedContact { com.googlecode.objectify.Key contact; google.registry.model.domain.DesignatedContact$Type type; - google.registry.model.domain.ReferenceUnion contactId; } enum google.registry.model.domain.DesignatedContact$Type { ADMIN; @@ -218,7 +217,6 @@ class google.registry.model.domain.DomainApplication { java.util.List encodedSignedMarks; java.util.Set> nsHosts; java.util.Set allContacts; - java.util.Set> nameservers; java.util.Set dsData; java.util.Set status; org.joda.money.Money auctionPrice; @@ -245,7 +243,6 @@ class google.registry.model.domain.DomainBase { java.lang.String tld; java.util.Set> nsHosts; java.util.Set allContacts; - java.util.Set> nameservers; java.util.Set dsData; java.util.Set status; org.joda.time.DateTime deletionTime; @@ -274,7 +271,6 @@ class google.registry.model.domain.DomainResource { java.util.Set> nsHosts; java.util.Set allContacts; java.util.Set gracePeriods; - java.util.Set> nameservers; java.util.Set dsData; java.util.Set status; java.util.Set subordinateHosts; @@ -307,9 +303,6 @@ enum google.registry.model.domain.Period$Unit { MONTHS; YEARS; } -class google.registry.model.domain.ReferenceUnion { - com.googlecode.objectify.Key linked; -} enum google.registry.model.domain.launch.ApplicationStatus { ALLOCATED; INVALID; diff --git a/javatests/google/registry/tools/GetApplicationCommandTest.java b/javatests/google/registry/tools/GetApplicationCommandTest.java index e334f26ec..b3ffacd03 100644 --- a/javatests/google/registry/tools/GetApplicationCommandTest.java +++ b/javatests/google/registry/tools/GetApplicationCommandTest.java @@ -41,7 +41,7 @@ public class GetApplicationCommandTest extends CommandTestCase(ContactResource(\"3-ROID\"))"); } @Test @@ -50,7 +50,6 @@ public class GetApplicationCommandTest extends CommandTestCase { runCommand("sh8013", "--expand"); assertInStdout("contactId=sh8013"); assertInStdout("Websafe key: agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw"); - assertNotInStdout("ReferenceUnion"); assertNotInStdout("LiveRef"); } diff --git a/javatests/google/registry/tools/GetDomainCommandTest.java b/javatests/google/registry/tools/GetDomainCommandTest.java index 3c014aa95..bf1cf161e 100644 --- a/javatests/google/registry/tools/GetDomainCommandTest.java +++ b/javatests/google/registry/tools/GetDomainCommandTest.java @@ -41,7 +41,7 @@ public class GetDomainCommandTest extends CommandTestCase { persistActiveDomain("example.tld"); runCommand("example.tld"); assertInStdout("fullyQualifiedDomainName=example.tld"); - assertInStdout("contactId=ReferenceUnion"); + assertInStdout("contact=Key(ContactResource(\"3-ROID\"))"); assertInStdout("Websafe key: agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw"); } @@ -52,7 +52,6 @@ public class GetDomainCommandTest extends CommandTestCase { assertInStdout("fullyQualifiedDomainName=example.tld"); assertInStdout("contactId=contact1234"); assertInStdout("Websafe key: agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw"); - assertNotInStdout("ReferenceUnion"); assertNotInStdout("LiveRef"); } diff --git a/javatests/google/registry/tools/GetHostCommandTest.java b/javatests/google/registry/tools/GetHostCommandTest.java index 1b3ffc26b..02e4a1d2c 100644 --- a/javatests/google/registry/tools/GetHostCommandTest.java +++ b/javatests/google/registry/tools/GetHostCommandTest.java @@ -50,7 +50,6 @@ public class GetHostCommandTest extends CommandTestCase { runCommand("ns1.example.tld", "--expand"); assertInStdout("fullyQualifiedHostName=ns1.example.tld"); assertInStdout("Websafe key: agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw"); - assertNotInStdout("ReferenceUnion"); assertNotInStdout("LiveRef"); } diff --git a/javatests/google/registry/tools/GetResourceByKeyCommandTest.java b/javatests/google/registry/tools/GetResourceByKeyCommandTest.java index 71551cf58..c579eb948 100644 --- a/javatests/google/registry/tools/GetResourceByKeyCommandTest.java +++ b/javatests/google/registry/tools/GetResourceByKeyCommandTest.java @@ -43,7 +43,7 @@ public class GetResourceByKeyCommandTest extends CommandTestCase(ContactResource(\"3-ROID\"))"); } @Test @@ -52,7 +52,6 @@ public class GetResourceByKeyCommandTest extends CommandTestCase