Delete end-date sunrise, landrush, and sunrush phases

This also deletes the associated commands and domain application specific
entities.

We haven't used any of these TLD phases since early 2015 and have no
intent to do so in the future, so it makes sense to delete them now so we
don't have to carry them through the Registry 3.0 migration.

Note that, while there are data model changes, there should be no required
data migrations. The fields and entities being removed will simply remain
as orphans. I confirmed that the removed types (such as the SUNRUSH_ADD
GracePeriodType) are no longer used in production data, and left types
that are still used, e.g. BillingEvent.Flag.LANDRUSH or
HistoryEntry.Type.ALLOCATE.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=228752843
This commit is contained in:
mcilwain
2019-01-10 16:23:35 -05:00
committed by Ben McIlwain
parent c74ffd7559
commit 580302898d
282 changed files with 344 additions and 17634 deletions
@@ -1,137 +0,0 @@
// 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.index;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Strings.isNullOrEmpty;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.util.CollectionUtils.isNullOrEmpty;
import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import google.registry.model.BackupGroupRoot;
import google.registry.model.annotations.ReportedOn;
import google.registry.model.domain.DomainApplication;
import google.registry.util.CollectionUtils;
import java.util.Set;
import javax.annotation.Nullable;
import org.joda.time.DateTime;
/**
* Entity for tracking all domain applications with a given fully qualified domain name.
*
* <p>Since this resource is always kept up to date as additional domain applications are created,
* it is never necessary to query them explicitly from Datastore.
*/
@ReportedOn
@Entity
public class DomainApplicationIndex extends BackupGroupRoot {
@Id
String fullyQualifiedDomainName;
/**
* A set of all domain applications with this fully qualified domain name. Never null or empty.
*
* <p>Although this stores {@link Key}s it is named "references" for historical reasons.
*/
Set<Key<DomainApplication>> references;
/** Returns a cloned list of all keys on this index. */
public ImmutableSet<Key<DomainApplication>> getKeys() {
return ImmutableSet.copyOf(references);
}
public String getFullyQualifiedDomainName() {
return fullyQualifiedDomainName;
}
/**
* Creates a DomainApplicationIndex with the specified list of keys.
*
* <p>Only use this method for data migrations. You probably want {@link #createUpdatedInstance}.
*/
public static DomainApplicationIndex createWithSpecifiedKeys(
String fullyQualifiedDomainName, ImmutableSet<Key<DomainApplication>> keys) {
checkArgument(!isNullOrEmpty(fullyQualifiedDomainName),
"fullyQualifiedDomainName must not be null or empty.");
checkArgument(!isNullOrEmpty(keys), "Keys must not be null or empty.");
DomainApplicationIndex instance = new DomainApplicationIndex();
instance.fullyQualifiedDomainName = fullyQualifiedDomainName;
instance.references = keys;
return instance;
}
public static Key<DomainApplicationIndex> createKey(DomainApplication application) {
return Key.create(DomainApplicationIndex.class, application.getFullyQualifiedDomainName());
}
/**
* Returns the set of all active DomainApplications for the given fully qualified domain name.
*
* <p>Note that loading the individual applications referenced by the keys are explicitly
* non-transactional. This is to avoid potentially over-enlisting multiple entity groups within a
* transaction.
*
* <p>Consequently within a transaction this method will not return any applications that are not
* yet committed to datastore, even if called on an updated DomainApplicationIndex instance
* storing keys to those applications.
*/
public static ImmutableSet<DomainApplication> loadActiveApplicationsByDomainName(
String fullyQualifiedDomainName, final DateTime now) {
final DomainApplicationIndex index = load(fullyQualifiedDomainName);
if (index == null) {
return ImmutableSet.of();
}
// Perform eventually consistent query, to avoid overenlisting cross entity groups
return ofy().doTransactionless(() -> {
ImmutableSet.Builder<DomainApplication> apps = new ImmutableSet.Builder<>();
for (DomainApplication app : ofy().load().keys(index.getKeys()).values()) {
if (app.getDeletionTime().isAfter(now)) {
apps.add(app);
}
}
return apps.build();
});
}
/**
* Returns the DomainApplicationIndex for the given fully qualified domain name.
*
* <p>Note that this can return null if there are no domain applications for this fully qualified
* domain name.
*/
@Nullable
public static DomainApplicationIndex load(String fullyQualifiedDomainName) {
return ofy().load().type(DomainApplicationIndex.class).id(fullyQualifiedDomainName).now();
}
/**
* Saves a new DomainApplicationIndex for this resource or updates the existing one.
*
* <p>This is the preferred method for creating an instance of DomainApplicationIndex because this
* performs the correct merging logic to add the given domain application to an existing index if
* there is one.
*/
public static DomainApplicationIndex createUpdatedInstance(DomainApplication application) {
DomainApplicationIndex existing = load(application.getFullyQualifiedDomainName());
ImmutableSet<Key<DomainApplication>> newKeys = CollectionUtils.union(
(existing == null ? ImmutableSet.of() : existing.getKeys()),
Key.create(application));
return createWithSpecifiedKeys(application.getFullyQualifiedDomainName(), newKeys);
}
}