mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 08:27:14 +02:00
Add ROID flag in FixDomainNameserverKeysCommand
There's a deleted domain with bad host resource keys. Since FKIs won't help us here, load a domain directly by key (i.e. by ROID) if we so choose. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=148685240
This commit is contained in:
parent
5a00317dcc
commit
023a76349e
1 changed files with 13 additions and 5 deletions
|
@ -31,6 +31,7 @@ import com.googlecode.objectify.Key;
|
|||
import com.googlecode.objectify.VoidWork;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.index.ForeignKeyIndex;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.tools.Command.RemoteApiCommand;
|
||||
import google.registry.tools.ConfirmingCommand;
|
||||
|
@ -51,17 +52,25 @@ import org.joda.time.DateTime;
|
|||
@Parameters(separators = " =", commandDescription = "Fix bad host keys on domains.")
|
||||
public class FixDomainNameserverKeysCommand extends ConfirmingCommand implements RemoteApiCommand {
|
||||
|
||||
@Parameter(description = "Fully-qualified domain names", required = true)
|
||||
@Parameter(description = "Fully-qualified domain names (or ROIDs, with -r)", required = true)
|
||||
private List<String> mainParameters;
|
||||
|
||||
@Parameter(
|
||||
names = {"-r", "--roid"},
|
||||
description = "Use domain ROID instead of fully qualified name (useful for deleted domains)")
|
||||
boolean useRoid;
|
||||
|
||||
private final LinkedHashMap<DomainResource, DomainResource> domainUpdates = new LinkedHashMap<>();
|
||||
private final LinkedHashMap<DomainResource, HistoryEntry> historyEntries = new LinkedHashMap<>();
|
||||
|
||||
@Override
|
||||
protected void init() throws Exception {
|
||||
DateTime now = DateTime.now(UTC);
|
||||
for (String domainName : mainParameters) {
|
||||
DomainResource domain = checkNotNull(loadByForeignKey(DomainResource.class, domainName, now));
|
||||
for (String domainNameOrRoid : mainParameters) {
|
||||
Key<DomainResource> domainKey = useRoid
|
||||
? Key.create(DomainResource.class, domainNameOrRoid)
|
||||
: ForeignKeyIndex.load(DomainResource.class, domainNameOrRoid, now).getResourceKey();
|
||||
DomainResource domain = checkNotNull(ofy().load().key(domainKey).now());
|
||||
ImmutableSet.Builder<Key<HostResource>> nameservers = new ImmutableSet.Builder<>();
|
||||
for (Key<HostResource> hostKey : domain.getNameservers()) {
|
||||
HostResource existingHost = ofy().load().key(hostKey).now();
|
||||
|
@ -117,8 +126,7 @@ public class FixDomainNameserverKeysCommand extends ConfirmingCommand implements
|
|||
checkState(
|
||||
Objects.equals(
|
||||
existingDomain,
|
||||
ofy().load().entity(existingDomain).now()
|
||||
.cloneProjectedAtTime(ofy().getTransactionTime())),
|
||||
ofy().load().entity(existingDomain).now()),
|
||||
"Domain %s changed since init() was called.",
|
||||
existingDomain.getFullyQualifiedDomainName());
|
||||
HistoryEntry historyEntryWithModificationTime =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue