Remove obsolete TransferData.extendedRegistrationYears

Now that transfers are always restricted to 1 year, it's unnecessary to store
extendedRegistrationYears on TransferData - it will always be equal to 1.  This
simplifies logic in a few other places, e.g. RdeDomainImportAction.

I verified in BigQuery that no DomainBases exist with extendedRegistrationYears
values that aren't either null or equal to 1.  At some point we should remove
the persisted fields from datastore via e.g. resaving all those domains, but
it's low priority and can wait until we have some more pressing migration.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=150373897
This commit is contained in:
nickfelt 2017-03-16 15:03:18 -07:00 committed by Ben McIlwain
parent 70fbdccea2
commit 09f619cce2
29 changed files with 54 additions and 215 deletions

View file

@ -17,7 +17,6 @@ package google.registry.rde;
import static google.registry.model.ofy.ObjectifyService.ofy;
import com.google.common.base.Ascii;
import com.google.common.base.Optional;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.Key;
@ -257,9 +256,9 @@ final class DomainResourceToXjcConverter {
bean.setAcRr(RdeUtil.makeXjcRdeRrType(model.getLosingClientId()));
bean.setReDate(model.getTransferRequestTime());
bean.setAcDate(model.getPendingTransferExpirationTime());
// TODO(b/25084229): fix exDate computation logic.
if (model.getTransferStatus() == TransferStatus.PENDING) {
int years = Optional.fromNullable(model.getExtendedRegistrationYears()).or(0);
bean.setExDate(domainExpires.plusYears(years));
bean.setExDate(domainExpires.plusYears(1));
} else {
bean.setExDate(domainExpires);
}

View file

@ -189,19 +189,17 @@ public class RdeDomainImportAction implements Runnable {
Money transferCost = getDomainRenewCost(
domain.getFullyQualifiedDomainName(),
transferData.getPendingTransferExpirationTime(),
transferData.getExtendedRegistrationYears());
1);
// Create speculative entities in anticipation of an automatic server approval.
ImmutableSet<TransferServerApproveEntity> serverApproveEntities =
createTransferServerApproveEntities(
transferData.getPendingTransferExpirationTime(),
domain.getRegistrationExpirationTime()
.plusYears(transferData.getExtendedRegistrationYears()),
domain.getRegistrationExpirationTime().plusYears(1),
historyEntry,
domain,
historyEntry.getTrid(),
transferData.getGainingClientId(),
transferCost,
transferData.getExtendedRegistrationYears(),
transferData.getTransferRequestTime());
transferData =
createPendingTransferData(transferData.asBuilder(), serverApproveEntities);

View file

@ -60,7 +60,6 @@ import java.security.ProviderException;
import java.security.SecureRandom;
import java.util.Random;
import org.joda.time.DateTime;
import org.joda.time.Years;
/** Utility class that converts an {@link XjcRdeDomainElement} into a {@link DomainResource}. */
final class XjcToDomainResourceConverter extends XjcToEppResourceConverter {
@ -208,7 +207,7 @@ final class XjcToDomainResourceConverter extends XjcToEppResourceConverter {
? ImmutableSet.<DelegationSignerData>of()
: ImmutableSet.copyOf(
transform(domain.getSecDNS().getDsDatas(), SECDNS_CONVERTER)))
.setTransferData(convertDomainTransferData(domain.getTrnData(), domain.getExDate()))
.setTransferData(convertDomainTransferData(domain.getTrnData()))
// authInfo pw must be a token between 6 and 16 characters in length
// generate a token of 16 characters as the default authInfo pw
.setAuthInfo(DomainAuthInfo
@ -241,34 +240,17 @@ final class XjcToDomainResourceConverter extends XjcToEppResourceConverter {
}
/** Converts {@link XjcRdeDomainTransferDataType} to {@link TransferData}. */
private static TransferData convertDomainTransferData(XjcRdeDomainTransferDataType data,
DateTime domainExpiration) {
private static TransferData convertDomainTransferData(XjcRdeDomainTransferDataType data) {
if (data == null) {
return TransferData.EMPTY;
}
// If the transfer is pending, calculate the number of years to add to the domain expiration
// on approval of the transfer.
TransferStatus transferStatus = TRANSFER_STATUS_MAPPER.xmlToEnum(data.getTrStatus().value());
// Get new expiration date
DateTime newExpirationTime = domainExpiration;
if (transferStatus == TransferStatus.PENDING) {
// Default to domain expiration time plus one year if no expiration is specified
if (data.getExDate() == null) {
newExpirationTime = newExpirationTime.plusYears(1);
} else {
newExpirationTime = data.getExDate();
}
}
// TODO(b/25084229): read in the exDate and store it somewhere.
return new TransferData.Builder()
.setTransferStatus(transferStatus)
.setTransferStatus(TRANSFER_STATUS_MAPPER.xmlToEnum(data.getTrStatus().value()))
.setGainingClientId(data.getReRr().getValue())
.setLosingClientId(data.getAcRr().getValue())
.setTransferRequestTime(data.getReDate())
.setPendingTransferExpirationTime(data.getAcDate())
// This will be wrong for domains that are not in pending transfer,
// but there isn't a reliable way to calculate it.
.setExtendedRegistrationYears(
Years.yearsBetween(domainExpiration, newExpirationTime).getYears())
.build();
}