diff --git a/java/google/registry/flows/ResourceFlowUtils.java b/java/google/registry/flows/ResourceFlowUtils.java index 27be17c18..ca3caaf23 100644 --- a/java/google/registry/flows/ResourceFlowUtils.java +++ b/java/google/registry/flows/ResourceFlowUtils.java @@ -255,13 +255,15 @@ public final class ResourceFlowUtils { * including the extended registration years field, and sets the expiration time of the last * pending transfer to now. */ - public static R approvePendingTransfer( - R resource, TransferStatus transferStatus, DateTime now) { - Builder builder = resolvePendingTransfer(resource, transferStatus, now); - builder + public static < + R extends EppResource & ResourceWithTransferData, + B extends Builder & BuilderWithTransferData> + R approvePendingTransfer(R resource, TransferStatus transferStatus, DateTime now) { + B builder = resolvePendingTransfer(resource, transferStatus, now); + return builder .setLastTransferTime(now) - .setCurrentSponsorClientId(resource.getTransferData().getGainingClientId()); - return builder.build(); + .setCurrentSponsorClientId(resource.getTransferData().getGainingClientId()) + .build(); } /** diff --git a/java/google/registry/model/EppResource.java b/java/google/registry/model/EppResource.java index 2b7269e3d..9814a6b8c 100644 --- a/java/google/registry/model/EppResource.java +++ b/java/google/registry/model/EppResource.java @@ -105,15 +105,6 @@ public abstract class EppResource extends BackupGroupRoot implements Buildable, @XmlElement(name = "upDate") DateTime lastEppUpdateTime; - /** - * The time that this resource was last transferred. - * - *

Can be null if the resource has never been transferred. - */ - // Map the method to XML, not the field, so subclasses can override it. - @XmlTransient - DateTime lastTransferTime; - /** Status values associated with this resource. */ Set status; @@ -157,11 +148,6 @@ public abstract class EppResource extends BackupGroupRoot implements Buildable, return nullToEmptyImmutableCopy(status); } - @XmlElement(name = "trDate") - public DateTime getLastTransferTime() { - return lastTransferTime; - } - public final DateTime getDeletionTime() { return deletionTime; } @@ -186,11 +172,21 @@ public abstract class EppResource extends BackupGroupRoot implements Buildable, /** An interface for resources that have transfer data. */ public interface ResourceWithTransferData { public TransferData getTransferData(); + + /** + * The time that this resource was last transferred. + * + *

Can be null if the resource has never been transferred. + */ + public DateTime getLastTransferTime(); } /** An interface for builders of resources that have transfer data. */ public interface BuilderWithTransferData> { public B setTransferData(TransferData transferData); + + /** Set the time when this resource was transferred. */ + public B setLastTransferTime(DateTime lastTransferTime); } /** Abstract builder for {@link EppResource} types. */ @@ -255,12 +251,6 @@ public abstract class EppResource extends BackupGroupRoot implements Buildable, return thisCastToDerived(); } - /** Set the time when this resource was transferred. */ - public B setLastTransferTime(DateTime lastTransferTime) { - getInstance().lastTransferTime = lastTransferTime; - return thisCastToDerived(); - } - /** Set this resource's status values. */ public B setStatusValues(ImmutableSet statusValues) { getInstance().status = statusValues; diff --git a/java/google/registry/model/contact/ContactResource.java b/java/google/registry/model/contact/ContactResource.java index 68245030c..2d73eb8cf 100644 --- a/java/google/registry/model/contact/ContactResource.java +++ b/java/google/registry/model/contact/ContactResource.java @@ -125,6 +125,14 @@ public class ContactResource extends EppResource @XmlTransient TransferData transferData; + /** + * The time that this resource was last transferred. + * + *

Can be null if the resource has never been transferred. + */ + @XmlElement(name = "trDate") + DateTime lastTransferTime; + // If any new fields are added which contain personal information, make sure they are cleared by // the wipeOut() function, so that data is not kept around for deleted contacts. @@ -170,6 +178,11 @@ public class ContactResource extends EppResource return Optional.fromNullable(transferData).or(TransferData.EMPTY); } + @Override + public DateTime getLastTransferTime() { + return lastTransferTime; + } + @Override public String getForeignKey() { return contactId; @@ -275,6 +288,12 @@ public class ContactResource extends EppResource return this; } + @Override + public Builder setLastTransferTime(DateTime lastTransferTime) { + getInstance().lastTransferTime = lastTransferTime; + return thisCastToDerived(); + } + /** * Remove all personally identifying information about a contact. * diff --git a/java/google/registry/model/domain/DomainApplication.java b/java/google/registry/model/domain/DomainApplication.java index 88c0430d2..5afa37909 100644 --- a/java/google/registry/model/domain/DomainApplication.java +++ b/java/google/registry/model/domain/DomainApplication.java @@ -185,13 +185,6 @@ public class DomainApplication extends DomainBase { return auctionPrice; } - /** Domain applications don't expose transfer time, so override this and mark it xml transient. */ - @XmlTransient - @Override - public final DateTime getLastTransferTime() { - return super.getLastTransferTime(); - } - /** * The application id is the repoId. */ diff --git a/java/google/registry/model/domain/DomainResource.java b/java/google/registry/model/domain/DomainResource.java index a48ebfc08..cc5f059e5 100644 --- a/java/google/registry/model/domain/DomainResource.java +++ b/java/google/registry/model/domain/DomainResource.java @@ -162,6 +162,14 @@ public class DomainResource extends DomainBase @XmlTransient TransferData transferData; + /** + * The time that this resource was last transferred. + * + *

Can be null if the resource has never been transferred. + */ + @XmlElement(name = "trDate") + DateTime lastTransferTime; + public ImmutableSet getSubordinateHosts() { return nullToEmptyImmutableCopy(subordinateHosts); } @@ -203,6 +211,11 @@ public class DomainResource extends DomainBase return Optional.fromNullable(transferData).or(TransferData.EMPTY); } + @Override + public DateTime getLastTransferTime() { + return lastTransferTime; + } + @Override public String getForeignKey() { return fullyQualifiedDomainName; @@ -462,5 +475,12 @@ public class DomainResource extends DomainBase getInstance().transferData = transferData; return thisCastToDerived(); } + + @Override + public Builder setLastTransferTime(DateTime lastTransferTime) { + getInstance().lastTransferTime = lastTransferTime; + return thisCastToDerived(); + } } } + diff --git a/java/google/registry/model/host/HostResource.java b/java/google/registry/model/host/HostResource.java index 395ee10d2..167b0d3de 100644 --- a/java/google/registry/model/host/HostResource.java +++ b/java/google/registry/model/host/HostResource.java @@ -92,6 +92,14 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource @DoNotHydrate Key superordinateDomain; + /** + * The time that this resource was last transferred. + * + *

Can be null if the resource has never been transferred. + */ + @XmlElement(name = "trDate") + DateTime lastTransferTime; + /** * The most recent time that the superordinate domain was changed, or null if this host is * external. @@ -113,6 +121,10 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource return nullToEmptyImmutableCopy(inetAddresses); } + public DateTime getLastTransferTime() { + return lastTransferTime; + } + public DateTime getLastSuperordinateChange() { return lastSuperordinateChange; } @@ -198,6 +210,11 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource return this; } + public Builder setLastTransferTime(DateTime lastTransferTime) { + getInstance().lastTransferTime = lastTransferTime; + return this; + } + @Override public HostResource build() { return super.build(); diff --git a/javatests/google/registry/flows/domain/DomainApplicationInfoFlowTest.java b/javatests/google/registry/flows/domain/DomainApplicationInfoFlowTest.java index bd15ed0ca..8e98e01a6 100644 --- a/javatests/google/registry/flows/domain/DomainApplicationInfoFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainApplicationInfoFlowTest.java @@ -90,7 +90,6 @@ public class DomainApplicationInfoFlowTest .setLastEppUpdateClientId("NewRegistrar") .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(Key.create(registrant)) .setContacts(ImmutableSet.of( DesignatedContact.create(Type.ADMIN, Key.create(contact)), @@ -125,7 +124,6 @@ public class DomainApplicationInfoFlowTest .setLastEppUpdateClientId("NewRegistrar") .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(Key.create(registrant)) .setContacts(ImmutableSet.of( DesignatedContact.create(Type.ADMIN, Key.create(contact)), @@ -350,7 +348,7 @@ public class DomainApplicationInfoFlowTest thrown.expect(ApplicationLaunchPhaseMismatchException.class); runFlow(); } - + /** Test registry extra logic manager with no flags. */ @Test diff --git a/javatests/google/registry/flows/domain/DomainTransferApproveFlowTest.java b/javatests/google/registry/flows/domain/DomainTransferApproveFlowTest.java index 4ccdf2457..c4d6af89d 100644 --- a/javatests/google/registry/flows/domain/DomainTransferApproveFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainTransferApproveFlowTest.java @@ -26,7 +26,7 @@ import static google.registry.testing.DatastoreHelper.getOnlyPollMessage; import static google.registry.testing.DatastoreHelper.getPollMessages; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DomainResourceSubject.assertAboutDomains; -import static google.registry.testing.GenericEppResourceSubject.assertAboutEppResources; +import static google.registry.testing.HostResourceSubject.assertAboutHosts; import static google.registry.util.DateTimeUtils.START_OF_TIME; import static java.util.Arrays.asList; import static org.joda.money.CurrencyUnit.USD; @@ -111,7 +111,7 @@ public class DomainTransferApproveFlowTest } private void assertTransferApproved(HostResource host) { - assertAboutEppResources().that(host) + assertAboutHosts().that(host) .hasCurrentSponsorClientId("NewRegistrar").and() .hasLastTransferTime(clock.nowUtc()).and() .doesNotHaveStatusValue(StatusValue.PENDING_TRANSFER); diff --git a/javatests/google/registry/flows/domain/DomainTransferRequestFlowTest.java b/javatests/google/registry/flows/domain/DomainTransferRequestFlowTest.java index 111fc57f5..4faa85bc6 100644 --- a/javatests/google/registry/flows/domain/DomainTransferRequestFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainTransferRequestFlowTest.java @@ -132,7 +132,7 @@ public class DomainTransferRequestFlowTest private void assertTransferApproved(HostResource host) { DateTime afterAutoAck = clock.nowUtc().plus(Registry.get("tld").getAutomaticTransferLength()); - assertAboutEppResources().that(host) + assertAboutHosts().that(host) .hasCurrentSponsorClientId("NewRegistrar").and() .hasLastTransferTime(afterAutoAck).and() .doesNotHaveStatusValue(StatusValue.PENDING_TRANSFER); diff --git a/javatests/google/registry/model/domain/DomainApplicationTest.java b/javatests/google/registry/model/domain/DomainApplicationTest.java index 0a7277b77..43374e88e 100644 --- a/javatests/google/registry/model/domain/DomainApplicationTest.java +++ b/javatests/google/registry/model/domain/DomainApplicationTest.java @@ -72,7 +72,6 @@ public class DomainApplicationTest extends EntityTestCase { .setCreationClientId("a registrar") .setLastEppUpdateTime(clock.nowUtc()) .setLastEppUpdateClientId("another registrar") - .setLastTransferTime(clock.nowUtc()) .setStatusValues(ImmutableSet.of( StatusValue.CLIENT_DELETE_PROHIBITED, StatusValue.SERVER_DELETE_PROHIBITED, diff --git a/javatests/google/registry/model/schema.txt b/javatests/google/registry/model/schema.txt index 04e9b372f..39c48131e 100644 --- a/javatests/google/registry/model/schema.txt +++ b/javatests/google/registry/model/schema.txt @@ -220,7 +220,6 @@ class google.registry.model.domain.DomainApplication { org.joda.money.Money auctionPrice; org.joda.time.DateTime deletionTime; org.joda.time.DateTime lastEppUpdateTime; - org.joda.time.DateTime lastTransferTime; } class google.registry.model.domain.DomainAuthInfo { google.registry.model.eppcommon.AuthInfo$PasswordAuth pw; @@ -244,7 +243,6 @@ class google.registry.model.domain.DomainBase { java.util.Set status; org.joda.time.DateTime deletionTime; org.joda.time.DateTime lastEppUpdateTime; - org.joda.time.DateTime lastTransferTime; } class google.registry.model.domain.DomainResource { @Id java.lang.String repoId; diff --git a/javatests/google/registry/testing/AbstractEppResourceSubject.java b/javatests/google/registry/testing/AbstractEppResourceSubject.java index 2531a5b3a..d3b04f765 100644 --- a/javatests/google/registry/testing/AbstractEppResourceSubject.java +++ b/javatests/google/registry/testing/AbstractEppResourceSubject.java @@ -150,20 +150,6 @@ abstract class AbstractEppResourceSubject "has deletionTime"); } - public And hasLastTransferTime(DateTime lastTransferTime) { - return hasValue( - lastTransferTime, - actual().getLastTransferTime(), - "has lastTransferTime"); - } - - public And hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) { - return doesNotHaveValue( - lastTransferTime, - actual().getLastTransferTime(), - "lastTransferTime"); - } - public And hasLastEppUpdateTime(DateTime lastUpdateTime) { return hasValue( lastUpdateTime, diff --git a/javatests/google/registry/testing/ContactResourceSubject.java b/javatests/google/registry/testing/ContactResourceSubject.java index ea3e2d894..a5554ed5a 100644 --- a/javatests/google/registry/testing/ContactResourceSubject.java +++ b/javatests/google/registry/testing/ContactResourceSubject.java @@ -162,6 +162,19 @@ public final class ContactResourceSubject "has transfer losingClientId"); } + public And hasLastTransferTime(DateTime lastTransferTime) { + return hasValue( + lastTransferTime, + actual().getLastTransferTime(), + "has lastTransferTime"); + } + + public And hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) { + return doesNotHaveValue( + lastTransferTime, + actual().getLastTransferTime(), + "lastTransferTime"); + } public static DelegatedVerb assertAboutContacts() { return assertAbout(new SubjectFactory()); } diff --git a/javatests/google/registry/testing/DomainResourceSubject.java b/javatests/google/registry/testing/DomainResourceSubject.java index 13039c923..470ecaf78 100644 --- a/javatests/google/registry/testing/DomainResourceSubject.java +++ b/javatests/google/registry/testing/DomainResourceSubject.java @@ -79,6 +79,20 @@ public final class DomainResourceSubject return andChainer(); } + public And hasLastTransferTime(DateTime lastTransferTime) { + return hasValue( + lastTransferTime, + actual().getLastTransferTime(), + "has lastTransferTime"); + } + + public And hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) { + return doesNotHaveValue( + lastTransferTime, + actual().getLastTransferTime(), + "lastTransferTime"); + } + public And hasDeletePollMessage() { if (actual().getDeletePollMessage() == null) { fail("has a delete poll message"); diff --git a/javatests/google/registry/testing/HostResourceSubject.java b/javatests/google/registry/testing/HostResourceSubject.java index 035ba2877..b184fb4cc 100644 --- a/javatests/google/registry/testing/HostResourceSubject.java +++ b/javatests/google/registry/testing/HostResourceSubject.java @@ -20,6 +20,8 @@ import static com.google.common.truth.Truth.assertAbout; import com.google.common.truth.AbstractVerb.DelegatedVerb; import com.google.common.truth.FailureStrategy; import google.registry.model.host.HostResource; +import google.registry.testing.TruthChainer.And; +import org.joda.time.DateTime; /** Truth subject for asserting things about {@link HostResource} instances. */ public final class HostResourceSubject @@ -36,4 +38,18 @@ public final class HostResourceSubject public static DelegatedVerb assertAboutHosts() { return assertAbout(new SubjectFactory()); } + + public And hasLastTransferTime(DateTime lastTransferTime) { + return hasValue( + lastTransferTime, + actual().getLastTransferTime(), + "has lastTransferTime"); + } + + public And hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) { + return doesNotHaveValue( + lastTransferTime, + actual().getLastTransferTime(), + "lastTransferTime"); + } }