diff --git a/core/src/main/java/google/registry/batch/RelockDomainAction.java b/core/src/main/java/google/registry/batch/RelockDomainAction.java index 418fb1273..93ad413ee 100644 --- a/core/src/main/java/google/registry/batch/RelockDomainAction.java +++ b/core/src/main/java/google/registry/batch/RelockDomainAction.java @@ -31,7 +31,7 @@ import google.registry.model.domain.DomainBase; import google.registry.model.domain.RegistryLock; import google.registry.model.eppcommon.StatusValue; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.model.tld.RegistryLockDao; import google.registry.persistence.VKey; import google.registry.request.Action; @@ -296,8 +296,8 @@ public class RelockDomainAction implements Runnable { ImmutableSet registryLockEmailAddresses = registrar.getContacts().stream() - .filter(RegistrarContact::isRegistryLockAllowed) - .map(RegistrarContact::getRegistryLockEmailAddress) + .filter(RegistrarPoc::isRegistryLockAllowed) + .map(RegistrarPoc::getRegistryLockEmailAddress) .filter(Optional::isPresent) .map(Optional::get) .collect(toImmutableSet()); diff --git a/core/src/main/java/google/registry/batch/SendExpiringCertificateNotificationEmailAction.java b/core/src/main/java/google/registry/batch/SendExpiringCertificateNotificationEmailAction.java index 514fe2856..6e977f87e 100644 --- a/core/src/main/java/google/registry/batch/SendExpiringCertificateNotificationEmailAction.java +++ b/core/src/main/java/google/registry/batch/SendExpiringCertificateNotificationEmailAction.java @@ -32,8 +32,8 @@ import com.google.common.net.MediaType; import google.registry.config.RegistryConfig.Config; import google.registry.flows.certs.CertificateChecker; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; -import google.registry.model.registrar.RegistrarContact.Type; +import google.registry.model.registrar.RegistrarPoc; +import google.registry.model.registrar.RegistrarPoc.Type; import google.registry.request.Action; import google.registry.request.Response; import google.registry.request.auth.Auth; @@ -281,9 +281,9 @@ public class SendExpiringCertificateNotificationEmailAction implements Runnable */ @VisibleForTesting ImmutableSet getEmailAddresses(Registrar registrar, Type contactType) { - ImmutableSortedSet contacts = registrar.getContactsOfType(contactType); + ImmutableSortedSet contacts = registrar.getContactsOfType(contactType); ImmutableSet.Builder recipientEmails = new ImmutableSet.Builder<>(); - for (RegistrarContact contact : contacts) { + for (RegistrarPoc contact : contacts) { try { recipientEmails.add(new InternetAddress(contact.getEmailAddress())); } catch (AddressException e) { diff --git a/core/src/main/java/google/registry/export/SyncGroupMembersAction.java b/core/src/main/java/google/registry/export/SyncGroupMembersAction.java index b29ee8c24..6d80174f1 100644 --- a/core/src/main/java/google/registry/export/SyncGroupMembersAction.java +++ b/core/src/main/java/google/registry/export/SyncGroupMembersAction.java @@ -32,7 +32,7 @@ import google.registry.config.RegistryConfig.Config; import google.registry.groups.GroupsConnection; import google.registry.groups.GroupsConnection.Role; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.request.Action; import google.registry.request.Response; import google.registry.request.auth.Auth; @@ -47,7 +47,7 @@ import javax.annotation.Nullable; import javax.inject.Inject; /** - * Action that syncs changes to {@link RegistrarContact} entities with Google Groups. + * Action that syncs changes to {@link RegistrarPoc} entities with Google Groups. * *

This uses the Directory API. */ @@ -99,7 +99,7 @@ public final class SyncGroupMembersAction implements Runnable { * Returns the Google Groups email address for the given registrar ID and RegistrarContact.Type. */ public static String getGroupEmailAddressForContactType( - String registrarId, RegistrarContact.Type type, String gSuiteDomainName) { + String registrarId, RegistrarPoc.Type type, String gSuiteDomainName) { // Take the registrar's ID, make it lowercase, and remove all characters that aren't // alphanumeric, hyphens, or underscores. return String.format( @@ -171,18 +171,17 @@ public final class SyncGroupMembersAction implements Runnable { private void syncRegistrarContacts(Registrar registrar) { String groupKey = ""; try { - Set registrarContacts = registrar.getContacts(); + Set registrarPocs = registrar.getContacts(); long totalAdded = 0; long totalRemoved = 0; - for (final RegistrarContact.Type type : RegistrarContact.Type.values()) { + for (final RegistrarPoc.Type type : RegistrarPoc.Type.values()) { groupKey = getGroupEmailAddressForContactType(registrar.getRegistrarId(), type, gSuiteDomainName); Set currentMembers = groupsConnection.getMembersOfGroup(groupKey); Set desiredMembers = - registrarContacts - .stream() + registrarPocs.stream() .filter(contact -> contact.getTypes().contains(type)) - .map(RegistrarContact::getEmailAddress) + .map(RegistrarPoc::getEmailAddress) .collect(toImmutableSet()); for (String email : Sets.difference(desiredMembers, currentMembers)) { groupsConnection.addMemberToGroup(groupKey, email, Role.MEMBER); diff --git a/core/src/main/java/google/registry/export/sheet/SyncRegistrarsSheet.java b/core/src/main/java/google/registry/export/sheet/SyncRegistrarsSheet.java index 70cb1c3c8..41ab32944 100644 --- a/core/src/main/java/google/registry/export/sheet/SyncRegistrarsSheet.java +++ b/core/src/main/java/google/registry/export/sheet/SyncRegistrarsSheet.java @@ -17,13 +17,13 @@ package google.registry.export.sheet; import static com.google.common.base.MoreObjects.firstNonNull; import static com.google.common.collect.ImmutableList.toImmutableList; import static google.registry.model.common.Cursor.CursorType.SYNC_REGISTRAR_SHEET; -import static google.registry.model.registrar.RegistrarContact.Type.ABUSE; -import static google.registry.model.registrar.RegistrarContact.Type.ADMIN; -import static google.registry.model.registrar.RegistrarContact.Type.BILLING; -import static google.registry.model.registrar.RegistrarContact.Type.LEGAL; -import static google.registry.model.registrar.RegistrarContact.Type.MARKETING; -import static google.registry.model.registrar.RegistrarContact.Type.TECH; -import static google.registry.model.registrar.RegistrarContact.Type.WHOIS; +import static google.registry.model.registrar.RegistrarPoc.Type.ABUSE; +import static google.registry.model.registrar.RegistrarPoc.Type.ADMIN; +import static google.registry.model.registrar.RegistrarPoc.Type.BILLING; +import static google.registry.model.registrar.RegistrarPoc.Type.LEGAL; +import static google.registry.model.registrar.RegistrarPoc.Type.MARKETING; +import static google.registry.model.registrar.RegistrarPoc.Type.TECH; +import static google.registry.model.registrar.RegistrarPoc.Type.WHOIS; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.persistence.transaction.TransactionManagerUtil.transactIfJpaTm; import static google.registry.util.DateTimeUtils.START_OF_TIME; @@ -36,7 +36,7 @@ import com.google.common.collect.Ordering; import google.registry.model.common.Cursor; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarAddress; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.util.Clock; import google.registry.util.DateTimeUtils; import java.io.IOException; @@ -92,7 +92,7 @@ class SyncRegistrarsSheet { .map( registrar -> { ImmutableMap.Builder builder = new ImmutableMap.Builder<>(); - ImmutableSortedSet contacts = registrar.getContacts(); + ImmutableSortedSet contacts = registrar.getContacts(); RegistrarAddress address = firstNonNull( registrar.getLocalizedAddress(), @@ -130,10 +130,10 @@ class SyncRegistrarsSheet { builder.put("billingContacts", convertContacts(contacts, byType(BILLING))); builder.put( "contactsMarkedAsWhoisAdmin", - convertContacts(contacts, RegistrarContact::getVisibleInWhoisAsAdmin)); + convertContacts(contacts, RegistrarPoc::getVisibleInWhoisAsAdmin)); builder.put( "contactsMarkedAsWhoisTech", - convertContacts(contacts, RegistrarContact::getVisibleInWhoisAsTech)); + convertContacts(contacts, RegistrarPoc::getVisibleInWhoisAsTech)); builder.put("emailAddress", convert(registrar.getEmailAddress())); builder.put("address.street", convert(address.getStreet())); builder.put("address.city", convert(address.getCity())); @@ -158,10 +158,10 @@ class SyncRegistrarsSheet { } private static String convertContacts( - Iterable contacts, Predicate filter) { + Iterable contacts, Predicate filter) { StringBuilder result = new StringBuilder(); boolean first = true; - for (RegistrarContact contact : contacts) { + for (RegistrarPoc contact : contacts) { if (!filter.test(contact)) { continue; } @@ -175,7 +175,7 @@ class SyncRegistrarsSheet { return result.toString(); } - private static Predicate byType(final RegistrarContact.Type type) { + private static Predicate byType(final RegistrarPoc.Type type) { return contact -> contact.getTypes().contains(type); } diff --git a/core/src/main/java/google/registry/model/EntityClasses.java b/core/src/main/java/google/registry/model/EntityClasses.java index 112f63a0c..08280e8f5 100644 --- a/core/src/main/java/google/registry/model/EntityClasses.java +++ b/core/src/main/java/google/registry/model/EntityClasses.java @@ -33,7 +33,6 @@ import google.registry.model.index.ForeignKeyIndex; import google.registry.model.poll.PollMessage; import google.registry.model.rde.RdeRevision; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; import google.registry.model.replay.LastSqlTransaction; import google.registry.model.replay.ReplayGap; import google.registry.model.reporting.HistoryEntry; @@ -75,7 +74,6 @@ public final class EntityClasses { PollMessage.OneTime.class, RdeRevision.class, Registrar.class, - RegistrarContact.class, Registry.class, ReplayGap.class, ServerSecret.class); diff --git a/core/src/main/java/google/registry/model/OteAccountBuilder.java b/core/src/main/java/google/registry/model/OteAccountBuilder.java index 8d9008ecf..e2c6454a5 100644 --- a/core/src/main/java/google/registry/model/OteAccountBuilder.java +++ b/core/src/main/java/google/registry/model/OteAccountBuilder.java @@ -35,7 +35,7 @@ import google.registry.model.common.GaeUserIdConverter; import google.registry.model.pricing.StaticPremiumListPricingEngine; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarAddress; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.model.tld.Registry; import google.registry.model.tld.Registry.TldState; import google.registry.model.tld.Registry.TldType; @@ -127,8 +127,7 @@ public final class OteAccountBuilder { private final Registry sunriseTld; private final Registry gaTld; private final Registry eapTld; - private final ImmutableList.Builder contactsBuilder = - new ImmutableList.Builder<>(); + private final ImmutableList.Builder contactsBuilder = new ImmutableList.Builder<>(); private ImmutableList registrars; private boolean replaceExisting = false; @@ -259,7 +258,7 @@ public final class OteAccountBuilder { private void saveAllEntities() { // use ImmutableObject instead of Registry so that the Key generation doesn't break ImmutableList registries = ImmutableList.of(sunriseTld, gaTld, eapTld); - ImmutableList contacts = contactsBuilder.build(); + ImmutableList contacts = contactsBuilder.build(); tm().transact( () -> { @@ -269,7 +268,7 @@ public final class OteAccountBuilder { registries.stream() .map(registry -> Registry.createVKey(registry.getTldStr())), registrars.stream().map(Registrar::createVKey), - contacts.stream().map(RegistrarContact::createVKey)) + contacts.stream().map(RegistrarPoc::createVKey)) .collect(toImmutableList()); ImmutableMap, ImmutableObject> existingObjects = tm().loadByKeysIfPresent(keys); @@ -351,10 +350,10 @@ public final class OteAccountBuilder { .build(); } - private static RegistrarContact createRegistrarContact( + private static RegistrarPoc createRegistrarContact( String email, String gaeUserId, Registrar registrar) { - return new RegistrarContact.Builder() - .setParent(registrar) + return new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName(email) .setEmailAddress(email) .setGaeUserId(gaeUserId) diff --git a/core/src/main/java/google/registry/model/registrar/Registrar.java b/core/src/main/java/google/registry/model/registrar/Registrar.java index 70c5e3997..05444827c 100644 --- a/core/src/main/java/google/registry/model/registrar/Registrar.java +++ b/core/src/main/java/google/registry/model/registrar/Registrar.java @@ -217,11 +217,9 @@ public class Registrar extends ImmutableObject immutableEnumSet( Type.REAL, Type.PDT, Type.OTE, Type.EXTERNAL_MONITORING, Type.MONITORING, Type.INTERNAL); - /** - * Compare two instances of {@link RegistrarContact} by their email addresses lexicographically. - */ - private static final Comparator CONTACT_EMAIL_COMPARATOR = - comparing(RegistrarContact::getEmailAddress, String::compareTo); + /** Compare two instances of {@link RegistrarPoc} by their email addresses lexicographically. */ + private static final Comparator CONTACT_EMAIL_COMPARATOR = + comparing(RegistrarPoc::getEmailAddress, String::compareTo); /** * A caching {@link Supplier} of a registrarId to {@link Registrar} map. @@ -628,46 +626,43 @@ public class Registrar extends ImmutableObject } /** - * Returns a list of all {@link RegistrarContact} objects for this registrar sorted by their email + * Returns a list of all {@link RegistrarPoc} objects for this registrar sorted by their email * address. */ - public ImmutableSortedSet getContacts() { + public ImmutableSortedSet getContacts() { return Streams.stream(getContactsIterable()) .filter(Objects::nonNull) .collect(toImmutableSortedSet(CONTACT_EMAIL_COMPARATOR)); } /** - * Returns a list of {@link RegistrarContact} objects of a given type for this registrar sorted by + * Returns a list of {@link RegistrarPoc} objects of a given type for this registrar sorted by * their email address. */ - public ImmutableSortedSet getContactsOfType(final RegistrarContact.Type type) { + public ImmutableSortedSet getContactsOfType(final RegistrarPoc.Type type) { return Streams.stream(getContactsIterable()) .filter(Objects::nonNull) - .filter((@Nullable RegistrarContact contact) -> contact.getTypes().contains(type)) + .filter((@Nullable RegistrarPoc contact) -> contact.getTypes().contains(type)) .collect(toImmutableSortedSet(CONTACT_EMAIL_COMPARATOR)); } /** - * Returns the {@link RegistrarContact} that is the WHOIS abuse contact for this registrar, or - * empty if one does not exist. + * Returns the {@link RegistrarPoc} that is the WHOIS abuse contact for this registrar, or empty + * if one does not exist. */ - public Optional getWhoisAbuseContact() { - return getContacts().stream() - .filter(RegistrarContact::getVisibleInDomainWhoisAsAbuse) - .findFirst(); + public Optional getWhoisAbuseContact() { + return getContacts().stream().filter(RegistrarPoc::getVisibleInDomainWhoisAsAbuse).findFirst(); } - private Iterable getContactsIterable() { + private Iterable getContactsIterable() { if (tm().isOfy()) { - return auditedOfy().load().type(RegistrarContact.class).ancestor(Registrar.this); + return auditedOfy().load().type(RegistrarPoc.class).ancestor(Registrar.this); } else { return tm().transact( () -> jpaTm() .query( - "FROM RegistrarPoc WHERE registrarId = :registrarId", - RegistrarContact.class) + "FROM RegistrarPoc WHERE registrarId = :registrarId", RegistrarPoc.class) .setParameter("registrarId", clientIdentifier) .getResultStream() .collect(toImmutableList())); diff --git a/core/src/main/java/google/registry/model/registrar/RegistrarContact.java b/core/src/main/java/google/registry/model/registrar/RegistrarPoc.java similarity index 73% rename from core/src/main/java/google/registry/model/registrar/RegistrarContact.java rename to core/src/main/java/google/registry/model/registrar/RegistrarPoc.java index bbab8b6ba..8c11d868d 100644 --- a/core/src/main/java/google/registry/model/registrar/RegistrarContact.java +++ b/core/src/main/java/google/registry/model/registrar/RegistrarPoc.java @@ -18,10 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Strings.isNullOrEmpty; import static com.google.common.collect.ImmutableSet.toImmutableSet; -import static com.google.common.collect.Sets.difference; import static com.google.common.io.BaseEncoding.base64; -import static google.registry.model.common.EntityGroupRoot.getCrossTldKey; -import static google.registry.model.ofy.ObjectifyService.auditedOfy; import static google.registry.model.registrar.Registrar.checkValidEmail; import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; @@ -31,36 +28,26 @@ import static google.registry.util.PasswordUtils.hashPassword; import static java.util.stream.Collectors.joining; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Enums; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; -import com.google.common.collect.Streams; -import com.googlecode.objectify.Key; -import com.googlecode.objectify.annotation.Entity; -import com.googlecode.objectify.annotation.Id; -import com.googlecode.objectify.annotation.Ignore; -import com.googlecode.objectify.annotation.Index; -import com.googlecode.objectify.annotation.OnLoad; -import com.googlecode.objectify.annotation.Parent; import google.registry.model.Buildable; import google.registry.model.ImmutableObject; import google.registry.model.JsonMapBuilder; import google.registry.model.Jsonifiable; import google.registry.model.UnsafeSerializable; -import google.registry.model.annotations.InCrossTld; import google.registry.model.annotations.ReportedOn; -import google.registry.model.registrar.RegistrarContact.RegistrarPocId; +import google.registry.model.registrar.RegistrarPoc.RegistrarPocId; import google.registry.persistence.VKey; import java.io.Serializable; -import java.util.Arrays; import java.util.Map; import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; +import javax.persistence.Entity; +import javax.persistence.Id; import javax.persistence.IdClass; -import javax.persistence.PostLoad; +import javax.persistence.Index; import javax.persistence.Table; -import javax.persistence.Transient; /** * A contact for a Registrar. Note, equality, hashCode and comparable have been overridden to only @@ -69,21 +56,12 @@ import javax.persistence.Transient; *

IMPORTANT NOTE: Any time that you change, update, or delete RegistrarContact entities, you * *MUST* also modify the persisted Registrar entity with {@link Registrar#contactsRequireSyncing} * set to true. - * - *

TODO(b/177567432): Rename the class name to RegistrarPoc after database migration */ @ReportedOn @Entity -@javax.persistence.Entity(name = "RegistrarPoc") -@Table( - indexes = { - @javax.persistence.Index(columnList = "gaeUserId", name = "registrarpoc_gae_user_id_idx") - }) +@Table(indexes = {@Index(columnList = "gaeUserId", name = "registrarpoc_gae_user_id_idx")}) @IdClass(RegistrarPocId.class) -@InCrossTld -public class RegistrarContact extends ImmutableObject implements Jsonifiable, UnsafeSerializable { - - @Parent @Transient Key parent; +public class RegistrarPoc extends ImmutableObject implements Jsonifiable, UnsafeSerializable { /** * Registrar contacts types for partner communication tracking. @@ -122,9 +100,9 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un String name; /** The email address of the contact. */ - @Id @javax.persistence.Id String emailAddress; + @Id String emailAddress; - @Ignore @javax.persistence.Id String registrarId; + @Id String registrarId; /** External email address of this contact used for registry lock confirmations. */ String registryLockEmailAddress; @@ -148,7 +126,7 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un * * @see com.google.appengine.api.users.User#getUserId() */ - @Index String gaeUserId; + String gaeUserId; /** * Whether this contact is publicly visible in WHOIS registrar query results as an Admin contact. @@ -168,7 +146,7 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un boolean visibleInDomainWhoisAsAbuse = false; /** - * Whether or not the contact is allowed to set their registry lock password through the registrar + * Whether the contact is allowed to set their registry lock password through the registrar * console. This will be set to false on contact creation and when the user sets a password. */ boolean allowedToSetRegistryLockPassword = false; @@ -182,16 +160,6 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un /** Randomly generated hash salt. */ String registryLockPasswordSalt; - public static ImmutableSet typesFromCSV(String csv) { - return typesFromStrings(Arrays.asList(csv.split(","))); - } - - public static ImmutableSet typesFromStrings(Iterable typeNames) { - return Streams.stream(typeNames) - .map(Enums.stringConverter(Type.class)) - .collect(toImmutableSet()); - } - /** * Helper to update the contacts associated with a Registrar. This requires querying for the * existing contacts, deleting existing contacts that are not part of the given {@code contacts} @@ -201,45 +169,23 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un * relevant Registrar entity with the {@link Registrar#contactsRequireSyncing} field set to true. */ public static void updateContacts( - final Registrar registrar, final ImmutableSet contacts) { + final Registrar registrar, final ImmutableSet contacts) { tm().transact( () -> { - if (tm().isOfy()) { - ImmutableSet> existingKeys = - ImmutableSet.copyOf( - auditedOfy() - .load() - .type(RegistrarContact.class) - .ancestor(registrar) - .keys()); - tm().delete( - difference( - existingKeys, - contacts.stream().map(Key::create).collect(toImmutableSet())) - .stream() - .map(key -> VKey.createOfy(RegistrarContact.class, key)) - .collect(toImmutableSet())); - } else { - ImmutableSet emailAddressesToKeep = - contacts.stream() - .map(RegistrarContact::getEmailAddress) - .collect(toImmutableSet()); - jpaTm() - .query( - "DELETE FROM RegistrarPoc WHERE registrarId = :registrarId AND " - + "emailAddress NOT IN :emailAddressesToKeep") - .setParameter("registrarId", registrar.getRegistrarId()) - .setParameter("emailAddressesToKeep", emailAddressesToKeep) - .executeUpdate(); - } + ImmutableSet emailAddressesToKeep = + contacts.stream().map(RegistrarPoc::getEmailAddress).collect(toImmutableSet()); + jpaTm() + .query( + "DELETE FROM RegistrarPoc WHERE registrarId = :registrarId AND " + + "emailAddress NOT IN :emailAddressesToKeep") + .setParameter("registrarId", registrar.getRegistrarId()) + .setParameter("emailAddressesToKeep", emailAddressesToKeep) + .executeUpdate(); + tm().putAll(contacts); }); } - public Key getParent() { - return parent; - } - public String getName() { return name; } @@ -371,31 +317,11 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un .build(); } - /** Sets Cloud SQL specific fields when the entity is loaded from Datastore. */ - @OnLoad - void onLoad() { - registrarId = parent.getName(); + public VKey createVKey() { + return VKey.createSql(RegistrarPoc.class, new RegistrarPocId(emailAddress, registrarId)); } - /** Sets Datastore specific fields when the entity is loaded from Cloud SQL. */ - @PostLoad - void postLoad() { - parent = Key.create(getCrossTldKey(), Registrar.class, registrarId); - } - - public VKey createVKey() { - return createVKey(Key.create(this)); - } - - /** Creates a {@link VKey} instance from a {@link Key} instance. */ - public static VKey createVKey(Key key) { - Key parent = key.getParent(); - String registrarId = parent.getName(); - String emailAddress = key.getName(); - return VKey.create(RegistrarContact.class, new RegistrarPocId(emailAddress, registrarId), key); - } - - /** Class to represent the composite primary key for {@link RegistrarContact} entity. */ + /** Class to represent the composite primary key for {@link RegistrarPoc} entity. */ @VisibleForTesting public static class RegistrarPocId extends ImmutableObject implements Serializable { @@ -404,6 +330,7 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un String registrarId; // Hibernate requires this default constructor. + @SuppressWarnings("unused") private RegistrarPocId() {} @VisibleForTesting @@ -413,27 +340,18 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un } } - /** A builder for constructing a {@link RegistrarContact}, since it is immutable. */ - public static class Builder extends Buildable.Builder { + /** A builder for constructing a {@link RegistrarPoc}, since it is immutable. */ + public static class Builder extends Buildable.Builder { public Builder() {} - private Builder(RegistrarContact instance) { + private Builder(RegistrarPoc instance) { super(instance); } - public Builder setParent(Registrar parent) { - return this.setParent(Key.create(parent)); - } - - public Builder setParent(Key parentKey) { - getInstance().parent = parentKey; - return this; - } - /** Build the registrar, nullifying empty fields. */ @Override - public RegistrarContact build() { - checkNotNull(getInstance().parent, "Registrar parent cannot be null"); + public RegistrarPoc build() { + checkNotNull(getInstance().registrarId, "Registrar ID cannot be null"); checkValidEmail(getInstance().emailAddress); // Check allowedToSetRegistryLockPassword here because if we want to allow the user to set // a registry lock password, we must also set up the correct registry lock email concurrently @@ -443,7 +361,6 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un !isNullOrEmpty(getInstance().registryLockEmailAddress), "Registry lock email must not be null if allowing registry lock access"); } - getInstance().registrarId = getInstance().parent.getName(); return cloneEmptyToNull(super.build()); } @@ -467,6 +384,16 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un return this; } + public Builder setRegistrarId(String registrarId) { + getInstance().registrarId = registrarId; + return this; + } + + public Builder setRegistrar(Registrar registrar) { + getInstance().registrarId = registrar.getRegistrarId(); + return this; + } + public Builder setFaxNumber(String faxNumber) { getInstance().faxNumber = faxNumber; return this; diff --git a/core/src/main/java/google/registry/persistence/converter/RegistrarPocSetConverter.java b/core/src/main/java/google/registry/persistence/converter/RegistrarPocSetConverter.java index d7207ec9d..4c93fc35a 100644 --- a/core/src/main/java/google/registry/persistence/converter/RegistrarPocSetConverter.java +++ b/core/src/main/java/google/registry/persistence/converter/RegistrarPocSetConverter.java @@ -14,7 +14,7 @@ package google.registry.persistence.converter; -import google.registry.model.registrar.RegistrarContact.Type; +import google.registry.model.registrar.RegistrarPoc.Type; import javax.persistence.AttributeConverter; import javax.persistence.Converter; diff --git a/core/src/main/java/google/registry/rdap/RdapJsonFormatter.java b/core/src/main/java/google/registry/rdap/RdapJsonFormatter.java index 92b4c93ea..12964eb2d 100644 --- a/core/src/main/java/google/registry/rdap/RdapJsonFormatter.java +++ b/core/src/main/java/google/registry/rdap/RdapJsonFormatter.java @@ -52,7 +52,7 @@ import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.HostResource; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarAddress; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntryDao; import google.registry.persistence.VKey; @@ -777,7 +777,7 @@ public class RdapJsonFormatter { } /** - * Creates a JSON object for a {@link RegistrarContact}. + * Creates a JSON object for a {@link RegistrarPoc}. * *

Returns empty if this contact shouldn't be visible (doesn't have a role). * @@ -794,11 +794,10 @@ public class RdapJsonFormatter { *

  • Registrar inside a Nameserver isn't required at all, and if given doesn't require any * contacts * - * @param registrarContact the registrar contact for which the JSON object should be created + * @param registrarPoc the registrar contact for which the JSON object should be created */ - static Optional makeRdapJsonForRegistrarContact( - RegistrarContact registrarContact) { - ImmutableList roles = makeRdapRoleList(registrarContact); + static Optional makeRdapJsonForRegistrarContact(RegistrarPoc registrarPoc) { + ImmutableList roles = makeRdapRoleList(registrarPoc); if (roles.isEmpty()) { return Optional.empty(); } @@ -808,20 +807,20 @@ public class RdapJsonFormatter { // Create the vCard. VcardArray.Builder vcardBuilder = VcardArray.builder(); // MUST include FN member: RDAP Response Profile 3.2 - String name = registrarContact.getName(); + String name = registrarPoc.getName(); if (name != null) { vcardBuilder.add(Vcard.create("fn", "text", name)); } // MUST include TEL and EMAIL members: RDAP Response Profile 2.4.5, 3.2 - String voicePhoneNumber = registrarContact.getPhoneNumber(); + String voicePhoneNumber = registrarPoc.getPhoneNumber(); if (voicePhoneNumber != null) { vcardBuilder.add(makePhoneEntry(PHONE_TYPE_VOICE, "tel:" + voicePhoneNumber)); } - String faxPhoneNumber = registrarContact.getFaxNumber(); + String faxPhoneNumber = registrarPoc.getFaxNumber(); if (faxPhoneNumber != null) { vcardBuilder.add(makePhoneEntry(PHONE_TYPE_FAX, "tel:" + faxPhoneNumber)); } - String emailAddress = registrarContact.getEmailAddress(); + String emailAddress = registrarPoc.getEmailAddress(); if (emailAddress != null) { vcardBuilder.add(Vcard.create("email", "text", emailAddress)); } @@ -857,16 +856,15 @@ public class RdapJsonFormatter { * *

    3.2. For direct Registrar queries, we SHOULD have at least "admin" and "tech". */ - private static ImmutableList makeRdapRoleList( - RegistrarContact registrarContact) { + private static ImmutableList makeRdapRoleList(RegistrarPoc registrarPoc) { ImmutableList.Builder rolesBuilder = new ImmutableList.Builder<>(); - if (registrarContact.getVisibleInWhoisAsAdmin()) { + if (registrarPoc.getVisibleInWhoisAsAdmin()) { rolesBuilder.add(RdapEntity.Role.ADMIN); } - if (registrarContact.getVisibleInWhoisAsTech()) { + if (registrarPoc.getVisibleInWhoisAsTech()) { rolesBuilder.add(RdapEntity.Role.TECH); } - if (registrarContact.getVisibleInDomainWhoisAsAbuse()) { + if (registrarPoc.getVisibleInDomainWhoisAsAbuse()) { rolesBuilder.add(RdapEntity.Role.ABUSE); } return rolesBuilder.build(); diff --git a/core/src/main/java/google/registry/reporting/spec11/Spec11EmailUtils.java b/core/src/main/java/google/registry/reporting/spec11/Spec11EmailUtils.java index e218ff02c..4467b83da 100644 --- a/core/src/main/java/google/registry/reporting/spec11/Spec11EmailUtils.java +++ b/core/src/main/java/google/registry/reporting/spec11/Spec11EmailUtils.java @@ -34,7 +34,7 @@ import google.registry.beam.spec11.ThreatMatch; import google.registry.config.RegistryConfig.Config; import google.registry.model.domain.DomainBase; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.reporting.spec11.soy.Spec11EmailSoyInfo; import google.registry.util.EmailMessage; import google.registry.util.SendEmailService; @@ -219,7 +219,7 @@ public class Spec11EmailUtils { return new InternetAddress( registrar .getWhoisAbuseContact() - .map(RegistrarContact::getEmailAddress) + .map(RegistrarPoc::getEmailAddress) .orElse(registrar.getEmailAddress())); } } diff --git a/core/src/main/java/google/registry/request/auth/AuthenticatedRegistrarAccessor.java b/core/src/main/java/google/registry/request/auth/AuthenticatedRegistrarAccessor.java index b5ebb46ac..782889b34 100644 --- a/core/src/main/java/google/registry/request/auth/AuthenticatedRegistrarAccessor.java +++ b/core/src/main/java/google/registry/request/auth/AuthenticatedRegistrarAccessor.java @@ -16,26 +16,21 @@ package google.registry.request.auth; import static com.google.common.base.MoreObjects.toStringHelper; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.ImmutableList.toImmutableList; -import static com.google.common.collect.Streams.stream; -import static google.registry.model.ofy.ObjectifyService.auditedOfy; import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.persistence.transaction.TransactionManagerUtil.transactIfJpaTm; import com.google.appengine.api.users.User; import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSetMultimap; import com.google.common.flogger.FluentLogger; -import com.googlecode.objectify.Key; import dagger.Lazy; import google.registry.config.RegistryConfig.Config; import google.registry.groups.GroupsConnection; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar.State; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import java.util.Optional; import javax.annotation.concurrent.Immutable; import javax.inject.Inject; @@ -43,8 +38,8 @@ import javax.inject.Inject; /** * Allows access only to {@link Registrar}s the current user has access to. * - *

    A user has OWNER role on a Registrar if there exists a {@link RegistrarContact} with that - * user's gaeId and the registrar as a parent. + *

    A user has OWNER role on a Registrar if there exists a {@link RegistrarPoc} with that user's + * gaeId and the registrar as a parent. * *

    An "admin" has in addition OWNER role on {@code #registryAdminClientId} and to all non-{@code * REAL} registrars (see {@link Registrar#getType}). @@ -54,8 +49,8 @@ import javax.inject.Inject; *

    A user is an "admin" if they are a GAE-admin, or if their email is in the "Support" G Suite * group. * - *

    NOTE: to check whether the user is in the "Support" G Suite group, we need a connection to - * G Suite. This in turn requires we have valid JsonCredentials, which not all environments have set + *

    NOTE: to check whether the user is in the "Support" G Suite group, we need a connection to G + * Suite. This in turn requires we have valid JsonCredentials, which not all environments have set * up. This connection will be created lazily (only if needed). * *

    Specifically, we don't instantiate the connection if: (a) gSuiteSupportGroupEmailAddress isn't @@ -319,34 +314,19 @@ public class AuthenticatedRegistrarAccessor { logger.atInfo().log("Checking registrar contacts for user ID %s.", user.getUserId()); // Find all registrars that have a registrar contact with this user's ID. - if (tm().isOfy()) { - ImmutableList> accessibleClientIds = - stream( - auditedOfy() - .load() - .type(RegistrarContact.class) - .filter("gaeUserId", user.getUserId())) - .map(RegistrarContact::getParent) - .collect(toImmutableList()); - // Filter out disabled registrars (note that pending registrars still allow console login). - auditedOfy().load().keys(accessibleClientIds).values().stream() - .filter(registrar -> registrar.getState() != State.DISABLED) - .forEach(registrar -> builder.put(registrar.getRegistrarId(), Role.OWNER)); - } else { - jpaTm() - .transact( - () -> - jpaTm() - .query( - "SELECT r FROM Registrar r INNER JOIN RegistrarPoc rp ON " - + "r.clientIdentifier = rp.registrarId WHERE rp.gaeUserId = " - + ":gaeUserId AND r.state != :state", - Registrar.class) - .setParameter("gaeUserId", user.getUserId()) - .setParameter("state", State.DISABLED) - .getResultStream() - .forEach(registrar -> builder.put(registrar.getRegistrarId(), Role.OWNER))); - } + jpaTm() + .transact( + () -> + jpaTm() + .query( + "SELECT r FROM Registrar r INNER JOIN RegistrarPoc rp ON " + + "r.clientIdentifier = rp.registrarId WHERE rp.gaeUserId = " + + ":gaeUserId AND r.state != :state", + Registrar.class) + .setParameter("gaeUserId", user.getUserId()) + .setParameter("state", State.DISABLED) + .getResultStream() + .forEach(registrar -> builder.put(registrar.getRegistrarId(), Role.OWNER))); // Admins have ADMIN access to all registrars, and also OWNER access to the registry registrar // and all non-REAL or non-live registrars. diff --git a/core/src/main/java/google/registry/tools/RegistrarContactCommand.java b/core/src/main/java/google/registry/tools/RegistrarPocCommand.java similarity index 89% rename from core/src/main/java/google/registry/tools/RegistrarContactCommand.java rename to core/src/main/java/google/registry/tools/RegistrarPocCommand.java index 2c1a58c1e..4e9b4ccc4 100644 --- a/core/src/main/java/google/registry/tools/RegistrarContactCommand.java +++ b/core/src/main/java/google/registry/tools/RegistrarPocCommand.java @@ -31,7 +31,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import google.registry.model.common.GaeUserIdConverter; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.tools.params.OptionalPhoneNumberParameter; import google.registry.tools.params.PathParameter; import java.io.IOException; @@ -51,7 +51,7 @@ import javax.annotation.Nullable; @Parameters( separators = " =", commandDescription = "Create/read/update/delete the various contact lists for a Registrar.") -final class RegistrarContactCommand extends MutatingCommand { +final class RegistrarPocCommand extends MutatingCommand { @Parameter( description = "Client identifier of the registrar account.", @@ -155,8 +155,7 @@ final class RegistrarContactCommand extends MutatingCommand { private static final ImmutableSet MODES_REQUIRING_CONTACT_SYNC = ImmutableSet.of(Mode.CREATE, Mode.UPDATE, Mode.DELETE); - @Nullable - private ImmutableSet contactTypes; + @Nullable private ImmutableSet contactTypes; @Override protected void init() throws Exception { @@ -179,17 +178,16 @@ final class RegistrarContactCommand extends MutatingCommand { contactTypes = ImmutableSet.of(); } else { contactTypes = - contactTypeNames - .stream() - .map(Enums.stringConverter(RegistrarContact.Type.class)) + contactTypeNames.stream() + .map(Enums.stringConverter(RegistrarPoc.Type.class)) .collect(toImmutableSet()); } - ImmutableSet contacts = registrar.getContacts(); - Map contactsMap = new LinkedHashMap<>(); - for (RegistrarContact rc : contacts) { + ImmutableSet contacts = registrar.getContacts(); + Map contactsMap = new LinkedHashMap<>(); + for (RegistrarPoc rc : contacts) { contactsMap.put(rc.getEmailAddress(), rc); } - RegistrarContact oldContact; + RegistrarPoc oldContact; switch (mode) { case LIST: listContacts(contacts); @@ -206,7 +204,7 @@ final class RegistrarContactCommand extends MutatingCommand { contactsMap.get(checkNotNull(email, "--email is required when --mode=UPDATE")), "No contact with the given email: %s", email); - RegistrarContact newContact = updateContact(oldContact, registrar); + RegistrarPoc newContact = updateContact(oldContact, registrar); checkArgument( !oldContact.getVisibleInDomainWhoisAsAbuse() || newContact.getVisibleInDomainWhoisAsAbuse(), @@ -236,19 +234,19 @@ final class RegistrarContactCommand extends MutatingCommand { } } - private void listContacts(Set contacts) throws IOException { + private void listContacts(Set contacts) throws IOException { List result = new ArrayList<>(); - for (RegistrarContact c : contacts) { + for (RegistrarPoc c : contacts) { result.add(c.toStringMultilinePlainText()); } Files.write(output, Joiner.on('\n').join(result).getBytes(UTF_8)); } - private RegistrarContact createContact(Registrar registrar) { + private RegistrarPoc createContact(Registrar registrar) { checkArgument(!isNullOrEmpty(name), "--name is required when --mode=CREATE"); checkArgument(!isNullOrEmpty(email), "--email is required when --mode=CREATE"); - RegistrarContact.Builder builder = new RegistrarContact.Builder(); - builder.setParent(registrar); + RegistrarPoc.Builder builder = new RegistrarPoc.Builder(); + builder.setRegistrar(registrar); builder.setName(name); builder.setEmailAddress(email); if (!isNullOrEmpty(registryLockEmail)) { @@ -282,11 +280,11 @@ final class RegistrarContactCommand extends MutatingCommand { return builder.build(); } - private RegistrarContact updateContact(RegistrarContact contact, Registrar registrar) { + private RegistrarPoc updateContact(RegistrarPoc contact, Registrar registrar) { checkNotNull(registrar); checkArgument(!isNullOrEmpty(email), "--email is required when --mode=UPDATE"); - RegistrarContact.Builder builder = - contact.asBuilder().setEmailAddress(email).setParent(registrar); + RegistrarPoc.Builder builder = + contact.asBuilder().setEmailAddress(email).setRegistrar(registrar); if (!isNullOrEmpty(name)) { builder.setName(name); } @@ -327,12 +325,11 @@ final class RegistrarContactCommand extends MutatingCommand { } private void unsetOtherWhoisAbuseFlags( - ImmutableSet contacts, @Nullable String emailAddressNotToChange) { - for (RegistrarContact contact : contacts) { + ImmutableSet contacts, @Nullable String emailAddressNotToChange) { + for (RegistrarPoc contact : contacts) { if (!contact.getEmailAddress().equals(emailAddressNotToChange) && contact.getVisibleInDomainWhoisAsAbuse()) { - RegistrarContact newContact = - contact.asBuilder().setVisibleInDomainWhoisAsAbuse(false).build(); + RegistrarPoc newContact = contact.asBuilder().setVisibleInDomainWhoisAsAbuse(false).build(); stageEntityChange(contact, newContact); } } diff --git a/core/src/main/java/google/registry/tools/RegistryTool.java b/core/src/main/java/google/registry/tools/RegistryTool.java index 3f708420f..3d3bba0d3 100644 --- a/core/src/main/java/google/registry/tools/RegistryTool.java +++ b/core/src/main/java/google/registry/tools/RegistryTool.java @@ -97,7 +97,7 @@ public final class RegistryTool { .put("login", LoginCommand.class) .put("logout", LogoutCommand.class) .put("pending_escrow", PendingEscrowCommand.class) - .put("registrar_contact", RegistrarContactCommand.class) + .put("registrar_poc", RegistrarPocCommand.class) .put("renew_domain", RenewDomainCommand.class) .put("resave_environment_entities", ResaveEnvironmentEntitiesCommand.class) .put("save_sql_credential", SaveSqlCredentialCommand.class) diff --git a/core/src/main/java/google/registry/tools/ResaveEnvironmentEntitiesCommand.java b/core/src/main/java/google/registry/tools/ResaveEnvironmentEntitiesCommand.java index 9363b9d41..0d5a08f0c 100644 --- a/core/src/main/java/google/registry/tools/ResaveEnvironmentEntitiesCommand.java +++ b/core/src/main/java/google/registry/tools/ResaveEnvironmentEntitiesCommand.java @@ -23,14 +23,14 @@ import com.beust.jcommander.Parameters; import com.googlecode.objectify.Key; import google.registry.model.annotations.DeleteAfterMigration; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.model.tld.Registry; /** * Command to re-save all environment entities to ensure that they have valid commit logs. * *

    The entities that are re-saved are those of type {@link Registry}, {@link Registrar}, and - * {@link RegistrarContact}. + * {@link RegistrarPoc}. */ @Parameters(commandDescription = "Re-save all environment entities.") @DeleteAfterMigration @@ -42,7 +42,7 @@ final class ResaveEnvironmentEntitiesCommand implements CommandWithRemoteApi { public void run() { batchSave(Registry.class); batchSave(Registrar.class); - batchSave(RegistrarContact.class); + batchSave(RegistrarPoc.class); } private static void batchSave(Class clazz) { diff --git a/core/src/main/java/google/registry/tools/server/CreateGroupsAction.java b/core/src/main/java/google/registry/tools/server/CreateGroupsAction.java index 5abb7e9cc..70a953dfd 100644 --- a/core/src/main/java/google/registry/tools/server/CreateGroupsAction.java +++ b/core/src/main/java/google/registry/tools/server/CreateGroupsAction.java @@ -24,7 +24,7 @@ import google.registry.config.RegistryConfig.Config; import google.registry.groups.GroupsConnection; import google.registry.groups.GroupsConnection.Role; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.request.Action; import google.registry.request.HttpException.BadRequestException; import google.registry.request.HttpException.InternalServerErrorException; @@ -64,7 +64,7 @@ public class CreateGroupsAction implements Runnable { if (registrar == null) { return; } - List types = asList(RegistrarContact.Type.values()); + List types = asList(RegistrarPoc.Type.values()); // Concurrently create the groups for each RegistrarContact.Type, collecting the results from // each call (which are either an Exception if it failed, or absent() if it succeeded). List> results = diff --git a/core/src/main/java/google/registry/ui/server/RegistrarFormFields.java b/core/src/main/java/google/registry/ui/server/RegistrarFormFields.java index c80a18609..052e8de42 100644 --- a/core/src/main/java/google/registry/ui/server/RegistrarFormFields.java +++ b/core/src/main/java/google/registry/ui/server/RegistrarFormFields.java @@ -28,7 +28,7 @@ import com.google.common.net.InternetDomainName; import com.google.re2j.Pattern; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarAddress; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.ui.forms.FormException; import google.registry.ui.forms.FormField; import google.registry.ui.forms.FormFieldException; @@ -217,10 +217,10 @@ public final class RegistrarFormFields { public static final FormField CONTACT_REGISTRY_LOCK_PASSWORD_FIELD = FormFields.NAME.asBuilderNamed("registryLockPassword").build(); - public static final FormField> CONTACT_TYPES = + public static final FormField> CONTACT_TYPES = FormField.named("types") .uppercased() - .asEnum(RegistrarContact.Type.class) + .asEnum(RegistrarPoc.Type.class) .asSet(Splitter.on(',').omitEmptyStrings().trimResults()) .build(); @@ -348,8 +348,8 @@ public final class RegistrarFormFields { } } - public static ImmutableList getRegistrarContactBuilders( - ImmutableSet existingContacts, @Nullable Map args) { + public static ImmutableList getRegistrarContactBuilders( + ImmutableSet existingContacts, @Nullable Map args) { if (args == null) { return ImmutableList.of(); } @@ -357,7 +357,7 @@ public final class RegistrarFormFields { if (!contactsAsMaps.isPresent()) { return ImmutableList.of(); } - ImmutableList.Builder result = new ImmutableList.Builder<>(); + ImmutableList.Builder result = new ImmutableList.Builder<>(); for (Map contactAsMap : contactsAsMaps.get()) { String emailAddress = CONTACT_EMAIL_ADDRESS_FIELD @@ -365,20 +365,19 @@ public final class RegistrarFormFields { .orElseThrow( () -> new IllegalArgumentException("Contacts from UI must have email addresses")); // Start with a new builder if the contact didn't previously exist - RegistrarContact.Builder contactBuilder = + RegistrarPoc.Builder contactBuilder = existingContacts.stream() .filter(rc -> rc.getEmailAddress().equals(emailAddress)) .findFirst() - .map(RegistrarContact::asBuilder) - .orElse(new RegistrarContact.Builder()); + .map(RegistrarPoc::asBuilder) + .orElse(new RegistrarPoc.Builder()); applyRegistrarContactArgs(contactBuilder, contactAsMap); result.add(contactBuilder); } return result.build(); } - private static void applyRegistrarContactArgs( - RegistrarContact.Builder builder, Map args) { + private static void applyRegistrarContactArgs(RegistrarPoc.Builder builder, Map args) { builder.setName(CONTACT_NAME_FIELD.extractUntyped(args).orElse(null)); builder.setEmailAddress(CONTACT_EMAIL_ADDRESS_FIELD.extractUntyped(args).orElse(null)); builder.setRegistryLockEmailAddress( diff --git a/core/src/main/java/google/registry/ui/server/registrar/ConsoleRegistrarCreatorAction.java b/core/src/main/java/google/registry/ui/server/registrar/ConsoleRegistrarCreatorAction.java index 37b8a3d37..8075f0d7d 100644 --- a/core/src/main/java/google/registry/ui/server/registrar/ConsoleRegistrarCreatorAction.java +++ b/core/src/main/java/google/registry/ui/server/registrar/ConsoleRegistrarCreatorAction.java @@ -32,7 +32,7 @@ import com.google.template.soy.tofu.SoyTofu; import google.registry.config.RegistryEnvironment; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarAddress; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.request.Action; import google.registry.request.Action.Method; import google.registry.request.Parameter; @@ -227,9 +227,9 @@ public final class ConsoleRegistrarCreatorAction extends HtmlAction { .setZip(optionalZip.orElse(null)) .build()) .build(); - RegistrarContact contact = - new RegistrarContact.Builder() - .setParent(registrar) + RegistrarPoc contact = + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName(consoleUserEmail.get()) .setEmailAddress(consoleUserEmail.get()) .setGaeUserId(gaeUserId) diff --git a/core/src/main/java/google/registry/ui/server/registrar/RegistrarSettingsAction.java b/core/src/main/java/google/registry/ui/server/registrar/RegistrarSettingsAction.java index 38f1121a5..3fa89a396 100644 --- a/core/src/main/java/google/registry/ui/server/registrar/RegistrarSettingsAction.java +++ b/core/src/main/java/google/registry/ui/server/registrar/RegistrarSettingsAction.java @@ -42,8 +42,8 @@ import google.registry.export.sheet.SyncRegistrarsSheetAction; import google.registry.flows.certs.CertificateChecker; import google.registry.flows.certs.CertificateChecker.InsecureCertificateException; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; -import google.registry.model.registrar.RegistrarContact.Type; +import google.registry.model.registrar.RegistrarPoc; +import google.registry.model.registrar.RegistrarPoc.Type; import google.registry.request.Action; import google.registry.request.Action.Service; import google.registry.request.HttpException.BadRequestException; @@ -116,7 +116,7 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA @Inject RegistrarSettingsAction() {} - private static boolean hasPhone(RegistrarContact contact) { + private static boolean hasPhone(RegistrarPoc contact) { return contact.getPhoneNumber() != null; } @@ -202,15 +202,15 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA abstract Registrar updatedRegistrar(); - abstract ImmutableSet contacts(); + abstract ImmutableSet contacts(); - abstract ImmutableSet updatedContacts(); + abstract ImmutableSet updatedContacts(); static EmailInfo create( Registrar registrar, Registrar updatedRegistrar, - ImmutableSet contacts, - ImmutableSet updatedContacts) { + ImmutableSet contacts, + ImmutableSet updatedContacts) { return new AutoValue_RegistrarSettingsAction_EmailInfo( registrar, updatedRegistrar, contacts, updatedContacts); } @@ -264,7 +264,7 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA // Keep the current contacts so we can later check that no required contact was // removed, email the changes to the contacts - ImmutableSet contacts = registrar.getContacts(); + ImmutableSet contacts = registrar.getContacts(); Registrar updatedRegistrar = registrar; // Do OWNER only updates to the registrar from the request. @@ -273,7 +273,7 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA updatedRegistrar = checkAndUpdateAdminControlledFields(updatedRegistrar, args); // read the contacts from the request. - ImmutableSet updatedContacts = readContacts(registrar, contacts, args); + ImmutableSet updatedContacts = readContacts(registrar, contacts, args); // Save the updated contacts if (!updatedContacts.equals(contacts)) { @@ -281,7 +281,7 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA throw new ForbiddenException("Only OWNERs can update the contacts"); } checkContactRequirements(contacts, updatedContacts); - RegistrarContact.updateContacts(updatedRegistrar, updatedContacts); + RegistrarPoc.updateContacts(updatedRegistrar, updatedContacts); updatedRegistrar = updatedRegistrar.asBuilder().setContactsRequireSyncing(true).build(); } @@ -293,10 +293,10 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA } private Map expandRegistrarWithContacts( - Iterable contacts, Registrar registrar) { + Iterable contacts, Registrar registrar) { ImmutableSet> expandedContacts = Streams.stream(contacts) - .map(RegistrarContact::toDiffableFieldMap) + .map(RegistrarPoc::toDiffableFieldMap) // Note: per the javadoc, toDiffableFieldMap includes sensitive data but we don't want // to display it here .peek( @@ -463,10 +463,10 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA } /** Reads the contacts from the supplied args. */ - public static ImmutableSet readContacts( - Registrar registrar, ImmutableSet existingContacts, Map args) { + public static ImmutableSet readContacts( + Registrar registrar, ImmutableSet existingContacts, Map args) { return RegistrarFormFields.getRegistrarContactBuilders(existingContacts, args).stream() - .map(builder -> builder.setParent(registrar).build()) + .map(builder -> builder.setRegistrar(registrar).build()) .collect(toImmutableSet()); } @@ -476,11 +476,10 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA * @throws FormException if the checks fail. */ void checkContactRequirements( - ImmutableSet existingContacts, - ImmutableSet updatedContacts) { + ImmutableSet existingContacts, ImmutableSet updatedContacts) { // Check that no two contacts use the same email address. Set emails = new HashSet<>(); - for (RegistrarContact contact : updatedContacts) { + for (RegistrarPoc contact : updatedContacts) { if (!emails.add(contact.getEmailAddress())) { throw new ContactRequirementException( String.format( @@ -489,14 +488,14 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA } } // Check that required contacts don't go away, once they are set. - Multimap oldContactsByType = HashMultimap.create(); - for (RegistrarContact contact : existingContacts) { + Multimap oldContactsByType = HashMultimap.create(); + for (RegistrarPoc contact : existingContacts) { for (Type t : contact.getTypes()) { oldContactsByType.put(t, contact); } } - Multimap newContactsByType = HashMultimap.create(); - for (RegistrarContact contact : updatedContacts) { + Multimap newContactsByType = HashMultimap.create(); + for (RegistrarPoc contact : updatedContacts) { for (Type t : contact.getTypes()) { newContactsByType.put(t, contact); } @@ -507,7 +506,7 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA } } ensurePhoneNumberNotRemovedForContactTypes(oldContactsByType, newContactsByType, Type.TECH); - Optional domainWhoisAbuseContact = + Optional domainWhoisAbuseContact = getDomainWhoisVisibleAbuseContact(updatedContacts); // If the new set has a domain WHOIS abuse contact, it must have a phone number. if (domainWhoisAbuseContact.isPresent() @@ -525,13 +524,12 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA } private static void checkContactRegistryLockRequirements( - ImmutableSet existingContacts, - ImmutableSet updatedContacts) { + ImmutableSet existingContacts, ImmutableSet updatedContacts) { // Any contact(s) with new passwords must be allowed to set them - for (RegistrarContact updatedContact : updatedContacts) { + for (RegistrarPoc updatedContact : updatedContacts) { if (updatedContact.isRegistryLockAllowed() || updatedContact.isAllowedToSetRegistryLockPassword()) { - RegistrarContact existingContact = + RegistrarPoc existingContact = existingContacts.stream() .filter( contact -> contact.getEmailAddress().equals(updatedContact.getEmailAddress())) @@ -564,10 +562,10 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA // Any previously-existing contacts with registry lock enabled cannot be deleted existingContacts.stream() - .filter(RegistrarContact::isRegistryLockAllowed) + .filter(RegistrarPoc::isRegistryLockAllowed) .forEach( contact -> { - Optional updatedContactOptional = + Optional updatedContactOptional = updatedContacts.stream() .filter( updatedContact -> @@ -593,8 +591,8 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA * one before. */ private static void ensurePhoneNumberNotRemovedForContactTypes( - Multimap oldContactsByType, - Multimap newContactsByType, + Multimap oldContactsByType, + Multimap newContactsByType, Type... types) { for (Type type : types) { if (oldContactsByType.get(type).stream().anyMatch(RegistrarSettingsAction::hasPhone) @@ -615,9 +613,9 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA * WHOIS record. Therefore it is possible to return inside the loop once one such contact is * found. */ - private static Optional getDomainWhoisVisibleAbuseContact( - Set contacts) { - return contacts.stream().filter(RegistrarContact::getVisibleInDomainWhoisAsAbuse).findFirst(); + private static Optional getDomainWhoisVisibleAbuseContact( + Set contacts) { + return contacts.stream().filter(RegistrarPoc::getVisibleInDomainWhoisAsAbuse).findFirst(); } /** @@ -626,7 +624,7 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA * contact addresses and enqueues a task to re-sync the registrar sheet. */ private void sendExternalUpdatesIfNecessary(EmailInfo emailInfo) { - ImmutableSet existingContacts = emailInfo.contacts(); + ImmutableSet existingContacts = emailInfo.contacts(); if (!sendEmailUtils.hasRecipients() && existingContacts.isEmpty()) { return; } @@ -663,7 +661,7 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA DiffUtils.prettyPrintDiffedMap(diffs, null)), existingContacts.stream() .filter(c -> c.getTypes().contains(Type.ADMIN)) - .map(RegistrarContact::getEmailAddress) + .map(RegistrarPoc::getEmailAddress) .collect(toImmutableList())); } diff --git a/core/src/main/java/google/registry/ui/server/registrar/RegistryLockGetAction.java b/core/src/main/java/google/registry/ui/server/registrar/RegistryLockGetAction.java index eccf1e427..09f7c3154 100644 --- a/core/src/main/java/google/registry/ui/server/registrar/RegistryLockGetAction.java +++ b/core/src/main/java/google/registry/ui/server/registrar/RegistryLockGetAction.java @@ -31,7 +31,7 @@ import com.google.common.net.MediaType; import com.google.gson.Gson; import google.registry.model.domain.RegistryLock; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.model.tld.RegistryLockDao; import google.registry.request.Action; import google.registry.request.Action.Method; @@ -118,17 +118,15 @@ public final class RegistryLockGetAction implements JsonGetAction { } } - static Optional getContactMatchingLogin(User user, Registrar registrar) { - ImmutableList matchingContacts = + static Optional getContactMatchingLogin(User user, Registrar registrar) { + ImmutableList matchingContacts = registrar.getContacts().stream() .filter(contact -> contact.getGaeUserId() != null) .filter(contact -> Objects.equals(contact.getGaeUserId(), user.getUserId())) .collect(toImmutableList()); if (matchingContacts.size() > 1) { ImmutableList matchingEmails = - matchingContacts.stream() - .map(RegistrarContact::getEmailAddress) - .collect(toImmutableList()); + matchingContacts.stream().map(RegistrarPoc::getEmailAddress).collect(toImmutableList()); throw new IllegalArgumentException( String.format( "User ID %s had multiple matching contacts with email addresses %s", @@ -157,15 +155,15 @@ public final class RegistryLockGetAction implements JsonGetAction { Registrar registrar = getRegistrarAndVerifyLockAccess(registrarAccessor, registrarId, isAdmin); User user = authResult.userAuthInfo().get().user(); - Optional contactOptional = getContactMatchingLogin(user, registrar); + Optional contactOptional = getContactMatchingLogin(user, registrar); boolean isRegistryLockAllowed = - isAdmin || contactOptional.map(RegistrarContact::isRegistryLockAllowed).orElse(false); + isAdmin || contactOptional.map(RegistrarPoc::isRegistryLockAllowed).orElse(false); // Use the contact's registry lock email if it's present, else use the login email (for admins) String relevantEmail = isAdmin ? user.getEmail() // if the contact isn't present, we shouldn't display the email anyway so empty is fine - : contactOptional.flatMap(RegistrarContact::getRegistryLockEmailAddress).orElse(""); + : contactOptional.flatMap(RegistrarPoc::getRegistryLockEmailAddress).orElse(""); return ImmutableMap.of( LOCK_ENABLED_FOR_CONTACT_PARAM, isRegistryLockAllowed, diff --git a/core/src/main/java/google/registry/ui/server/registrar/RegistryLockPostAction.java b/core/src/main/java/google/registry/ui/server/registrar/RegistryLockPostAction.java index bbbc1a85d..144340938 100644 --- a/core/src/main/java/google/registry/ui/server/registrar/RegistryLockPostAction.java +++ b/core/src/main/java/google/registry/ui/server/registrar/RegistryLockPostAction.java @@ -33,7 +33,7 @@ import google.registry.config.RegistryConfig.Config; import google.registry.flows.domain.DomainFlowUtils; import google.registry.model.domain.RegistryLock; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.request.Action; import google.registry.request.Action.Method; import google.registry.request.HttpException.ForbiddenException; @@ -192,7 +192,7 @@ public class RegistryLockPostAction implements Runnable, JsonActionRunner.JsonAc // registry lock enabled, and that the user provided a correct password Registrar registrar = getRegistrarAndVerifyLockAccess(registrarAccessor, postInput.registrarId, false); - RegistrarContact registrarContact = + RegistrarPoc registrarPoc = getContactMatchingLogin(user, registrar) .orElseThrow( () -> @@ -200,16 +200,16 @@ public class RegistryLockPostAction implements Runnable, JsonActionRunner.JsonAc String.format( "Cannot match user %s to registrar contact", user.getUserId()))); checkArgument( - registrarContact.verifyRegistryLockPassword(postInput.password), + registrarPoc.verifyRegistryLockPassword(postInput.password), "Incorrect registry lock password for contact"); - return registrarContact + return registrarPoc .getRegistryLockEmailAddress() .orElseThrow( () -> new IllegalStateException( String.format( "Contact %s had no registry lock email address", - registrarContact.getEmailAddress()))); + registrarPoc.getEmailAddress()))); } /** Value class that represents the expected input body from the UI request. */ diff --git a/core/src/main/java/google/registry/whois/DomainWhoisResponse.java b/core/src/main/java/google/registry/whois/DomainWhoisResponse.java index 03a0fc6e1..63f566cc2 100644 --- a/core/src/main/java/google/registry/whois/DomainWhoisResponse.java +++ b/core/src/main/java/google/registry/whois/DomainWhoisResponse.java @@ -32,7 +32,7 @@ import google.registry.model.domain.DomainBase; import google.registry.model.domain.GracePeriod; import google.registry.model.eppcommon.StatusValue; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.model.translators.EnumToAttributeAdapter.EppEnum; import google.registry.persistence.VKey; import java.util.Objects; @@ -80,11 +80,9 @@ final class DomainWhoisResponse extends WhoisResponseImpl { "Could not load registrar %s", domain.getCurrentSponsorRegistrarId()); Registrar registrar = registrarOptional.get(); - Optional abuseContact = - registrar - .getContacts() - .stream() - .filter(RegistrarContact::getVisibleInDomainWhoisAsAbuse) + Optional abuseContact = + registrar.getContacts().stream() + .filter(RegistrarPoc::getVisibleInDomainWhoisAsAbuse) .findFirst(); return WhoisResponseResults.create( new DomainEmitter() @@ -102,10 +100,10 @@ final class DomainWhoisResponse extends WhoisResponseImpl { // is an abuse contact, we can get an email address from it. .emitField( "Registrar Abuse Contact Email", - abuseContact.map(RegistrarContact::getEmailAddress).orElse("")) + abuseContact.map(RegistrarPoc::getEmailAddress).orElse("")) .emitField( "Registrar Abuse Contact Phone", - abuseContact.map(RegistrarContact::getPhoneNumber).orElse("")) + abuseContact.map(RegistrarPoc::getPhoneNumber).orElse("")) .emitStatusValues(domain.getStatusValues(), domain.getGracePeriods()) .emitContact("Registrant", Optional.of(domain.getRegistrant()), preferUnicode) .emitContact("Admin", getContactReference(Type.ADMIN), preferUnicode) diff --git a/core/src/main/java/google/registry/whois/RegistrarWhoisResponse.java b/core/src/main/java/google/registry/whois/RegistrarWhoisResponse.java index 47ca4b40b..9983348c3 100644 --- a/core/src/main/java/google/registry/whois/RegistrarWhoisResponse.java +++ b/core/src/main/java/google/registry/whois/RegistrarWhoisResponse.java @@ -17,7 +17,7 @@ package google.registry.whois; import static com.google.common.base.Preconditions.checkNotNull; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import java.util.Set; import javax.annotation.Nullable; import org.joda.time.DateTime; @@ -44,7 +44,7 @@ class RegistrarWhoisResponse extends WhoisResponseImpl { @Override public WhoisResponseResults getResponse(boolean preferUnicode, String disclaimer) { - Set contacts = registrar.getContacts(); + Set contacts = registrar.getContacts(); String plaintext = new RegistrarEmitter() .emitField("Registrar", registrar.getRegistrarName()) @@ -59,8 +59,8 @@ class RegistrarWhoisResponse extends WhoisResponseImpl { registrar.getPhoneNumber(), registrar.getFaxNumber(), registrar.getEmailAddress()) .emitField("Registrar WHOIS Server", registrar.getWhoisServer()) .emitField("Registrar URL", registrar.getUrl()) - .emitRegistrarContacts("Admin", contacts, AdminOrTech.ADMIN) - .emitRegistrarContacts("Technical", contacts, AdminOrTech.TECH) + .emitRegistrarPocs("Admin", contacts, AdminOrTech.ADMIN) + .emitRegistrarPocs("Technical", contacts, AdminOrTech.TECH) .emitLastUpdated(getTimestamp()) .emitFooter(disclaimer) .toString(); @@ -70,11 +70,9 @@ class RegistrarWhoisResponse extends WhoisResponseImpl { /** An emitter with logic for registrars. */ static class RegistrarEmitter extends Emitter { /** Emits the registrar contact of the given type. */ - RegistrarEmitter emitRegistrarContacts( - String contactLabel, - Iterable contacts, - AdminOrTech type) { - for (RegistrarContact contact : contacts) { + RegistrarEmitter emitRegistrarPocs( + String contactLabel, Iterable contacts, AdminOrTech type) { + for (RegistrarPoc contact : contacts) { if ((type == AdminOrTech.ADMIN && contact.getVisibleInWhoisAsAdmin()) || (type == AdminOrTech.TECH && contact.getVisibleInWhoisAsTech())) { emitField(contactLabel + " Contact", contact.getName()) diff --git a/core/src/main/resources/META-INF/persistence.xml b/core/src/main/resources/META-INF/persistence.xml index 8bdc87cec..fe10bd245 100644 --- a/core/src/main/resources/META-INF/persistence.xml +++ b/core/src/main/resources/META-INF/persistence.xml @@ -59,7 +59,7 @@ google.registry.model.poll.PollMessage$Autorenew google.registry.model.rde.RdeRevision google.registry.model.registrar.Registrar - google.registry.model.registrar.RegistrarContact + google.registry.model.registrar.RegistrarPoc google.registry.model.tld.label.PremiumList google.registry.model.tld.label.PremiumList$PremiumEntry google.registry.model.tld.label.ReservedList diff --git a/core/src/test/java/google/registry/batch/SendExpiringCertificateNotificationEmailActionTest.java b/core/src/test/java/google/registry/batch/SendExpiringCertificateNotificationEmailActionTest.java index 2eab9b7ce..427737b48 100644 --- a/core/src/test/java/google/registry/batch/SendExpiringCertificateNotificationEmailActionTest.java +++ b/core/src/test/java/google/registry/batch/SendExpiringCertificateNotificationEmailActionTest.java @@ -35,8 +35,8 @@ import google.registry.batch.SendExpiringCertificateNotificationEmailAction.Regi import google.registry.flows.certs.CertificateChecker; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarAddress; -import google.registry.model.registrar.RegistrarContact; -import google.registry.model.registrar.RegistrarContact.Type; +import google.registry.model.registrar.RegistrarPoc; +import google.registry.model.registrar.RegistrarPoc.Type; import google.registry.testing.AppEngineExtension; import google.registry.testing.DualDatabaseTest; import google.registry.testing.FakeClock; @@ -220,15 +220,15 @@ class SendExpiringCertificateNotificationEmailActionTest { .asBuilder() .setFailoverClientCertificate(cert.get(), clock.nowUtc()) .build()); - ImmutableList contacts = + ImmutableList contacts = ImmutableList.of( - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("Will Doe") .setEmailAddress("will@example-registrar.tld") .setPhoneNumber("+1.3105551213") .setFaxNumber("+1.3105551213") - .setTypes(ImmutableSet.of(RegistrarContact.Type.TECH)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.TECH)) .setVisibleInWhoisAsAdmin(true) .setVisibleInWhoisAsTech(false) .build()); @@ -510,51 +510,51 @@ class SendExpiringCertificateNotificationEmailActionTest { @TestOfyAndSql void getEmailAddresses_success_returnsAListOfEmails() throws Exception { Registrar registrar = persistResource(makeRegistrar1()); - ImmutableList contacts = + ImmutableList contacts = ImmutableList.of( - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("John Doe") .setEmailAddress("jd@example-registrar.tld") .setPhoneNumber("+1.3105551213") .setFaxNumber("+1.3105551213") - .setTypes(ImmutableSet.of(RegistrarContact.Type.TECH)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.TECH)) .setVisibleInWhoisAsAdmin(true) .setVisibleInWhoisAsTech(false) .build(), - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("John Smith") .setEmailAddress("js@example-registrar.tld") .setPhoneNumber("+1.1111111111") .setFaxNumber("+1.1111111111") - .setTypes(ImmutableSet.of(RegistrarContact.Type.TECH)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.TECH)) .build(), - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("Will Doe") .setEmailAddress("will@example-registrar.tld") .setPhoneNumber("+1.3105551213") .setFaxNumber("+1.3105551213") - .setTypes(ImmutableSet.of(RegistrarContact.Type.TECH)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.TECH)) .setVisibleInWhoisAsAdmin(true) .setVisibleInWhoisAsTech(false) .build(), - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("Mike Doe") .setEmailAddress("mike@example-registrar.tld") .setPhoneNumber("+1.1111111111") .setFaxNumber("+1.1111111111") - .setTypes(ImmutableSet.of(RegistrarContact.Type.ADMIN)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.ADMIN)) .build(), - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("John T") .setEmailAddress("john@example-registrar.tld") .setPhoneNumber("+1.3105551215") .setFaxNumber("+1.3105551216") - .setTypes(ImmutableSet.of(RegistrarContact.Type.ADMIN)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.ADMIN)) .setVisibleInWhoisAsTech(true) .build()); persistSimpleResources(contacts); @@ -710,20 +710,20 @@ class SendExpiringCertificateNotificationEmailActionTest { } /** Returns persisted sample contacts with a customized contact email type. */ - private ImmutableList persistSampleContacts( - Registrar registrar, RegistrarContact.Type emailType) { + private ImmutableList persistSampleContacts( + Registrar registrar, RegistrarPoc.Type emailType) { return persistSimpleResources( ImmutableList.of( - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("Will Doe") .setEmailAddress("will@example-registrar.tld") .setPhoneNumber("+1.0105551213") .setFaxNumber("+1.0105551213") .setTypes(ImmutableSet.of(emailType)) .build(), - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("Will Smith") .setEmailAddress("will@test-registrar.tld") .setPhoneNumber("+1.3105551213") diff --git a/core/src/test/java/google/registry/export/SyncGroupMembersActionTest.java b/core/src/test/java/google/registry/export/SyncGroupMembersActionTest.java index 29bfe38fb..2e62b7016 100644 --- a/core/src/test/java/google/registry/export/SyncGroupMembersActionTest.java +++ b/core/src/test/java/google/registry/export/SyncGroupMembersActionTest.java @@ -16,9 +16,9 @@ package google.registry.export; import static com.google.common.truth.Truth.assertThat; import static google.registry.export.SyncGroupMembersAction.getGroupEmailAddressForContactType; -import static google.registry.model.registrar.RegistrarContact.Type.ADMIN; -import static google.registry.model.registrar.RegistrarContact.Type.MARKETING; -import static google.registry.model.registrar.RegistrarContact.Type.TECH; +import static google.registry.model.registrar.RegistrarPoc.Type.ADMIN; +import static google.registry.model.registrar.RegistrarPoc.Type.MARKETING; +import static google.registry.model.registrar.RegistrarPoc.Type.TECH; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.testing.DatabaseHelper.loadRegistrar; import static google.registry.testing.DatabaseHelper.persistResource; @@ -37,7 +37,7 @@ import com.google.common.collect.Iterables; import google.registry.groups.DirectoryGroupsConnection; import google.registry.groups.GroupsConnection.Role; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.request.Response; import google.registry.testing.AppEngineExtension; import google.registry.testing.DualDatabaseTest; @@ -78,10 +78,9 @@ public class SyncGroupMembersActionTest { @TestOfyAndSql void test_getGroupEmailAddressForContactType_convertsToLowercase() { - assertThat(getGroupEmailAddressForContactType( - "SomeRegistrar", - RegistrarContact.Type.ADMIN, - "domain-registry.example")) + assertThat( + getGroupEmailAddressForContactType( + "SomeRegistrar", RegistrarPoc.Type.ADMIN, "domain-registry.example")) .isEqualTo("someregistrar-primary-contacts@domain-registry.example"); } @@ -156,15 +155,15 @@ public class SyncGroupMembersActionTest { when(connection.getMembersOfGroup("theregistrar-primary-contacts@domain-registry.example")) .thenReturn(ImmutableSet.of()); persistResource( - new RegistrarContact.Builder() - .setParent(loadRegistrar("NewRegistrar")) + new RegistrarPoc.Builder() + .setRegistrar(loadRegistrar("NewRegistrar")) .setName("Binary Star") .setEmailAddress("binarystar@example.tld") .setTypes(ImmutableSet.of(ADMIN, MARKETING)) .build()); persistResource( - new RegistrarContact.Builder() - .setParent(loadRegistrar("TheRegistrar")) + new RegistrarPoc.Builder() + .setRegistrar(loadRegistrar("TheRegistrar")) .setName("Hexadecimal") .setEmailAddress("hexadecimal@snow.fall") .setTypes(ImmutableSet.of(TECH)) diff --git a/core/src/test/java/google/registry/export/sheet/SyncRegistrarsSheetTest.java b/core/src/test/java/google/registry/export/sheet/SyncRegistrarsSheetTest.java index b228684e7..ab2fe6425 100644 --- a/core/src/test/java/google/registry/export/sheet/SyncRegistrarsSheetTest.java +++ b/core/src/test/java/google/registry/export/sheet/SyncRegistrarsSheetTest.java @@ -38,7 +38,7 @@ import google.registry.model.common.Cursor; import google.registry.model.ofy.Ofy; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarAddress; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.testing.AppEngineExtension; import google.registry.testing.DatabaseHelper; import google.registry.testing.DualDatabaseTest; @@ -85,7 +85,7 @@ public class SyncRegistrarsSheetTest { // We don't do this for ofy because ofy's loadAllOf() can't be called in a transaction but // _must_ be called in a transaction in JPA. if (!tm().isOfy()) { - tm().transact(() -> tm().loadAllOf(RegistrarContact.class)) + tm().transact(() -> tm().loadAllOf(RegistrarPoc.class)) .forEach(DatabaseHelper::deleteResource); } Registrar.loadAll().forEach(DatabaseHelper::deleteResource); @@ -161,33 +161,34 @@ public class SyncRegistrarsSheetTest { .setUrl("http://www.example.org/aaa_registrar") .setBillingAccountMap(ImmutableMap.of(USD, "USD1234", JPY, "JPY7890")) .build(); - ImmutableList contacts = ImmutableList.of( - new RegistrarContact.Builder() - .setParent(registrar) - .setName("Jane Doe") - .setEmailAddress("contact@example.com") - .setPhoneNumber("+1.1234567890") - .setTypes(ImmutableSet.of(RegistrarContact.Type.ADMIN, RegistrarContact.Type.BILLING)) - .build(), - new RegistrarContact.Builder() - .setParent(registrar) - .setName("John Doe") - .setEmailAddress("john.doe@example.tld") - .setPhoneNumber("+1.1234567890") - .setFaxNumber("+1.1234567891") - .setTypes(ImmutableSet.of(RegistrarContact.Type.ADMIN)) - // Purposely flip the internal/external admin/tech - // distinction to make sure we're not relying on it. Sigh. - .setVisibleInWhoisAsAdmin(false) - .setVisibleInWhoisAsTech(true) - .setGaeUserId("light") - .build(), - new RegistrarContact.Builder() - .setParent(registrar) - .setName("Jane Smith") - .setEmailAddress("pride@example.net") - .setTypes(ImmutableSet.of(RegistrarContact.Type.TECH)) - .build()); + ImmutableList contacts = + ImmutableList.of( + new RegistrarPoc.Builder() + .setRegistrar(registrar) + .setName("Jane Doe") + .setEmailAddress("contact@example.com") + .setPhoneNumber("+1.1234567890") + .setTypes(ImmutableSet.of(RegistrarPoc.Type.ADMIN, RegistrarPoc.Type.BILLING)) + .build(), + new RegistrarPoc.Builder() + .setRegistrar(registrar) + .setName("John Doe") + .setEmailAddress("john.doe@example.tld") + .setPhoneNumber("+1.1234567890") + .setFaxNumber("+1.1234567891") + .setTypes(ImmutableSet.of(RegistrarPoc.Type.ADMIN)) + // Purposely flip the internal/external admin/tech + // distinction to make sure we're not relying on it. Sigh. + .setVisibleInWhoisAsAdmin(false) + .setVisibleInWhoisAsTech(true) + .setGaeUserId("light") + .build(), + new RegistrarPoc.Builder() + .setRegistrar(registrar) + .setName("Jane Smith") + .setEmailAddress("pride@example.net") + .setTypes(ImmutableSet.of(RegistrarPoc.Type.TECH)) + .build()); // Use registrar key for contacts' parent. DateTime registrarCreationTime = persistResource(registrar).getCreationTime(); persistSimpleResources(contacts); diff --git a/core/src/test/java/google/registry/model/OteAccountBuilderTest.java b/core/src/test/java/google/registry/model/OteAccountBuilderTest.java index d8e137ae2..83a936d8e 100644 --- a/core/src/test/java/google/registry/model/OteAccountBuilderTest.java +++ b/core/src/test/java/google/registry/model/OteAccountBuilderTest.java @@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.ImmutableList; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.model.tld.Registry; import google.registry.model.tld.Registry.TldState; import google.registry.testing.AppEngineExtension; @@ -93,9 +93,8 @@ public final class OteAccountBuilderTest { private void assertContactExists(String registrarId, String email) { Registrar registrar = Registrar.loadByRegistrarId(registrarId).get(); - assertThat(registrar.getContacts().stream().map(RegistrarContact::getEmailAddress)) - .contains(email); - RegistrarContact contact = + assertThat(registrar.getContacts().stream().map(RegistrarPoc::getEmailAddress)).contains(email); + RegistrarPoc contact = registrar.getContacts().stream() .filter(c -> email.equals(c.getEmailAddress())) .findAny() diff --git a/core/src/test/java/google/registry/model/common/ClassPathManagerTest.java b/core/src/test/java/google/registry/model/common/ClassPathManagerTest.java index 9292ae002..9ccc544c1 100644 --- a/core/src/test/java/google/registry/model/common/ClassPathManagerTest.java +++ b/core/src/test/java/google/registry/model/common/ClassPathManagerTest.java @@ -34,7 +34,6 @@ import google.registry.model.index.ForeignKeyIndex.ForeignKeyHostIndex; import google.registry.model.poll.PollMessage; import google.registry.model.rde.RdeRevision; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; import google.registry.model.replay.LastSqlTransaction; import google.registry.model.replay.ReplayGap; import google.registry.model.reporting.HistoryEntry; @@ -70,7 +69,6 @@ public class ClassPathManagerTest { assertThat(ClassPathManager.getClass("ReplayGap")).isEqualTo(ReplayGap.class); assertThat(ClassPathManager.getClass("ContactResource")).isEqualTo(ContactResource.class); assertThat(ClassPathManager.getClass("Cancellation")).isEqualTo(Cancellation.class); - assertThat(ClassPathManager.getClass("RegistrarContact")).isEqualTo(RegistrarContact.class); assertThat(ClassPathManager.getClass("LastSqlTransaction")).isEqualTo(LastSqlTransaction.class); assertThat(ClassPathManager.getClass("GaeUserIdConverter")).isEqualTo(GaeUserIdConverter.class); assertThat(ClassPathManager.getClass("EppResourceIndexBucket")) @@ -130,7 +128,6 @@ public class ClassPathManagerTest { assertThat(ClassPathManager.getClassName(ReplayGap.class)).isEqualTo("ReplayGap"); assertThat(ClassPathManager.getClassName(ContactResource.class)).isEqualTo("ContactResource"); assertThat(ClassPathManager.getClassName(Cancellation.class)).isEqualTo("Cancellation"); - assertThat(ClassPathManager.getClassName(RegistrarContact.class)).isEqualTo("RegistrarContact"); assertThat(ClassPathManager.getClassName(LastSqlTransaction.class)) .isEqualTo("LastSqlTransaction"); assertThat(ClassPathManager.getClassName(GaeUserIdConverter.class)) diff --git a/core/src/test/java/google/registry/model/registrar/RegistrarTest.java b/core/src/test/java/google/registry/model/registrar/RegistrarTest.java index 705d822e7..e18df9626 100644 --- a/core/src/test/java/google/registry/model/registrar/RegistrarTest.java +++ b/core/src/test/java/google/registry/model/registrar/RegistrarTest.java @@ -63,7 +63,7 @@ import org.junit.jupiter.api.BeforeEach; class RegistrarTest extends EntityTestCase { private Registrar registrar; - private RegistrarContact abuseAdminContact; + private RegistrarPoc abuseAdminContact; @BeforeEach void setUp() { @@ -127,27 +127,26 @@ class RegistrarTest extends EntityTestCase { .build()); persistResource(registrar); abuseAdminContact = - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("John Abused") .setEmailAddress("johnabuse@example.com") .setVisibleInWhoisAsAdmin(true) .setVisibleInWhoisAsTech(false) .setPhoneNumber("+1.2125551213") .setFaxNumber("+1.2125551213") - .setTypes(ImmutableSet.of(RegistrarContact.Type.ABUSE, RegistrarContact.Type.ADMIN)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.ABUSE, RegistrarPoc.Type.ADMIN)) .build(); persistSimpleResources( ImmutableList.of( abuseAdminContact, - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("John Doe") .setEmailAddress("johndoe@example.com") .setPhoneNumber("+1.2125551213") .setFaxNumber("+1.2125551213") - .setTypes( - ImmutableSet.of(RegistrarContact.Type.LEGAL, RegistrarContact.Type.MARKETING)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.LEGAL, RegistrarPoc.Type.MARKETING)) .build())); } @@ -296,50 +295,50 @@ class RegistrarTest extends EntityTestCase { @TestOfyAndSql void testSuccess_emptyContactTypesAllowed() { persistSimpleResource( - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("John Abussy") .setEmailAddress("johnabussy@example.com") .setPhoneNumber("+1.2125551213") .setFaxNumber("+1.2125551213") // No setTypes(...) .build()); - for (RegistrarContact rc : registrar.getContacts()) { + for (RegistrarPoc rc : registrar.getContacts()) { rc.toJsonMap(); } } @TestOfyAndSql void testSuccess_getContactsByType() { - RegistrarContact newTechContact = + RegistrarPoc newTechContact = persistSimpleResource( - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("Jake Tech") .setEmailAddress("jaketech@example.com") .setVisibleInWhoisAsAdmin(true) .setVisibleInWhoisAsTech(true) .setPhoneNumber("+1.2125551213") .setFaxNumber("+1.2125551213") - .setTypes(ImmutableSet.of(RegistrarContact.Type.TECH)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.TECH)) .build()); - RegistrarContact newTechAbuseContact = + RegistrarPoc newTechAbuseContact = persistSimpleResource( - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("Jim Tech-Abuse") .setEmailAddress("jimtechAbuse@example.com") .setVisibleInWhoisAsAdmin(true) .setVisibleInWhoisAsTech(true) .setPhoneNumber("+1.2125551213") .setFaxNumber("+1.2125551213") - .setTypes(ImmutableSet.of(RegistrarContact.Type.TECH, RegistrarContact.Type.ABUSE)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.TECH, RegistrarPoc.Type.ABUSE)) .build()); - ImmutableSortedSet techContacts = - registrar.getContactsOfType(RegistrarContact.Type.TECH); + ImmutableSortedSet techContacts = + registrar.getContactsOfType(RegistrarPoc.Type.TECH); assertThat(techContacts).containsExactly(newTechContact, newTechAbuseContact).inOrder(); - ImmutableSortedSet abuseContacts = - registrar.getContactsOfType(RegistrarContact.Type.ABUSE); + ImmutableSortedSet abuseContacts = + registrar.getContactsOfType(RegistrarPoc.Type.ABUSE); assertThat(abuseContacts).containsExactly(newTechAbuseContact, abuseAdminContact).inOrder(); } diff --git a/core/src/test/java/google/registry/persistence/VKeyTest.java b/core/src/test/java/google/registry/persistence/VKeyTest.java index a5ecdb05f..075749587 100644 --- a/core/src/test/java/google/registry/persistence/VKeyTest.java +++ b/core/src/test/java/google/registry/persistence/VKeyTest.java @@ -25,7 +25,7 @@ import google.registry.model.billing.BillingEvent.OneTime; import google.registry.model.common.ClassPathManager; import google.registry.model.domain.DomainBase; import google.registry.model.host.HostResource; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.testing.AppEngineExtension; import google.registry.testing.TestObject; import org.junit.jupiter.api.BeforeAll; @@ -68,7 +68,7 @@ class VKeyTest { IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, - () -> VKey.create(RegistrarContact.class, "fake@example.com")); + () -> VKey.create(RegistrarPoc.class, "fake@example.com")); assertThat(thrown).hasMessageThat().contains("BackupGroupRoot"); } diff --git a/core/src/test/java/google/registry/persistence/transaction/JpaTransactionManagerExtension.java b/core/src/test/java/google/registry/persistence/transaction/JpaTransactionManagerExtension.java index ffa73e47d..d199707c5 100644 --- a/core/src/test/java/google/registry/persistence/transaction/JpaTransactionManagerExtension.java +++ b/core/src/test/java/google/registry/persistence/transaction/JpaTransactionManagerExtension.java @@ -32,7 +32,7 @@ import com.google.common.io.Resources; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar.State; import google.registry.model.registrar.RegistrarAddress; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.persistence.HibernateSchemaExporter; import google.registry.persistence.NomulusPostgreSql; import google.registry.persistence.PersistenceModule; @@ -388,15 +388,15 @@ abstract class JpaTransactionManagerExtension implements BeforeEachCallback, Aft * Public factory for first RegistrarContact to allow comparison against stored value in unit * tests. */ - public static RegistrarContact makeRegistrarContact1() { - return new RegistrarContact.Builder() - .setParent(makeRegistrar1()) + public static RegistrarPoc makeRegistrarContact1() { + return new RegistrarPoc.Builder() + .setRegistrar(makeRegistrar1()) .setName("Jane Doe") .setVisibleInWhoisAsAdmin(true) .setVisibleInWhoisAsTech(false) .setEmailAddress("janedoe@theregistrar.com") .setPhoneNumber("+1.1234567890") - .setTypes(ImmutableSet.of(RegistrarContact.Type.ADMIN)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.ADMIN)) .build(); } @@ -404,25 +404,25 @@ abstract class JpaTransactionManagerExtension implements BeforeEachCallback, Aft * Public factory for second RegistrarContact to allow comparison against stored value in unit * tests. */ - public static RegistrarContact makeRegistrarContact2() { - return new RegistrarContact.Builder() - .setParent(makeRegistrar2()) + public static RegistrarPoc makeRegistrarContact2() { + return new RegistrarPoc.Builder() + .setRegistrar(makeRegistrar2()) .setName("John Doe") .setEmailAddress("johndoe@theregistrar.com") .setPhoneNumber("+1.1234567890") - .setTypes(ImmutableSet.of(RegistrarContact.Type.ADMIN)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.ADMIN)) .setGaeUserId(THE_REGISTRAR_GAE_USER_ID) .build(); } - public static RegistrarContact makeRegistrarContact3() { - return new RegistrarContact.Builder() - .setParent(makeRegistrar2()) + public static RegistrarPoc makeRegistrarContact3() { + return new RegistrarPoc.Builder() + .setRegistrar(makeRegistrar2()) .setName("Marla Singer") .setEmailAddress("Marla.Singer@crr.com") .setRegistryLockEmailAddress("Marla.Singer.RegistryLock@crr.com") .setPhoneNumber("+1.2128675309") - .setTypes(ImmutableSet.of(RegistrarContact.Type.TECH)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.TECH)) .setGaeUserId(MARLA_SINGER_GAE_USER_ID) .setAllowedToSetRegistryLockPassword(true) .setRegistryLockPassword("hi") diff --git a/core/src/test/java/google/registry/rdap/RdapJsonFormatterTest.java b/core/src/test/java/google/registry/rdap/RdapJsonFormatterTest.java index c53afba9b..d9d0ef64a 100644 --- a/core/src/test/java/google/registry/rdap/RdapJsonFormatterTest.java +++ b/core/src/test/java/google/registry/rdap/RdapJsonFormatterTest.java @@ -40,7 +40,7 @@ import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.HostResource; import google.registry.model.ofy.Ofy; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.model.reporting.HistoryEntry; import google.registry.model.transfer.DomainTransferData; import google.registry.model.transfer.TransferStatus; @@ -260,43 +260,43 @@ class RdapJsonFormatterTest { clock.nowUtc().minusMonths(3))); } - static ImmutableList makeMoreRegistrarContacts(Registrar registrar) { + static ImmutableList makeMoreRegistrarContacts(Registrar registrar) { return ImmutableList.of( - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("Baby Doe") .setEmailAddress("babydoe@example.com") .setPhoneNumber("+1.2125551217") .setFaxNumber("+1.2125551218") - .setTypes(ImmutableSet.of(RegistrarContact.Type.ADMIN)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.ADMIN)) .setVisibleInWhoisAsAdmin(false) .setVisibleInWhoisAsTech(false) .build(), - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("John Doe") .setEmailAddress("johndoe@example.com") .setFaxNumber("+1.2125551213") - .setTypes(ImmutableSet.of(RegistrarContact.Type.ADMIN)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.ADMIN)) .setVisibleInWhoisAsAdmin(false) .setVisibleInWhoisAsTech(true) .build(), - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("Jane Doe") .setEmailAddress("janedoe@example.com") .setPhoneNumber("+1.2125551215") - .setTypes(ImmutableSet.of(RegistrarContact.Type.TECH, RegistrarContact.Type.ADMIN)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.TECH, RegistrarPoc.Type.ADMIN)) .setVisibleInWhoisAsAdmin(true) .setVisibleInWhoisAsTech(false) .build(), - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("Play Doe") .setEmailAddress("playdoe@example.com") .setPhoneNumber("+1.2125551217") .setFaxNumber("+1.2125551218") - .setTypes(ImmutableSet.of(RegistrarContact.Type.BILLING)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.BILLING)) .setVisibleInWhoisAsAdmin(true) .setVisibleInWhoisAsTech(true) .build()); diff --git a/core/src/test/java/google/registry/schema/registrar/RegistrarContactTest.java b/core/src/test/java/google/registry/schema/registrar/RegistrarPocTest.java similarity index 86% rename from core/src/test/java/google/registry/schema/registrar/RegistrarContactTest.java rename to core/src/test/java/google/registry/schema/registrar/RegistrarPocTest.java index bf7a15752..b97ed1387 100644 --- a/core/src/test/java/google/registry/schema/registrar/RegistrarContactTest.java +++ b/core/src/test/java/google/registry/schema/registrar/RegistrarPocTest.java @@ -15,7 +15,7 @@ package google.registry.schema.registrar; import static com.google.common.truth.Truth.assertThat; -import static google.registry.model.registrar.RegistrarContact.Type.WHOIS; +import static google.registry.model.registrar.RegistrarPoc.Type.WHOIS; import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm; import static google.registry.testing.DatabaseHelper.insertInDb; import static google.registry.testing.DatabaseHelper.loadByEntity; @@ -23,7 +23,7 @@ import static google.registry.testing.SqlHelper.saveRegistrar; import com.google.common.collect.ImmutableSet; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationWithCoverageExtension; import google.registry.testing.DatastoreEntityExtension; @@ -33,8 +33,8 @@ import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -/** Unit tests for persisting {@link RegistrarContact} entities. */ -class RegistrarContactTest { +/** Unit tests for persisting {@link RegistrarPoc} entities. */ +class RegistrarPocTest { @RegisterExtension @Order(value = 1) @@ -46,14 +46,14 @@ class RegistrarContactTest { private Registrar testRegistrar; - private RegistrarContact testRegistrarPoc; + private RegistrarPoc testRegistrarPoc; @BeforeEach public void beforeEach() { testRegistrar = saveRegistrar("registrarId"); testRegistrarPoc = - new RegistrarContact.Builder() - .setParent(testRegistrar) + new RegistrarPoc.Builder() + .setRegistrar(testRegistrar) .setName("Judith Registrar") .setEmailAddress("judith.doe@example.com") .setRegistryLockEmailAddress("judith.doe@external.com") @@ -75,7 +75,7 @@ class RegistrarContactTest { @Test void testSerializable_succeeds() { insertInDb(testRegistrarPoc); - RegistrarContact persisted = jpaTm().transact(() -> jpaTm().loadByEntity(testRegistrarPoc)); + RegistrarPoc persisted = jpaTm().transact(() -> jpaTm().loadByEntity(testRegistrarPoc)); assertThat(SerializeUtils.serializeDeserialize(persisted)).isEqualTo(persisted); } } diff --git a/core/src/test/java/google/registry/testing/AppEngineExtension.java b/core/src/test/java/google/registry/testing/AppEngineExtension.java index bd71391d9..8de685250 100644 --- a/core/src/test/java/google/registry/testing/AppEngineExtension.java +++ b/core/src/test/java/google/registry/testing/AppEngineExtension.java @@ -49,7 +49,7 @@ import google.registry.model.ofy.ObjectifyService; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar.State; import google.registry.model.registrar.RegistrarAddress; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationWithCoverageExtension; @@ -326,15 +326,15 @@ public final class AppEngineExtension implements BeforeEachCallback, AfterEachCa * Public factory for first RegistrarContact to allow comparison against stored value in unit * tests. */ - public static RegistrarContact makeRegistrarContact1() { - return new RegistrarContact.Builder() - .setParent(makeRegistrar1()) + public static RegistrarPoc makeRegistrarContact1() { + return new RegistrarPoc.Builder() + .setRegistrar(makeRegistrar1()) .setName("Jane Doe") .setVisibleInWhoisAsAdmin(true) .setVisibleInWhoisAsTech(false) .setEmailAddress("janedoe@theregistrar.com") .setPhoneNumber("+1.1234567890") - .setTypes(ImmutableSet.of(RegistrarContact.Type.ADMIN)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.ADMIN)) .build(); } @@ -342,25 +342,25 @@ public final class AppEngineExtension implements BeforeEachCallback, AfterEachCa * Public factory for second RegistrarContact to allow comparison against stored value in unit * tests. */ - public static RegistrarContact makeRegistrarContact2() { - return new RegistrarContact.Builder() - .setParent(makeRegistrar2()) + public static RegistrarPoc makeRegistrarContact2() { + return new RegistrarPoc.Builder() + .setRegistrar(makeRegistrar2()) .setName("John Doe") .setEmailAddress("johndoe@theregistrar.com") .setPhoneNumber("+1.1234567890") - .setTypes(ImmutableSet.of(RegistrarContact.Type.ADMIN)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.ADMIN)) .setGaeUserId(THE_REGISTRAR_GAE_USER_ID) .build(); } - public static RegistrarContact makeRegistrarContact3() { - return new RegistrarContact.Builder() - .setParent(makeRegistrar2()) + public static RegistrarPoc makeRegistrarContact3() { + return new RegistrarPoc.Builder() + .setRegistrar(makeRegistrar2()) .setName("Marla Singer") .setEmailAddress("Marla.Singer@crr.com") .setRegistryLockEmailAddress("Marla.Singer.RegistryLock@crr.com") .setPhoneNumber("+1.2128675309") - .setTypes(ImmutableSet.of(RegistrarContact.Type.TECH)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.TECH)) .setGaeUserId(MARLA_SINGER_GAE_USER_ID) .setAllowedToSetRegistryLockPassword(true) .setRegistryLockPassword("hi") diff --git a/core/src/test/java/google/registry/testing/FullFieldsTestEntityHelper.java b/core/src/test/java/google/registry/testing/FullFieldsTestEntityHelper.java index 1c4d32447..97561b763 100644 --- a/core/src/test/java/google/registry/testing/FullFieldsTestEntityHelper.java +++ b/core/src/test/java/google/registry/testing/FullFieldsTestEntityHelper.java @@ -37,7 +37,7 @@ import google.registry.model.eppcommon.Trid; import google.registry.model.host.HostResource; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarAddress; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.model.reporting.HistoryEntry; import google.registry.persistence.VKey; import google.registry.util.Idn; @@ -89,34 +89,34 @@ public final class FullFieldsTestEntityHelper { .build(); } - public static ImmutableList makeRegistrarContacts(Registrar registrar) { + public static ImmutableList makeRegistrarContacts(Registrar registrar) { return ImmutableList.of( - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("John Doe") .setEmailAddress("johndoe@example.com") .setPhoneNumber("+1.2125551213") .setFaxNumber("+1.2125551213") - .setTypes(ImmutableSet.of(RegistrarContact.Type.ADMIN)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.ADMIN)) // Purposely flip the internal/external admin/tech // distinction to make sure we're not relying on it. Sigh. .setVisibleInWhoisAsAdmin(false) .setVisibleInWhoisAsTech(true) .build(), - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("Jane Doe") .setEmailAddress("janedoe@example.com") .setPhoneNumber("+1.2125551215") .setFaxNumber("+1.2125551216") - .setTypes(ImmutableSet.of(RegistrarContact.Type.TECH)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.TECH)) // Purposely flip the internal/external admin/tech // distinction to make sure we're not relying on it. Sigh. .setVisibleInWhoisAsAdmin(true) .setVisibleInWhoisAsTech(false) .build(), - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("Jake Doe") .setEmailAddress("jakedoe@example.com") .setPhoneNumber("+1.2125551216") diff --git a/core/src/test/java/google/registry/tools/RegistrarContactCommandTest.java b/core/src/test/java/google/registry/tools/RegistrarPocCommandTest.java similarity index 69% rename from core/src/test/java/google/registry/tools/RegistrarContactCommandTest.java rename to core/src/test/java/google/registry/tools/RegistrarPocCommandTest.java index ba5f1868c..5405512a1 100644 --- a/core/src/test/java/google/registry/tools/RegistrarContactCommandTest.java +++ b/core/src/test/java/google/registry/tools/RegistrarPocCommandTest.java @@ -15,10 +15,10 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; -import static google.registry.model.registrar.RegistrarContact.Type.ABUSE; -import static google.registry.model.registrar.RegistrarContact.Type.ADMIN; -import static google.registry.model.registrar.RegistrarContact.Type.TECH; -import static google.registry.model.registrar.RegistrarContact.Type.WHOIS; +import static google.registry.model.registrar.RegistrarPoc.Type.ABUSE; +import static google.registry.model.registrar.RegistrarPoc.Type.ADMIN; +import static google.registry.model.registrar.RegistrarPoc.Type.TECH; +import static google.registry.model.registrar.RegistrarPoc.Type.WHOIS; import static google.registry.testing.DatabaseHelper.loadRegistrar; import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistSimpleResource; @@ -30,14 +30,14 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import java.nio.file.Files; import java.nio.file.Paths; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -/** Unit tests for {@link RegistrarContactCommand}. */ -class RegistrarContactCommandTest extends CommandTestCase { +/** Unit tests for {@link RegistrarPocCommand}. */ +class RegistrarPocCommandTest extends CommandTestCase { private String output; @@ -49,11 +49,11 @@ class RegistrarContactCommandTest extends CommandTestCase contacts = ImmutableList.of( - new RegistrarContact.Builder() - .setParent(registrar) - .setName("Judith Doe") - .setEmailAddress("judith.doe@example.com") - .setTypes(ImmutableSet.of(WHOIS)) - .setVisibleInWhoisAsAdmin(true) - .setVisibleInWhoisAsTech(true) - .setVisibleInDomainWhoisAsAbuse(false) - .build()); + ImmutableList contacts = + ImmutableList.of( + new RegistrarPoc.Builder() + .setRegistrar(registrar) + .setName("Judith Doe") + .setEmailAddress("judith.doe@example.com") + .setTypes(ImmutableSet.of(WHOIS)) + .setVisibleInWhoisAsAdmin(true) + .setVisibleInWhoisAsTech(true) + .setVisibleInDomainWhoisAsAbuse(false) + .build()); persistSimpleResources(contacts); runCommandForced( "--mode=UPDATE", @@ -98,11 +99,11 @@ class RegistrarContactCommandTest extends CommandTestCase rc.getEmailAddress().equals("jane.doe@example.com")) .findFirst() .get(); - assertThat(registrarContact.getGaeUserId()).matches("-?[0-9]+"); + assertThat(registrarPoc.getGaeUserId()).matches("-?[0-9]+"); } @Test void testUpdate_disableConsoleAccess() throws Exception { Registrar registrar = loadRegistrar("NewRegistrar"); persistSimpleResource( - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("Judith Doe") .setEmailAddress("judith.doe@example.com") .setGaeUserId("11111") @@ -152,23 +153,23 @@ class RegistrarContactCommandTest extends CommandTestCase registrarContacts = + ImmutableList registrarPocs = loadRegistrar("NewRegistrar").getContacts().asList(); - for (RegistrarContact registrarContact : registrarContacts) { - if (registrarContact.getName().equals("John Doe")) { - assertThat(registrarContact.getVisibleInDomainWhoisAsAbuse()).isTrue(); + for (RegistrarPoc registrarPoc : registrarPocs) { + if (registrarPoc.getName().equals("John Doe")) { + assertThat(registrarPoc.getVisibleInDomainWhoisAsAbuse()).isTrue(); } else { - assertThat(registrarContact.getVisibleInDomainWhoisAsAbuse()).isFalse(); + assertThat(registrarPoc.getVisibleInDomainWhoisAsAbuse()).isFalse(); } } } @@ -194,8 +195,8 @@ class RegistrarContactCommandTest extends CommandTestCase registrarContact.asBuilder().setRegistryLockPassword("foo")); + () -> registrarPoc.asBuilder().setRegistryLockPassword("foo")); // Next, try (and fail) to allow registry lock without a registry lock email assertThat( @@ -429,7 +431,7 @@ class RegistrarContactCommandTest extends CommandTestCase { } private void verifyRegistrarContactCreation(String registrarName, String email) { - ImmutableSet registrarContacts = - loadRegistrar(registrarName).getContacts(); - assertThat(registrarContacts).hasSize(1); - RegistrarContact registrarContact = registrarContacts.stream().findAny().get(); - assertThat(registrarContact.getEmailAddress()).isEqualTo(email); - assertThat(registrarContact.getName()).isEqualTo(email); - assertThat(registrarContact.getGaeUserId()).isNotNull(); + ImmutableSet registrarPocs = loadRegistrar(registrarName).getContacts(); + assertThat(registrarPocs).hasSize(1); + RegistrarPoc registrarPoc = registrarPocs.stream().findAny().get(); + assertThat(registrarPoc.getEmailAddress()).isEqualTo(email); + assertThat(registrarPoc.getName()).isEqualTo(email); + assertThat(registrarPoc.getGaeUserId()).isNotNull(); } @Test diff --git a/core/src/test/java/google/registry/ui/server/registrar/ConsoleRegistrarCreatorActionTest.java b/core/src/test/java/google/registry/ui/server/registrar/ConsoleRegistrarCreatorActionTest.java index 71fcc5d8c..68dc46cb2 100644 --- a/core/src/test/java/google/registry/ui/server/registrar/ConsoleRegistrarCreatorActionTest.java +++ b/core/src/test/java/google/registry/ui/server/registrar/ConsoleRegistrarCreatorActionTest.java @@ -32,7 +32,7 @@ import com.google.common.collect.ImmutableSetMultimap; import google.registry.config.RegistryEnvironment; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarAddress; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.request.Action.Method; import google.registry.request.auth.AuthLevel; import google.registry.request.auth.AuthResult; @@ -218,8 +218,8 @@ final class ConsoleRegistrarCreatorActionTest { assertThat(registrar.getContacts()) .containsExactly( - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setGaeUserId("-1509175207") .setGaeUserId(convertEmailAddressToGaeUserId("myclientid@registry.example")) .setName("myclientid@registry.example") diff --git a/core/src/test/java/google/registry/ui/server/registrar/ContactSettingsTest.java b/core/src/test/java/google/registry/ui/server/registrar/ContactSettingsTest.java index ef98ebc39..7e25260f6 100644 --- a/core/src/test/java/google/registry/ui/server/registrar/ContactSettingsTest.java +++ b/core/src/test/java/google/registry/ui/server/registrar/ContactSettingsTest.java @@ -23,8 +23,8 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; -import google.registry.model.registrar.RegistrarContact.Type; +import google.registry.model.registrar.RegistrarPoc; +import google.registry.model.registrar.RegistrarPoc.Type; import google.registry.testing.AppEngineExtension; import java.util.List; import java.util.Map; @@ -80,8 +80,7 @@ class ContactSettingsTest extends RegistrarSettingsActionTestCase { action.handleJsonRequest(ImmutableMap.of("op", "update", "id", CLIENT_ID, "args", regMap)); assertThat(response).containsEntry("status", "SUCCESS"); - RegistrarContact foundContact = - Iterables.getOnlyElement(loadRegistrar(CLIENT_ID).getContacts()); + RegistrarPoc foundContact = Iterables.getOnlyElement(loadRegistrar(CLIENT_ID).getContacts()); assertThat(foundContact.getName()).isEqualTo(adminContact.get("name")); assertThat(foundContact.getEmailAddress()).isEqualTo(adminContact.get("emailAddress")); assertThat(foundContact.getPhoneNumber()).isEqualTo(adminContact.get("phoneNumber")); @@ -130,7 +129,7 @@ class ContactSettingsTest extends RegistrarSettingsActionTestCase { void testPost_updateContacts_cannotRemoveWhoisAbuseContact_error() { // First make the contact's info visible in whois as abuse contact info. Registrar registrar = loadRegistrar(CLIENT_ID); - RegistrarContact rc = + RegistrarPoc rc = AppEngineExtension.makeRegistrarContact2() .asBuilder() .setVisibleInDomainWhoisAsAbuse(true) @@ -157,7 +156,7 @@ class ContactSettingsTest extends RegistrarSettingsActionTestCase { void testPost_updateContacts_whoisAbuseContactMustHavePhoneNumber_error() { // First make the contact's info visible in whois as abuse contact info. Registrar registrar = loadRegistrar(CLIENT_ID); - RegistrarContact rc = + RegistrarPoc rc = AppEngineExtension.makeRegistrarContact2() .asBuilder() .setVisibleInDomainWhoisAsAbuse(true) @@ -184,7 +183,7 @@ class ContactSettingsTest extends RegistrarSettingsActionTestCase { void testSuccess_setRegistryLockPassword() { addPasswordToContactTwo(); String emailAddress = AppEngineExtension.makeRegistrarContact2().getEmailAddress(); - RegistrarContact newContactWithPassword = + RegistrarPoc newContactWithPassword = loadRegistrar(CLIENT_ID).getContacts().stream() .filter(rc -> rc.getEmailAddress().equals(emailAddress)) .findFirst() @@ -197,7 +196,7 @@ class ContactSettingsTest extends RegistrarSettingsActionTestCase { void testSuccess_setRegistryLockPassword_notOverriddenLater() { addPasswordToContactTwo(); String emailAddress = AppEngineExtension.makeRegistrarContact2().getEmailAddress(); - RegistrarContact newContactWithPassword = + RegistrarPoc newContactWithPassword = loadRegistrar(CLIENT_ID).getContacts().stream() .filter(rc -> rc.getEmailAddress().equals(emailAddress)) .findFirst() @@ -226,7 +225,7 @@ class ContactSettingsTest extends RegistrarSettingsActionTestCase { } private void addPasswordToContactTwo() { - RegistrarContact contact = + RegistrarPoc contact = persistResource( AppEngineExtension.makeRegistrarContact2() .asBuilder() @@ -331,7 +330,7 @@ class ContactSettingsTest extends RegistrarSettingsActionTestCase { addPasswordToContactTwo(); Map reqJson = loadRegistrar(CLIENT_ID).toJsonMap(); String emailAddress = AppEngineExtension.makeRegistrarContact2().getEmailAddress(); - RegistrarContact newContactWithPassword = + RegistrarPoc newContactWithPassword = loadRegistrar(CLIENT_ID).getContacts().stream() .filter(rc -> rc.getEmailAddress().equals(emailAddress)) .findFirst() diff --git a/core/src/test/java/google/registry/ui/server/registrar/RegistrarSettingsActionTestCase.java b/core/src/test/java/google/registry/ui/server/registrar/RegistrarSettingsActionTestCase.java index 031b8ef92..753423ed6 100644 --- a/core/src/test/java/google/registry/ui/server/registrar/RegistrarSettingsActionTestCase.java +++ b/core/src/test/java/google/registry/ui/server/registrar/RegistrarSettingsActionTestCase.java @@ -37,7 +37,7 @@ import com.google.common.collect.ImmutableSortedMap; import com.google.common.truth.Truth; import google.registry.flows.certs.CertificateChecker; import google.registry.model.ofy.Ofy; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.request.JsonActionRunner; import google.registry.request.JsonResponse; import google.registry.request.ResponseImpl; @@ -94,7 +94,7 @@ public abstract class RegistrarSettingsActionTestCase { final RegistrarSettingsAction action = new RegistrarSettingsAction(); private final StringWriter writer = new StringWriter(); - RegistrarContact techContact; + RegistrarPoc techContact; CloudTasksHelper cloudTasksHelper = new CloudTasksHelper(); @@ -107,7 +107,7 @@ public abstract class RegistrarSettingsActionTestCase { // Add a technical contact to the registrar (in addition to the default admin contact created by // AppEngineExtension). techContact = - getOnlyElement(loadRegistrar(CLIENT_ID).getContactsOfType(RegistrarContact.Type.TECH)); + getOnlyElement(loadRegistrar(CLIENT_ID).getContactsOfType(RegistrarPoc.Type.TECH)); action.registrarAccessor = null; action.jsonActionRunner = diff --git a/core/src/test/java/google/registry/ui/server/registrar/RegistryLockGetActionTest.java b/core/src/test/java/google/registry/ui/server/registrar/RegistryLockGetActionTest.java index 2e9fdf255..d5aaa7a20 100644 --- a/core/src/test/java/google/registry/ui/server/registrar/RegistryLockGetActionTest.java +++ b/core/src/test/java/google/registry/ui/server/registrar/RegistryLockGetActionTest.java @@ -33,7 +33,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSetMultimap; import com.google.gson.Gson; import google.registry.model.domain.RegistryLock; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.request.Action.Method; import google.registry.request.auth.AuthLevel; import google.registry.request.auth.AuthResult; @@ -70,7 +70,7 @@ final class RegistryLockGetActionTest { @BeforeEach void beforeEach() { - user = userFromRegistrarContact(AppEngineExtension.makeRegistrarContact3()); + user = userFromRegistrarPoc(AppEngineExtension.makeRegistrarContact3()); fakeClock.setTo(DateTime.parse("2000-06-08T22:00:00.0Z")); authResult = AuthResult.create(AuthLevel.USER, UserAuthInfo.create(user, false)); accessor = @@ -356,8 +356,7 @@ final class RegistryLockGetActionTest { assertThat(response.getStatus()).isEqualTo(SC_FORBIDDEN); } - static User userFromRegistrarContact(RegistrarContact registrarContact) { - return new User( - registrarContact.getEmailAddress(), "gmail.com", registrarContact.getGaeUserId()); + static User userFromRegistrarPoc(RegistrarPoc registrarPoc) { + return new User(registrarPoc.getEmailAddress(), "gmail.com", registrarPoc.getGaeUserId()); } } diff --git a/core/src/test/java/google/registry/ui/server/registrar/RegistryLockPostActionTest.java b/core/src/test/java/google/registry/ui/server/registrar/RegistryLockPostActionTest.java index 870cd3093..7573eab80 100644 --- a/core/src/test/java/google/registry/ui/server/registrar/RegistryLockPostActionTest.java +++ b/core/src/test/java/google/registry/ui/server/registrar/RegistryLockPostActionTest.java @@ -25,7 +25,7 @@ import static google.registry.testing.SqlHelper.getMostRecentRegistryLockByRepoI import static google.registry.testing.SqlHelper.getRegistryLockByVerificationCode; import static google.registry.testing.SqlHelper.saveRegistryLock; import static google.registry.tools.LockOrUnlockDomainCommand.REGISTRY_LOCK_STATUSES; -import static google.registry.ui.server.registrar.RegistryLockGetActionTest.userFromRegistrarContact; +import static google.registry.ui.server.registrar.RegistryLockGetActionTest.userFromRegistrarPoc; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; @@ -99,8 +99,8 @@ final class RegistryLockPostActionTest { @BeforeEach void beforeEach() throws Exception { - userWithLockPermission = userFromRegistrarContact(AppEngineExtension.makeRegistrarContact3()); - userWithoutPermission = userFromRegistrarContact(AppEngineExtension.makeRegistrarContact2()); + userWithLockPermission = userFromRegistrarPoc(AppEngineExtension.makeRegistrarContact3()); + userWithoutPermission = userFromRegistrarPoc(AppEngineExtension.makeRegistrarContact2()); createTld("tld"); domain = persistResource(newDomainBase("example.tld")); @@ -314,7 +314,7 @@ final class RegistryLockPostActionTest { } @Test - void testFailure_notEnabledForRegistrarContact() { + void testFailure_notEnabledForRegistrarPoc() { action = createAction( AuthResult.create(AuthLevel.USER, UserAuthInfo.create(userWithoutPermission, false))); diff --git a/core/src/test/java/google/registry/webdriver/RegistrarConsoleScreenshotTest.java b/core/src/test/java/google/registry/webdriver/RegistrarConsoleScreenshotTest.java index 1e8dbfa8d..f3336ab2e 100644 --- a/core/src/test/java/google/registry/webdriver/RegistrarConsoleScreenshotTest.java +++ b/core/src/test/java/google/registry/webdriver/RegistrarConsoleScreenshotTest.java @@ -34,7 +34,7 @@ import google.registry.model.domain.DomainBase; import google.registry.model.domain.RegistryLock; import google.registry.model.ofy.OfyFilter; import google.registry.model.registrar.Registrar.State; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.module.frontend.FrontendServlet; import google.registry.server.RegistryTestServer; import google.registry.testing.AppEngineExtension; @@ -181,7 +181,7 @@ class RegistrarConsoleScreenshotTest extends WebDriverTestCase { server.runInAppEngineEnvironment( () -> { - RegistrarContact contact = + RegistrarPoc contact = loadRegistrar("TheRegistrar").getContacts().stream() .filter(c -> c.getEmailAddress().equals("johndoe@theregistrar.com")) .findFirst() diff --git a/core/src/test/java/google/registry/webdriver/RegistrarConsoleWebTest.java b/core/src/test/java/google/registry/webdriver/RegistrarConsoleWebTest.java index 8d13c7b14..8da608b6c 100644 --- a/core/src/test/java/google/registry/webdriver/RegistrarConsoleWebTest.java +++ b/core/src/test/java/google/registry/webdriver/RegistrarConsoleWebTest.java @@ -25,7 +25,7 @@ import com.googlecode.objectify.ObjectifyFilter; import google.registry.model.ofy.OfyFilter; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarAddress; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.module.frontend.FrontendServlet; import google.registry.server.RegistryTestServer; import org.junit.jupiter.api.extension.RegisterExtension; @@ -179,10 +179,10 @@ public class RegistrarConsoleWebTest extends WebDriverTestCase { void testContactSettingsView() throws Throwable { driver.get(server.getUrl("/registrar#contact-settings")); driver.waitForDisplayedElement(By.id("reg-app-btn-add")); - ImmutableList contacts = + ImmutableList contacts = server.runInAppEngineEnvironment( () -> loadRegistrar("TheRegistrar").getContacts().asList()); - for (RegistrarContact contact : contacts) { + for (RegistrarPoc contact : contacts) { assertEltTextPresent(By.id("contacts[0].name"), contact.getName()); assertEltTextPresent(By.id("contacts[0].emailAddress"), contact.getEmailAddress()); assertEltTextPresent(By.id("contacts[0].phoneNumber"), contact.getPhoneNumber()); diff --git a/core/src/test/java/google/registry/whois/DomainWhoisResponseTest.java b/core/src/test/java/google/registry/whois/DomainWhoisResponseTest.java index 6517c24a5..addec3628 100644 --- a/core/src/test/java/google/registry/whois/DomainWhoisResponseTest.java +++ b/core/src/test/java/google/registry/whois/DomainWhoisResponseTest.java @@ -35,7 +35,7 @@ import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.HostResource; import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.persistence.VKey; import google.registry.testing.AppEngineExtension; import google.registry.testing.DualDatabaseTest; @@ -55,7 +55,7 @@ class DomainWhoisResponseTest { private HostResource hostResource1; private HostResource hostResource2; - private RegistrarContact abuseContact; + private RegistrarPoc abuseContact; private ContactResource adminContact; private ContactResource registrant; private ContactResource techContact; @@ -74,14 +74,15 @@ class DomainWhoisResponseTest { .setIanaIdentifier(5555555L) .build()); - abuseContact = persistResource( - new RegistrarContact.Builder() - .setParent(registrar) - .setName("Jake Doe") - .setEmailAddress("jakedoe@theregistrar.com") - .setPhoneNumber("+1.2125551216") - .setVisibleInDomainWhoisAsAbuse(true) - .build()); + abuseContact = + persistResource( + new RegistrarPoc.Builder() + .setRegistrar(registrar) + .setName("Jake Doe") + .setEmailAddress("jakedoe@theregistrar.com") + .setPhoneNumber("+1.2125551216") + .setVisibleInDomainWhoisAsAbuse(true) + .build()); createTld("tld"); diff --git a/core/src/test/java/google/registry/whois/RegistrarWhoisResponseTest.java b/core/src/test/java/google/registry/whois/RegistrarWhoisResponseTest.java index a017ea707..0df7446a3 100644 --- a/core/src/test/java/google/registry/whois/RegistrarWhoisResponseTest.java +++ b/core/src/test/java/google/registry/whois/RegistrarWhoisResponseTest.java @@ -24,7 +24,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarAddress; -import google.registry.model.registrar.RegistrarContact; +import google.registry.model.registrar.RegistrarPoc; import google.registry.testing.AppEngineExtension; import google.registry.testing.FakeClock; import google.registry.whois.WhoisResponse.WhoisResponseResults; @@ -64,50 +64,50 @@ class RegistrarWhoisResponseTest { .setUrl("http://my.fake.url") .build(); // Use the registrar key for contacts' parent. - ImmutableList contacts = + ImmutableList contacts = ImmutableList.of( - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("Joe Registrar") .setEmailAddress("joeregistrar@example-registrar.tld") .setPhoneNumber("+1.3105551213") .setFaxNumber("+1.3105551213") - .setTypes(ImmutableSet.of(RegistrarContact.Type.ADMIN)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.ADMIN)) .setVisibleInWhoisAsAdmin(true) .setVisibleInWhoisAsTech(false) .build(), - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("John Doe") .setEmailAddress("johndoe@example-registrar.tld") .setPhoneNumber("+1.1111111111") .setFaxNumber("+1.1111111111") - .setTypes(ImmutableSet.of(RegistrarContact.Type.ADMIN)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.ADMIN)) .build(), - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("Jane Registrar") .setEmailAddress("janeregistrar@example-registrar.tld") .setPhoneNumber("+1.3105551214") .setFaxNumber("+1.3105551213") - .setTypes(ImmutableSet.of(RegistrarContact.Type.ADMIN)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.ADMIN)) .setVisibleInWhoisAsAdmin(true) .build(), - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("Jane Doe") .setEmailAddress("janedoe@example-registrar.tld") .setPhoneNumber("+1.1111111112") .setFaxNumber("+1.1111111112") - .setTypes(ImmutableSet.of(RegistrarContact.Type.TECH)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.TECH)) .build(), - new RegistrarContact.Builder() - .setParent(registrar) + new RegistrarPoc.Builder() + .setRegistrar(registrar) .setName("Bonnie & Clyde") .setEmailAddress("johngeek@example-registrar.tld") .setPhoneNumber("+1.3105551215") .setFaxNumber("+1.3105551216") - .setTypes(ImmutableSet.of(RegistrarContact.Type.TECH)) + .setTypes(ImmutableSet.of(RegistrarPoc.Type.TECH)) .setVisibleInWhoisAsTech(true) .build()); persistResource(registrar); diff --git a/core/src/test/resources/google/registry/export/backup_kinds.txt b/core/src/test/resources/google/registry/export/backup_kinds.txt index 4a53e596e..2aa3bb93d 100644 --- a/core/src/test/resources/google/registry/export/backup_kinds.txt +++ b/core/src/test/resources/google/registry/export/backup_kinds.txt @@ -17,5 +17,4 @@ PollMessage RdeRevision Recurring Registrar -RegistrarContact Registry diff --git a/core/src/test/resources/google/registry/export/crosstld_kinds.txt b/core/src/test/resources/google/registry/export/crosstld_kinds.txt index bd7a3bd78..54330cf6e 100644 --- a/core/src/test/resources/google/registry/export/crosstld_kinds.txt +++ b/core/src/test/resources/google/registry/export/crosstld_kinds.txt @@ -1,5 +1,4 @@ Cursor Registrar -RegistrarContact Registry ServerSecret diff --git a/core/src/test/resources/google/registry/export/reporting_kinds.txt b/core/src/test/resources/google/registry/export/reporting_kinds.txt index d6f227ef2..e0c8e59aa 100644 --- a/core/src/test/resources/google/registry/export/reporting_kinds.txt +++ b/core/src/test/resources/google/registry/export/reporting_kinds.txt @@ -13,5 +13,4 @@ OneTime PollMessage Recurring Registrar -RegistrarContact Registry diff --git a/core/src/test/resources/google/registry/model/schema.txt b/core/src/test/resources/google/registry/model/schema.txt index 08d99fac7..661d81419 100644 --- a/core/src/test/resources/google/registry/model/schema.txt +++ b/core/src/test/resources/google/registry/model/schema.txt @@ -590,31 +590,6 @@ class google.registry.model.registrar.RegistrarAddress { java.lang.String zip; java.util.List street; } -class google.registry.model.registrar.RegistrarContact { - @Id java.lang.String emailAddress; - @Parent com.googlecode.objectify.Key parent; - boolean allowedToSetRegistryLockPassword; - boolean visibleInDomainWhoisAsAbuse; - boolean visibleInWhoisAsAdmin; - boolean visibleInWhoisAsTech; - java.lang.String faxNumber; - java.lang.String gaeUserId; - java.lang.String name; - java.lang.String phoneNumber; - java.lang.String registryLockEmailAddress; - java.lang.String registryLockPasswordHash; - java.lang.String registryLockPasswordSalt; - java.util.Set types; -} -enum google.registry.model.registrar.RegistrarContact$Type { - ABUSE; - ADMIN; - BILLING; - LEGAL; - MARKETING; - TECH; - WHOIS; -} class google.registry.model.replay.LastSqlTransaction { @Id long id; long transactionId; diff --git a/core/src/test/resources/google/registry/ui/server/registrar/update_registrar_email.txt b/core/src/test/resources/google/registry/ui/server/registrar/update_registrar_email.txt index 7c8e0af1b..19a195aa2 100644 --- a/core/src/test/resources/google/registry/ui/server/registrar/update_registrar_email.txt +++ b/core/src/test/resources/google/registry/ui/server/registrar/update_registrar_email.txt @@ -11,9 +11,9 @@ emailAddress: the.registrar@example.com -> thase@the.registrar url: http://my.fake.url -> http://my.new.url contacts: ADDED: - {parent=Key(EntityGroupRoot("cross-tld")/Registrar("TheRegistrar")), name=Extra Terrestrial, emailAddress=etphonehome@example.com, registrarId=TheRegistrar, registryLockEmailAddress=null, phoneNumber=+1.2345678901, faxNumber=null, types=[ADMIN, BILLING, TECH, WHOIS], gaeUserId=null, visibleInWhoisAsAdmin=true, visibleInWhoisAsTech=false, visibleInDomainWhoisAsAbuse=false, allowedToSetRegistryLockPassword=false} + {name=Extra Terrestrial, emailAddress=etphonehome@example.com, registrarId=TheRegistrar, registryLockEmailAddress=null, phoneNumber=+1.2345678901, faxNumber=null, types=[ADMIN, BILLING, TECH, WHOIS], gaeUserId=null, visibleInWhoisAsAdmin=true, visibleInWhoisAsTech=false, visibleInDomainWhoisAsAbuse=false, allowedToSetRegistryLockPassword=false} REMOVED: - {parent=Key(EntityGroupRoot("cross-tld")/Registrar("TheRegistrar")), name=John Doe, emailAddress=johndoe@theregistrar.com, registrarId=TheRegistrar, registryLockEmailAddress=null, phoneNumber=+1.1234567890, faxNumber=null, types=[ADMIN], gaeUserId=31337, visibleInWhoisAsAdmin=false, visibleInWhoisAsTech=false, visibleInDomainWhoisAsAbuse=false, allowedToSetRegistryLockPassword=false} + {name=John Doe, emailAddress=johndoe@theregistrar.com, registrarId=TheRegistrar, registryLockEmailAddress=null, phoneNumber=+1.1234567890, faxNumber=null, types=[ADMIN], gaeUserId=31337, visibleInWhoisAsAdmin=false, visibleInWhoisAsTech=false, visibleInDomainWhoisAsAbuse=false, allowedToSetRegistryLockPassword=false} FINAL CONTENTS: - {parent=Key(EntityGroupRoot("cross-tld")/Registrar("TheRegistrar")), name=Extra Terrestrial, emailAddress=etphonehome@example.com, registrarId=TheRegistrar, registryLockEmailAddress=null, phoneNumber=+1.2345678901, faxNumber=null, types=[ADMIN, BILLING, TECH, WHOIS], gaeUserId=null, visibleInWhoisAsAdmin=true, visibleInWhoisAsTech=false, visibleInDomainWhoisAsAbuse=false, allowedToSetRegistryLockPassword=false}, - {parent=Key(EntityGroupRoot("cross-tld")/Registrar("TheRegistrar")), name=Marla Singer, emailAddress=Marla.Singer@crr.com, registrarId=TheRegistrar, registryLockEmailAddress=Marla.Singer.RegistryLock@crr.com, phoneNumber=+1.2128675309, faxNumber=null, types=[TECH], gaeUserId=12345, visibleInWhoisAsAdmin=false, visibleInWhoisAsTech=false, visibleInDomainWhoisAsAbuse=false, allowedToSetRegistryLockPassword=false} + {name=Extra Terrestrial, emailAddress=etphonehome@example.com, registrarId=TheRegistrar, registryLockEmailAddress=null, phoneNumber=+1.2345678901, faxNumber=null, types=[ADMIN, BILLING, TECH, WHOIS], gaeUserId=null, visibleInWhoisAsAdmin=true, visibleInWhoisAsTech=false, visibleInDomainWhoisAsAbuse=false, allowedToSetRegistryLockPassword=false}, + {name=Marla Singer, emailAddress=Marla.Singer@crr.com, registrarId=TheRegistrar, registryLockEmailAddress=Marla.Singer.RegistryLock@crr.com, phoneNumber=+1.2128675309, faxNumber=null, types=[TECH], gaeUserId=12345, visibleInWhoisAsAdmin=false, visibleInWhoisAsTech=false, visibleInDomainWhoisAsAbuse=false, allowedToSetRegistryLockPassword=false}