mirror of
https://github.com/google/nomulus.git
synced 2025-06-28 23:33:36 +02:00
[]
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=133597433
This commit is contained in:
parent
c30c5bc399
commit
0518f63aad
5 changed files with 76 additions and 40 deletions
|
@ -217,6 +217,60 @@ public class ResourceFlowUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn a resource into a builder with its pending transfer resolved.
|
||||||
|
*
|
||||||
|
* <p>This removes the {@link StatusValue#PENDING_TRANSFER} status, sets the
|
||||||
|
* {@link TransferStatus}, clears all the server-approve fields on the {@link TransferData}
|
||||||
|
* including the extended registration years field, and sets the expiration time of the last
|
||||||
|
* pending transfer to now.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private static <R extends EppResource> EppResource.Builder<R, ?> resolvePendingTransfer(
|
||||||
|
R resource, TransferStatus transferStatus, DateTime now) {
|
||||||
|
return (EppResource.Builder<R, ?>) resource.asBuilder()
|
||||||
|
.removeStatusValue(StatusValue.PENDING_TRANSFER)
|
||||||
|
.setTransferData(resource.getTransferData().asBuilder()
|
||||||
|
.setExtendedRegistrationYears(null)
|
||||||
|
.setServerApproveEntities(null)
|
||||||
|
.setServerApproveBillingEvent(null)
|
||||||
|
.setServerApproveAutorenewEvent(null)
|
||||||
|
.setServerApproveAutorenewPollMessage(null)
|
||||||
|
.setTransferStatus(transferStatus)
|
||||||
|
.setPendingTransferExpirationTime(now)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve a pending transfer by awarding it to the gaining client.
|
||||||
|
*
|
||||||
|
* <p>This removes the {@link StatusValue#PENDING_TRANSFER} status, sets the
|
||||||
|
* {@link TransferStatus}, clears all the server-approve fields on the {@link TransferData}
|
||||||
|
* including the extended registration years field, and sets the expiration time of the last
|
||||||
|
* pending transfer to now.
|
||||||
|
*/
|
||||||
|
public static <R extends EppResource> R approvePendingTransfer(
|
||||||
|
R resource, TransferStatus transferStatus, DateTime now) {
|
||||||
|
Builder<R, ?> builder = resolvePendingTransfer(resource, transferStatus, now);
|
||||||
|
builder
|
||||||
|
.setLastTransferTime(now)
|
||||||
|
.setCurrentSponsorClientId(resource.getTransferData().getGainingClientId());
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve a pending transfer by denying it.
|
||||||
|
*
|
||||||
|
* <p>This removes the {@link StatusValue#PENDING_TRANSFER} status, sets the
|
||||||
|
* {@link TransferStatus}, clears all the server-approve fields on the {@link TransferData}
|
||||||
|
* including the extended registration years field, sets the new client id, and sets the last
|
||||||
|
* transfer time and the expiration time of the last pending transfer to now.
|
||||||
|
*/
|
||||||
|
public static <R extends EppResource> R denyPendingTransfer(
|
||||||
|
R resource, TransferStatus transferStatus, DateTime now) {
|
||||||
|
return resolvePendingTransfer(resource, transferStatus, now).build();
|
||||||
|
}
|
||||||
|
|
||||||
/** The specified resource belongs to another client. */
|
/** The specified resource belongs to another client. */
|
||||||
public static class ResourceNotOwnedException extends AuthorizationErrorException {
|
public static class ResourceNotOwnedException extends AuthorizationErrorException {
|
||||||
public ResourceNotOwnedException() {
|
public ResourceNotOwnedException() {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
package google.registry.flows.contact;
|
package google.registry.flows.contact;
|
||||||
|
|
||||||
|
import static google.registry.flows.ResourceFlowUtils.approvePendingTransfer;
|
||||||
import static google.registry.flows.ResourceFlowUtils.verifyOptionalAuthInfoForResource;
|
import static google.registry.flows.ResourceFlowUtils.verifyOptionalAuthInfoForResource;
|
||||||
import static google.registry.flows.ResourceFlowUtils.verifyResourceOwnership;
|
import static google.registry.flows.ResourceFlowUtils.verifyResourceOwnership;
|
||||||
import static google.registry.flows.contact.ContactFlowUtils.createGainingTransferPollMessage;
|
import static google.registry.flows.contact.ContactFlowUtils.createGainingTransferPollMessage;
|
||||||
|
@ -38,6 +39,7 @@ import google.registry.model.eppinput.ResourceCommand;
|
||||||
import google.registry.model.eppoutput.EppOutput;
|
import google.registry.model.eppoutput.EppOutput;
|
||||||
import google.registry.model.poll.PollMessage;
|
import google.registry.model.poll.PollMessage;
|
||||||
import google.registry.model.reporting.HistoryEntry;
|
import google.registry.model.reporting.HistoryEntry;
|
||||||
|
import google.registry.model.transfer.TransferData;
|
||||||
import google.registry.model.transfer.TransferStatus;
|
import google.registry.model.transfer.TransferStatus;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@ -70,15 +72,13 @@ public class ContactTransferApproveFlow extends LoggedInFlow implements Transact
|
||||||
throw new ResourceToMutateDoesNotExistException(ContactResource.class, targetId);
|
throw new ResourceToMutateDoesNotExistException(ContactResource.class, targetId);
|
||||||
}
|
}
|
||||||
verifyOptionalAuthInfoForResource(authInfo, existingResource);
|
verifyOptionalAuthInfoForResource(authInfo, existingResource);
|
||||||
if (existingResource.getTransferData().getTransferStatus() != TransferStatus.PENDING) {
|
TransferData transferData = existingResource.getTransferData();
|
||||||
|
if (transferData.getTransferStatus() != TransferStatus.PENDING) {
|
||||||
throw new NotPendingTransferException(targetId);
|
throw new NotPendingTransferException(targetId);
|
||||||
}
|
}
|
||||||
verifyResourceOwnership(clientId, existingResource);
|
verifyResourceOwnership(clientId, existingResource);
|
||||||
ContactResource newResource = existingResource.asBuilder()
|
ContactResource newResource =
|
||||||
.clearPendingTransfer(TransferStatus.CLIENT_APPROVED, now)
|
approvePendingTransfer(existingResource, TransferStatus.CLIENT_APPROVED, now);
|
||||||
.setLastTransferTime(now)
|
|
||||||
.setCurrentSponsorClientId(existingResource.getTransferData().getGainingClientId())
|
|
||||||
.build();
|
|
||||||
HistoryEntry historyEntry = historyBuilder
|
HistoryEntry historyEntry = historyBuilder
|
||||||
.setType(HistoryEntry.Type.CONTACT_TRANSFER_APPROVE)
|
.setType(HistoryEntry.Type.CONTACT_TRANSFER_APPROVE)
|
||||||
.setModificationTime(now)
|
.setModificationTime(now)
|
||||||
|
@ -90,7 +90,7 @@ public class ContactTransferApproveFlow extends LoggedInFlow implements Transact
|
||||||
ofy().save().<Object>entities(newResource, historyEntry, gainingPollMessage);
|
ofy().save().<Object>entities(newResource, historyEntry, gainingPollMessage);
|
||||||
// Delete the billing event and poll messages that were written in case the transfer would have
|
// Delete the billing event and poll messages that were written in case the transfer would have
|
||||||
// been implicitly server approved.
|
// been implicitly server approved.
|
||||||
ofy().delete().keys(existingResource.getTransferData().getServerApproveEntities());
|
ofy().delete().keys(transferData.getServerApproveEntities());
|
||||||
return createOutput(SUCCESS, createTransferResponse(targetId, newResource.getTransferData()));
|
return createOutput(SUCCESS, createTransferResponse(targetId, newResource.getTransferData()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
package google.registry.flows.contact;
|
package google.registry.flows.contact;
|
||||||
|
|
||||||
|
import static google.registry.flows.ResourceFlowUtils.denyPendingTransfer;
|
||||||
import static google.registry.flows.ResourceFlowUtils.verifyOptionalAuthInfoForResource;
|
import static google.registry.flows.ResourceFlowUtils.verifyOptionalAuthInfoForResource;
|
||||||
import static google.registry.flows.contact.ContactFlowUtils.createLosingTransferPollMessage;
|
import static google.registry.flows.contact.ContactFlowUtils.createLosingTransferPollMessage;
|
||||||
import static google.registry.flows.contact.ContactFlowUtils.createTransferResponse;
|
import static google.registry.flows.contact.ContactFlowUtils.createTransferResponse;
|
||||||
|
@ -38,6 +39,7 @@ import google.registry.model.eppinput.ResourceCommand;
|
||||||
import google.registry.model.eppoutput.EppOutput;
|
import google.registry.model.eppoutput.EppOutput;
|
||||||
import google.registry.model.poll.PollMessage;
|
import google.registry.model.poll.PollMessage;
|
||||||
import google.registry.model.reporting.HistoryEntry;
|
import google.registry.model.reporting.HistoryEntry;
|
||||||
|
import google.registry.model.transfer.TransferData;
|
||||||
import google.registry.model.transfer.TransferStatus;
|
import google.registry.model.transfer.TransferStatus;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@ -71,15 +73,15 @@ public class ContactTransferCancelFlow extends LoggedInFlow implements Transacti
|
||||||
throw new ResourceToMutateDoesNotExistException(ContactResource.class, targetId);
|
throw new ResourceToMutateDoesNotExistException(ContactResource.class, targetId);
|
||||||
}
|
}
|
||||||
verifyOptionalAuthInfoForResource(authInfo, existingResource);
|
verifyOptionalAuthInfoForResource(authInfo, existingResource);
|
||||||
if (existingResource.getTransferData().getTransferStatus() != TransferStatus.PENDING) {
|
TransferData transferData = existingResource.getTransferData();
|
||||||
|
if (transferData.getTransferStatus() != TransferStatus.PENDING) {
|
||||||
throw new NotPendingTransferException(targetId);
|
throw new NotPendingTransferException(targetId);
|
||||||
}
|
}
|
||||||
if (!clientId.equals(existingResource.getTransferData().getGainingClientId())) {
|
if (!clientId.equals(transferData.getGainingClientId())) {
|
||||||
throw new NotTransferInitiatorException();
|
throw new NotTransferInitiatorException();
|
||||||
}
|
}
|
||||||
ContactResource newResource = existingResource.asBuilder()
|
ContactResource newResource =
|
||||||
.clearPendingTransfer(TransferStatus.CLIENT_CANCELLED, now)
|
denyPendingTransfer(existingResource, TransferStatus.CLIENT_CANCELLED, now);
|
||||||
.build();
|
|
||||||
HistoryEntry historyEntry = historyBuilder
|
HistoryEntry historyEntry = historyBuilder
|
||||||
.setType(HistoryEntry.Type.CONTACT_TRANSFER_CANCEL)
|
.setType(HistoryEntry.Type.CONTACT_TRANSFER_CANCEL)
|
||||||
.setModificationTime(now)
|
.setModificationTime(now)
|
||||||
|
@ -91,7 +93,7 @@ public class ContactTransferCancelFlow extends LoggedInFlow implements Transacti
|
||||||
ofy().save().<Object>entities(newResource, historyEntry, losingPollMessage);
|
ofy().save().<Object>entities(newResource, historyEntry, losingPollMessage);
|
||||||
// Delete the billing event and poll messages that were written in case the transfer would have
|
// Delete the billing event and poll messages that were written in case the transfer would have
|
||||||
// been implicitly server approved.
|
// been implicitly server approved.
|
||||||
ofy().delete().keys(existingResource.getTransferData().getServerApproveEntities());
|
ofy().delete().keys(transferData.getServerApproveEntities());
|
||||||
return createOutput(SUCCESS, createTransferResponse(targetId, newResource.getTransferData()));
|
return createOutput(SUCCESS, createTransferResponse(targetId, newResource.getTransferData()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
package google.registry.flows.contact;
|
package google.registry.flows.contact;
|
||||||
|
|
||||||
|
import static google.registry.flows.ResourceFlowUtils.denyPendingTransfer;
|
||||||
import static google.registry.flows.ResourceFlowUtils.verifyOptionalAuthInfoForResource;
|
import static google.registry.flows.ResourceFlowUtils.verifyOptionalAuthInfoForResource;
|
||||||
import static google.registry.flows.ResourceFlowUtils.verifyResourceOwnership;
|
import static google.registry.flows.ResourceFlowUtils.verifyResourceOwnership;
|
||||||
import static google.registry.flows.contact.ContactFlowUtils.createGainingTransferPollMessage;
|
import static google.registry.flows.contact.ContactFlowUtils.createGainingTransferPollMessage;
|
||||||
|
@ -37,6 +38,7 @@ import google.registry.model.eppcommon.AuthInfo;
|
||||||
import google.registry.model.eppoutput.EppOutput;
|
import google.registry.model.eppoutput.EppOutput;
|
||||||
import google.registry.model.poll.PollMessage;
|
import google.registry.model.poll.PollMessage;
|
||||||
import google.registry.model.reporting.HistoryEntry;
|
import google.registry.model.reporting.HistoryEntry;
|
||||||
|
import google.registry.model.transfer.TransferData;
|
||||||
import google.registry.model.transfer.TransferStatus;
|
import google.registry.model.transfer.TransferStatus;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@ -68,13 +70,13 @@ public class ContactTransferRejectFlow extends LoggedInFlow implements Transacti
|
||||||
throw new ResourceToMutateDoesNotExistException(ContactResource.class, targetId);
|
throw new ResourceToMutateDoesNotExistException(ContactResource.class, targetId);
|
||||||
}
|
}
|
||||||
verifyOptionalAuthInfoForResource(authInfo, existingResource);
|
verifyOptionalAuthInfoForResource(authInfo, existingResource);
|
||||||
if (existingResource.getTransferData().getTransferStatus() != TransferStatus.PENDING) {
|
TransferData transferData = existingResource.getTransferData();
|
||||||
|
if (transferData.getTransferStatus() != TransferStatus.PENDING) {
|
||||||
throw new NotPendingTransferException(targetId);
|
throw new NotPendingTransferException(targetId);
|
||||||
}
|
}
|
||||||
verifyResourceOwnership(clientId, existingResource);
|
verifyResourceOwnership(clientId, existingResource);
|
||||||
ContactResource newResource = existingResource.asBuilder()
|
ContactResource newResource =
|
||||||
.clearPendingTransfer(TransferStatus.CLIENT_REJECTED, now)
|
denyPendingTransfer(existingResource, TransferStatus.CLIENT_REJECTED, now);
|
||||||
.build();
|
|
||||||
HistoryEntry historyEntry = historyBuilder
|
HistoryEntry historyEntry = historyBuilder
|
||||||
.setType(HistoryEntry.Type.CONTACT_TRANSFER_REJECT)
|
.setType(HistoryEntry.Type.CONTACT_TRANSFER_REJECT)
|
||||||
.setModificationTime(now)
|
.setModificationTime(now)
|
||||||
|
@ -85,7 +87,7 @@ public class ContactTransferRejectFlow extends LoggedInFlow implements Transacti
|
||||||
ofy().save().<Object>entities(newResource, historyEntry, gainingPollMessage);
|
ofy().save().<Object>entities(newResource, historyEntry, gainingPollMessage);
|
||||||
// Delete the billing event and poll messages that were written in case the transfer would have
|
// Delete the billing event and poll messages that were written in case the transfer would have
|
||||||
// been implicitly server approved.
|
// been implicitly server approved.
|
||||||
ofy().delete().keys(existingResource.getTransferData().getServerApproveEntities());
|
ofy().delete().keys(transferData.getServerApproveEntities());
|
||||||
return createOutput(SUCCESS, createTransferResponse(targetId, newResource.getTransferData()));
|
return createOutput(SUCCESS, createTransferResponse(targetId, newResource.getTransferData()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ import google.registry.model.eppcommon.StatusValue;
|
||||||
import google.registry.model.eppoutput.EppResponse.ResponseData;
|
import google.registry.model.eppoutput.EppResponse.ResponseData;
|
||||||
import google.registry.model.ofy.CommitLogManifest;
|
import google.registry.model.ofy.CommitLogManifest;
|
||||||
import google.registry.model.transfer.TransferData;
|
import google.registry.model.transfer.TransferData;
|
||||||
import google.registry.model.transfer.TransferStatus;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlTransient;
|
import javax.xml.bind.annotation.XmlTransient;
|
||||||
|
@ -304,27 +303,6 @@ public abstract class EppResource extends BackupGroupRoot implements Buildable,
|
||||||
return thisCastToDerived();
|
return thisCastToDerived();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a pending transfer.
|
|
||||||
*
|
|
||||||
* <p>This removes the {@link StatusValue#PENDING_TRANSFER} status, clears all the
|
|
||||||
* server-approve fields on the {@link TransferData} including the extended registration years
|
|
||||||
* field, and sets the expiration time of the last pending transfer (i.e. the one being cleared)
|
|
||||||
* to now.
|
|
||||||
*/
|
|
||||||
public B clearPendingTransfer(TransferStatus transferStatus, DateTime now) {
|
|
||||||
removeStatusValue(StatusValue.PENDING_TRANSFER);
|
|
||||||
return setTransferData(getInstance().getTransferData().asBuilder()
|
|
||||||
.setExtendedRegistrationYears(null)
|
|
||||||
.setServerApproveEntities(null)
|
|
||||||
.setServerApproveBillingEvent(null)
|
|
||||||
.setServerApproveAutorenewEvent(null)
|
|
||||||
.setServerApproveAutorenewPollMessage(null)
|
|
||||||
.setTransferStatus(transferStatus)
|
|
||||||
.setPendingTransferExpirationTime(now)
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Wipe out any personal information in the resource. */
|
/** Wipe out any personal information in the resource. */
|
||||||
public B wipeOut() {
|
public B wipeOut() {
|
||||||
return thisCastToDerived();
|
return thisCastToDerived();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue