mirror of
https://github.com/google/nomulus.git
synced 2025-05-01 12:37:52 +02:00
When searching for domains by nameserver name or IP address, we fetch the matching nameserver keys, then search for domains by those keys. We limit the number of nameserver keys returned, to avoid arbitrarily large domain queries. This CL adds a warning to the RDAP response if we retrieved the maximum number of nameservers. This may indicate that we have not found all the domains. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=168885124
74 lines
2.7 KiB
Java
74 lines
2.7 KiB
Java
// 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.rdap;
|
|
|
|
import static google.registry.rdap.RdapIcannStandardInformation.POSSIBLY_INCOMPLETE_NOTICES;
|
|
import static google.registry.rdap.RdapIcannStandardInformation.TRUNCATION_NOTICES;
|
|
|
|
import com.google.auto.value.AutoValue;
|
|
import com.google.common.collect.ImmutableList;
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
|
/**
|
|
* Holds domain, nameserver and entity search results.
|
|
*
|
|
* <p>We need to know not only the list of things we found, but also whether the result set was
|
|
* truncated to the limit. If it is, we must add the ICANN-mandated notice to that effect.
|
|
*/
|
|
@AutoValue
|
|
abstract class RdapSearchResults {
|
|
|
|
enum IncompletenessWarningType {
|
|
|
|
/** Result set is complete. */
|
|
NONE,
|
|
|
|
/** Result set has been limited to the maximum size. */
|
|
TRUNCATED,
|
|
|
|
/**
|
|
* Result set might be missing data because the first step of a two-step query returned a data
|
|
* set that was limited in size.
|
|
*/
|
|
MIGHT_BE_INCOMPLETE
|
|
}
|
|
|
|
static RdapSearchResults create(ImmutableList<ImmutableMap<String, Object>> jsonList) {
|
|
return create(jsonList, IncompletenessWarningType.NONE);
|
|
}
|
|
|
|
static RdapSearchResults create(
|
|
ImmutableList<ImmutableMap<String, Object>> jsonList,
|
|
IncompletenessWarningType incompletenessWarningType) {
|
|
return new AutoValue_RdapSearchResults(jsonList, incompletenessWarningType);
|
|
}
|
|
|
|
/** List of JSON result object representations. */
|
|
abstract ImmutableList<ImmutableMap<String, Object>> jsonList();
|
|
|
|
/** Type of warning to display regarding possible incomplete data. */
|
|
abstract IncompletenessWarningType incompletenessWarningType();
|
|
|
|
/** Convenience method to get the appropriate warnings for the incompleteness warning type. */
|
|
ImmutableList<ImmutableMap<String, Object>> getIncompletenessWarnings() {
|
|
if (incompletenessWarningType() == IncompletenessWarningType.TRUNCATED) {
|
|
return TRUNCATION_NOTICES;
|
|
}
|
|
if (incompletenessWarningType() == IncompletenessWarningType.MIGHT_BE_INCOMPLETE) {
|
|
return POSSIBLY_INCOMPLETE_NOTICES;
|
|
}
|
|
return ImmutableList.<ImmutableMap<String, Object>>of();
|
|
}
|
|
}
|