Initial, easy changes to support later addition of RDAP metrics

I split this out to avoid having a giant CL that changes everything. The actual
metrics will follow later.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=174356874
This commit is contained in:
mountford 2017-11-02 11:39:25 -07:00 committed by jianglai
parent c126c05810
commit 5b8ee87ecc
13 changed files with 127 additions and 46 deletions

View file

@ -31,6 +31,7 @@ import google.registry.model.domain.DesignatedContact;
import google.registry.model.registrar.Registrar;
import google.registry.rdap.RdapJsonFormatter.BoilerplateType;
import google.registry.rdap.RdapJsonFormatter.OutputDataType;
import google.registry.rdap.RdapMetrics.EndpointType;
import google.registry.rdap.RdapSearchResults.IncompletenessWarningType;
import google.registry.request.Action;
import google.registry.request.HttpException.BadRequestException;
@ -76,6 +77,11 @@ public class RdapEntitySearchAction extends RdapActionBase {
return "entity search";
}
@Override
public EndpointType getEndpointType() {
return EndpointType.ENTITIES;
}
@Override
public String getActionPath() {
return PATH;
@ -169,12 +175,10 @@ public class RdapEntitySearchAction extends RdapActionBase {
// Get the contact matches and return the results, fetching an additional contact to detect
// truncation. Don't bother searching for contacts by name if the request would not be able to
// see any names anyway.
RdapResourcesAndIncompletenessWarningType<ContactResource>
resourcesAndIncompletenessWarningType;
RdapResultSet<ContactResource> resultSet;
RdapAuthorization authorization = getAuthorization();
if (authorization.role() == RdapAuthorization.Role.PUBLIC) {
resourcesAndIncompletenessWarningType =
RdapResourcesAndIncompletenessWarningType.create(ImmutableList.of());
resultSet = RdapResultSet.create(ImmutableList.of());
} else {
Query<ContactResource> query =
queryItems(
@ -186,9 +190,9 @@ public class RdapEntitySearchAction extends RdapActionBase {
if (authorization.role() != RdapAuthorization.Role.ADMINISTRATOR) {
query = query.filter("currentSponsorClientId in", authorization.clientIds());
}
resourcesAndIncompletenessWarningType = getMatchingResources(query, false, now);
resultSet = getMatchingResources(query, false, now);
}
return makeSearchResults(resourcesAndIncompletenessWarningType, registrars, now);
return makeSearchResults(resultSet, registrars, now);
}
/**
@ -264,15 +268,9 @@ public class RdapEntitySearchAction extends RdapActionBase {
* arguments.
*/
private RdapSearchResults makeSearchResults(
RdapResourcesAndIncompletenessWarningType<ContactResource>
resourcesAndIncompletenessWarningType,
List<Registrar> registrars,
DateTime now) {
RdapResultSet<ContactResource> resultSet, List<Registrar> registrars, DateTime now) {
return makeSearchResults(
resourcesAndIncompletenessWarningType.resources(),
resourcesAndIncompletenessWarningType.incompletenessWarningType(),
registrars,
now);
resultSet.resources(), resultSet.incompletenessWarningType(), registrars, now);
}
/**