From c2ed7429d35ff949da10656f70ada1618c5123d1 Mon Sep 17 00:00:00 2001 From: mcilwain Date: Tue, 12 Dec 2017 14:29:27 -0800 Subject: [PATCH] Delete AuctionStatusCommand It's untested, we suspect it's not actually working properly, and we don't intend to ever need to use anything having to do with auctions ever again. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=178815580 --- .../registry/tools/AuctionStatusCommand.java | 120 ------------------ java/google/registry/tools/RegistryTool.java | 1 - 2 files changed, 121 deletions(-) delete mode 100644 java/google/registry/tools/AuctionStatusCommand.java diff --git a/java/google/registry/tools/AuctionStatusCommand.java b/java/google/registry/tools/AuctionStatusCommand.java deleted file mode 100644 index 451d33f1c..000000000 --- a/java/google/registry/tools/AuctionStatusCommand.java +++ /dev/null @@ -1,120 +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.tools; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; -import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName; -import static google.registry.model.ofy.ObjectifyService.ofy; -import static google.registry.model.registry.Registries.findTldForName; -import static java.nio.charset.StandardCharsets.UTF_8; - -import com.beust.jcommander.Parameter; -import com.beust.jcommander.Parameters; -import com.google.common.base.Function; -import com.google.common.base.Strings; -import com.google.common.collect.ComparisonChain; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableList.Builder; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import com.google.common.collect.Ordering; -import com.google.common.net.InternetDomainName; -import google.registry.model.contact.ContactResource; -import google.registry.model.domain.DomainApplication; -import google.registry.tools.Command.RemoteApiCommand; -import google.registry.tools.params.PathParameter; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.List; - -/** Command to check the status of domain applications. */ -@Parameters(separators = " =", commandDescription = "Check auction status") -final class AuctionStatusCommand implements RemoteApiCommand { - - @Parameter( - description = "Domains(s) to check", - required = true) - private List mainArguments; - - @Parameter( - names = {"-o", "--output"}, - description = "Output file.", - validateWith = PathParameter.OutputFile.class) - private Path output = Paths.get("/dev/stdout"); - - @Override - public void run() throws Exception { - final ImmutableSet domains = ImmutableSet.copyOf(mainArguments); - Files.write( - output, - FluentIterable.from(domains) - .transformAndConcat( - fullyQualifiedDomainName -> { - checkState( - findTldForName(InternetDomainName.from(fullyQualifiedDomainName)).isPresent(), - "No tld found for %s", - fullyQualifiedDomainName); - return ofy() - .transactNewReadOnly( - () -> { - Builder applications = - new Builder<>(); - for (String domain : domains) { - applications.addAll( - loadActiveApplicationsByDomainName( - domain, ofy().getTransactionTime())); - } - return Lists.transform( - ImmutableList.sortedCopyOf(ORDERING, applications.build()), - APPLICATION_FORMATTER); - }); - }), - UTF_8); - } - - private static final Ordering ORDERING = new Ordering() { - @Override - public int compare(DomainApplication left, DomainApplication right) { - return ComparisonChain.start() - .compare(left.getFullyQualifiedDomainName(), right.getFullyQualifiedDomainName()) - .compareTrueFirst( - left.getEncodedSignedMarks().isEmpty(), right.getEncodedSignedMarks().isEmpty()) - .compare(left.getApplicationStatus(), right.getApplicationStatus()) - .compare(left.getCreationTime(), right.getCreationTime()) - .result(); - }}; - - private static final Function APPLICATION_FORMATTER = - app -> { - ContactResource registrant = checkNotNull(ofy().load().key(app.getRegistrant()).now()); - Object[] keysAndValues = - new Object[] { - "Domain", app.getFullyQualifiedDomainName(), - "Type", app.getEncodedSignedMarks().isEmpty() ? "Landrush" : "Sunrise", - "Application Status", app.getApplicationStatus(), - "Application ID", app.getForeignKey(), - "Application Timestamp", app.getCreationTime(), - "Last Update", app.getLastEppUpdateTime(), - "Registrar Name", app.getCurrentSponsorClientId(), - "Registrant Email", registrant.getEmailAddress(), - "Registrant Phone", registrant.getVoiceNumber().getPhoneNumber() - }; - return String.format( - Strings.repeat("%-25s= %s\n", keysAndValues.length / 2), keysAndValues); - }; -} diff --git a/java/google/registry/tools/RegistryTool.java b/java/google/registry/tools/RegistryTool.java index 29cb933d7..caa2114ba 100644 --- a/java/google/registry/tools/RegistryTool.java +++ b/java/google/registry/tools/RegistryTool.java @@ -30,7 +30,6 @@ public final class RegistryTool { public static final ImmutableMap> COMMAND_MAP = new ImmutableMap.Builder>() .put("allocate_domain", AllocateDomainCommand.class) - .put("auction_status", AuctionStatusCommand.class) .put("canonicalize_labels", CanonicalizeLabelsCommand.class) .put("check_snapshot", CheckSnapshotCommand.class) .put("convert_idn", ConvertIdnCommand.class)