mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 16:37:13 +02:00
Automated g4 rollback of changelist 240574585.
*** Reason for rollback *** The inconsistent class loading is breaking the tests *** Original change description *** Validate provided email addresses when creating a Registrar *** ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=241014945
This commit is contained in:
parent
315be3eab0
commit
25f1d58969
10 changed files with 24 additions and 137 deletions
|
@ -16,7 +16,6 @@ package google.registry.model.registrar;
|
|||
|
||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Strings.emptyToNull;
|
||||
import static com.google.common.base.Strings.nullToEmpty;
|
||||
import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
||||
|
@ -85,8 +84,6 @@ import java.util.Optional;
|
|||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.mail.internet.AddressException;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
|
@ -831,7 +828,7 @@ public class Registrar extends ImmutableObject implements Buildable, Jsonifiable
|
|||
}
|
||||
|
||||
public Builder setEmailAddress(String emailAddress) {
|
||||
getInstance().emailAddress = checkValidEmail(emailAddress);
|
||||
getInstance().emailAddress = emailAddress;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -851,7 +848,7 @@ public class Registrar extends ImmutableObject implements Buildable, Jsonifiable
|
|||
}
|
||||
|
||||
public Builder setIcannReferralEmail(String icannReferralEmail) {
|
||||
getInstance().icannReferralEmail = checkValidEmail(icannReferralEmail);
|
||||
getInstance().icannReferralEmail = icannReferralEmail;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -894,20 +891,6 @@ public class Registrar extends ImmutableObject implements Buildable, Jsonifiable
|
|||
}
|
||||
}
|
||||
|
||||
/** Verifies that the email address in question is not null and has a valid format. */
|
||||
static String checkValidEmail(String email) {
|
||||
checkNotNull(email, "Provided email was null");
|
||||
try {
|
||||
InternetAddress internetAddress = new InternetAddress(email, true);
|
||||
internetAddress.validate();
|
||||
} catch (AddressException e) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Provided email %s is not a valid email address", email));
|
||||
}
|
||||
return email;
|
||||
}
|
||||
|
||||
|
||||
/** Loads all registrar entities directly from Datastore. */
|
||||
public static Iterable<Registrar> loadAll() {
|
||||
return ImmutableList.copyOf(ofy().load().type(Registrar.class).ancestor(getCrossTldKey()));
|
||||
|
|
|
@ -18,7 +18,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static com.google.common.collect.Sets.difference;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.registrar.Registrar.checkValidEmail;
|
||||
import static google.registry.util.CollectionUtils.nullToEmptyImmutableSortedCopy;
|
||||
import static java.util.stream.Collectors.joining;
|
||||
|
||||
|
@ -297,7 +296,7 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable {
|
|||
@Override
|
||||
public RegistrarContact build() {
|
||||
checkNotNull(getInstance().parent, "Registrar parent cannot be null");
|
||||
checkValidEmail(getInstance().emailAddress);
|
||||
checkNotNull(getInstance().emailAddress, "Email address cannot be null");
|
||||
return cloneEmptyToNull(super.build());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue