mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Remove the ofy().load() inside of HostResource.cloneProjectedAtTime
In fact, completely eviscerate cloneProjectedAtTime (to be removed in a followup CL) in favor of doing the projection of transfers and the loading of values from the superordinate domain at call sites. This is one of the issues that blocked the memcache audit work, since the load inside of cloneProjectedAtTime could not be controlled by the caller. Note: fixed a minor bug where a subordinate host created after its superordinate domain was last transferred should have lastTransferTime==null but was previously reporting the domain's lastTransferTime. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=149769125
This commit is contained in:
parent
1f000b94e6
commit
9174855a47
67 changed files with 970 additions and 471 deletions
|
@ -14,7 +14,11 @@
|
|||
|
||||
package google.registry.rde;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import com.google.common.net.InetAddresses;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.xjc.host.XjcHostAddrType;
|
||||
|
@ -25,28 +29,62 @@ import google.registry.xjc.rdehost.XjcRdeHost;
|
|||
import google.registry.xjc.rdehost.XjcRdeHostElement;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/** Utility class that turns {@link HostResource} as {@link XjcRdeHostElement}. */
|
||||
final class HostResourceToXjcConverter {
|
||||
|
||||
/** Converts {@link HostResource} to {@link XjcRdeHostElement}. */
|
||||
static XjcRdeHostElement convert(HostResource host) {
|
||||
return new XjcRdeHostElement(convertHost(host));
|
||||
/** Converts a subordinate {@link HostResource} to {@link XjcRdeHostElement}. */
|
||||
static XjcRdeHostElement convertSubordinate(
|
||||
HostResource host, DomainResource superordinateDomain) {
|
||||
checkArgument(Key.create(superordinateDomain).equals(host.getSuperordinateDomain()));
|
||||
return new XjcRdeHostElement(convertSubordinateHost(host, superordinateDomain));
|
||||
}
|
||||
|
||||
/** Converts an external {@link HostResource} to {@link XjcRdeHostElement}. */
|
||||
static XjcRdeHostElement convertExternal(HostResource host) {
|
||||
checkArgument(!host.isSubordinate());
|
||||
return new XjcRdeHostElement(convertExternalHost(host));
|
||||
}
|
||||
|
||||
/** Converts {@link HostResource} to {@link XjcRdeHost}. */
|
||||
static XjcRdeHost convertHost(HostResource model) {
|
||||
static XjcRdeHost convertSubordinateHost(HostResource model, DomainResource superordinateDomain) {
|
||||
XjcRdeHost bean = convertHostCommon(
|
||||
model,
|
||||
superordinateDomain.getCurrentSponsorClientId(),
|
||||
model.computeLastTransferTime(superordinateDomain));
|
||||
if (superordinateDomain.getStatusValues().contains(StatusValue.PENDING_TRANSFER)) {
|
||||
bean.getStatuses().add(convertStatusValue(StatusValue.PENDING_TRANSFER));
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
/** Converts {@link HostResource} to {@link XjcRdeHost}. */
|
||||
static XjcRdeHost convertExternalHost(HostResource model) {
|
||||
return convertHostCommon(
|
||||
model,
|
||||
model.getPersistedCurrentSponsorClientId(),
|
||||
model.getLastTransferTime());
|
||||
}
|
||||
|
||||
private static XjcRdeHost convertHostCommon(
|
||||
HostResource model, String clientId, DateTime lastTransferTime) {
|
||||
XjcRdeHost bean = new XjcRdeHost();
|
||||
bean.setName(model.getFullyQualifiedHostName());
|
||||
bean.setRoid(model.getRepoId());
|
||||
bean.setClID(model.getCurrentSponsorClientId());
|
||||
bean.setTrDate(model.getLastTransferTime());
|
||||
bean.setCrDate(model.getCreationTime());
|
||||
bean.setUpDate(model.getLastEppUpdateTime());
|
||||
bean.setCrRr(RdeAdapter.convertRr(model.getCreationClientId(), null));
|
||||
bean.setUpRr(RdeAdapter.convertRr(model.getLastEppUpdateClientId(), null));
|
||||
bean.setCrRr(RdeAdapter.convertRr(model.getCreationClientId(), null));
|
||||
bean.setClID(clientId);
|
||||
bean.setTrDate(lastTransferTime);
|
||||
for (StatusValue status : model.getStatusValues()) {
|
||||
// TODO(b/34844887): Remove when PENDING_TRANSFER is not persisted on host resources.
|
||||
if (status.equals(StatusValue.PENDING_TRANSFER)) {
|
||||
continue;
|
||||
}
|
||||
// TODO(cgoldfeder): Add in LINKED status if applicable.
|
||||
bean.getStatuses().add(convertStatusValue(status));
|
||||
}
|
||||
for (InetAddress addr : model.getInetAddresses()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue