mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Remove buildWithoutImplicitStatusValues
This was used in DomainInfoFlow to return a DomainResource with no nameservers without making INACTIVE show up. It was nominally used in DomainApplicationInfoFlow for the same reason, but that's just an artifact of the old flow hierarchy since applications never have INACTIVE set anyways. In either case, now that we have the DomainInfo return object instead of returning DomainResource directly from the flow, it's better handled within the flow. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=145582317
This commit is contained in:
parent
f647ea1190
commit
8071a1bdb5
4 changed files with 39 additions and 68 deletions
|
@ -97,7 +97,7 @@ public final class DomainApplicationInfoFlow implements Flow {
|
|||
}
|
||||
// We don't support authInfo for applications, so if it's another registrar always fail.
|
||||
verifyResourceOwnership(clientId, application);
|
||||
application = getResourceInfo(application);
|
||||
boolean showDelegatedHosts = ((Info) resourceCommand).getHostsRequest().requestDelegated();
|
||||
prefetchReferencedResources(application);
|
||||
return responseBuilder
|
||||
.setResData(DomainInfoData.newBuilder()
|
||||
|
@ -106,7 +106,9 @@ public final class DomainApplicationInfoFlow implements Flow {
|
|||
.setStatusValues(application.getStatusValues())
|
||||
.setRegistrant(ofy().load().key(application.getRegistrant()).now().getContactId())
|
||||
.setContacts(loadForeignKeyedDesignatedContacts(application.getContacts()))
|
||||
.setNameservers(application.loadNameserverFullyQualifiedHostNames())
|
||||
.setNameservers(showDelegatedHosts
|
||||
? application.loadNameserverFullyQualifiedHostNames()
|
||||
: null)
|
||||
.setCurrentSponsorClientId(application.getCurrentSponsorClientId())
|
||||
.setCreationClientId(application.getCreationClientId())
|
||||
.setCreationTime(application.getCreationTime())
|
||||
|
@ -118,18 +120,6 @@ public final class DomainApplicationInfoFlow implements Flow {
|
|||
.build();
|
||||
}
|
||||
|
||||
DomainApplication getResourceInfo(DomainApplication application) {
|
||||
if (!((Info) resourceCommand).getHostsRequest().requestDelegated()) {
|
||||
// Delegated hosts are present by default, so clear them out if they aren't wanted.
|
||||
// This requires overriding the implicit status values so that we don't get INACTIVE added due
|
||||
// to the missing nameservers.
|
||||
return application.asBuilder()
|
||||
.setNameservers(null)
|
||||
.buildWithoutImplicitStatusValues();
|
||||
}
|
||||
return application;
|
||||
}
|
||||
|
||||
ImmutableList<ResponseExtension> getDomainResponseExtensions(
|
||||
DomainApplication application, LaunchInfoExtension launchInfo) {
|
||||
ImmutableList.Builder<Mark> marksBuilder = new ImmutableList.Builder<>();
|
||||
|
|
|
@ -40,7 +40,6 @@ import google.registry.model.domain.DomainCommand.Info;
|
|||
import google.registry.model.domain.DomainCommand.Info.HostsRequest;
|
||||
import google.registry.model.domain.DomainInfoData;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.DomainResource.Builder;
|
||||
import google.registry.model.domain.fee06.FeeInfoCommandExtensionV06;
|
||||
import google.registry.model.domain.fee06.FeeInfoResponseExtensionV06;
|
||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||
|
@ -98,59 +97,43 @@ public final class DomainInfoFlow implements Flow {
|
|||
customLogic.beforeResponse(
|
||||
BeforeResponseParameters.newBuilder()
|
||||
.setDomain(domain)
|
||||
.setResData(getResourceInfo(domain))
|
||||
.setResData(domain)
|
||||
.setResponseExtensions(getDomainResponseExtensions(domain, now))
|
||||
.build());
|
||||
domain = responseData.resData();
|
||||
prefetchReferencedResources(domain);
|
||||
return responseBuilder
|
||||
.setResData(DomainInfoData.newBuilder()
|
||||
.setFullyQualifiedDomainName(domain.getFullyQualifiedDomainName())
|
||||
.setRepoId(domain.getRepoId())
|
||||
.setStatusValues(domain.getStatusValues())
|
||||
.setRegistrant(ofy().load().key(domain.getRegistrant()).now().getContactId())
|
||||
.setContacts(loadForeignKeyedDesignatedContacts(domain.getContacts()))
|
||||
.setNameservers(domain.loadNameserverFullyQualifiedHostNames())
|
||||
.setSubordinateHosts(domain.getSubordinateHosts())
|
||||
.setCurrentSponsorClientId(domain.getCurrentSponsorClientId())
|
||||
.setCreationClientId(domain.getCreationClientId())
|
||||
.setCreationTime(domain.getCreationTime())
|
||||
.setLastEppUpdateClientId(domain.getLastEppUpdateClientId())
|
||||
.setLastEppUpdateTime(domain.getLastEppUpdateTime())
|
||||
.setRegistrationExpirationTime(domain.getRegistrationExpirationTime())
|
||||
.setLastTransferTime(domain.getLastTransferTime())
|
||||
.setAuthInfo(domain.getAuthInfo())
|
||||
.build())
|
||||
.setExtensions(responseData.responseExtensions())
|
||||
.build();
|
||||
}
|
||||
|
||||
private DomainResource getResourceInfo(DomainResource domain) {
|
||||
// Registrars can only see a few fields on unauthorized domains.
|
||||
// This is a policy decision that is left up to us by the rfcs.
|
||||
DomainInfoData.Builder infoBuilder = DomainInfoData.newBuilder()
|
||||
.setFullyQualifiedDomainName(domain.getFullyQualifiedDomainName())
|
||||
.setRepoId(domain.getRepoId())
|
||||
.setCurrentSponsorClientId(domain.getCurrentSponsorClientId())
|
||||
.setRegistrant(ofy().load().key(domain.getRegistrant()).now().getContactId());
|
||||
// If authInfo is non-null, then the caller is authorized to see the full information since we
|
||||
// will have already verified the authInfo is valid.
|
||||
if (!(clientId.equals(domain.getCurrentSponsorClientId()) || authInfo.isPresent())) {
|
||||
// Registrars can only see a few fields on unauthorized domains.
|
||||
// This is a policy decision that is left up to us by the rfcs.
|
||||
return new DomainResource.Builder()
|
||||
.setFullyQualifiedDomainName(domain.getFullyQualifiedDomainName())
|
||||
.setRepoId(domain.getRepoId())
|
||||
.setCurrentSponsorClientId(domain.getCurrentSponsorClientId())
|
||||
.setRegistrant(domain.getRegistrant())
|
||||
// If we didn't do this, we'd get implicit status values.
|
||||
.buildWithoutImplicitStatusValues();
|
||||
if (clientId.equals(domain.getCurrentSponsorClientId()) || authInfo.isPresent()) {
|
||||
HostsRequest hostsRequest = ((Info) resourceCommand).getHostsRequest();
|
||||
infoBuilder
|
||||
.setStatusValues(domain.getStatusValues())
|
||||
.setContacts(loadForeignKeyedDesignatedContacts(domain.getContacts()))
|
||||
.setNameservers(hostsRequest.requestDelegated()
|
||||
? domain.loadNameserverFullyQualifiedHostNames()
|
||||
: null)
|
||||
.setSubordinateHosts(hostsRequest.requestSubordinate()
|
||||
? domain.getSubordinateHosts()
|
||||
: null)
|
||||
.setCreationClientId(domain.getCreationClientId())
|
||||
.setCreationTime(domain.getCreationTime())
|
||||
.setLastEppUpdateClientId(domain.getLastEppUpdateClientId())
|
||||
.setLastEppUpdateTime(domain.getLastEppUpdateTime())
|
||||
.setRegistrationExpirationTime(domain.getRegistrationExpirationTime())
|
||||
.setLastTransferTime(domain.getLastTransferTime())
|
||||
.setAuthInfo(domain.getAuthInfo());
|
||||
}
|
||||
HostsRequest hostsRequest = ((Info) resourceCommand).getHostsRequest();
|
||||
Builder info = domain.asBuilder();
|
||||
if (!hostsRequest.requestSubordinate()) {
|
||||
info.setSubordinateHosts(null);
|
||||
}
|
||||
if (!hostsRequest.requestDelegated()) {
|
||||
// Delegated hosts are present by default, so clear them out if they aren't wanted.
|
||||
// This requires overriding the implicit status values so that we don't get INACTIVE added due
|
||||
// to the missing nameservers.
|
||||
return info.setNameservers(null).buildWithoutImplicitStatusValues();
|
||||
}
|
||||
return info.build();
|
||||
return responseBuilder
|
||||
.setResData(infoBuilder.build())
|
||||
.setExtensions(responseData.responseExtensions())
|
||||
.build();
|
||||
}
|
||||
|
||||
private ImmutableList<ResponseExtension> getDomainResponseExtensions(
|
||||
|
|
|
@ -281,11 +281,6 @@ public abstract class EppResource extends BackupGroupRoot implements Buildable {
|
|||
if (difference(getInstance().getStatusValues(), StatusValue.LINKED).isEmpty()) {
|
||||
addStatusValue(StatusValue.OK);
|
||||
}
|
||||
return buildWithoutImplicitStatusValues();
|
||||
}
|
||||
|
||||
/** Build the resource, nullifying empty strings and sets and setting defaults. */
|
||||
public T buildWithoutImplicitStatusValues() {
|
||||
// If there is no deletion time, set it to END_OF_TIME.
|
||||
setDeletionTime(Optional.fromNullable(getInstance().deletionTime).or(END_OF_TIME));
|
||||
return ImmutableObject.cloneEmptyToNull(super.build());
|
||||
|
|
|
@ -57,12 +57,14 @@ public abstract class DomainInfoData implements ResponseData {
|
|||
abstract String getRepoId();
|
||||
|
||||
@XmlElement(name = "status")
|
||||
@Nullable
|
||||
abstract ImmutableSet<StatusValue> getStatusValues();
|
||||
|
||||
@XmlElement(name = "registrant")
|
||||
abstract String getRegistrant();
|
||||
|
||||
@XmlElement(name = "contact")
|
||||
@Nullable
|
||||
abstract ImmutableSet<ForeignKeyedDesignatedContact> getContacts();
|
||||
|
||||
@XmlElementWrapper(name = "ns")
|
||||
|
@ -110,9 +112,10 @@ public abstract class DomainInfoData implements ResponseData {
|
|||
public abstract static class Builder {
|
||||
public abstract Builder setFullyQualifiedDomainName(String fullyQualifiedDomainName);
|
||||
public abstract Builder setRepoId(String repoId);
|
||||
public abstract Builder setStatusValues(ImmutableSet<StatusValue> statusValues);
|
||||
public abstract Builder setStatusValues(@Nullable ImmutableSet<StatusValue> statusValues);
|
||||
public abstract Builder setRegistrant(String registrant);
|
||||
public abstract Builder setContacts(ImmutableSet<ForeignKeyedDesignatedContact> contacts);
|
||||
public abstract Builder setContacts(
|
||||
@Nullable ImmutableSet<ForeignKeyedDesignatedContact> contacts);
|
||||
public abstract Builder setNameservers(@Nullable ImmutableSet<String> nameservers);
|
||||
public abstract Builder setSubordinateHosts(@Nullable ImmutableSet<String> subordinateHosts);
|
||||
public abstract Builder setCurrentSponsorClientId(String currentSponsorClientId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue