mirror of
https://github.com/google/nomulus.git
synced 2025-07-23 11:16:04 +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
132
java/google/registry/model/contact/ContactInfoData.java
Normal file
132
java/google/registry/model/contact/ContactInfoData.java
Normal file
|
@ -0,0 +1,132 @@
|
|||
// 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.contact;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.auto.value.AutoValue.CopyAnnotations;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
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.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
|
||||
/** The {@link ResponseData} returned for an EPP info flow on a contact. */
|
||||
@XmlRootElement(name = "infData")
|
||||
@XmlType(propOrder = {
|
||||
"contactId",
|
||||
"repoId",
|
||||
"statusValues",
|
||||
"postalInfos",
|
||||
"voiceNumber",
|
||||
"faxNumber",
|
||||
"emailAddress",
|
||||
"currentSponsorClientId",
|
||||
"creationClientId",
|
||||
"creationTime",
|
||||
"lastEppUpdateClientId",
|
||||
"lastEppUpdateTime",
|
||||
"lastTransferTime",
|
||||
"authInfo",
|
||||
"disclose" })
|
||||
@AutoValue
|
||||
@CopyAnnotations
|
||||
public abstract class ContactInfoData implements ResponseData {
|
||||
|
||||
@XmlElement(name = "id")
|
||||
abstract String getContactId();
|
||||
|
||||
@XmlElement(name = "roid")
|
||||
abstract String getRepoId();
|
||||
|
||||
@XmlElement(name = "status")
|
||||
abstract ImmutableSet<StatusValue> getStatusValues();
|
||||
|
||||
@XmlElement(name = "postalInfo")
|
||||
abstract ImmutableList<PostalInfo> getPostalInfos();
|
||||
|
||||
@XmlElement(name = "voice")
|
||||
@Nullable
|
||||
abstract ContactPhoneNumber getVoiceNumber();
|
||||
|
||||
@XmlElement(name = "fax")
|
||||
@Nullable
|
||||
abstract ContactPhoneNumber getFaxNumber();
|
||||
|
||||
@XmlElement(name = "email")
|
||||
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
|
||||
@Nullable
|
||||
abstract String getEmailAddress();
|
||||
|
||||
@XmlElement(name = "clID")
|
||||
abstract String getCurrentSponsorClientId();
|
||||
|
||||
@XmlElement(name = "crID")
|
||||
abstract String getCreationClientId();
|
||||
|
||||
@XmlElement(name = "crDate")
|
||||
abstract DateTime getCreationTime();
|
||||
|
||||
@XmlElement(name = "upID")
|
||||
@Nullable
|
||||
abstract String getLastEppUpdateClientId();
|
||||
|
||||
@XmlElement(name = "upDate")
|
||||
@Nullable
|
||||
abstract DateTime getLastEppUpdateTime();
|
||||
|
||||
@XmlElement(name = "trDate")
|
||||
@Nullable
|
||||
abstract DateTime getLastTransferTime();
|
||||
|
||||
@XmlElement(name = "authInfo")
|
||||
@Nullable
|
||||
abstract ContactAuthInfo getAuthInfo();
|
||||
|
||||
@XmlElement(name = "disclose")
|
||||
@Nullable
|
||||
abstract Disclose getDisclose();
|
||||
|
||||
/** Builder for {@link ContactInfoData}. */
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
public abstract Builder setContactId(String contactId);
|
||||
public abstract Builder setRepoId(String repoId);
|
||||
public abstract Builder setStatusValues(ImmutableSet<StatusValue> statusValues);
|
||||
public abstract Builder setPostalInfos(ImmutableList<PostalInfo> postalInfos);
|
||||
public abstract Builder setVoiceNumber(@Nullable ContactPhoneNumber voiceNumber);
|
||||
public abstract Builder setFaxNumber(@Nullable ContactPhoneNumber faxNumber);
|
||||
public abstract Builder setEmailAddress(@Nullable String emailAddress);
|
||||
public abstract Builder setCurrentSponsorClientId(String currentSponsorClientId);
|
||||
public abstract Builder setCreationClientId(String creationClientId);
|
||||
public abstract Builder setCreationTime(DateTime creationTime);
|
||||
public abstract Builder setLastEppUpdateClientId(@Nullable String lastEppUpdateClientId);
|
||||
public abstract Builder setLastEppUpdateTime(@Nullable DateTime lastEppUpdateTime);
|
||||
public abstract Builder setLastTransferTime(@Nullable DateTime lastTransferTime);
|
||||
public abstract Builder setAuthInfo(@Nullable ContactAuthInfo authInfo);
|
||||
public abstract Builder setDisclose(@Nullable Disclose disclose);
|
||||
public abstract ContactInfoData build();
|
||||
}
|
||||
|
||||
public static Builder newBuilder() {
|
||||
return new AutoValue_ContactInfoData.Builder();
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
|
|||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.googlecode.objectify.annotation.Cache;
|
||||
import com.googlecode.objectify.annotation.Entity;
|
||||
|
@ -34,13 +35,7 @@ import google.registry.model.annotations.ExternalMessagingName;
|
|||
import google.registry.model.annotations.ReportedOn;
|
||||
import google.registry.model.contact.PostalInfo.Type;
|
||||
import google.registry.model.transfer.TransferData;
|
||||
import java.util.List;
|
||||
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 javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
|
@ -48,23 +43,6 @@ import org.joda.time.DateTime;
|
|||
*
|
||||
* @see <a href="https://tools.ietf.org/html/rfc5733">RFC 5733</a>
|
||||
*/
|
||||
@XmlRootElement(name = "infData")
|
||||
@XmlType(propOrder = {
|
||||
"contactId",
|
||||
"repoId",
|
||||
"status",
|
||||
"postalInfosAsList",
|
||||
"voice",
|
||||
"fax",
|
||||
"email",
|
||||
"currentSponsorClientId",
|
||||
"creationClientId",
|
||||
"creationTime",
|
||||
"lastEppUpdateClientId",
|
||||
"lastEppUpdateTime",
|
||||
"lastTransferTime",
|
||||
"authInfo",
|
||||
"disclose" })
|
||||
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
|
||||
@ReportedOn
|
||||
@Entity
|
||||
|
@ -79,7 +57,6 @@ public class ContactResource extends EppResource
|
|||
* from (creationTime, deletionTime) there can only be one contact in the datastore with this id.
|
||||
* However, there can be many contacts with the same id and non-overlapping lifetimes.
|
||||
*/
|
||||
@XmlTransient
|
||||
String contactId;
|
||||
|
||||
/**
|
||||
|
@ -87,7 +64,6 @@ public class ContactResource extends EppResource
|
|||
* US-ASCII character set. Personal info; cleared by {@link Builder#wipeOut}.
|
||||
*/
|
||||
@IgnoreSave(IfNull.class)
|
||||
@XmlTransient
|
||||
PostalInfo localizedPostalInfo;
|
||||
|
||||
/**
|
||||
|
@ -95,7 +71,6 @@ public class ContactResource extends EppResource
|
|||
* {@link Builder#wipeOut}.
|
||||
*/
|
||||
@IgnoreSave(IfNull.class)
|
||||
@XmlTransient
|
||||
PostalInfo internationalizedPostalInfo;
|
||||
|
||||
/**
|
||||
|
@ -104,7 +79,6 @@ public class ContactResource extends EppResource
|
|||
* info; cleared by {@link Builder#wipeOut}.
|
||||
*/
|
||||
@Index
|
||||
@XmlTransient
|
||||
String searchName;
|
||||
|
||||
/** Contact’s voice number. Personal info; cleared by {@link Builder#wipeOut}. */
|
||||
|
@ -117,14 +91,12 @@ public class ContactResource extends EppResource
|
|||
|
||||
/** Contact’s email address. Personal info; cleared by {@link Builder#wipeOut}. */
|
||||
@IgnoreSave(IfNull.class)
|
||||
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
|
||||
String email;
|
||||
|
||||
/** Authorization info (aka transfer secret) of the contact. */
|
||||
ContactAuthInfo authInfo;
|
||||
|
||||
/** Data about any pending or past transfers on this contact. */
|
||||
@XmlTransient
|
||||
TransferData transferData;
|
||||
|
||||
/**
|
||||
|
@ -132,17 +104,14 @@ public class ContactResource extends EppResource
|
|||
*
|
||||
* <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.
|
||||
|
||||
/** Disclosure policy. */
|
||||
@IgnoreSave(IfNull.class)
|
||||
Disclose disclose;
|
||||
|
||||
@XmlElement(name = "id")
|
||||
public String getContactId() {
|
||||
return contactId;
|
||||
}
|
||||
|
@ -199,7 +168,7 @@ public class ContactResource extends EppResource
|
|||
* transforms the persisted format to the XML format for marshalling.
|
||||
*/
|
||||
@XmlElement(name = "postalInfo")
|
||||
public List<PostalInfo> getPostalInfosAsList() {
|
||||
public ImmutableList<PostalInfo> getPostalInfosAsList() {
|
||||
return FluentIterable
|
||||
.from(Lists.newArrayList(localizedPostalInfo, internationalizedPostalInfo))
|
||||
.filter(Predicates.notNull())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue