mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 00:17:20 +02:00
Don't throw an exception on orphaned contacts
Return Optional.absent() instead of throwing NotFoundException when a user has a contact record but the Registrar entity is missing. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=138423965
This commit is contained in:
parent
7a77819977
commit
cbe76e8615
2 changed files with 16 additions and 2 deletions
|
@ -24,6 +24,7 @@ import com.google.appengine.api.users.UserService;
|
|||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.util.FormattingLogger;
|
||||
|
@ -121,7 +122,12 @@ public class SessionUtils {
|
|||
if (contact == null) {
|
||||
return Optional.absent();
|
||||
}
|
||||
return Optional.of(ofy().load().key(contact.getParent()).safe());
|
||||
Optional<Registrar> result = Optional.fromNullable(ofy().load().key(contact.getParent()).now());
|
||||
if (!result.isPresent()) {
|
||||
logger.severefmt(
|
||||
"A contact record exists for non-existent registrar: %s.", Key.create(contact));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** @see #hasAccessToRegistrar(Registrar, String) */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue