Remove temporary @OnLoad used for setting period in DomainApplication

Now that the registration period has been added to DomainApplication, we
can remove this @OnLoad that was populating it for objects that were
missing the period.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=159464438
This commit is contained in:
Ben McIlwain 2017-06-19 12:53:57 -07:00
parent fc78fd7d4a
commit fd1051f90a
4 changed files with 2 additions and 182 deletions

View file

@ -14,22 +14,15 @@
package google.registry.model.domain;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import com.google.common.collect.ImmutableList;
import com.googlecode.objectify.annotation.EntitySubclass;
import com.googlecode.objectify.annotation.OnLoad;
import google.registry.model.annotations.ExternalMessagingName;
import google.registry.model.domain.launch.ApplicationStatus;
import google.registry.model.domain.launch.LaunchPhase;
import google.registry.model.eppcommon.Trid;
import google.registry.model.eppinput.EppInput;
import google.registry.model.eppinput.EppInput.ResourceCommandWrapper;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.smd.EncodedSignedMark;
import google.registry.xml.XmlTransformer;
import java.io.ByteArrayInputStream;
import java.util.List;
import org.joda.money.Money;
import org.joda.time.DateTime;
@ -66,69 +59,6 @@ public class DomainApplication extends DomainBase {
/** The amount paid at auction for the right to register the domain. Used only for reporting. */
Money auctionPrice;
// TODO(b/32447342): remove this once the period has been populated on all DomainApplications
@OnLoad
void setYears() {
if (period == null) {
// Extract the registration period from the XML used to create the domain application.
try {
HistoryEntry history = ofy().load()
.type(HistoryEntry.class)
.ancestor(this)
.order("modificationTime")
.first()
.now();
if (history != null) {
byte[] xmlBytes = history.getXmlBytes();
EppInput eppInput = unmarshal(EppInput.class, xmlBytes);
period = ((DomainCommand.Create)
((ResourceCommandWrapper) eppInput.getCommandWrapper().getCommand())
.getResourceCommand()).getPeriod();
}
} catch (Exception e) {
// If we encounter an exception, give up on this defaulting.
}
}
}
/**
* Unmarshal bytes into Epp classes.
*
* <p>This method, and the things it depends on, are copied from EppXmlTransformer, because that
* class is in the flows directory, and we don't want a build dependency of model on build. It can
* be removed when the @OnLoad method is removed.
*
* @param clazz type to return, specified as a param to enforce typesafe generics
* @see "http://errorprone.info/bugpattern/TypeParameterUnusedInFormals"
*/
private static <T> T unmarshal(Class<T> clazz, byte[] bytes) throws Exception {
return INPUT_TRANSFORMER.unmarshal(clazz, new ByteArrayInputStream(bytes));
}
// Hardcoded XML schemas, ordered with respect to dependency.
private static final ImmutableList<String> SCHEMAS = ImmutableList.of(
"eppcom.xsd",
"epp.xsd",
"contact.xsd",
"host.xsd",
"domain.xsd",
"rgp.xsd",
"secdns.xsd",
"fee06.xsd",
"fee11.xsd",
"fee12.xsd",
"metadata.xsd",
"mark.xsd",
"dsig.xsd",
"smd.xsd",
"launch.xsd",
"allocate.xsd");
private static final XmlTransformer INPUT_TRANSFORMER =
new XmlTransformer(SCHEMAS, EppInput.class);
// End of copied stuff used by @OnLoad method
@Override
public String getFullyQualifiedDomainName() {
return fullyQualifiedDomainName;