mirror of
https://github.com/google/nomulus.git
synced 2025-06-27 06:44:51 +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
|
@ -16,10 +16,39 @@ package google.registry.tools;
|
|||
|
||||
import com.google.common.base.Ascii;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
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.model.index.ForeignKeyIndex;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/** Container class for static utility methods. */
|
||||
class CommandUtilities {
|
||||
|
||||
/** A useful parameter enum for commands that operate on {@link EppResource} objects. */
|
||||
public enum ResourceType {
|
||||
CONTACT,
|
||||
HOST,
|
||||
DOMAIN,
|
||||
APPLICATION;
|
||||
|
||||
public Key<? extends EppResource> getKey(String uniqueId, DateTime now) {
|
||||
return this == APPLICATION
|
||||
? Key.create(DomainApplication.class, uniqueId)
|
||||
: ForeignKeyIndex.loadAndGetKey(
|
||||
ImmutableMap.of(
|
||||
CONTACT, ContactResource.class,
|
||||
HOST, HostResource.class,
|
||||
DOMAIN, DomainResource.class).get(this),
|
||||
uniqueId,
|
||||
now);
|
||||
}
|
||||
}
|
||||
|
||||
static String addHeader(String header, String body) {
|
||||
return String.format("%s:\n%s\n%s", header, Strings.repeat("-", header.length() + 1), body);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue