// Copyright 2017 The Nomulus Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package google.registry.model; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.Sets.difference; import static com.google.common.collect.Sets.union; import static google.registry.util.CollectionUtils.difference; import static google.registry.util.CollectionUtils.nullToEmpty; import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy; import static google.registry.util.DateTimeUtils.END_OF_TIME; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedMap; import com.googlecode.objectify.Key; import com.googlecode.objectify.annotation.Id; import com.googlecode.objectify.annotation.Index; import com.googlecode.objectify.annotation.OnLoad; import google.registry.model.eppcommon.StatusValue; import google.registry.model.ofy.CommitLogManifest; import google.registry.model.transfer.TransferData; import java.util.Set; import org.joda.time.DateTime; /** An EPP entity object (i.e. a domain, application, contact, or host). */ public abstract class EppResource extends BackupGroupRoot implements Buildable { /** * Unique identifier in the registry for this resource. * *
This is in the (\w|_){1,80}-\w{1,8} format specified by RFC 5730 for roidType. * @see RFC 5730 */ @Id String repoId; /** The ID of the registrar that is currently sponsoring this resource. */ @Index String currentSponsorClientId; /** The ID of the registrar that created this resource. */ String creationClientId; /** * The ID of the registrar that last updated this resource. * *
This does not refer to the last delta made on this object, which might include out-of-band
* edits; it only includes EPP-visible modifications such as {@literal This scheme allows for setting pending deletes in the future and having them magically drop
* out of the index at that time, as long as we query for resources whose deletion time is before
* now.
*/
@Index
DateTime deletionTime;
/**
* The time that this resource was last updated.
*
* This does not refer to the last delta made on this object, which might include out-of-band
* edits; it only includes EPP-visible modifications such as {@literal Note: Only the last revision on a given date is stored. The key is the transaction
* timestamp, not midnight.
*
* @see google.registry.model.translators.CommitLogRevisionsTranslatorFactory
*/
ImmutableSortedMap For subordinate hosts, this value may not represent the actual current client id, which is
* the client id of the superordinate host. For all other resources this is the true client id.
*/
public final String getPersistedCurrentSponsorClientId() {
return currentSponsorClientId;
}
public final ImmutableSet Can be null if the resource has never been transferred.
*/
public DateTime getLastTransferTime();
}
/** An interface for builders of resources that have transfer data. */
public interface BuilderWithTransferData> {
public B setTransferData(TransferData transferData);
/** Set the time when this resource was transferred. */
public B setLastTransferTime(DateTime lastTransferTime);
}
/** Abstract builder for {@link EppResource} types. */
public abstract static class Builder Note: This can only be used if the creation time hasn't already been set, which it is in
* normal EPP flows.
*/
public B setCreationTime(DateTime creationTime) {
checkState(getInstance().creationTime.timestamp == null,
"creationTime can only be set once for EppResource.");
getInstance().creationTime = CreateAutoTimestamp.create(creationTime);
return thisCastToDerived();
}
/** Set the time this resource was created. Should only be used in tests. */
@VisibleForTesting
public B setCreationTimeForTest(DateTime creationTime) {
getInstance().creationTime = CreateAutoTimestamp.create(creationTime);
return thisCastToDerived();
}
/** Set the time after which this resource should be considered deleted. */
public B setDeletionTime(DateTime deletionTime) {
getInstance().deletionTime = deletionTime;
return thisCastToDerived();
}
/** Set the current sponsoring registrar. */
public B setPersistedCurrentSponsorClientId(String currentSponsorClientId) {
getInstance().currentSponsorClientId = currentSponsorClientId;
return thisCastToDerived();
}
/** Set the registrar that created this resource. */
public B setCreationClientId(String creationClientId) {
getInstance().creationClientId = creationClientId;
return thisCastToDerived();
}
/** Set the time when a {@literal
*
*
*