mirror of
https://github.com/google/nomulus.git
synced 2025-05-12 22:38:16 +02:00
Inject RDAP help information in ConfigModule
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=140849879
This commit is contained in:
parent
3740171bbf
commit
c59b738b5b
57 changed files with 436 additions and 306 deletions
|
@ -20,10 +20,7 @@ import static google.registry.request.Action.Method.HEAD;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.rdap.RdapJsonFormatter.BoilerplateType;
|
||||
import google.registry.rdap.RdapJsonFormatter.MakeRdapJsonNoticeParameters;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.HttpException.InternalServerErrorException;
|
||||
import google.registry.request.HttpException.NotFoundException;
|
||||
import google.registry.util.Clock;
|
||||
import javax.inject.Inject;
|
||||
|
||||
|
@ -35,85 +32,6 @@ public class RdapHelpAction extends RdapActionBase {
|
|||
|
||||
public static final String PATH = "/rdap/help";
|
||||
|
||||
/**
|
||||
* Path for the terms of service. The terms of service are also used to create the required
|
||||
* boilerplate notice, so we make it a publicly visible that we can use elsewhere to reference it.
|
||||
*/
|
||||
public static final String TERMS_OF_SERVICE_PATH = "/tos";
|
||||
|
||||
/**
|
||||
* Map from a relative path underneath the RDAP root path to the appropriate
|
||||
* {@link MakeRdapJsonNoticeParameters} object.
|
||||
*/
|
||||
private static final ImmutableMap<String, MakeRdapJsonNoticeParameters> HELP_MAP =
|
||||
ImmutableMap.of(
|
||||
"/",
|
||||
MakeRdapJsonNoticeParameters.builder()
|
||||
.title("RDAP Help")
|
||||
.description(ImmutableList.of(
|
||||
"RDAP Help Topics (use /help/topic for information)",
|
||||
"syntax",
|
||||
"tos (Terms of Service)"))
|
||||
.linkValueSuffix("help/")
|
||||
.linkHrefUrlString("https://www.registry.google/about/rdap/index.html")
|
||||
.build(),
|
||||
"/index",
|
||||
MakeRdapJsonNoticeParameters.builder()
|
||||
.title("RDAP Help")
|
||||
.description(ImmutableList.of(
|
||||
"RDAP Help Topics (use /help/topic for information)",
|
||||
"syntax",
|
||||
"tos (Terms of Service)"))
|
||||
.linkValueSuffix("help/index")
|
||||
.linkHrefUrlString("https://www.registry.google/about/rdap/index.html")
|
||||
.build(),
|
||||
"/syntax",
|
||||
MakeRdapJsonNoticeParameters.builder()
|
||||
.title("RDAP Command Syntax")
|
||||
.description(ImmutableList.of(
|
||||
"domain/XXXX",
|
||||
"nameserver/XXXX",
|
||||
"entity/XXXX",
|
||||
"domains?name=XXXX",
|
||||
"domains?nsLdhName=XXXX",
|
||||
"domains?nsIp=XXXX",
|
||||
"nameservers?name=XXXX",
|
||||
"nameservers?ip=XXXX",
|
||||
"entities?fn=XXXX",
|
||||
"entities?handle=XXXX",
|
||||
"help/XXXX"))
|
||||
.linkValueSuffix("help/syntax")
|
||||
.linkHrefUrlString("https://www.registry.google/about/rdap/syntax.html")
|
||||
.build(),
|
||||
TERMS_OF_SERVICE_PATH,
|
||||
MakeRdapJsonNoticeParameters.builder()
|
||||
.title("RDAP Terms of Service")
|
||||
.description(ImmutableList.of(
|
||||
"By querying our Domain Database, you are agreeing to comply with these terms so"
|
||||
+ " please read them carefully.",
|
||||
"Any information provided is 'as is' without any guarantee of accuracy.",
|
||||
"Please do not misuse the Domain Database. It is intended solely for"
|
||||
+ " query-based access.",
|
||||
"Don't use the Domain Database to allow, enable, or otherwise support the"
|
||||
+ " transmission of mass unsolicited, commercial advertising or"
|
||||
+ " solicitations.",
|
||||
"Don't access our Domain Database through the use of high volume, automated"
|
||||
+ " electronic processes that send queries or data to the systems of"
|
||||
+ " Charleston Road Registry or any ICANN-accredited registrar.",
|
||||
"You may only use the information contained in the Domain Database for lawful"
|
||||
+ " purposes.",
|
||||
"Do not compile, repackage, disseminate, or otherwise use the information"
|
||||
+ " contained in the Domain Database in its entirety, or in any substantial"
|
||||
+ " portion, without our prior written permission.",
|
||||
"We may retain certain details about queries to our Domain Database for the"
|
||||
+ " purposes of detecting and preventing misuse.",
|
||||
"We reserve the right to restrict or deny your access to the database if we"
|
||||
+ " suspect that you have failed to comply with these terms.",
|
||||
"We reserve the right to modify this agreement at any time."))
|
||||
.linkValueSuffix("help/tos")
|
||||
.linkHrefUrlString("https://www.registry.google/about/rdap/tos.html")
|
||||
.build());
|
||||
|
||||
@Inject Clock clock;
|
||||
@Inject RdapHelpAction() {}
|
||||
|
||||
|
@ -133,28 +51,12 @@ public class RdapHelpAction extends RdapActionBase {
|
|||
// We rely on addTopLevelEntries to notice if we are sending the TOS notice, and not add a
|
||||
// duplicate boilerplate entry.
|
||||
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
|
||||
RdapJsonFormatter.addTopLevelEntries(
|
||||
rdapJsonFormatter.addTopLevelEntries(
|
||||
builder,
|
||||
BoilerplateType.OTHER,
|
||||
ImmutableList.of(getJsonHelpNotice(pathSearchString, rdapLinkBase)),
|
||||
ImmutableList.of(rdapJsonFormatter.getJsonHelpNotice(pathSearchString, rdapLinkBase)),
|
||||
ImmutableList.<ImmutableMap<String, Object>>of(),
|
||||
rdapLinkBase);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
static ImmutableMap<String, Object> getJsonHelpNotice(
|
||||
String pathSearchString, String rdapLinkBase) {
|
||||
if (pathSearchString.isEmpty()) {
|
||||
pathSearchString = "/";
|
||||
}
|
||||
if (!HELP_MAP.containsKey(pathSearchString)) {
|
||||
throw new NotFoundException("no help found for " + pathSearchString);
|
||||
}
|
||||
try {
|
||||
return RdapJsonFormatter.makeRdapJsonNotice(
|
||||
HELP_MAP.get(pathSearchString), rdapLinkBase);
|
||||
} catch (Exception e) {
|
||||
throw new InternalServerErrorException("unable to read help for " + pathSearchString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue