mirror of
https://github.com/google/nomulus.git
synced 2025-07-19 17:26:09 +02:00
Remove duplicate version of lookupSuperordinateDomain() function
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=148657943
This commit is contained in:
parent
90114858fa
commit
64bfbea324
4 changed files with 7 additions and 34 deletions
|
@ -14,18 +14,14 @@
|
|||
|
||||
package google.registry.rde.imports;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static google.registry.flows.host.HostFlowUtils.lookupSuperordinateDomain;
|
||||
import static google.registry.mapreduce.MapreduceRunner.PARAM_MAP_SHARDS;
|
||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.registry.Registries.findTldForName;
|
||||
import static google.registry.util.PipelineUtils.createJobPath;
|
||||
|
||||
import com.google.appengine.tools.mapreduce.Mapper;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.VoidWork;
|
||||
|
@ -135,29 +131,6 @@ public class RdeHostLinkAction implements Runnable {
|
|||
throw new HostLinkException(xjcHost.getName(), xjcHost.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link DomainResource} this host is subordinate to, or absent for out of zone
|
||||
* hosts.
|
||||
*
|
||||
* @throws IllegalStateException for hosts without superordinate domains
|
||||
*/
|
||||
private static Optional<DomainResource> lookupSuperordinateDomain(
|
||||
InternetDomainName hostName, DateTime now) {
|
||||
Optional<InternetDomainName> tld = findTldForName(hostName);
|
||||
// out of zone hosts cannot be linked
|
||||
if (!tld.isPresent()) {
|
||||
return Optional.absent();
|
||||
}
|
||||
// This is a subordinate host
|
||||
String domainName = Joiner.on('.').join(Iterables.skip(
|
||||
hostName.parts(), hostName.parts().size() - (tld.get().parts().size() + 1)));
|
||||
DomainResource superordinateDomain = loadByForeignKey(DomainResource.class, domainName, now);
|
||||
// Hosts can't be linked if domains import hasn't been run
|
||||
checkState(
|
||||
superordinateDomain != null, "Superordinate domain does not exist: %s", domainName);
|
||||
return Optional.of(superordinateDomain);
|
||||
}
|
||||
}
|
||||
|
||||
private static class HostLinkException extends RuntimeException {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue