Class EppResourceUtils
EppResource
.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends EppResource>
com.google.common.collect.ImmutableSet<String> checkResourcesExist
(Class<T> clazz, Collection<String> uniqueIds, org.joda.time.DateTime now) Checks multipleEppResource
objects from the database by unique ids.static String
createDomainRepoId
(long repoId, String tld) Returns the full domain repoId in the format HEX-TLD for the specified long id and tld.static String
createRepoId
(long repoId, String roidSuffix) Returns the full repoId in the format HEX-TLD for the specified long id and ROID suffix.getLinkedDomainKeys
(VKey<? extends EppResource> key, org.joda.time.DateTime now, Integer limit) Returns a set ofVKey
for domains that reference a specified contact or host.static boolean
isActive
(EppResource resource, org.joda.time.DateTime time) static boolean
isDeleted
(EppResource resource, org.joda.time.DateTime time) static boolean
isLinked
(VKey<? extends EppResource> key, org.joda.time.DateTime now) Returns whether the given contact or host is linked to (that is, referenced by) a domain.static <T extends EppResource>
TloadAtPointInTime
(T resource, org.joda.time.DateTime timestamp) Rewinds anEppResource
object to a given point in time.static <T extends EppResource>
Supplier<T> loadAtPointInTimeAsync
(T resource, org.joda.time.DateTime timestamp) Rewinds anEppResource
object to a given point in time.static <T extends EppResource>
Optional<T> loadByForeignKey
(Class<T> clazz, String foreignKey, org.joda.time.DateTime now) Loads the last created version of anEppResource
from the database by foreign key.static <T extends EppResource>
Optional<T> loadByForeignKeyCached
(Class<T> clazz, String foreignKey, org.joda.time.DateTime now) Loads the last created version of anEppResource
from the database by foreign key, using a cache.static <T extends TransferData,
E extends EppResource & EppResource.ResourceWithTransferData<T>, B extends EppResource.Builder<?, B> & EppResource.BuilderWithTransferData<T, B>>
voidprojectResourceOntoBuilderAtTime
(E resource, B builder, org.joda.time.DateTime now) Perform common operations for projecting anEppResource
at a given time: Process an automatic transfer.static <T extends TransferData,
B extends EppResource.Builder<?, B> & EppResource.BuilderWithTransferData<T, B>>
voidsetAutomaticTransferSuccessProperties
(B builder, TransferData transferData) Process an automatic transfer on a resource.static <T extends EppResource>
Function<T, T> transformAtTime
(org.joda.time.DateTime now) Returns a Function that transforms an EppResource to the given DateTime, suitable for use with Iterables.transform() over a collection of EppResources.
-
Method Details
-
createDomainRepoId
Returns the full domain repoId in the format HEX-TLD for the specified long id and tld. -
createRepoId
Returns the full repoId in the format HEX-TLD for the specified long id and ROID suffix. -
loadByForeignKey
public static <T extends EppResource> Optional<T> loadByForeignKey(Class<T> clazz, String foreignKey, org.joda.time.DateTime now) Loads the last created version of anEppResource
from the database by foreign key.Returns empty if no resource with this foreign key was ever created, or if the most recently created resource was deleted before time "now".
Loading an
EppResource
by itself is not sufficient to know its current state since it may have various expirable conditions and status values that might implicitly change its state as time progresses even if it has not been updated in the database. Rather, the resource must be combined with a timestamp to view its current state. We use a global last updated timestamp on the resource's entity group (which is essentially free since all writes to the entity group must be serialized anyways) to guarantee monotonically increasing write times, and forward our projected time to the greater of this timestamp or "now". This guarantees that we're not projecting into the past.- Parameters:
clazz
- the resource type to loadforeignKey
- id to matchnow
- the current logical time to project resources at
-
loadByForeignKeyCached
public static <T extends EppResource> Optional<T> loadByForeignKeyCached(Class<T> clazz, String foreignKey, org.joda.time.DateTime now) Loads the last created version of anEppResource
from the database by foreign key, using a cache.Returns null if no resource with this foreign key was ever created, or if the most recently created resource was deleted before time "now".
Loading an
EppResource
by itself is not sufficient to know its current state since it may have various expirable conditions and status values that might implicitly change its state as time progresses even if it has not been updated in the database. Rather, the resource must be combined with a timestamp to view its current state. We use a global last updated timestamp to guarantee monotonically increasing write times, and forward our projected time to the greater of this timestamp or "now". This guarantees that we're not projecting into the past.Do not call this cached version for anything that needs transactional consistency. It should only be used when it's OK if the data is potentially being out of date, e.g. WHOIS.
- Parameters:
clazz
- the resource type to loadforeignKey
- id to matchnow
- the current logical time to project resources at
-
checkResourcesExist
public static <T extends EppResource> com.google.common.collect.ImmutableSet<String> checkResourcesExist(Class<T> clazz, Collection<String> uniqueIds, org.joda.time.DateTime now) Checks multipleEppResource
objects from the database by unique ids.There are currently no resources that support checks and do not use foreign keys. If we need to support that case in the future, we can loosen the type to allow any
EppResource
and add code to do the lookup by id directly.- Parameters:
clazz
- the resource type to loaduniqueIds
- a list of ids to matchnow
- the logical time of the check
-
transformAtTime
Returns a Function that transforms an EppResource to the given DateTime, suitable for use with Iterables.transform() over a collection of EppResources. -
isActive
-
isDeleted
-
setAutomaticTransferSuccessProperties
public static <T extends TransferData,B extends EppResource.Builder<?, void setAutomaticTransferSuccessPropertiesB> & EppResource.BuilderWithTransferData<T, B>> (B builder, TransferData transferData) Process an automatic transfer on a resource. -
projectResourceOntoBuilderAtTime
public static <T extends TransferData,E extends EppResource & EppResource.ResourceWithTransferData<T>, void projectResourceOntoBuilderAtTimeB extends EppResource.Builder<?, B> & EppResource.BuilderWithTransferData<T, B>> (E resource, B builder, org.joda.time.DateTime now) Perform common operations for projecting anEppResource
at a given time:- Process an automatic transfer.
-
loadAtPointInTime
public static <T extends EppResource> T loadAtPointInTime(T resource, org.joda.time.DateTime timestamp) Rewinds anEppResource
object to a given point in time.This method costs nothing if
resource
is already current. Otherwise, it needs to perform a single fetch operation.Warning: A resource can only be rolled backwards in time, not forwards; therefore
resource
should be whatever's currently in SQL.- Returns:
- the resource at
timestamp
ornull
if resource is deleted or not yet created
-
loadAtPointInTimeAsync
public static <T extends EppResource> Supplier<T> loadAtPointInTimeAsync(T resource, org.joda.time.DateTime timestamp) Rewinds anEppResource
object to a given point in time.This method costs nothing if
resource
is already current. Otherwise, it returns an async operation that performs a single fetch operation.- Returns:
- an asynchronous operation returning resource at
timestamp
ornull
if resource is deleted or not yet created - See Also:
-
getLinkedDomainKeys
public static com.google.common.collect.ImmutableSet<VKey<Domain>> getLinkedDomainKeys(VKey<? extends EppResource> key, org.joda.time.DateTime now, @Nullable Integer limit) Returns a set ofVKey
for domains that reference a specified contact or host.This is an eventually consistent query if used for the database.
- Parameters:
key
- the referent keynow
- the logical time of the checklimit
- the maximum number of returned keys, unlimited if null
-
isLinked
Returns whether the given contact or host is linked to (that is, referenced by) a domain.This is an eventually consistent query.
- Parameters:
key
- the referent keynow
- the logical time of the check
-