Scope down lastTransferTime to only ContactResource, DomainResource

and HostResource.

DomainApplication is not transferable and has no need for this
field. HostResource needs it because it can be transferred with
a domain.

This is all in service of removing the ofy().load() inside of
host's cloneProjectedAtTime.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=139346925
This commit is contained in:
cgoldfeder 2016-11-16 10:18:31 -08:00 committed by Ben McIlwain
parent 5368489987
commit fdc8ceb6bb
15 changed files with 121 additions and 56 deletions

View file

@ -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.
*
* <p>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<StatusValue> 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.
*
* <p>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<B extends BuilderWithTransferData<B>> {
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<StatusValue> statusValues) {
getInstance().status = statusValues;

View file

@ -125,6 +125,14 @@ public class ContactResource extends EppResource
@XmlTransient
TransferData transferData;
/**
* The time that this resource was last transferred.
*
* <p>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.
*

View file

@ -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.
*/

View file

@ -162,6 +162,14 @@ public class DomainResource extends DomainBase
@XmlTransient
TransferData transferData;
/**
* The time that this resource was last transferred.
*
* <p>Can be null if the resource has never been transferred.
*/
@XmlElement(name = "trDate")
DateTime lastTransferTime;
public ImmutableSet<String> 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();
}
}
}

View file

@ -92,6 +92,14 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource
@DoNotHydrate
Key<DomainResource> superordinateDomain;
/**
* The time that this resource was last transferred.
*
* <p>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();