mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Add the ability to dump the history of a single resource
This would have saved me 2+ hours yesterday of mucking around in datastore and manually copying out the xml bytes so that I could base64decode them. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=139472542
This commit is contained in:
parent
419a04bc26
commit
5bac24186f
3 changed files with 57 additions and 25 deletions
|
@ -14,7 +14,6 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static google.registry.model.index.ForeignKeyIndex.loadAndGetKey;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
@ -23,10 +22,7 @@ import com.beust.jcommander.Parameter;
|
|||
import com.beust.jcommander.Parameters;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.EppResource;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.domain.DomainApplication;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.tools.CommandUtilities.ResourceType;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
|
@ -40,8 +36,6 @@ import org.joda.time.DateTime;
|
|||
commandDescription = "Load and resave EPP resources by foreign key")
|
||||
public final class ResaveEppResourceCommand extends MutatingCommand {
|
||||
|
||||
private enum ResourceType { CONTACT, HOST, DOMAIN, APPLICATION }
|
||||
|
||||
@Parameter(
|
||||
names = "--type",
|
||||
description = "Resource type.")
|
||||
|
@ -55,27 +49,11 @@ public final class ResaveEppResourceCommand extends MutatingCommand {
|
|||
@Override
|
||||
protected void init() throws Exception {
|
||||
Key<? extends EppResource> resourceKey = checkArgumentNotNull(
|
||||
getResourceKey(type, uniqueId, DateTime.now(UTC)),
|
||||
type.getKey(uniqueId, DateTime.now(UTC)),
|
||||
"Could not find active resource of type %s: %s", type, uniqueId);
|
||||
// Load the resource directly to bypass running cloneProjectedAtTime() automatically, which can
|
||||
// cause stageEntityChange() to fail due to implicit projection changes.
|
||||
EppResource resource = ofy().load().key(resourceKey).now();
|
||||
stageEntityChange(resource, resource);
|
||||
}
|
||||
|
||||
private Key<? extends EppResource> getResourceKey(
|
||||
ResourceType type, String uniqueId, DateTime now) {
|
||||
switch (type) {
|
||||
case CONTACT:
|
||||
return loadAndGetKey(ContactResource.class, uniqueId, now);
|
||||
case HOST:
|
||||
return loadAndGetKey(HostResource.class, uniqueId, now);
|
||||
case DOMAIN:
|
||||
return loadAndGetKey(DomainResource.class, uniqueId, now);
|
||||
case APPLICATION:
|
||||
return Key.create(DomainApplication.class, uniqueId);
|
||||
default:
|
||||
throw new IllegalStateException("Unknown type: " + type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue