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

@ -96,15 +96,14 @@ public final class ResourceFlowUtils {
builder = new ContactTransferResponse.Builder().setContactId(eppResource.getForeignKey()); builder = new ContactTransferResponse.Builder().setContactId(eppResource.getForeignKey());
} else { } else {
DomainResource domain = (DomainResource) eppResource; DomainResource domain = (DomainResource) eppResource;
builder = new DomainTransferResponse.Builder() builder =
.setFullyQualifiedDomainNameName(eppResource.getForeignKey()) new DomainTransferResponse.Builder()
.setExtendedRegistrationExpirationTime( .setFullyQualifiedDomainNameName(eppResource.getForeignKey())
ADD_EXDATE_STATUSES.contains(transferData.getTransferStatus()) // TODO(b/25084229): fix exDate computation logic.
? extendRegistrationWithCap( .setExtendedRegistrationExpirationTime(
now, ADD_EXDATE_STATUSES.contains(transferData.getTransferStatus())
domain.getRegistrationExpirationTime(), ? extendRegistrationWithCap(now, domain.getRegistrationExpirationTime(), 1)
transferData.getExtendedRegistrationYears()) : null);
: null);
} }
builder.setGainingClientId(transferData.getGainingClientId()) builder.setGainingClientId(transferData.getGainingClientId())
.setLosingClientId(transferData.getLosingClientId()) .setLosingClientId(transferData.getLosingClientId())
@ -218,7 +217,6 @@ public final class ResourceFlowUtils {
TransferData oldTransferData, TransferStatus transferStatus, DateTime now) { TransferData oldTransferData, TransferStatus transferStatus, DateTime now) {
checkArgument(!oldTransferData.equals(TransferData.EMPTY), "No old transfer to resolve."); checkArgument(!oldTransferData.equals(TransferData.EMPTY), "No old transfer to resolve.");
return oldTransferData.asBuilder() return oldTransferData.asBuilder()
.setExtendedRegistrationYears(null)
.setServerApproveEntities(null) .setServerApproveEntities(null)
.setServerApproveBillingEvent(null) .setServerApproveBillingEvent(null)
.setServerApproveAutorenewEvent(null) .setServerApproveAutorenewEvent(null)

View file

@ -108,20 +108,20 @@ public final class DomainTransferApproveFlow implements TransactionalFlow {
.setOtherClientId(gainingClientId) .setOtherClientId(gainingClientId)
.setParent(Key.create(existingDomain)) .setParent(Key.create(existingDomain))
.build(); .build();
int extraYears = transferData.getExtendedRegistrationYears();
// Bill for the transfer. // Bill for the transfer.
BillingEvent.OneTime billingEvent = new BillingEvent.OneTime.Builder() BillingEvent.OneTime billingEvent = new BillingEvent.OneTime.Builder()
.setReason(Reason.TRANSFER) .setReason(Reason.TRANSFER)
.setTargetId(targetId) .setTargetId(targetId)
.setClientId(gainingClientId) .setClientId(gainingClientId)
.setPeriodYears(extraYears) .setPeriodYears(1)
.setCost(getDomainRenewCost(targetId, transferData.getTransferRequestTime(), extraYears)) .setCost(getDomainRenewCost(targetId, transferData.getTransferRequestTime(), 1))
.setEventTime(now) .setEventTime(now)
.setBillingTime(now.plus(Registry.get(tld).getTransferGracePeriodLength())) .setBillingTime(now.plus(Registry.get(tld).getTransferGracePeriodLength()))
.setParent(historyEntry) .setParent(historyEntry)
.build(); .build();
// If we are within an autorenew grace period, cancel the autorenew billing event and reduce // If we are within an autorenew grace period, cancel the autorenew billing event and don't
// the number of years to extend the registration by one to "subsume" the autorenew. // increase the registration time, since the transfer subsumes the autorenew's extra year.
int extraYears = 1; // All transfers are one year.
GracePeriod autorenewGrace = GracePeriod autorenewGrace =
getOnlyElement(existingDomain.getGracePeriodsOfType(GracePeriodStatus.AUTO_RENEW), null); getOnlyElement(existingDomain.getGracePeriodsOfType(GracePeriodStatus.AUTO_RENEW), null);
if (autorenewGrace != null) { if (autorenewGrace != null) {

View file

@ -85,11 +85,8 @@ public final class DomainTransferQueryFlow implements Flow {
DateTime newExpirationTime = null; DateTime newExpirationTime = null;
if (transferData.getTransferStatus().isApproved() if (transferData.getTransferStatus().isApproved()
|| transferData.getTransferStatus().equals(TransferStatus.PENDING)) { || transferData.getTransferStatus().equals(TransferStatus.PENDING)) {
// TODO(b/25084229): This is not quite right. // TODO(b/25084229): fix exDate computation logic.
newExpirationTime = extendRegistrationWithCap( newExpirationTime = extendRegistrationWithCap(now, domain.getRegistrationExpirationTime(), 1);
now,
domain.getRegistrationExpirationTime(),
transferData.getExtendedRegistrationYears());
} }
return responseBuilder return responseBuilder
.setResData(createTransferResponse(targetId, transferData, newExpirationTime)) .setResData(createTransferResponse(targetId, transferData, newExpirationTime))

View file

@ -128,7 +128,6 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
extensionManager.validate(); extensionManager.validate();
validateClientIsLoggedIn(gainingClientId); validateClientIsLoggedIn(gainingClientId);
Period period = ((Transfer) resourceCommand).getPeriod(); Period period = ((Transfer) resourceCommand).getPeriod();
int years = period.getValue();
DateTime now = ofy().getTransactionTime(); DateTime now = ofy().getTransactionTime();
DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now); DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now);
verifyTransferAllowed(existingDomain, period, now); verifyTransferAllowed(existingDomain, period, now);
@ -143,25 +142,24 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
DateTime automaticTransferTime = now.plus(registry.getAutomaticTransferLength()); DateTime automaticTransferTime = now.plus(registry.getAutomaticTransferLength());
// If the domain will be in the auto-renew grace period at the moment of transfer, the transfer // If the domain will be in the auto-renew grace period at the moment of transfer, the transfer
// will subsume the autorenew, so we reduce by 1 the number of years to extend the registration. // will subsume the autorenew, so we don't add the normal extra year from the transfer.
// Note that the regular "years" remains the same since it affects the transfer charge amount. // The gaining registrar is still billed for the extra year; the losing registrar will get a
// The gaining registrar is still billed for the full years; the losing registrar will get a
// cancellation for the autorenew written out within createTransferServerApproveEntities(). // cancellation for the autorenew written out within createTransferServerApproveEntities().
// //
// See b/19430703#comment17 and https://www.icann.org/news/advisory-2002-06-06-en for the // See b/19430703#comment17 and https://www.icann.org/news/advisory-2002-06-06-en for the
// policy documentation for transfers subsuming autorenews within the autorenew grace period. // policy documentation for transfers subsuming autorenews within the autorenew grace period.
int registrationExtensionYears = years; int extraYears = 1;
DomainResource domainAtTransferTime = DomainResource domainAtTransferTime =
existingDomain.cloneProjectedAtTime(automaticTransferTime); existingDomain.cloneProjectedAtTime(automaticTransferTime);
if (!domainAtTransferTime.getGracePeriodsOfType(GracePeriodStatus.AUTO_RENEW).isEmpty()) { if (!domainAtTransferTime.getGracePeriodsOfType(GracePeriodStatus.AUTO_RENEW).isEmpty()) {
registrationExtensionYears--; extraYears--;
} }
// The new expiration time if there is a server approval. // The new expiration time if there is a server approval.
DateTime serverApproveNewExpirationTime = DateTime serverApproveNewExpirationTime =
extendRegistrationWithCap( extendRegistrationWithCap(
automaticTransferTime, automaticTransferTime,
domainAtTransferTime.getRegistrationExpirationTime(), domainAtTransferTime.getRegistrationExpirationTime(),
registrationExtensionYears); extraYears);
// Create speculative entities in anticipation of an automatic server approval. // Create speculative entities in anticipation of an automatic server approval.
ImmutableSet<TransferServerApproveEntity> serverApproveEntities = ImmutableSet<TransferServerApproveEntity> serverApproveEntities =
createTransferServerApproveEntities( createTransferServerApproveEntities(
@ -172,11 +170,10 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
trid, trid,
gainingClientId, gainingClientId,
feesAndCredits.getTotalCost(), feesAndCredits.getTotalCost(),
years,
now); now);
// Create the transfer data that represents the pending transfer. // Create the transfer data that represents the pending transfer.
TransferData pendingTransferData = createPendingTransferData( TransferData pendingTransferData = createPendingTransferData(
createTransferDataBuilder(existingDomain, automaticTransferTime, years, now), createTransferDataBuilder(existingDomain, automaticTransferTime, now),
serverApproveEntities); serverApproveEntities);
// Create a poll message to notify the losing registrar that a transfer was requested. // Create a poll message to notify the losing registrar that a transfer was requested.
PollMessage requestPollMessage = createLosingTransferPollMessage( PollMessage requestPollMessage = createLosingTransferPollMessage(
@ -262,14 +259,13 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
} }
private Builder createTransferDataBuilder( private Builder createTransferDataBuilder(
DomainResource existingDomain, DateTime automaticTransferTime, int years, DateTime now) { DomainResource existingDomain, DateTime automaticTransferTime, DateTime now) {
return new TransferData.Builder() return new TransferData.Builder()
.setTransferRequestTrid(trid) .setTransferRequestTrid(trid)
.setTransferRequestTime(now) .setTransferRequestTime(now)
.setGainingClientId(gainingClientId) .setGainingClientId(gainingClientId)
.setLosingClientId(existingDomain.getCurrentSponsorClientId()) .setLosingClientId(existingDomain.getCurrentSponsorClientId())
.setPendingTransferExpirationTime(automaticTransferTime) .setPendingTransferExpirationTime(automaticTransferTime);
.setExtendedRegistrationYears(years);
} }
private DomainTransferResponse createResponse( private DomainTransferResponse createResponse(

View file

@ -92,13 +92,12 @@ public final class DomainTransferUtils {
Trid trid, Trid trid,
String gainingClientId, String gainingClientId,
Money transferCost, Money transferCost,
int years,
DateTime now) { DateTime now) {
String targetId = existingDomain.getFullyQualifiedDomainName(); String targetId = existingDomain.getFullyQualifiedDomainName();
// Create a TransferData for the server-approve case to use for the speculative poll messages. // Create a TransferData for the server-approve case to use for the speculative poll messages.
TransferData serverApproveTransferData = TransferData serverApproveTransferData =
createTransferDataBuilder( createTransferDataBuilder(
existingDomain, trid, gainingClientId, automaticTransferTime, years, now) existingDomain, trid, gainingClientId, automaticTransferTime, now)
.setTransferStatus(TransferStatus.SERVER_APPROVED) .setTransferStatus(TransferStatus.SERVER_APPROVED)
.build(); .build();
Registry registry = Registry.get(existingDomain.getTld()); Registry registry = Registry.get(existingDomain.getTld());
@ -110,8 +109,7 @@ public final class DomainTransferUtils {
targetId, targetId,
gainingClientId, gainingClientId,
registry, registry,
transferCost, transferCost))
years))
.addAll( .addAll(
createOptionalAutorenewCancellation( createOptionalAutorenewCancellation(
automaticTransferTime, historyEntry, targetId, existingDomain) automaticTransferTime, historyEntry, targetId, existingDomain)
@ -255,14 +253,13 @@ public final class DomainTransferUtils {
String targetId, String targetId,
String gainingClientId, String gainingClientId,
Registry registry, Registry registry,
Money transferCost, Money transferCost) {
int years) {
return new BillingEvent.OneTime.Builder() return new BillingEvent.OneTime.Builder()
.setReason(Reason.TRANSFER) .setReason(Reason.TRANSFER)
.setTargetId(targetId) .setTargetId(targetId)
.setClientId(gainingClientId) .setClientId(gainingClientId)
.setCost(transferCost) .setCost(transferCost)
.setPeriodYears(years) .setPeriodYears(1)
.setEventTime(automaticTransferTime) .setEventTime(automaticTransferTime)
.setBillingTime(automaticTransferTime.plus(registry.getTransferGracePeriodLength())) .setBillingTime(automaticTransferTime.plus(registry.getTransferGracePeriodLength()))
.setParent(historyEntry) .setParent(historyEntry)
@ -274,15 +271,13 @@ public final class DomainTransferUtils {
Trid trid, Trid trid,
String gainingClientId, String gainingClientId,
DateTime automaticTransferTime, DateTime automaticTransferTime,
int years,
DateTime now) { DateTime now) {
return new TransferData.Builder() return new TransferData.Builder()
.setTransferRequestTrid(trid) .setTransferRequestTrid(trid)
.setTransferRequestTime(now) .setTransferRequestTime(now)
.setGainingClientId(gainingClientId) .setGainingClientId(gainingClientId)
.setLosingClientId(existingDomain.getCurrentSponsorClientId()) .setLosingClientId(existingDomain.getCurrentSponsorClientId())
.setPendingTransferExpirationTime(automaticTransferTime) .setPendingTransferExpirationTime(automaticTransferTime);
.setExtendedRegistrationYears(years);
} }
private DomainTransferUtils() {} private DomainTransferUtils() {}

View file

@ -247,9 +247,8 @@ public class DomainResource extends DomainBase
cloneProjectedAtTime(transferExpirationTime.minusMillis(1)); cloneProjectedAtTime(transferExpirationTime.minusMillis(1));
// If we are within an autorenew grace period, the transfer will subsume the autorenew. There // If we are within an autorenew grace period, the transfer will subsume the autorenew. There
// will already be a cancellation written in advance by the transfer request flow, so we don't // will already be a cancellation written in advance by the transfer request flow, so we don't
// need to worry about billing, but we do need to reduce the number of years added to the // need to worry about billing, but we do need to cancel out the expiration time increase.
// expiration time by one to account for the year added by the autorenew. int extraYears = 1; // All transfers are one year.
int extraYears = transferData.getExtendedRegistrationYears();
if (domainAtTransferTime.getGracePeriodStatuses().contains(GracePeriodStatus.AUTO_RENEW)) { if (domainAtTransferTime.getGracePeriodStatuses().contains(GracePeriodStatus.AUTO_RENEW)) {
extraYears--; extraYears--;
} }

View file

@ -81,12 +81,6 @@ public class TransferData extends BaseTransferObject implements Buildable {
/** The transaction id of the most recent transfer request (or null if there never was one). */ /** The transaction id of the most recent transfer request (or null if there never was one). */
Trid transferRequestTrid; Trid transferRequestTrid;
/**
* The number of years to add to the registration expiration time if this transfer is approved.
* Can be null if never transferred, or for resource types where it's not applicable.
*/
Integer extendedRegistrationYears;
public ImmutableSet<Key<? extends TransferServerApproveEntity>> getServerApproveEntities() { public ImmutableSet<Key<? extends TransferServerApproveEntity>> getServerApproveEntities() {
return nullToEmptyImmutableCopy(serverApproveEntities); return nullToEmptyImmutableCopy(serverApproveEntities);
} }
@ -107,10 +101,6 @@ public class TransferData extends BaseTransferObject implements Buildable {
return transferRequestTrid; return transferRequestTrid;
} }
public Integer getExtendedRegistrationYears() {
return extendedRegistrationYears;
}
@Override @Override
public Builder asBuilder() { public Builder asBuilder() {
return new Builder(clone(this)); return new Builder(clone(this));
@ -155,12 +145,6 @@ public class TransferData extends BaseTransferObject implements Buildable {
getInstance().transferRequestTrid = transferRequestTrid; getInstance().transferRequestTrid = transferRequestTrid;
return this; return this;
} }
/** Set the years to add to the registration if this transfer completes. */
public Builder setExtendedRegistrationYears(Integer extendedRegistrationYears) {
getInstance().extendedRegistrationYears = extendedRegistrationYears;
return thisCastToDerived();
}
} }
/** /**

View file

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

View file

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

View file

@ -60,7 +60,6 @@ import java.security.ProviderException;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.Random; import java.util.Random;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.Years;
/** Utility class that converts an {@link XjcRdeDomainElement} into a {@link DomainResource}. */ /** Utility class that converts an {@link XjcRdeDomainElement} into a {@link DomainResource}. */
final class XjcToDomainResourceConverter extends XjcToEppResourceConverter { final class XjcToDomainResourceConverter extends XjcToEppResourceConverter {
@ -208,7 +207,7 @@ final class XjcToDomainResourceConverter extends XjcToEppResourceConverter {
? ImmutableSet.<DelegationSignerData>of() ? ImmutableSet.<DelegationSignerData>of()
: ImmutableSet.copyOf( : ImmutableSet.copyOf(
transform(domain.getSecDNS().getDsDatas(), SECDNS_CONVERTER))) 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 // authInfo pw must be a token between 6 and 16 characters in length
// generate a token of 16 characters as the default authInfo pw // generate a token of 16 characters as the default authInfo pw
.setAuthInfo(DomainAuthInfo .setAuthInfo(DomainAuthInfo
@ -241,34 +240,17 @@ final class XjcToDomainResourceConverter extends XjcToEppResourceConverter {
} }
/** Converts {@link XjcRdeDomainTransferDataType} to {@link TransferData}. */ /** Converts {@link XjcRdeDomainTransferDataType} to {@link TransferData}. */
private static TransferData convertDomainTransferData(XjcRdeDomainTransferDataType data, private static TransferData convertDomainTransferData(XjcRdeDomainTransferDataType data) {
DateTime domainExpiration) {
if (data == null) { if (data == null) {
return TransferData.EMPTY; return TransferData.EMPTY;
} }
// If the transfer is pending, calculate the number of years to add to the domain expiration // TODO(b/25084229): read in the exDate and store it somewhere.
// 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();
}
}
return new TransferData.Builder() return new TransferData.Builder()
.setTransferStatus(transferStatus) .setTransferStatus(TRANSFER_STATUS_MAPPER.xmlToEnum(data.getTrStatus().value()))
.setGainingClientId(data.getReRr().getValue()) .setGainingClientId(data.getReRr().getValue())
.setLosingClientId(data.getAcRr().getValue()) .setLosingClientId(data.getAcRr().getValue())
.setTransferRequestTime(data.getReDate()) .setTransferRequestTime(data.getReDate())
.setPendingTransferExpirationTime(data.getAcDate()) .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(); .build();
} }

View file

@ -298,18 +298,15 @@ public class DomainTransferApproveFlowTest
DateTime oldExpirationTime = clock.nowUtc().minusDays(1); DateTime oldExpirationTime = clock.nowUtc().minusDays(1);
persistResource(domain.asBuilder() persistResource(domain.asBuilder()
.setRegistrationExpirationTime(oldExpirationTime) .setRegistrationExpirationTime(oldExpirationTime)
.setTransferData(domain.getTransferData().asBuilder()
.setExtendedRegistrationYears(2)
.build())
.build()); .build());
// The autorenew should be subsumed into the transfer resulting in 2 years of renewal in total. // The autorenew should be subsumed into the transfer resulting in 1 year of renewal in total.
clock.advanceOneMilli(); clock.advanceOneMilli();
doSuccessfulTest( doSuccessfulTest(
"tld", "tld",
"domain_transfer_approve_domain_authinfo.xml", "domain_transfer_approve_domain_authinfo.xml",
"domain_transfer_approve_response_autorenew.xml", "domain_transfer_approve_response_autorenew.xml",
oldExpirationTime.plusYears(2), oldExpirationTime.plusYears(1),
2, 1,
// Expect the grace period for autorenew to be cancelled. // Expect the grace period for autorenew to be cancelled.
new BillingEvent.Cancellation.Builder() new BillingEvent.Cancellation.Builder()
.setReason(Reason.RENEW) .setReason(Reason.RENEW)

View file

@ -101,7 +101,6 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
TRANSFER_REQUEST_TIME, TRANSFER_REQUEST_TIME,
TRANSFER_EXPIRATION_TIME, TRANSFER_EXPIRATION_TIME,
EXTENDED_REGISTRATION_EXPIRATION_TIME, EXTENDED_REGISTRATION_EXPIRATION_TIME,
EXTENDED_REGISTRATION_YEARS,
TRANSFER_REQUEST_TIME); TRANSFER_REQUEST_TIME);
} }
@ -176,8 +175,7 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
domain, domain,
historyEntry, historyEntry,
TRANSFER_REQUEST_TIME, TRANSFER_REQUEST_TIME,
TRANSFER_EXPIRATION_TIME, TRANSFER_EXPIRATION_TIME);
EXTENDED_REGISTRATION_YEARS);
} }
/** Get the autorenew event that the losing client will have after a SERVER_APPROVED transfer. */ /** Get the autorenew event that the losing client will have after a SERVER_APPROVED transfer. */

View file

@ -148,10 +148,10 @@ public class DomainTransferQueryFlowTest
@Test @Test
public void testSuccess_tenYears() throws Exception { public void testSuccess_tenYears() throws Exception {
// Extend registration by 9 years here; with the extra 1 year from the transfer, we should
// hit the 10-year capping.
domain = persistResource(domain.asBuilder() domain = persistResource(domain.asBuilder()
.setTransferData(domain.getTransferData().asBuilder() .setRegistrationExpirationTime(domain.getRegistrationExpirationTime().plusYears(9))
.setExtendedRegistrationYears(10)
.build())
.build()); .build());
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_query.xml", "domain_transfer_query.xml",

View file

@ -164,7 +164,6 @@ public class DomainTransferRequestFlowTest
domain = reloadResourceByForeignKey(); domain = reloadResourceByForeignKey();
final HistoryEntry historyEntryTransferRequest = final HistoryEntry historyEntryTransferRequest =
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST); getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST);
int registrationYears = domain.getTransferData().getExtendedRegistrationYears();
subordinateHost = reloadResourceAndCloneAtTime(subordinateHost, clock.nowUtc()); subordinateHost = reloadResourceAndCloneAtTime(subordinateHost, clock.nowUtc());
assertTransferRequested(domain); assertTransferRequested(domain);
assertAboutDomains().that(domain) assertAboutDomains().that(domain)
@ -174,7 +173,7 @@ public class DomainTransferRequestFlowTest
HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST); HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST);
assertAboutHistoryEntries() assertAboutHistoryEntries()
.that(historyEntryTransferRequest) .that(historyEntryTransferRequest)
.hasPeriodYears(registrationYears) .hasPeriodYears(1)
.and() .and()
.hasOtherClientId("TheRegistrar"); .hasOtherClientId("TheRegistrar");
assertAboutHosts().that(subordinateHost).hasNoHistoryEntries(); assertAboutHosts().that(subordinateHost).hasNoHistoryEntries();
@ -190,8 +189,8 @@ public class DomainTransferRequestFlowTest
.setEventTime(implicitTransferTime) .setEventTime(implicitTransferTime)
.setBillingTime(implicitTransferTime.plus(registry.getTransferGracePeriodLength())) .setBillingTime(implicitTransferTime.plus(registry.getTransferGracePeriodLength()))
.setClientId("NewRegistrar") .setClientId("NewRegistrar")
.setCost(transferCost.or(Money.of(USD, 11).multipliedBy(registrationYears))) .setCost(transferCost.or(Money.of(USD, 11)))
.setPeriodYears(registrationYears) .setPeriodYears(1)
.setParent(historyEntryTransferRequest) .setParent(historyEntryTransferRequest)
.build(); .build();
assertBillingEvents(FluentIterable.from(extraExpectedBillingEvents) assertBillingEvents(FluentIterable.from(extraExpectedBillingEvents)

View file

@ -12,7 +12,7 @@
<domain:reDate>2000-06-06T22:00:00.0Z</domain:reDate> <domain:reDate>2000-06-06T22:00:00.0Z</domain:reDate>
<domain:acID>TheRegistrar</domain:acID> <domain:acID>TheRegistrar</domain:acID>
<domain:acDate>2000-06-09T22:00:00.0Z</domain:acDate> <domain:acDate>2000-06-09T22:00:00.0Z</domain:acDate>
<domain:exDate>2002-06-08T22:00:00.0Z</domain:exDate> <domain:exDate>2001-06-08T22:00:00.0Z</domain:exDate>
</domain:trnData> </domain:trnData>
</resData> </resData>
<trID> <trID>

View file

@ -193,7 +193,6 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
.setTransferRequestTime(requestTime) .setTransferRequestTime(requestTime)
.setLosingClientId("TheRegistrar") .setLosingClientId("TheRegistrar")
.setPendingTransferExpirationTime(transferExpirationTime) .setPendingTransferExpirationTime(transferExpirationTime)
.setExtendedRegistrationYears(1)
.build()) .build())
.build()); .build());
persistResource( persistResource(
@ -222,7 +221,6 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
.setTransferRequestTime(requestTime) .setTransferRequestTime(requestTime)
.setLosingClientId("NewRegistrar") .setLosingClientId("NewRegistrar")
.setPendingTransferExpirationTime(transferExpirationTime) .setPendingTransferExpirationTime(transferExpirationTime)
.setExtendedRegistrationYears(1)
.build()) .build())
.build()); .build());
persistResource( persistResource(

View file

@ -113,7 +113,6 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
.setTransferRequestTime(requestTime) .setTransferRequestTime(requestTime)
.setLosingClientId("TheRegistrar") .setLosingClientId("TheRegistrar")
.setPendingTransferExpirationTime(transferExpirationTime) .setPendingTransferExpirationTime(transferExpirationTime)
.setExtendedRegistrationYears(1)
.build()) .build())
.build(); .build();
} }

View file

@ -102,7 +102,6 @@ public class ContactResourceTest extends EntityTestCase {
.build()) .build())
.setStatusValues(ImmutableSet.of(StatusValue.OK)) .setStatusValues(ImmutableSet.of(StatusValue.OK))
.setTransferData(new TransferData.Builder() .setTransferData(new TransferData.Builder()
.setExtendedRegistrationYears(0)
.setGainingClientId("gaining") .setGainingClientId("gaining")
.setLosingClientId("losing") .setLosingClientId("losing")
.setPendingTransferExpirationTime(clock.nowUtc()) .setPendingTransferExpirationTime(clock.nowUtc())

View file

@ -124,7 +124,6 @@ public class DomainResourceTest extends EntityTestCase {
LaunchNotice.create("tcnid", "validatorId", START_OF_TIME, START_OF_TIME)) LaunchNotice.create("tcnid", "validatorId", START_OF_TIME, START_OF_TIME))
.setTransferData( .setTransferData(
new TransferData.Builder() new TransferData.Builder()
.setExtendedRegistrationYears(1)
.setGainingClientId("gaining") .setGainingClientId("gaining")
.setLosingClientId("losing") .setLosingClientId("losing")
.setPendingTransferExpirationTime(clock.nowUtc()) .setPendingTransferExpirationTime(clock.nowUtc())
@ -306,7 +305,6 @@ public class DomainResourceTest extends EntityTestCase {
.setServerApproveBillingEvent(Key.create(transferBillingEvent)) .setServerApproveBillingEvent(Key.create(transferBillingEvent))
.setServerApproveEntities(ImmutableSet.<Key<? extends TransferServerApproveEntity>>of( .setServerApproveEntities(ImmutableSet.<Key<? extends TransferServerApproveEntity>>of(
Key.create(transferBillingEvent))) Key.create(transferBillingEvent)))
.setExtendedRegistrationYears(1)
.build()) .build())
.addGracePeriod( .addGracePeriod(
// Okay for billing event to be null since the point of this grace period is just // Okay for billing event to be null since the point of this grace period is just

View file

@ -61,7 +61,6 @@ public class HostResourceTest extends EntityTestCase {
newDomainResource("example.com").asBuilder() newDomainResource("example.com").asBuilder()
.setRepoId("1-COM") .setRepoId("1-COM")
.setTransferData(new TransferData.Builder() .setTransferData(new TransferData.Builder()
.setExtendedRegistrationYears(0)
.setGainingClientId("gaining") .setGainingClientId("gaining")
.setLosingClientId("losing") .setLosingClientId("losing")
.setPendingTransferExpirationTime(clock.nowUtc()) .setPendingTransferExpirationTime(clock.nowUtc())

View file

@ -876,7 +876,6 @@ class google.registry.model.transfer.TransferData {
com.googlecode.objectify.Key<google.registry.model.poll.PollMessage$Autorenew> serverApproveAutorenewPollMessage; com.googlecode.objectify.Key<google.registry.model.poll.PollMessage$Autorenew> serverApproveAutorenewPollMessage;
google.registry.model.eppcommon.Trid transferRequestTrid; google.registry.model.eppcommon.Trid transferRequestTrid;
google.registry.model.transfer.TransferStatus transferStatus; google.registry.model.transfer.TransferStatus transferStatus;
java.lang.Integer extendedRegistrationYears;
java.lang.String gainingClientId; java.lang.String gainingClientId;
java.lang.String losingClientId; java.lang.String losingClientId;
java.util.Set<com.googlecode.objectify.Key<? extends google.registry.model.transfer.TransferData$TransferServerApproveEntity>> serverApproveEntities; java.util.Set<com.googlecode.objectify.Key<? extends google.registry.model.transfer.TransferData$TransferServerApproveEntity>> serverApproveEntities;

View file

@ -160,7 +160,6 @@ public class RdapJsonFormatterTest {
.setTransferRequestTime(clock.nowUtc().minusDays(1)) .setTransferRequestTime(clock.nowUtc().minusDays(1))
.setLosingClientId("TheRegistrar") .setLosingClientId("TheRegistrar")
.setPendingTransferExpirationTime(clock.nowUtc().plusYears(100)) .setPendingTransferExpirationTime(clock.nowUtc().plusYears(100))
.setExtendedRegistrationYears(1)
.build()) .build())
.build()))) .build())))
.build()); .build());

View file

@ -332,7 +332,6 @@ public class ContactResourceToXjcConverterTest {
.setPhoneNumber("+1.2126660001") .setPhoneNumber("+1.2126660001")
.build()) .build())
.setTransferData(new TransferData.Builder() .setTransferData(new TransferData.Builder()
.setExtendedRegistrationYears(1)
.setGainingClientId("TheRegistrar") .setGainingClientId("TheRegistrar")
.setLosingClientId("NewRegistrar") .setLosingClientId("NewRegistrar")
.setTransferRequestTime(DateTime.parse("1925-04-19TZ")) .setTransferRequestTime(DateTime.parse("1925-04-19TZ"))

View file

@ -324,7 +324,6 @@ public class DomainResourceToXjcConverterTest {
.setParent(historyEntry) .setParent(historyEntry)
.build()))) .build())))
.setTransferData(new TransferData.Builder() .setTransferData(new TransferData.Builder()
.setExtendedRegistrationYears(1)
.setGainingClientId("gaining") .setGainingClientId("gaining")
.setLosingClientId("losing") .setLosingClientId("losing")
.setPendingTransferExpirationTime(DateTime.parse("1925-04-20T00:00:00Z")) .setPendingTransferExpirationTime(DateTime.parse("1925-04-20T00:00:00Z"))

View file

@ -149,7 +149,6 @@ final class RdeFixtures {
.setParent(historyEntry) .setParent(historyEntry)
.build()))) .build())))
.setTransferData(new TransferData.Builder() .setTransferData(new TransferData.Builder()
.setExtendedRegistrationYears(1)
.setGainingClientId("gaining") .setGainingClientId("gaining")
.setLosingClientId("losing") .setLosingClientId("losing")
.setPendingTransferExpirationTime(DateTime.parse("1925-04-20T00:00:00Z")) .setPendingTransferExpirationTime(DateTime.parse("1925-04-20T00:00:00Z"))

View file

@ -388,36 +388,6 @@ public class XjcToDomainResourceConverterTest {
.isEqualTo(DateTime.parse("2015-01-08T22:00:00.0Z")); .isEqualTo(DateTime.parse("2015-01-08T22:00:00.0Z"));
} }
@Test
public void testConvertDomainResourcePendingTransferDefaultExtendedYears() throws Exception {
persistActiveContact("jd1234");
persistActiveContact("sh8013");
final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_pending_transfer.xml");
DomainResource domain = persistResource(convertDomainInTransaction(xjcDomain));
assertThat(domain.getTransferData()).isNotNull();
assertThat(domain.getTransferData().getExtendedRegistrationYears()).isEqualTo(1);
}
@Test
public void testConvertDomainResourcePendingTransferExtendOneYear() throws Exception {
persistActiveContact("jd1234");
persistActiveContact("sh8013");
final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_pending_transfer_1yr.xml");
DomainResource domain = persistResource(convertDomainInTransaction(xjcDomain));
assertThat(domain.getTransferData()).isNotNull();
assertThat(domain.getTransferData().getExtendedRegistrationYears()).isEqualTo(1);
}
@Test
public void testConvertDomainResourcePendingTransferExtendTwoYears() throws Exception {
persistActiveContact("jd1234");
persistActiveContact("sh8013");
final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_pending_transfer_2yr.xml");
DomainResource domain = persistResource(convertDomainInTransaction(xjcDomain));
assertThat(domain.getTransferData()).isNotNull();
assertThat(domain.getTransferData().getExtendedRegistrationYears()).isEqualTo(2);
}
private static DomainResource convertDomainInTransaction(final XjcRdeDomain xjcDomain) { private static DomainResource convertDomainInTransaction(final XjcRdeDomain xjcDomain) {
final HistoryEntry historyEntry = createHistoryEntryForDomainImport(xjcDomain); final HistoryEntry historyEntry = createHistoryEntryForDomainImport(xjcDomain);
final BillingEvent.Recurring autorenewBillingEvent = final BillingEvent.Recurring autorenewBillingEvent =

View file

@ -1,24 +0,0 @@
<rdeDom:domain
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"
xmlns:rdeDom="urn:ietf:params:xml:ns:rdeDomain-1.0">
<rdeDom:name>example1.example</rdeDom:name>
<rdeDom:roid>Dexample1-TEST</rdeDom:roid>
<rdeDom:status s="pendingTransfer"/>
<rdeDom:registrant>jd1234</rdeDom:registrant>
<rdeDom:contact type="admin">sh8013</rdeDom:contact>
<rdeDom:contact type="tech">sh8013</rdeDom:contact>
<rdeDom:clID>RegistrarX</rdeDom:clID>
<rdeDom:crRr client="jdoe">RegistrarX</rdeDom:crRr>
<rdeDom:crDate>1999-04-03T22:00:00.0Z</rdeDom:crDate>
<rdeDom:exDate>2015-04-03T22:00:00.0Z</rdeDom:exDate>
<rdeDom:upRr>RegistrarY</rdeDom:upRr>
<rdeDom:upDate>2015-01-03T22:00:00.0Z</rdeDom:upDate>
<rdeDom:trnData>
<rdeDom:trStatus>pending</rdeDom:trStatus>
<rdeDom:reRr>RegistrarY</rdeDom:reRr>
<rdeDom:reDate>2015-01-03T22:00:00.0Z</rdeDom:reDate>
<rdeDom:acRr>RegistrarX</rdeDom:acRr>
<rdeDom:acDate>2015-01-08T22:00:00.0Z</rdeDom:acDate>
<rdeDom:exDate>2016-04-03T22:00:00.0Z</rdeDom:exDate>
</rdeDom:trnData>
</rdeDom:domain>

View file

@ -1,24 +0,0 @@
<rdeDom:domain
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"
xmlns:rdeDom="urn:ietf:params:xml:ns:rdeDomain-1.0">
<rdeDom:name>example1.example</rdeDom:name>
<rdeDom:roid>Dexample1-TEST</rdeDom:roid>
<rdeDom:status s="pendingTransfer"/>
<rdeDom:registrant>jd1234</rdeDom:registrant>
<rdeDom:contact type="admin">sh8013</rdeDom:contact>
<rdeDom:contact type="tech">sh8013</rdeDom:contact>
<rdeDom:clID>RegistrarX</rdeDom:clID>
<rdeDom:crRr client="jdoe">RegistrarX</rdeDom:crRr>
<rdeDom:crDate>1999-04-03T22:00:00.0Z</rdeDom:crDate>
<rdeDom:exDate>2015-04-03T22:00:00.0Z</rdeDom:exDate>
<rdeDom:upRr>RegistrarY</rdeDom:upRr>
<rdeDom:upDate>2015-01-03T22:00:00.0Z</rdeDom:upDate>
<rdeDom:trnData>
<rdeDom:trStatus>pending</rdeDom:trStatus>
<rdeDom:reRr>RegistrarY</rdeDom:reRr>
<rdeDom:reDate>2015-01-03T22:00:00.0Z</rdeDom:reDate>
<rdeDom:acRr>RegistrarX</rdeDom:acRr>
<rdeDom:acDate>2015-01-08T22:00:00.0Z</rdeDom:acDate>
<rdeDom:exDate>2017-04-03T22:00:00.0Z</rdeDom:exDate>
</rdeDom:trnData>
</rdeDom:domain>

View file

@ -431,12 +431,6 @@ public class DatastoreHelper {
.setPendingTransferExpirationTime(expirationTime); .setPendingTransferExpirationTime(expirationTime);
} }
private static Builder createTransferDataBuilder(
DateTime requestTime, DateTime expirationTime, Integer extendedRegistrationYears) {
return createTransferDataBuilder(requestTime, expirationTime)
.setExtendedRegistrationYears(extendedRegistrationYears);
}
public static PollMessage.OneTime createPollMessageForImplicitTransfer( public static PollMessage.OneTime createPollMessageForImplicitTransfer(
EppResource contact, EppResource contact,
HistoryEntry historyEntry, HistoryEntry historyEntry,
@ -460,8 +454,7 @@ public class DatastoreHelper {
DomainResource domain, DomainResource domain,
HistoryEntry historyEntry, HistoryEntry historyEntry,
DateTime costLookupTime, DateTime costLookupTime,
DateTime eventTime, DateTime eventTime) {
Integer extendedRegistrationYears) {
return new BillingEvent.OneTime.Builder() return new BillingEvent.OneTime.Builder()
.setReason(Reason.TRANSFER) .setReason(Reason.TRANSFER)
.setTargetId(domain.getFullyQualifiedDomainName()) .setTargetId(domain.getFullyQualifiedDomainName())
@ -469,10 +462,8 @@ public class DatastoreHelper {
.setBillingTime( .setBillingTime(
eventTime.plus(Registry.get(domain.getTld()).getTransferGracePeriodLength())) eventTime.plus(Registry.get(domain.getTld()).getTransferGracePeriodLength()))
.setClientId("NewRegistrar") .setClientId("NewRegistrar")
.setPeriodYears(extendedRegistrationYears) .setPeriodYears(1)
.setCost( .setCost(getDomainRenewCost(domain.getFullyQualifiedDomainName(), costLookupTime, 1))
getDomainRenewCost(
domain.getFullyQualifiedDomainName(), costLookupTime, extendedRegistrationYears))
.setParent(historyEntry) .setParent(historyEntry)
.build(); .build();
} }
@ -522,7 +513,6 @@ public class DatastoreHelper {
DateTime requestTime, DateTime requestTime,
DateTime expirationTime, DateTime expirationTime,
DateTime extendedRegistrationExpirationTime, DateTime extendedRegistrationExpirationTime,
int extendedRegistrationYears,
DateTime now) { DateTime now) {
HistoryEntry historyEntryDomainTransfer = persistResource( HistoryEntry historyEntryDomainTransfer = persistResource(
new HistoryEntry.Builder() new HistoryEntry.Builder()
@ -533,8 +523,7 @@ public class DatastoreHelper {
domain, domain,
historyEntryDomainTransfer, historyEntryDomainTransfer,
requestTime, requestTime,
expirationTime, expirationTime));
extendedRegistrationYears));
BillingEvent.Recurring gainingClientAutorenewEvent = persistResource( BillingEvent.Recurring gainingClientAutorenewEvent = persistResource(
new BillingEvent.Recurring.Builder() new BillingEvent.Recurring.Builder()
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
@ -571,8 +560,7 @@ public class DatastoreHelper {
} else { } else {
deleteResource(autorenewPollMessage); deleteResource(autorenewPollMessage);
} }
Builder transferDataBuilder = createTransferDataBuilder( Builder transferDataBuilder = createTransferDataBuilder(requestTime, expirationTime);
requestTime, expirationTime, extendedRegistrationYears);
return persistResource(domain.asBuilder() return persistResource(domain.asBuilder()
.setPersistedCurrentSponsorClientId("TheRegistrar") .setPersistedCurrentSponsorClientId("TheRegistrar")
.addStatusValue(StatusValue.PENDING_TRANSFER) .addStatusValue(StatusValue.PENDING_TRANSFER)
@ -602,7 +590,6 @@ public class DatastoreHelper {
expirationTime, expirationTime,
now))))) now)))))
.setTransferRequestTrid(Trid.create("transferClient-trid", "transferServer-trid")) .setTransferRequestTrid(Trid.create("transferClient-trid", "transferServer-trid"))
.setExtendedRegistrationYears(extendedRegistrationYears)
.build()) .build())
.build()); .build());
} }