mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Add scrap tool for populating required registrar fields
This tool finds all registrars that have a null name, or a null localizedAddress field, and populates them as follows: - The registrar's name is updated to its clientId - The registrar's empty localizedAddress fields are replaced with fake data ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=155739946
This commit is contained in:
parent
6b6b8d25c7
commit
b08e317505
2 changed files with 75 additions and 0 deletions
|
@ -15,6 +15,7 @@
|
||||||
package google.registry.tools;
|
package google.registry.tools;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import google.registry.tools.javascrap.PopulateNullRegistrarFieldsCommand;
|
||||||
import google.registry.tools.javascrap.RemoveDomainTransferDataCommand;
|
import google.registry.tools.javascrap.RemoveDomainTransferDataCommand;
|
||||||
import google.registry.tools.javascrap.RemoveIpAddressCommand;
|
import google.registry.tools.javascrap.RemoveIpAddressCommand;
|
||||||
|
|
||||||
|
@ -97,6 +98,7 @@ public final class RegistryTool {
|
||||||
.put("logout", LogoutCommand.class)
|
.put("logout", LogoutCommand.class)
|
||||||
.put("make_billing_tables", MakeBillingTablesCommand.class)
|
.put("make_billing_tables", MakeBillingTablesCommand.class)
|
||||||
.put("pending_escrow", PendingEscrowCommand.class)
|
.put("pending_escrow", PendingEscrowCommand.class)
|
||||||
|
.put("populate_null_registrar_fields", PopulateNullRegistrarFieldsCommand.class)
|
||||||
.put("publish_detail_report", PublishDetailReportCommand.class)
|
.put("publish_detail_report", PublishDetailReportCommand.class)
|
||||||
.put("registrar_activity_report", RegistrarActivityReportCommand.class)
|
.put("registrar_activity_report", RegistrarActivityReportCommand.class)
|
||||||
.put("registrar_contact", RegistrarContactCommand.class)
|
.put("registrar_contact", RegistrarContactCommand.class)
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package google.registry.tools.javascrap;
|
||||||
|
|
||||||
|
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||||
|
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
|
|
||||||
|
import com.beust.jcommander.Parameters;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import google.registry.model.registrar.Registrar;
|
||||||
|
import google.registry.model.registrar.Registrar.Builder;
|
||||||
|
import google.registry.model.registrar.RegistrarAddress;
|
||||||
|
import google.registry.tools.MutatingCommand;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scrap tool to update Registrars with null registrarName or localizedAddress fields.
|
||||||
|
*
|
||||||
|
* <p>This sets a null registrarName to the key name, and null localizedAddress fields to fake data.
|
||||||
|
*/
|
||||||
|
@Parameters(
|
||||||
|
separators = " =",
|
||||||
|
commandDescription = "Populate previously null required registrar fields."
|
||||||
|
)
|
||||||
|
public class PopulateNullRegistrarFieldsCommand extends MutatingCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void init() throws Exception {
|
||||||
|
for (Registrar registrar : ofy().load().type(Registrar.class).ancestor(getCrossTldKey())) {
|
||||||
|
Builder changeBuilder = registrar.asBuilder();
|
||||||
|
changeBuilder.setRegistrarName(
|
||||||
|
firstNonNull(registrar.getRegistrarName(), registrar.getClientId()));
|
||||||
|
|
||||||
|
RegistrarAddress address = registrar.getLocalizedAddress();
|
||||||
|
if (address == null) {
|
||||||
|
changeBuilder.setLocalizedAddress(
|
||||||
|
new RegistrarAddress.Builder()
|
||||||
|
.setCity("Fakington")
|
||||||
|
.setCountryCode("US")
|
||||||
|
.setState("FL")
|
||||||
|
.setZip("12345")
|
||||||
|
.setStreet(ImmutableList.of("123 Fake Street"))
|
||||||
|
.build());
|
||||||
|
} else {
|
||||||
|
changeBuilder.setLocalizedAddress(
|
||||||
|
new RegistrarAddress.Builder()
|
||||||
|
.setCity(firstNonNull(address.getCity(), "Fakington"))
|
||||||
|
.setCountryCode(firstNonNull(address.getCountryCode(), "US"))
|
||||||
|
.setState(firstNonNull(address.getState(), "FL"))
|
||||||
|
.setZip(firstNonNull(address.getZip(), "12345"))
|
||||||
|
.setStreet(firstNonNull(address.getStreet(), ImmutableList.of("123 Fake Street")))
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
Registrar changedRegistrar = changeBuilder.build();
|
||||||
|
if (!Objects.equals(registrar, changedRegistrar)) {
|
||||||
|
stageEntityChange(registrar, changedRegistrar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue