1515package google .registry .tools ;
1616
1717import static com .google .common .base .Preconditions .checkArgument ;
18- import static com .google .common .collect .ImmutableSet .toImmutableSet ;
1918import static google .registry .model .domain .rgp .GracePeriodStatus .AUTO_RENEW ;
2019import static google .registry .model .eppcommon .StatusValue .PENDING_DELETE ;
2120import static google .registry .model .eppcommon .StatusValue .SERVER_UPDATE_PROHIBITED ;
22- import static google .registry .persistence .transaction .TransactionManagerFactory .tm ;
2321import static java .util .function .Predicate .isEqual ;
2422
2523import com .beust .jcommander .Parameter ;
3028import com .google .common .flogger .FluentLogger ;
3129import com .google .template .soy .data .SoyMapData ;
3230import google .registry .flows .ResourceFlowUtils ;
33- import google .registry .model .domain .DesignatedContact ;
3431import google .registry .model .domain .Domain ;
3532import google .registry .model .domain .GracePeriodBase ;
3633import google .registry .model .eppcommon .StatusValue ;
@@ -66,15 +63,6 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
6663 validateWith = NameserversParameter .class )
6764 private Set <String > addNameservers = new HashSet <>();
6865
69- // TODO(b/184067241): enforce only one of each type of contact
70- @ Parameter (
71- names = "--add_admins" ,
72- description = "Admins to add. Cannot be set if --admins is set." )
73- private List <String > addAdmins = new ArrayList <>();
74-
75- @ Parameter (names = "--add_techs" , description = "Techs to add. Cannot be set if --techs is set." )
76- private List <String > addTechs = new ArrayList <>();
77-
7866 @ Parameter (
7967 names = "--add_statuses" ,
8068 description = "Statuses to add. Cannot be set if --statuses is set."
@@ -97,18 +85,6 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
9785 validateWith = NameserversParameter .class )
9886 private Set <String > removeNameservers = new HashSet <>();
9987
100- @ Parameter (
101- names = "--remove_admins" ,
102- description = "Admins to remove. Cannot be set if --admins is set."
103- )
104- private List <String > removeAdmins = new ArrayList <>();
105-
106- @ Parameter (
107- names = "--remove_techs" ,
108- description = "Techs to remove. Cannot be set if --techs is set."
109- )
110- private List <String > removeTechs = new ArrayList <>();
111-
11288 @ Parameter (
11389 names = "--remove_statuses" ,
11490 description = "Statuses to remove. Cannot be set if --statuses is set."
@@ -154,16 +130,6 @@ protected void initMutatingEppToolCommand()
154130 } else {
155131 checkArgument (addNameservers .size () <= 13 , "You can add at most 13 nameservers." );
156132 }
157- if (!admins .isEmpty ()) {
158- checkArgument (
159- addAdmins .isEmpty () && removeAdmins .isEmpty (),
160- "If you provide the admins flag, you cannot use the add_admins and remove_admins flags." );
161- }
162- if (!techs .isEmpty ()) {
163- checkArgument (
164- addTechs .isEmpty () && removeTechs .isEmpty (),
165- "If you provide the techs flag, you cannot use the add_techs and remove_techs flags." );
166- }
167133 if (!statuses .isEmpty ()) {
168134 checkArgument (
169135 addStatuses .isEmpty () && removeStatuses .isEmpty (),
@@ -197,16 +163,12 @@ protected void initMutatingEppToolCommand()
197163 domainName );
198164
199165 // Use TreeSets so that the results are always in the same order (this makes testing easier).
200- Set <String > addAdminsThisDomain = new TreeSet <>(addAdmins );
201- Set <String > removeAdminsThisDomain = new TreeSet <>(removeAdmins );
202- Set <String > addTechsThisDomain = new TreeSet <>(addTechs );
203- Set <String > removeTechsThisDomain = new TreeSet <>(removeTechs );
204166 Set <String > addNameserversThisDomain = new TreeSet <>(addNameservers );
205167 Set <String > removeNameserversThisDomain = new TreeSet <>(removeNameservers );
206168 Set <String > addStatusesThisDomain = new TreeSet <>(addStatuses );
207169 Set <String > removeStatusesThisDomain = new TreeSet <>(removeStatuses );
208170
209- if (!nameservers .isEmpty () || !admins . isEmpty () || ! techs . isEmpty () || ! statuses .isEmpty ()) {
171+ if (!nameservers .isEmpty () || !statuses .isEmpty ()) {
210172 if (!nameservers .isEmpty ()) {
211173 ImmutableSortedSet <String > existingNameservers = domain .loadNameserverHostNames ();
212174 populateAddRemoveLists (
@@ -223,27 +185,7 @@ protected void initMutatingEppToolCommand()
223185 "The resulting nameservers count for domain %s would be more than 13" ,
224186 domainName );
225187 }
226- if (!admins .isEmpty () || !techs .isEmpty ()) {
227- ImmutableSet <String > existingAdmins =
228- getContactsOfType (domain , DesignatedContact .Type .ADMIN );
229- ImmutableSet <String > existingTechs =
230- getContactsOfType (domain , DesignatedContact .Type .TECH );
231188
232- if (!admins .isEmpty ()) {
233- populateAddRemoveLists (
234- ImmutableSet .copyOf (admins ),
235- existingAdmins ,
236- addAdminsThisDomain ,
237- removeAdminsThisDomain );
238- }
239- if (!techs .isEmpty ()) {
240- populateAddRemoveLists (
241- ImmutableSet .copyOf (techs ),
242- existingTechs ,
243- addTechsThisDomain ,
244- removeTechsThisDomain );
245- }
246- }
247189 if (!statuses .isEmpty ()) {
248190 Set <String > currentStatusValues = new HashSet <>();
249191 for (StatusValue statusValue : domain .getStatusValues ()) {
@@ -259,17 +201,13 @@ protected void initMutatingEppToolCommand()
259201
260202 boolean add =
261203 (!addNameserversThisDomain .isEmpty ()
262- || !addAdminsThisDomain .isEmpty ()
263- || !addTechsThisDomain .isEmpty ()
264204 || !addStatusesThisDomain .isEmpty ());
265205
266206 boolean remove =
267207 (!removeNameserversThisDomain .isEmpty ()
268- || !removeAdminsThisDomain .isEmpty ()
269- || !removeTechsThisDomain .isEmpty ()
270208 || !removeStatusesThisDomain .isEmpty ());
271209
272- boolean change = ( registrant != null || password != null ) ;
210+ boolean change = password != null ;
273211 boolean secDns =
274212 (!addDsRecords .isEmpty ()
275213 || !removeDsRecords .isEmpty ()
@@ -297,16 +235,11 @@ protected void initMutatingEppToolCommand()
297235 "domain" , domainName ,
298236 "add" , add ,
299237 "addNameservers" , addNameserversThisDomain ,
300- "addAdmins" , addAdminsThisDomain ,
301- "addTechs" , addTechsThisDomain ,
302238 "addStatuses" , addStatusesThisDomain ,
303239 "remove" , remove ,
304240 "removeNameservers" , removeNameserversThisDomain ,
305- "removeAdmins" , removeAdminsThisDomain ,
306- "removeTechs" , removeTechsThisDomain ,
307241 "removeStatuses" , removeStatusesThisDomain ,
308242 "change" , change ,
309- "registrant" , registrant ,
310243 "password" , password ,
311244 "secdns" , secDns ,
312245 "addDsRecords" , DsRecord .convertToSoy (addDsRecords ),
@@ -337,13 +270,4 @@ private void populateAddRemoveLists(
337270 addSet .addAll (Sets .difference (targetSet , oldSet ));
338271 removeSet .addAll (Sets .difference (oldSet , targetSet ));
339272 }
340-
341- ImmutableSet <String > getContactsOfType (Domain domain , final DesignatedContact .Type contactType ) {
342- return tm ().transact (
343- () ->
344- domain .getContacts ().stream ()
345- .filter (contact -> contact .getType ().equals (contactType ))
346- .map (contact -> tm ().loadByKey (contact .getContactKey ()).getContactId ())
347- .collect (toImmutableSet ()));
348- }
349273}
0 commit comments