mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 00:17:20 +02:00
Move VerifyOteAction to tools/server
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=116825910
This commit is contained in:
parent
3eef39126d
commit
6772b2ef80
6 changed files with 33 additions and 17 deletions
|
@ -8,7 +8,7 @@
|
||||||
<servlet>
|
<servlet>
|
||||||
<display-name>Verify OTE</display-name>
|
<display-name>Verify OTE</display-name>
|
||||||
<servlet-name>verify-ote</servlet-name>
|
<servlet-name>verify-ote</servlet-name>
|
||||||
<servlet-class>com.google.domain.registry.ui.server.admin.VerifyOteServlet</servlet-class>
|
<servlet-class>com.google.domain.registry.module.tools.ToolsServlet</servlet-class>
|
||||||
<load-on-startup>1</load-on-startup>
|
<load-on-startup>1</load-on-startup>
|
||||||
</servlet>
|
</servlet>
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
|
|
|
@ -36,6 +36,7 @@ import com.google.domain.registry.tools.server.ListReservedListsAction;
|
||||||
import com.google.domain.registry.tools.server.ListTldsAction;
|
import com.google.domain.registry.tools.server.ListTldsAction;
|
||||||
import com.google.domain.registry.tools.server.ToolsServerModule;
|
import com.google.domain.registry.tools.server.ToolsServerModule;
|
||||||
import com.google.domain.registry.tools.server.UpdatePremiumListAction;
|
import com.google.domain.registry.tools.server.UpdatePremiumListAction;
|
||||||
|
import com.google.domain.registry.tools.server.VerifyOteAction;
|
||||||
import com.google.domain.registry.tools.server.javascrap.AnnihilateNonDefaultNamespacesAction;
|
import com.google.domain.registry.tools.server.javascrap.AnnihilateNonDefaultNamespacesAction;
|
||||||
|
|
||||||
import dagger.Subcomponent;
|
import dagger.Subcomponent;
|
||||||
|
@ -68,4 +69,5 @@ interface ToolsRequestComponent {
|
||||||
PublishDetailReportAction publishDetailReportAction();
|
PublishDetailReportAction publishDetailReportAction();
|
||||||
ResaveAllEppResourcesAction resaveAllEppResourcesAction();
|
ResaveAllEppResourcesAction resaveAllEppResourcesAction();
|
||||||
UpdatePremiumListAction updatePremiumListAction();
|
UpdatePremiumListAction updatePremiumListAction();
|
||||||
|
VerifyOteAction verifyOteAction();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,14 @@ import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.domain.registry.config.RegistryEnvironment;
|
import com.google.domain.registry.config.RegistryEnvironment;
|
||||||
import com.google.domain.registry.model.registrar.Registrar;
|
import com.google.domain.registry.model.registrar.Registrar;
|
||||||
import com.google.domain.registry.tools.Command.GtechCommand;
|
import com.google.domain.registry.tools.Command.GtechCommand;
|
||||||
|
import com.google.domain.registry.tools.server.VerifyOteAction;
|
||||||
|
|
||||||
import com.beust.jcommander.Parameter;
|
import com.beust.jcommander.Parameter;
|
||||||
import com.beust.jcommander.Parameters;
|
import com.beust.jcommander.Parameters;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
@ -81,11 +83,13 @@ final class VerifyOteCommand implements ServerSideCommand, GtechCommand {
|
||||||
// the input is valid.
|
// the input is valid.
|
||||||
verifyNotNull(loadByClientId(clientId + "-1"), "Registrar %s does not exist.", clientId);
|
verifyNotNull(loadByClientId(clientId + "-1"), "Registrar %s does not exist.", clientId);
|
||||||
}
|
}
|
||||||
Iterable<String> registrars =
|
Collection<String> registrars =
|
||||||
mainParameters.isEmpty() ? getAllRegistrarNames() : mainParameters;
|
mainParameters.isEmpty() ? getAllRegistrarNames() : mainParameters;
|
||||||
Map<String, Object> response = connection.sendJson(
|
Map<String, Object> response = connection.sendJson(
|
||||||
"/_dr/admin/verifyOte",
|
VerifyOteAction.PATH,
|
||||||
ImmutableMap.of("summarize", Boolean.toString(summarize), "registrars", registrars));
|
ImmutableMap.of(
|
||||||
|
"summarize", Boolean.toString(summarize),
|
||||||
|
"registrars", new ArrayList<>(registrars)));
|
||||||
System.out.println(Strings.repeat("-", 80));
|
System.out.println(Strings.repeat("-", 80));
|
||||||
for (Entry<String, Object> registrar : response.entrySet()) {
|
for (Entry<String, Object> registrar : response.entrySet()) {
|
||||||
System.out.printf(
|
System.out.printf(
|
||||||
|
|
|
@ -12,6 +12,7 @@ java_library(
|
||||||
"//java/com/google/common/io",
|
"//java/com/google/common/io",
|
||||||
"//java/com/google/domain/registry/config",
|
"//java/com/google/domain/registry/config",
|
||||||
"//java/com/google/domain/registry/export",
|
"//java/com/google/domain/registry/export",
|
||||||
|
"//java/com/google/domain/registry/flows",
|
||||||
"//java/com/google/domain/registry/gcs",
|
"//java/com/google/domain/registry/gcs",
|
||||||
"//java/com/google/domain/registry/groups",
|
"//java/com/google/domain/registry/groups",
|
||||||
"//java/com/google/domain/registry/mapreduce",
|
"//java/com/google/domain/registry/mapreduce",
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package com.google.domain.registry.ui.server.admin;
|
package com.google.domain.registry.tools.server;
|
||||||
|
|
||||||
import static com.google.common.base.Predicates.not;
|
import static com.google.common.base.Predicates.not;
|
||||||
import static com.google.common.collect.Maps.toMap;
|
import static com.google.common.collect.Maps.toMap;
|
||||||
|
@ -64,7 +64,9 @@ import com.google.domain.registry.model.eppinput.EppInput;
|
||||||
import com.google.domain.registry.model.eppinput.EppInput.ResourceCommandWrapper;
|
import com.google.domain.registry.model.eppinput.EppInput.ResourceCommandWrapper;
|
||||||
import com.google.domain.registry.model.host.HostCommand;
|
import com.google.domain.registry.model.host.HostCommand;
|
||||||
import com.google.domain.registry.model.reporting.HistoryEntry;
|
import com.google.domain.registry.model.reporting.HistoryEntry;
|
||||||
import com.google.domain.registry.security.JsonTransportServlet;
|
import com.google.domain.registry.request.Action;
|
||||||
|
import com.google.domain.registry.request.JsonActionRunner;
|
||||||
|
import com.google.domain.registry.request.JsonActionRunner.JsonAction;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
@ -72,26 +74,35 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A servlet that verifies a registrar's OTE status. Note that this is eventually consistent, so
|
* A servlet that verifies a registrar's OTE status. Note that this is eventually consistent, so
|
||||||
* OT&E commands that have been run just previously to verification may not be picked up yet.
|
* OT&E commands that have been run just previously to verification may not be picked up yet.
|
||||||
*/
|
*/
|
||||||
public class VerifyOteServlet extends JsonTransportServlet {
|
@Action(
|
||||||
|
path = VerifyOteAction.PATH,
|
||||||
|
method = Action.Method.POST,
|
||||||
|
xsrfProtection = true,
|
||||||
|
xsrfScope = "admin")
|
||||||
|
public class VerifyOteAction implements Runnable, JsonAction {
|
||||||
|
|
||||||
public static final String XSRF_SCOPE = "admin";
|
public static final String PATH = "/_dr/admin/verifyOte";
|
||||||
|
|
||||||
public VerifyOteServlet() {
|
@Inject JsonActionRunner jsonActionRunner;
|
||||||
super(XSRF_SCOPE, true);
|
@Inject VerifyOteAction() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
jsonActionRunner.run(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Map<String, Object> doJsonPost(HttpServletRequest req, Map<String, ?> params) {
|
public Map<String, Object> handleJsonRequest(Map<String, ?> json) {
|
||||||
final boolean summarize = Boolean.parseBoolean((String) params.get("summarize"));
|
final boolean summarize = Boolean.parseBoolean((String) json.get("summarize"));
|
||||||
return toMap(
|
return toMap(
|
||||||
(List<String>) params.get("registrars"),
|
(List<String>) json.get("registrars"),
|
||||||
new Function<String, Object>() {
|
new Function<String, Object>() {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
|
@ -84,9 +84,7 @@ public final class RegistryTestServer {
|
||||||
route("/_dr/admin/registry/*",
|
route("/_dr/admin/registry/*",
|
||||||
com.google.domain.registry.ui.server.admin.RegistryServlet.class),
|
com.google.domain.registry.ui.server.admin.RegistryServlet.class),
|
||||||
route("/_dr/admin/registrar/*",
|
route("/_dr/admin/registrar/*",
|
||||||
com.google.domain.registry.ui.server.admin.RegistrarServlet.class),
|
com.google.domain.registry.ui.server.admin.RegistrarServlet.class));
|
||||||
route("/_dr/admin/verifyOte",
|
|
||||||
com.google.domain.registry.ui.server.admin.VerifyOteServlet.class));
|
|
||||||
|
|
||||||
private final TestServer server;
|
private final TestServer server;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue