diff --git a/core/src/main/java/google/registry/model/BackupGroupRoot.java b/core/src/main/java/google/registry/model/BackupGroupRoot.java index 78c1a9480..bb103bc0c 100644 --- a/core/src/main/java/google/registry/model/BackupGroupRoot.java +++ b/core/src/main/java/google/registry/model/BackupGroupRoot.java @@ -60,4 +60,25 @@ public abstract class BackupGroupRoot extends ImmutableObject implements UnsafeS protected void copyUpdateTimestamp(BackupGroupRoot other) { this.updateTimestamp = PreconditionsUtils.checkArgumentNotNull(other, "other").updateTimestamp; } + + /** + * Resets the {@link #updateTimestamp} to force Hibernate to persist it. + * + *
This method is for use in setters in derived builders that do not result in the derived + * object being persisted. + */ + protected void resetUpdateTimestamp() { + this.updateTimestamp = UpdateAutoTimestamp.create(null); + } + + /** + * Sets the {@link #updateTimestamp}. + * + *
This method is for use in the few places where we need to restore the update timestamp after + * mutating a collection in order to force the new timestamp to be persisted when it ordinarily + * wouldn't. + */ + protected void setUpdateTimestamp(UpdateAutoTimestamp timestamp) { + updateTimestamp = timestamp; + } } diff --git a/core/src/main/java/google/registry/model/EppResource.java b/core/src/main/java/google/registry/model/EppResource.java index 77f7e682d..8bad5d6e4 100644 --- a/core/src/main/java/google/registry/model/EppResource.java +++ b/core/src/main/java/google/registry/model/EppResource.java @@ -362,6 +362,16 @@ public abstract class EppResource extends BackupGroupRoot implements Buildable { return thisCastToDerived(); } + /** + * Set the update timestamp. + * + *
This is provided at EppResource since BackupGroupRoot doesn't have a Builder.
+ */
+ public B setUpdateTimestamp(UpdateAutoTimestamp updateTimestamp) {
+ getInstance().setUpdateTimestamp(updateTimestamp);
+ return thisCastToDerived();
+ }
+
/** Build the resource, nullifying empty strings and sets and setting defaults. */
@Override
public T build() {
diff --git a/core/src/main/java/google/registry/model/bulkquery/BulkQueryEntities.java b/core/src/main/java/google/registry/model/bulkquery/BulkQueryEntities.java
index 29b2493a9..8c86f8d06 100644
--- a/core/src/main/java/google/registry/model/bulkquery/BulkQueryEntities.java
+++ b/core/src/main/java/google/registry/model/bulkquery/BulkQueryEntities.java
@@ -74,6 +74,8 @@ public class BulkQueryEntities {
builder.setGracePeriods(gracePeriods);
builder.setDsData(delegationSignerData);
builder.setNameservers(nsHosts);
+ // Restore the original update timestamp (this gets cleared when we set nameservers or DS data).
+ builder.setUpdateTimestamp(domainBaseLite.getUpdateTimestamp());
return builder.build();
}
@@ -100,6 +102,9 @@ public class BulkQueryEntities {
dsDataHistories.stream()
.map(DelegationSignerData::create)
.collect(toImmutableSet()))
+ // Restore the original update timestamp (this gets cleared when we set nameservers or
+ // DS data).
+ .setUpdateTimestamp(domainHistoryLite.domainContent.getUpdateTimestamp())
.build();
builder.setDomain(newDomainContent);
}
diff --git a/core/src/main/java/google/registry/model/domain/DomainContent.java b/core/src/main/java/google/registry/model/domain/DomainContent.java
index 187ee82cb..fb3748613 100644
--- a/core/src/main/java/google/registry/model/domain/DomainContent.java
+++ b/core/src/main/java/google/registry/model/domain/DomainContent.java
@@ -895,6 +895,7 @@ public class DomainContent extends EppResource
public B setDsData(ImmutableSet