mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 08:57:12 +02:00
Make EppInput.getSingleExtension() return Optional, not @Nullable
This makes it harder to use it incorrectly by accident. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=181795813
This commit is contained in:
parent
fbdb148540
commit
315e6d57bf
21 changed files with 290 additions and 239 deletions
|
@ -68,7 +68,6 @@ import google.registry.model.domain.DomainCommand.Update.AddRemove;
|
|||
import google.registry.model.domain.DomainCommand.Update.Change;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.GracePeriod;
|
||||
import google.registry.model.domain.fee.FeeTransformCommandExtension;
|
||||
import google.registry.model.domain.fee.FeeUpdateCommandExtension;
|
||||
import google.registry.model.domain.metadata.MetadataExtension;
|
||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||
|
@ -222,13 +221,13 @@ public final class DomainUpdateFlow implements TransactionalFlow {
|
|||
checkAllowedAccessToTld(clientId, tld);
|
||||
}
|
||||
Registry registry = Registry.get(tld);
|
||||
FeeTransformCommandExtension feeUpdate =
|
||||
Optional<FeeUpdateCommandExtension> feeUpdate =
|
||||
eppInput.getSingleExtension(FeeUpdateCommandExtension.class);
|
||||
// If the fee extension is present, validate it (even if the cost is zero, to check for price
|
||||
// mismatches). Don't rely on the the validateFeeChallenge check for feeUpdate nullness, because
|
||||
// it throws an error if the name is premium, and we don't want to do that here.
|
||||
FeesAndCredits feesAndCredits = pricingLogic.getUpdatePrice(registry, targetId, now);
|
||||
if (feeUpdate != null) {
|
||||
if (feeUpdate.isPresent()) {
|
||||
validateFeeChallenge(targetId, existingDomain.getTld(), now, feeUpdate, feesAndCredits);
|
||||
} else if (!feesAndCredits.getTotalCost().isZero()) {
|
||||
// If it's not present but the cost is not zero, throw an exception.
|
||||
|
@ -268,14 +267,15 @@ public final class DomainUpdateFlow implements TransactionalFlow {
|
|||
checkSameValuesNotAddedAndRemoved(add.getContacts(), remove.getContacts());
|
||||
checkSameValuesNotAddedAndRemoved(add.getStatusValues(), remove.getStatusValues());
|
||||
Change change = command.getInnerChange();
|
||||
SecDnsUpdateExtension secDnsUpdate = eppInput.getSingleExtension(SecDnsUpdateExtension.class);
|
||||
Optional<SecDnsUpdateExtension> secDnsUpdate =
|
||||
eppInput.getSingleExtension(SecDnsUpdateExtension.class);
|
||||
DomainResource.Builder domainBuilder =
|
||||
domain
|
||||
.asBuilder()
|
||||
// Handle the secDNS extension.
|
||||
.setDsData(
|
||||
secDnsUpdate != null
|
||||
? updateDsData(domain.getDsData(), secDnsUpdate)
|
||||
secDnsUpdate.isPresent()
|
||||
? updateDsData(domain.getDsData(), secDnsUpdate.get())
|
||||
: domain.getDsData())
|
||||
.setLastEppUpdateTime(now)
|
||||
.setLastEppUpdateClientId(clientId)
|
||||
|
@ -355,8 +355,9 @@ public final class DomainUpdateFlow implements TransactionalFlow {
|
|||
DomainResource newDomain,
|
||||
HistoryEntry historyEntry,
|
||||
DateTime now) {
|
||||
MetadataExtension metadataExtension = eppInput.getSingleExtension(MetadataExtension.class);
|
||||
if (metadataExtension != null && metadataExtension.getRequestedByRegistrar()) {
|
||||
Optional<MetadataExtension> metadataExtension =
|
||||
eppInput.getSingleExtension(MetadataExtension.class);
|
||||
if (metadataExtension.isPresent() && metadataExtension.get().getRequestedByRegistrar()) {
|
||||
for (StatusValue statusValue
|
||||
: symmetricDifference(existingDomain.getStatusValues(), newDomain.getStatusValues())) {
|
||||
if (statusValue.isChargedStatus()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue