mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 03:57:51 +02:00
Deal with some getOfyKey() references (#1696)
Now that ofy keys aren't necessarily being restored, it seemed prudent to audit existing uses to verify that we aren't relying on any keys that may now be null. This fixes one case that appeared to be potentially problematic (in ResourceFlowUtils), removes a few methods that call getOfyKey() but are no longer used, and adds comments to one use of the key that appears to be safe after visual inspection.
This commit is contained in:
parent
f62732547f
commit
af63b63477
3 changed files with 3 additions and 27 deletions
|
@ -169,7 +169,7 @@ public final class ResourceFlowUtils {
|
|||
// The roid should match one of the contacts.
|
||||
Optional<VKey<ContactResource>> foundContact =
|
||||
domain.getReferencedContacts().stream()
|
||||
.filter(key -> key.getOfyKey().getName().equals(authRepoId))
|
||||
.filter(key -> key.getSqlKey().equals(authRepoId))
|
||||
.findFirst();
|
||||
if (!foundContact.isPresent()) {
|
||||
throw new BadAuthInfoForResourceException();
|
||||
|
|
|
@ -32,7 +32,6 @@ import com.googlecode.objectify.annotation.Id;
|
|||
import com.googlecode.objectify.annotation.Ignore;
|
||||
import com.googlecode.objectify.annotation.IgnoreSave;
|
||||
import com.googlecode.objectify.annotation.Index;
|
||||
import com.googlecode.objectify.annotation.OnLoad;
|
||||
import com.googlecode.objectify.annotation.Parent;
|
||||
import com.googlecode.objectify.condition.IfNull;
|
||||
import google.registry.model.Buildable;
|
||||
|
@ -205,12 +204,6 @@ public abstract class BillingEvent extends ImmutableObject
|
|||
domainHistoryRevisionId);
|
||||
}
|
||||
|
||||
@OnLoad
|
||||
void onLoad() {
|
||||
domainHistoryRevisionId = parent.getId();
|
||||
domainRepoId = parent.getParent().getName();
|
||||
}
|
||||
|
||||
public String getRegistrarId() {
|
||||
return clientId;
|
||||
}
|
||||
|
@ -437,15 +430,6 @@ public abstract class BillingEvent extends ImmutableObject
|
|||
return new Builder(clone(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
void onLoad() {
|
||||
super.onLoad();
|
||||
if (cancellationMatchingBillingEvent != null) {
|
||||
recurringEventHistoryRevisionId =
|
||||
cancellationMatchingBillingEvent.getOfyKey().getParent().getId();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void postLoad() {
|
||||
super.postLoad();
|
||||
|
@ -493,6 +477,7 @@ public abstract class BillingEvent extends ImmutableObject
|
|||
public Builder setCancellationMatchingBillingEvent(
|
||||
VKey<Recurring> cancellationMatchingBillingEvent) {
|
||||
getInstance().cancellationMatchingBillingEvent = cancellationMatchingBillingEvent;
|
||||
// getOfyKey() here is safe, recurring billing event VKeys have a valid ofy key.
|
||||
getInstance().recurringEventHistoryRevisionId =
|
||||
cancellationMatchingBillingEvent.getOfyKey().getParent().getId();
|
||||
return this;
|
||||
|
@ -526,6 +511,7 @@ public abstract class BillingEvent extends ImmutableObject
|
|||
== (instance.cancellationMatchingBillingEvent != null),
|
||||
"Cancellation matching billing event must be set if and only if the SYNTHETIC flag "
|
||||
+ "is set.");
|
||||
// getOfyKey() here is safe, billing event VKeys have a valid ofy key.
|
||||
checkState(
|
||||
!instance.getFlags().contains(Flag.SYNTHETIC)
|
||||
|| (instance.cancellationMatchingBillingEvent.getOfyKey().getParent().getId()
|
||||
|
|
|
@ -122,16 +122,6 @@ public class DomainTransferData extends TransferData<DomainTransferData.Builder>
|
|||
return super.copyConstantFieldsToBuilder().setTransferPeriod(this.transferPeriod);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix the VKey "kind" for the PollMessage keys.
|
||||
*
|
||||
* <p>For use by DomainBase/DomainHistory OnLoad methods ONLY.
|
||||
*/
|
||||
public void convertVKeys() {
|
||||
serverApproveAutorenewPollMessage =
|
||||
PollMessage.Autorenew.convertVKey(serverApproveAutorenewPollMessage);
|
||||
}
|
||||
|
||||
public Period getTransferPeriod() {
|
||||
return transferPeriod;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue