mirror of
https://github.com/google/nomulus.git
synced 2025-07-14 06:55:20 +02:00
Create *InfoData objects instead of reusing *Resource objects
This is probably best from a code-cleanliness perspective anyways, but the rationale is that tightly coupling the resources to the info responses was a straightjacket that required all status values and fields to be directly available on the resource. With this change, I already was able to get rid of the preMarshal() hackery, and I will be able to get rid of cloneWithLinkedStatus() and most of the contents of cloneProjectedAtTime() for non-domains. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=144252924
This commit is contained in:
parent
96a71ded91
commit
b0bcc1bb3d
22 changed files with 586 additions and 230 deletions
|
@ -33,27 +33,10 @@ import google.registry.model.smd.EncodedSignedMark;
|
|||
import google.registry.xml.XmlTransformer;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.List;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/** An application to create a domain. */
|
||||
@XmlRootElement(name = "infData")
|
||||
@XmlType(propOrder = {
|
||||
"fullyQualifiedDomainName",
|
||||
"repoId",
|
||||
"status",
|
||||
"marshalledRegistrant",
|
||||
"marshalledContacts",
|
||||
"marshalledNameservers",
|
||||
"currentSponsorClientId",
|
||||
"creationClientId",
|
||||
"creationTime",
|
||||
"lastEppUpdateClientId",
|
||||
"lastEppUpdateTime",
|
||||
"authInfo"})
|
||||
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
|
||||
@EntitySubclass(index = true)
|
||||
@ExternalMessagingName("application")
|
||||
|
@ -66,30 +49,24 @@ public class DomainApplication extends DomainBase {
|
|||
*
|
||||
* <p>This field may be null for applications that were created before the field was added.
|
||||
*/
|
||||
@XmlTransient
|
||||
Trid creationTrid;
|
||||
|
||||
/**
|
||||
* The phase which this application is registered for. We store this only so we can return it back
|
||||
* to the user on info commands.
|
||||
*/
|
||||
@XmlTransient
|
||||
LaunchPhase phase;
|
||||
|
||||
/** The requested registration period. */
|
||||
@XmlTransient
|
||||
Period period;
|
||||
|
||||
/** The current status of this application. */
|
||||
@XmlTransient
|
||||
ApplicationStatus applicationStatus;
|
||||
|
||||
/** The encoded signed marks which were asserted when this application was created. */
|
||||
@XmlTransient
|
||||
List<EncodedSignedMark> encodedSignedMarks;
|
||||
|
||||
/** The amount paid at auction for the right to register the domain. Used only for reporting. */
|
||||
@XmlTransient
|
||||
Money auctionPrice;
|
||||
|
||||
// TODO(b/32447342): remove this once the period has been populated on all DomainApplications
|
||||
|
|
|
@ -22,7 +22,6 @@ import static com.google.common.collect.Iterables.any;
|
|||
import static com.google.common.collect.Sets.difference;
|
||||
import static com.google.common.collect.Sets.union;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.util.CollectionUtils.forceEmptyToNull;
|
||||
import static google.registry.util.CollectionUtils.nullToEmpty;
|
||||
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
||||
import static google.registry.util.CollectionUtils.nullToEmptyImmutableSortedCopy;
|
||||
|
@ -49,12 +48,8 @@ import google.registry.model.domain.launch.LaunchNotice;
|
|||
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.host.HostResource;
|
||||
import java.util.Set;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
/** Shared base class for {@link DomainResource} and {@link DomainApplication}. */
|
||||
@XmlTransient
|
||||
@ReportedOn
|
||||
@Entity
|
||||
public abstract class DomainBase extends EppResource {
|
||||
|
@ -69,17 +64,14 @@ public abstract class DomainBase extends EppResource {
|
|||
* @invariant fullyQualifiedDomainName == fullyQualifiedDomainName.toLowerCase()
|
||||
*/
|
||||
@Index
|
||||
@XmlElement(name = "name")
|
||||
String fullyQualifiedDomainName;
|
||||
|
||||
/** The top level domain this is under, dernormalized from {@link #fullyQualifiedDomainName}. */
|
||||
@Index
|
||||
@XmlTransient
|
||||
String tld;
|
||||
|
||||
/** References to hosts that are the nameservers for the domain. */
|
||||
@Index
|
||||
@XmlTransient
|
||||
Set<Key<HostResource>> nsHosts;
|
||||
|
||||
/**
|
||||
|
@ -87,7 +79,6 @@ public abstract class DomainBase extends EppResource {
|
|||
*
|
||||
* <p>These are stored in one field so that we can query across all contacts at once.
|
||||
*/
|
||||
@XmlTransient
|
||||
Set<DesignatedContact> allContacts;
|
||||
|
||||
/** Authorization info (aka transfer secret) of the domain. */
|
||||
|
@ -99,7 +90,6 @@ public abstract class DomainBase extends EppResource {
|
|||
* <p>This is {@literal @}XmlTransient because it needs to be returned under the "extension" tag
|
||||
* of an info response rather than inside the "infData" tag.
|
||||
*/
|
||||
@XmlTransient
|
||||
Set<DelegationSignerData> dsData;
|
||||
|
||||
/**
|
||||
|
@ -107,7 +97,6 @@ public abstract class DomainBase extends EppResource {
|
|||
* {@literal @}XmlTransient because it's not returned in an info response.
|
||||
*/
|
||||
@IgnoreSave(IfNull.class)
|
||||
@XmlTransient
|
||||
LaunchNotice launchNotice;
|
||||
|
||||
/**
|
||||
|
@ -116,52 +105,8 @@ public abstract class DomainBase extends EppResource {
|
|||
* @see google.registry.tldconfig.idn.IdnLabelValidator#findValidIdnTableForTld
|
||||
*/
|
||||
@IgnoreSave(IfNull.class)
|
||||
@XmlTransient
|
||||
String idnTableName;
|
||||
|
||||
/**
|
||||
* Synchronously load all referenced contacts and hosts into the Objectify session cache.
|
||||
*
|
||||
* <p>This saves an extra datastore roundtrip on marshalling, since contacts, hosts, and the
|
||||
* registrant will all be in the session cache when their respective methods are called.
|
||||
*/
|
||||
private void preMarshal() {
|
||||
// Calling values() blocks until loading is done.
|
||||
ofy().load().values(union(getNameservers(), getReferencedContacts())).values();
|
||||
}
|
||||
|
||||
/** JAXB java beans property to marshal nameserver hostnames. */
|
||||
@XmlElementWrapper(name = "ns")
|
||||
@XmlElement(name = "hostObj")
|
||||
private ImmutableSet<String> getMarshalledNameservers() {
|
||||
preMarshal();
|
||||
// If there are no nameservers we must return null, or an empty "ns" element will be marshalled.
|
||||
return forceEmptyToNull(loadNameserverFullyQualifiedHostNames());
|
||||
}
|
||||
|
||||
/** JAXB java beans property to marshal non-registrant contact ids. */
|
||||
@XmlElement(name = "contact")
|
||||
private ImmutableSet<ForeignKeyedDesignatedContact> getMarshalledContacts() {
|
||||
preMarshal();
|
||||
return FluentIterable.from(getContacts())
|
||||
.transform(
|
||||
new Function<DesignatedContact, ForeignKeyedDesignatedContact>() {
|
||||
@Override
|
||||
public ForeignKeyedDesignatedContact apply(DesignatedContact designated) {
|
||||
return ForeignKeyedDesignatedContact.create(
|
||||
designated.getType(),
|
||||
ofy().load().key(designated.getContactKey()).now().getContactId());
|
||||
}})
|
||||
.toSet();
|
||||
}
|
||||
|
||||
/** JAXB java beans property to marshal nameserver hostnames. */
|
||||
@XmlElement(name = "registrant")
|
||||
private String getMarshalledRegistrant() {
|
||||
preMarshal();
|
||||
return ofy().load().key(getRegistrant()).now().getContactId();
|
||||
}
|
||||
|
||||
public String getFullyQualifiedDomainName() {
|
||||
return fullyQualifiedDomainName;
|
||||
}
|
||||
|
|
146
java/google/registry/model/domain/DomainInfoData.java
Normal file
146
java/google/registry/model/domain/DomainInfoData.java
Normal file
|
@ -0,0 +1,146 @@
|
|||
// Copyright 2016 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.model.domain;
|
||||
|
||||
import static google.registry.util.CollectionUtils.forceEmptyToNull;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.auto.value.AutoValue.CopyAnnotations;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.eppoutput.EppResponse.ResponseData;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/** The {@link ResponseData} returned for an EPP info flow on a domain. */
|
||||
@XmlRootElement(name = "infData")
|
||||
@XmlType(propOrder = {
|
||||
"fullyQualifiedDomainName",
|
||||
"repoId",
|
||||
"statusValues",
|
||||
"registrant",
|
||||
"contacts",
|
||||
"nameservers",
|
||||
"subordinateHosts",
|
||||
"currentSponsorClientId",
|
||||
"creationClientId",
|
||||
"creationTime",
|
||||
"lastEppUpdateClientId",
|
||||
"lastEppUpdateTime",
|
||||
"registrationExpirationTime",
|
||||
"lastTransferTime",
|
||||
"authInfo"})
|
||||
@AutoValue
|
||||
@CopyAnnotations
|
||||
public abstract class DomainInfoData implements ResponseData {
|
||||
|
||||
@XmlElement(name = "name")
|
||||
abstract String getFullyQualifiedDomainName();
|
||||
|
||||
@XmlElement(name = "roid")
|
||||
abstract String getRepoId();
|
||||
|
||||
@XmlElement(name = "status")
|
||||
abstract ImmutableSet<StatusValue> getStatusValues();
|
||||
|
||||
@XmlElement(name = "registrant")
|
||||
abstract String getRegistrant();
|
||||
|
||||
@XmlElement(name = "contact")
|
||||
abstract ImmutableSet<ForeignKeyedDesignatedContact> getContacts();
|
||||
|
||||
@XmlElementWrapper(name = "ns")
|
||||
@XmlElement(name = "hostObj")
|
||||
@Nullable
|
||||
abstract ImmutableSet<String> getNameservers();
|
||||
|
||||
@XmlElement(name = "host")
|
||||
@Nullable
|
||||
abstract ImmutableSet<String> getSubordinateHosts();
|
||||
|
||||
@XmlElement(name = "clID")
|
||||
abstract String getCurrentSponsorClientId();
|
||||
|
||||
@XmlElement(name = "crID")
|
||||
@Nullable
|
||||
abstract String getCreationClientId();
|
||||
|
||||
@XmlElement(name = "crDate")
|
||||
@Nullable
|
||||
abstract DateTime getCreationTime();
|
||||
|
||||
@XmlElement(name = "upID")
|
||||
@Nullable
|
||||
abstract String getLastEppUpdateClientId();
|
||||
|
||||
@XmlElement(name = "upDate")
|
||||
@Nullable
|
||||
abstract DateTime getLastEppUpdateTime();
|
||||
|
||||
@XmlElement(name = "exDate")
|
||||
@Nullable
|
||||
abstract DateTime getRegistrationExpirationTime();
|
||||
|
||||
@XmlElement(name = "trDate")
|
||||
@Nullable
|
||||
abstract DateTime getLastTransferTime();
|
||||
|
||||
@XmlElement(name = "authInfo")
|
||||
@Nullable
|
||||
abstract DomainAuthInfo getAuthInfo();
|
||||
|
||||
/** Builder for {@link DomainInfoData}. */
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
public abstract Builder setFullyQualifiedDomainName(String fullyQualifiedDomainName);
|
||||
public abstract Builder setRepoId(String repoId);
|
||||
public abstract Builder setStatusValues(ImmutableSet<StatusValue> statusValues);
|
||||
public abstract Builder setRegistrant(String registrant);
|
||||
public abstract Builder setContacts(ImmutableSet<ForeignKeyedDesignatedContact> contacts);
|
||||
public abstract Builder setNameservers(@Nullable ImmutableSet<String> nameservers);
|
||||
public abstract Builder setSubordinateHosts(@Nullable ImmutableSet<String> subordinateHosts);
|
||||
public abstract Builder setCurrentSponsorClientId(String currentSponsorClientId);
|
||||
public abstract Builder setCreationClientId(@Nullable String creationClientId);
|
||||
public abstract Builder setCreationTime(@Nullable DateTime creationTime);
|
||||
public abstract Builder setLastEppUpdateClientId(@Nullable String lastEppUpdateClientId);
|
||||
public abstract Builder setLastEppUpdateTime(@Nullable DateTime lastEppUpdateTime);
|
||||
public abstract Builder setRegistrationExpirationTime(
|
||||
@Nullable DateTime registrationExpirationTime);
|
||||
public abstract Builder setLastTransferTime(@Nullable DateTime lastTransferTime);
|
||||
public abstract Builder setAuthInfo(@Nullable DomainAuthInfo authInfo);
|
||||
|
||||
/** Internal accessor for use in {@link #build}. */
|
||||
@Nullable
|
||||
abstract ImmutableSet<String> getNameservers();
|
||||
|
||||
/** Generated build method. */
|
||||
abstract DomainInfoData autoBuild();
|
||||
|
||||
/** Public build method. */
|
||||
public DomainInfoData build() {
|
||||
// If there are no nameservers use null, or an empty "ns" element will be marshalled.
|
||||
setNameservers(forceEmptyToNull(getNameservers()));
|
||||
return autoBuild();
|
||||
}
|
||||
}
|
||||
|
||||
public static Builder newBuilder() {
|
||||
return new AutoValue_DomainInfoData.Builder();
|
||||
}
|
||||
}
|
|
@ -44,10 +44,6 @@ import google.registry.model.transfer.TransferData;
|
|||
import google.registry.model.transfer.TransferStatus;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Interval;
|
||||
|
||||
|
@ -56,23 +52,6 @@ import org.joda.time.Interval;
|
|||
*
|
||||
* @see <a href="https://tools.ietf.org/html/rfc5731">RFC 5731</a>
|
||||
*/
|
||||
@XmlRootElement(name = "infData")
|
||||
@XmlType(propOrder = {
|
||||
"fullyQualifiedDomainName",
|
||||
"repoId",
|
||||
"status",
|
||||
"marshalledRegistrant",
|
||||
"marshalledContacts",
|
||||
"marshalledNameservers",
|
||||
"subordinateHosts",
|
||||
"currentSponsorClientId",
|
||||
"creationClientId",
|
||||
"creationTime",
|
||||
"lastEppUpdateClientId",
|
||||
"lastEppUpdateTime",
|
||||
"registrationExpirationTime",
|
||||
"lastTransferTime",
|
||||
"authInfo"})
|
||||
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
|
||||
@EntitySubclass(index = true)
|
||||
@ExternalMessagingName("domain")
|
||||
|
@ -91,11 +70,9 @@ public class DomainResource extends DomainBase
|
|||
StatusValue.SERVER_HOLD);
|
||||
|
||||
/** Fully qualified host names of this domain's active subordinate hosts. */
|
||||
@XmlElement(name = "host")
|
||||
Set<String> subordinateHosts;
|
||||
|
||||
/** When this domain's registration will expire. */
|
||||
@XmlElement(name = "exDate")
|
||||
DateTime registrationExpirationTime;
|
||||
|
||||
/**
|
||||
|
@ -105,7 +82,6 @@ public class DomainResource extends DomainBase
|
|||
* refer to a {@link PollMessage} timed to when the domain is fully deleted. If the domain is
|
||||
* restored, the message should be deleted.
|
||||
*/
|
||||
@XmlTransient
|
||||
Key<PollMessage.OneTime> deletePollMessage;
|
||||
|
||||
/**
|
||||
|
@ -116,7 +92,6 @@ public class DomainResource extends DomainBase
|
|||
* {@link #registrationExpirationTime} is changed the recurrence should be closed, a new one
|
||||
* should be created, and this field should be updated to point to the new one.
|
||||
*/
|
||||
@XmlTransient
|
||||
Key<BillingEvent.Recurring> autorenewBillingEvent;
|
||||
|
||||
/**
|
||||
|
@ -127,11 +102,9 @@ public class DomainResource extends DomainBase
|
|||
* {@link #registrationExpirationTime} is changed the recurrence should be closed, a new one
|
||||
* should be created, and this field should be updated to point to the new one.
|
||||
*/
|
||||
@XmlTransient
|
||||
Key<PollMessage.Autorenew> autorenewPollMessage;
|
||||
|
||||
/** The unexpired grace periods for this domain (some of which may not be active yet). */
|
||||
@XmlTransient
|
||||
Set<GracePeriod> gracePeriods;
|
||||
|
||||
/**
|
||||
|
@ -139,7 +112,6 @@ public class DomainResource extends DomainBase
|
|||
* Will only be populated for domains allocated from a sunrise application.
|
||||
*/
|
||||
@IgnoreSave(IfNull.class)
|
||||
@XmlTransient
|
||||
String smdId;
|
||||
|
||||
/**
|
||||
|
@ -147,7 +119,6 @@ public class DomainResource extends DomainBase
|
|||
* for domains allocated from an application.
|
||||
*/
|
||||
@IgnoreSave(IfNull.class)
|
||||
@XmlTransient
|
||||
DateTime applicationTime;
|
||||
|
||||
/**
|
||||
|
@ -155,11 +126,9 @@ public class DomainResource extends DomainBase
|
|||
* allocated from an application.
|
||||
*/
|
||||
@IgnoreSave(IfNull.class)
|
||||
@XmlTransient
|
||||
Key<DomainApplication> application;
|
||||
|
||||
/** Data about any pending or past transfers on this domain. */
|
||||
@XmlTransient
|
||||
TransferData transferData;
|
||||
|
||||
/**
|
||||
|
@ -167,7 +136,6 @@ public class DomainResource extends DomainBase
|
|||
*
|
||||
* <p>Can be null if the resource has never been transferred.
|
||||
*/
|
||||
@XmlElement(name = "trDate")
|
||||
DateTime lastTransferTime;
|
||||
|
||||
public ImmutableSet<String> getSubordinateHosts() {
|
||||
|
|
|
@ -25,14 +25,15 @@ import javax.xml.bind.annotation.XmlValue;
|
|||
* @see <a href="http://tools.ietf.org/html/rfc5731#section-2.2">
|
||||
* RFC 5731 - EPP Domain Name Mapping - Contact and Client Identifiers</a>
|
||||
*/
|
||||
class ForeignKeyedDesignatedContact extends ImmutableObject {
|
||||
public class ForeignKeyedDesignatedContact extends ImmutableObject {
|
||||
@XmlAttribute(required = true)
|
||||
DesignatedContact.Type type;
|
||||
|
||||
@XmlValue
|
||||
String contactId;
|
||||
|
||||
static ForeignKeyedDesignatedContact create(DesignatedContact.Type type, String contactId) {
|
||||
public static ForeignKeyedDesignatedContact create(
|
||||
DesignatedContact.Type type, String contactId) {
|
||||
ForeignKeyedDesignatedContact instance = new ForeignKeyedDesignatedContact();
|
||||
instance.type = type;
|
||||
instance.contactId = contactId;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue