Fall back to icannReferralEmail when creating registrars through the command line

This is if the separate email field isn't specified.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=239504636
This commit is contained in:
gbrodman 2019-03-20 16:55:59 -07:00 committed by jianglai
parent 1e2a60a390
commit 0ead4f8d9d
3 changed files with 44 additions and 20 deletions

View file

@ -92,12 +92,8 @@ abstract class CreateOrUpdateRegistrarCommand extends MutatingCommand {
String registrarName;
@Nullable
@Parameter(
names = "--email",
description = "Email address of registrar",
converter = OptionalStringParameter.class,
validateWith = OptionalStringParameter.class)
Optional<String> email;
@Parameter(names = "--email", description = "Email address of registrar")
String email;
@Nullable
@Parameter(
@ -280,8 +276,11 @@ abstract class CreateOrUpdateRegistrarCommand extends MutatingCommand {
if (!isNullOrEmpty(registrarName)) {
builder.setRegistrarName(registrarName);
}
if (email != null) {
builder.setEmailAddress(email.orElse(null));
if (!isNullOrEmpty(email)) {
builder.setEmailAddress(email);
} else if (!isNullOrEmpty(
icannReferralEmail)) { // fall back to ICANN referral email if present
builder.setEmailAddress(icannReferralEmail);
}
if (url != null) {
builder.setUrl(url.orElse(null));