mirror of
https://github.com/google/nomulus.git
synced 2025-07-07 03:33:28 +02:00
Convert DomainTransferRejectFlow to use tm() methods (#977)
* Convert DomainTransferRejectFlow to use tm() methods This change includes a few other necessary dependencies to converting DomainTransferRejectFlowTest to be a dual-database test. Namely: - The basic "use tm() instead of ofy()" and "branching database selection on what were previously raw ofy queries" - Modification of the PollMessage convertVKey methods to do what they say they do - Filling the generic pending / response fields in PollMessage based on what type of poll message it is (this has to be done because SQL is not very good at storing ambiguous superclasses) - Setting the generic pending / repsonse fields in PollMessage upon build - Filling out the serverApproveEntities field in DomainTransferData with all necessary poll messages / billing events that should be cancelled on rejection - Scattered changes in DatabaseHelper to make sure that we're saving and loading entities correctly where we weren't before
This commit is contained in:
parent
e07139665e
commit
4176f7dd9c
14 changed files with 300 additions and 171 deletions
|
@ -23,11 +23,11 @@ import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_CREATE;
|
|||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_TRANSFER_REJECT;
|
||||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST;
|
||||
import static google.registry.testing.DatabaseHelper.assertBillingEvents;
|
||||
import static google.registry.testing.DatabaseHelper.deleteResource;
|
||||
import static google.registry.testing.DatabaseHelper.getOnlyHistoryEntryOfType;
|
||||
import static google.registry.testing.DatabaseHelper.getOnlyPollMessage;
|
||||
import static google.registry.testing.DatabaseHelper.getPollMessages;
|
||||
import static google.registry.testing.DatabaseHelper.loadRegistrar;
|
||||
import static google.registry.testing.DatabaseHelper.persistDomainAsDeleted;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DomainBaseSubject.assertAboutDomains;
|
||||
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||
|
@ -56,12 +56,14 @@ import google.registry.model.reporting.HistoryEntry;
|
|||
import google.registry.model.transfer.TransferData;
|
||||
import google.registry.model.transfer.TransferResponse;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link DomainTransferRejectFlow}. */
|
||||
@DualDatabaseTest
|
||||
class DomainTransferRejectFlowTest
|
||||
extends DomainTransferFlowTestCase<DomainTransferRejectFlow, DomainBase> {
|
||||
|
||||
|
@ -151,31 +153,31 @@ class DomainTransferRejectFlowTest
|
|||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testSuccess() throws Exception {
|
||||
doSuccessfulTest("domain_transfer_reject.xml", "domain_transfer_reject_response.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testDryRun() throws Exception {
|
||||
setEppInput("domain_transfer_reject.xml");
|
||||
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
|
||||
dryRunFlowAssertResponse(loadFile("domain_transfer_reject_response.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testSuccess_domainAuthInfo() throws Exception {
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_reject_domain_authinfo.xml", "domain_transfer_reject_response.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testSuccess_contactAuthInfo() throws Exception {
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_reject_contact_authinfo.xml", "domain_transfer_reject_response.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testFailure_notAuthorizedForTld() {
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
|
||||
|
@ -188,7 +190,7 @@ class DomainTransferRejectFlowTest
|
|||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testSuccess_superuserNotAuthorizedForTld() throws Exception {
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
|
||||
|
@ -196,7 +198,7 @@ class DomainTransferRejectFlowTest
|
|||
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_transfer_reject_response.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testFailure_badContactPassword() {
|
||||
// Change the contact's password so it does not match the password in the file.
|
||||
contact =
|
||||
|
@ -212,7 +214,7 @@ class DomainTransferRejectFlowTest
|
|||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testFailure_badDomainPassword() {
|
||||
// Change the domain's password so it does not match the password in the file.
|
||||
domain =
|
||||
|
@ -228,7 +230,7 @@ class DomainTransferRejectFlowTest
|
|||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testFailure_neverBeenTransferred() {
|
||||
changeTransferStatus(null);
|
||||
EppException thrown =
|
||||
|
@ -237,7 +239,7 @@ class DomainTransferRejectFlowTest
|
|||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testFailure_clientApproved() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
|
||||
EppException thrown =
|
||||
|
@ -246,7 +248,7 @@ class DomainTransferRejectFlowTest
|
|||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testFailure_clientRejected() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
|
||||
EppException thrown =
|
||||
|
@ -255,7 +257,7 @@ class DomainTransferRejectFlowTest
|
|||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testFailure_clientCancelled() {
|
||||
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
|
||||
EppException thrown =
|
||||
|
@ -264,7 +266,7 @@ class DomainTransferRejectFlowTest
|
|||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testFailure_serverApproved() {
|
||||
changeTransferStatus(TransferStatus.SERVER_APPROVED);
|
||||
EppException thrown =
|
||||
|
@ -273,7 +275,7 @@ class DomainTransferRejectFlowTest
|
|||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testFailure_serverCancelled() {
|
||||
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
||||
EppException thrown =
|
||||
|
@ -282,7 +284,7 @@ class DomainTransferRejectFlowTest
|
|||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testFailure_gainingClient() {
|
||||
setClientIdForFlow("NewRegistrar");
|
||||
EppException thrown =
|
||||
|
@ -291,7 +293,7 @@ class DomainTransferRejectFlowTest
|
|||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testFailure_unrelatedClient() {
|
||||
setClientIdForFlow("ClientZ");
|
||||
EppException thrown =
|
||||
|
@ -300,7 +302,7 @@ class DomainTransferRejectFlowTest
|
|||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testFailure_deletedDomain() throws Exception {
|
||||
domain =
|
||||
persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||
|
@ -310,9 +312,9 @@ class DomainTransferRejectFlowTest
|
|||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testFailure_nonexistentDomain() throws Exception {
|
||||
deleteResource(domain);
|
||||
persistDomainAsDeleted(domain, clock.nowUtc());
|
||||
ResourceDoesNotExistException thrown =
|
||||
assertThrows(
|
||||
ResourceDoesNotExistException.class, () -> doFailingTest("domain_transfer_reject.xml"));
|
||||
|
@ -322,7 +324,7 @@ class DomainTransferRejectFlowTest
|
|||
// NB: No need to test pending delete status since pending transfers will get cancelled upon
|
||||
// entering pending delete phase. So it's already handled in that test case.
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testIcannActivityReportField_getsLogged() throws Exception {
|
||||
runFlow();
|
||||
assertIcannReportingActivityFieldLogged("srs-dom-transfer-reject");
|
||||
|
@ -338,7 +340,7 @@ class DomainTransferRejectFlowTest
|
|||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testIcannTransactionRecord_noRecordsToCancel() throws Exception {
|
||||
setUpGracePeriodDurations();
|
||||
runFlow();
|
||||
|
@ -348,7 +350,7 @@ class DomainTransferRejectFlowTest
|
|||
.containsExactly(DomainTransactionRecord.create("tld", clock.nowUtc(), TRANSFER_NACKED, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testIcannTransactionRecord_cancelsPreviousRecords() throws Exception {
|
||||
setUpGracePeriodDurations();
|
||||
DomainTransactionRecord previousSuccessRecord =
|
||||
|
|
|
@ -21,6 +21,7 @@ import static com.google.common.truth.Truth.assertThat;
|
|||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.truth.Correspondence;
|
||||
import com.google.common.truth.Correspondence.BinaryPredicate;
|
||||
|
@ -50,6 +51,11 @@ public final class ImmutableObjectSubject extends Subject {
|
|||
this.actual = actual;
|
||||
}
|
||||
|
||||
public void isEqualExceptFields(
|
||||
@Nullable ImmutableObject expected, Iterable<String> ignoredFields) {
|
||||
isEqualExceptFields(expected, Iterables.toArray(ignoredFields, String.class));
|
||||
}
|
||||
|
||||
public void isEqualExceptFields(@Nullable ImmutableObject expected, String... ignoredFields) {
|
||||
if (actual == null) {
|
||||
assertThat(expected).isNull();
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.model.domain;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.flows.domain.DomainTransferUtils.createPendingTransferData;
|
||||
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
|
@ -34,11 +35,13 @@ import google.registry.model.billing.BillingEvent.Reason;
|
|||
import google.registry.model.common.EntityGroupRoot;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.domain.DesignatedContact.Type;
|
||||
import google.registry.model.domain.Period.Unit;
|
||||
import google.registry.model.domain.launch.LaunchNotice;
|
||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.eppcommon.Trid;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.poll.PollMessage;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
|
@ -54,6 +57,7 @@ import org.joda.money.Money;
|
|||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.testcontainers.shaded.com.google.common.collect.ImmutableList;
|
||||
|
||||
/** Verify that we can store/retrieve DomainBase objects from a SQL database. */
|
||||
@DualDatabaseTest
|
||||
|
@ -617,15 +621,15 @@ public class DomainBaseSqlTest {
|
|||
.setParent(historyEntry)
|
||||
.build();
|
||||
DomainTransferData transferData =
|
||||
new DomainTransferData.Builder()
|
||||
.setServerApproveBillingEvent(
|
||||
createLegacyVKey(BillingEvent.OneTime.class, oneTimeBillingEvent.getId()))
|
||||
.setServerApproveAutorenewEvent(
|
||||
createLegacyVKey(BillingEvent.Recurring.class, billEvent.getId()))
|
||||
.setServerApproveAutorenewPollMessage(
|
||||
createLegacyVKey(
|
||||
PollMessage.Autorenew.class, autorenewPollMessage.getId()))
|
||||
.build();
|
||||
createPendingTransferData(
|
||||
new DomainTransferData.Builder()
|
||||
.setTransferRequestTrid(Trid.create("foo", "bar"))
|
||||
.setTransferRequestTime(fakeClock.nowUtc())
|
||||
.setGainingClientId("registrar2")
|
||||
.setLosingClientId("registrar1")
|
||||
.setPendingTransferExpirationTime(fakeClock.nowUtc().plusDays(1)),
|
||||
ImmutableSet.of(oneTimeBillingEvent, billEvent, autorenewPollMessage),
|
||||
Period.create(0, Unit.YEARS));
|
||||
gracePeriods =
|
||||
ImmutableSet.of(
|
||||
GracePeriod.create(
|
||||
|
@ -708,10 +712,17 @@ public class DomainBaseSqlTest {
|
|||
// Fix the original creation timestamp (this gets initialized on first write)
|
||||
DomainBase org = domain.asBuilder().setCreationTime(thatDomain.getCreationTime()).build();
|
||||
|
||||
String[] moreExcepts = Arrays.copyOf(excepts, excepts.length + 1);
|
||||
moreExcepts[moreExcepts.length - 1] = "updateTimestamp";
|
||||
|
||||
ImmutableList<String> moreExcepts =
|
||||
new ImmutableList.Builder<String>()
|
||||
.addAll(Arrays.asList(excepts))
|
||||
.add("updateTimestamp")
|
||||
.add("transferData")
|
||||
.build();
|
||||
// Note that the equality comparison forces a lazy load of all fields.
|
||||
assertAboutImmutableObjects().that(thatDomain).isEqualExceptFields(org, moreExcepts);
|
||||
// Transfer data cannot be directly compared due to serverApproveEtities inequalities
|
||||
assertAboutImmutableObjects()
|
||||
.that(domain.getTransferData())
|
||||
.isEqualExceptFields(org.getTransferData(), "serverApproveEntities");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -326,8 +326,7 @@ public class DatabaseHelper {
|
|||
* Returns a persisted domain that is the passed-in domain modified to be deleted at the specified
|
||||
* time.
|
||||
*/
|
||||
public static DomainBase persistDomainAsDeleted(
|
||||
DomainBase domain, DateTime deletionTime) {
|
||||
public static DomainBase persistDomainAsDeleted(DomainBase domain, DateTime deletionTime) {
|
||||
return persistResource(domain.asBuilder().setDeletionTime(deletionTime).build());
|
||||
}
|
||||
|
||||
|
@ -347,7 +346,7 @@ public class DatabaseHelper {
|
|||
}
|
||||
|
||||
public static ReservedList persistReservedList(
|
||||
String listName, boolean shouldPublish, String... lines) {
|
||||
String listName, boolean shouldPublish, String... lines) {
|
||||
ReservedList reservedList =
|
||||
new ReservedList.Builder()
|
||||
.setName(listName)
|
||||
|
@ -512,10 +511,7 @@ public class DatabaseHelper {
|
|||
}
|
||||
|
||||
public static BillingEvent.OneTime createBillingEventForTransfer(
|
||||
DomainBase domain,
|
||||
HistoryEntry historyEntry,
|
||||
DateTime costLookupTime,
|
||||
DateTime eventTime) {
|
||||
DomainBase domain, HistoryEntry historyEntry, DateTime costLookupTime, DateTime eventTime) {
|
||||
return new BillingEvent.OneTime.Builder()
|
||||
.setReason(Reason.TRANSFER)
|
||||
.setTargetId(domain.getDomainName())
|
||||
|
@ -530,10 +526,7 @@ public class DatabaseHelper {
|
|||
}
|
||||
|
||||
public static ContactResource persistContactWithPendingTransfer(
|
||||
ContactResource contact,
|
||||
DateTime requestTime,
|
||||
DateTime expirationTime,
|
||||
DateTime now) {
|
||||
ContactResource contact, DateTime requestTime, DateTime expirationTime, DateTime now) {
|
||||
HistoryEntry historyEntryContactTransfer =
|
||||
persistResource(
|
||||
new HistoryEntry.Builder()
|
||||
|
@ -587,26 +580,29 @@ public class DatabaseHelper {
|
|||
String domainName = String.format("%s.%s", label, tld);
|
||||
String repoId = generateNewDomainRoid(tld);
|
||||
DomainBase domain =
|
||||
new DomainBase.Builder()
|
||||
.setRepoId(repoId)
|
||||
.setDomainName(domainName)
|
||||
.setPersistedCurrentSponsorClientId("TheRegistrar")
|
||||
.setCreationClientId("TheRegistrar")
|
||||
.setCreationTimeForTest(creationTime)
|
||||
.setRegistrationExpirationTime(expirationTime)
|
||||
.setRegistrant(contact.createVKey())
|
||||
.setContacts(
|
||||
ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, contact.createVKey()),
|
||||
DesignatedContact.create(Type.TECH, contact.createVKey())))
|
||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("fooBAR")))
|
||||
.addGracePeriod(
|
||||
GracePeriod.create(GracePeriodStatus.ADD, repoId, now.plusDays(10), "foo", null))
|
||||
.build();
|
||||
HistoryEntry historyEntryDomainCreate =
|
||||
persistResource(
|
||||
new HistoryEntry.Builder()
|
||||
new DomainBase.Builder()
|
||||
.setRepoId(repoId)
|
||||
.setDomainName(domainName)
|
||||
.setPersistedCurrentSponsorClientId("TheRegistrar")
|
||||
.setCreationClientId("TheRegistrar")
|
||||
.setCreationTimeForTest(creationTime)
|
||||
.setRegistrationExpirationTime(expirationTime)
|
||||
.setRegistrant(contact.createVKey())
|
||||
.setContacts(
|
||||
ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, contact.createVKey()),
|
||||
DesignatedContact.create(Type.TECH, contact.createVKey())))
|
||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("fooBAR")))
|
||||
.addGracePeriod(
|
||||
GracePeriod.create(
|
||||
GracePeriodStatus.ADD, repoId, now.plusDays(10), "TheRegistrar", null))
|
||||
.build());
|
||||
DomainHistory historyEntryDomainCreate =
|
||||
persistResource(
|
||||
new DomainHistory.Builder()
|
||||
.setType(HistoryEntry.Type.DOMAIN_CREATE)
|
||||
.setModificationTime(now)
|
||||
.setParent(domain)
|
||||
.build());
|
||||
BillingEvent.Recurring autorenewEvent =
|
||||
|
@ -643,18 +639,17 @@ public class DatabaseHelper {
|
|||
DateTime requestTime,
|
||||
DateTime expirationTime,
|
||||
DateTime extendedRegistrationExpirationTime) {
|
||||
HistoryEntry historyEntryDomainTransfer =
|
||||
DomainHistory historyEntryDomainTransfer =
|
||||
persistResource(
|
||||
new HistoryEntry.Builder()
|
||||
new DomainHistory.Builder()
|
||||
.setType(HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST)
|
||||
.setModificationTime(tm().transact(() -> tm().getTransactionTime()))
|
||||
.setParent(domain)
|
||||
.build());
|
||||
BillingEvent.OneTime transferBillingEvent = persistResource(createBillingEventForTransfer(
|
||||
domain,
|
||||
historyEntryDomainTransfer,
|
||||
requestTime,
|
||||
expirationTime));
|
||||
BillingEvent.OneTime transferBillingEvent =
|
||||
persistResource(
|
||||
createBillingEventForTransfer(
|
||||
domain, historyEntryDomainTransfer, requestTime, expirationTime));
|
||||
BillingEvent.Recurring gainingClientAutorenewEvent =
|
||||
persistResource(
|
||||
new BillingEvent.Recurring.Builder()
|
||||
|
@ -678,18 +673,18 @@ public class DatabaseHelper {
|
|||
.build());
|
||||
// Modify the existing autorenew event to reflect the pending transfer.
|
||||
persistResource(
|
||||
tm().loadByKey(domain.getAutorenewBillingEvent())
|
||||
.asBuilder()
|
||||
.setRecurrenceEndTime(expirationTime)
|
||||
.build());
|
||||
transactIfJpaTm(
|
||||
() ->
|
||||
tm().loadByKey(domain.getAutorenewBillingEvent())
|
||||
.asBuilder()
|
||||
.setRecurrenceEndTime(expirationTime)
|
||||
.build()));
|
||||
// Update the end time of the existing autorenew poll message. We must delete it if it has no
|
||||
// events left in it.
|
||||
PollMessage.Autorenew autorenewPollMessage = tm().loadByKey(domain.getAutorenewPollMessage());
|
||||
PollMessage.Autorenew autorenewPollMessage =
|
||||
transactIfJpaTm(() -> tm().loadByKey(domain.getAutorenewPollMessage()));
|
||||
if (autorenewPollMessage.getEventTime().isBefore(expirationTime)) {
|
||||
persistResource(
|
||||
autorenewPollMessage.asBuilder()
|
||||
.setAutorenewEndTime(expirationTime)
|
||||
.build());
|
||||
persistResource(autorenewPollMessage.asBuilder().setAutorenewEndTime(expirationTime).build());
|
||||
} else {
|
||||
deleteResource(autorenewPollMessage);
|
||||
}
|
||||
|
@ -928,11 +923,8 @@ public class DatabaseHelper {
|
|||
}
|
||||
|
||||
public static PollMessage getOnlyPollMessage(
|
||||
String clientId,
|
||||
DateTime now,
|
||||
Class<? extends PollMessage> subType) {
|
||||
return getPollMessages(clientId, now)
|
||||
.stream()
|
||||
String clientId, DateTime now, Class<? extends PollMessage> subType) {
|
||||
return getPollMessages(clientId, now).stream()
|
||||
.filter(subType::isInstance)
|
||||
.map(subType::cast)
|
||||
.collect(onlyElement());
|
||||
|
@ -957,10 +949,7 @@ public class DatabaseHelper {
|
|||
return createDomainRepoId(ObjectifyService.allocateId(), tld);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a newly allocated, globally unique contact/host repoId of the format
|
||||
* HEX_TLD-ROID.
|
||||
*/
|
||||
/** Returns a newly allocated, globally unique contact/host repoId of the format HEX_TLD-ROID. */
|
||||
public static String generateNewContactHostRoid() {
|
||||
return createRepoId(ObjectifyService.allocateId(), getContactAndHostRoidSuffix());
|
||||
}
|
||||
|
@ -1131,8 +1120,7 @@ public class DatabaseHelper {
|
|||
*/
|
||||
public static ImmutableList<HistoryEntry> getHistoryEntriesOfType(
|
||||
EppResource resource, final HistoryEntry.Type type) {
|
||||
return getHistoryEntries(resource)
|
||||
.stream()
|
||||
return getHistoryEntries(resource).stream()
|
||||
.filter(entry -> entry.getType() == type)
|
||||
.collect(toImmutableList());
|
||||
}
|
||||
|
@ -1143,7 +1131,7 @@ public class DatabaseHelper {
|
|||
*/
|
||||
public static HistoryEntry getOnlyHistoryEntryOfType(
|
||||
EppResource resource, final HistoryEntry.Type type) {
|
||||
List<HistoryEntry> historyEntries = getHistoryEntriesOfType(resource, type);
|
||||
List<HistoryEntry> historyEntries = getHistoryEntriesOfType(resource, type);
|
||||
assertThat(historyEntries).hasSize(1);
|
||||
return historyEntries.get(0);
|
||||
}
|
||||
|
@ -1151,13 +1139,16 @@ public class DatabaseHelper {
|
|||
private static HistoryEntry.Type getHistoryEntryType(EppResource resource) {
|
||||
if (resource instanceof ContactResource) {
|
||||
return resource.getRepoId() != null
|
||||
? HistoryEntry.Type.CONTACT_CREATE : HistoryEntry.Type.CONTACT_UPDATE;
|
||||
? HistoryEntry.Type.CONTACT_CREATE
|
||||
: HistoryEntry.Type.CONTACT_UPDATE;
|
||||
} else if (resource instanceof HostResource) {
|
||||
return resource.getRepoId() != null
|
||||
? HistoryEntry.Type.HOST_CREATE : HistoryEntry.Type.HOST_UPDATE;
|
||||
? HistoryEntry.Type.HOST_CREATE
|
||||
: HistoryEntry.Type.HOST_UPDATE;
|
||||
} else if (resource instanceof DomainBase) {
|
||||
return resource.getRepoId() != null
|
||||
? HistoryEntry.Type.DOMAIN_CREATE : HistoryEntry.Type.DOMAIN_UPDATE;
|
||||
? HistoryEntry.Type.DOMAIN_CREATE
|
||||
: HistoryEntry.Type.DOMAIN_UPDATE;
|
||||
} else {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
@ -1215,7 +1206,7 @@ public class DatabaseHelper {
|
|||
tm().clearSessionCache();
|
||||
}
|
||||
|
||||
/** Force the create and update timestamps to get written into the resource. **/
|
||||
/** Force the create and update timestamps to get written into the resource. */
|
||||
public static <R> R cloneAndSetAutoTimestamps(final R resource) {
|
||||
R result;
|
||||
if (tm().isOfy()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue