From 4923393686ef13ae2426a78711ef104c2ed1bfa8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 16 Sep 2011 17:50:33 +0200 Subject: [PATCH] Rework own identity selection algorithm to always find the best result. --- src/main/java/net/pterodactylus/wotns/main/Resolver.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/pterodactylus/wotns/main/Resolver.java b/src/main/java/net/pterodactylus/wotns/main/Resolver.java index 4e53528..94a098e 100644 --- a/src/main/java/net/pterodactylus/wotns/main/Resolver.java +++ b/src/main/java/net/pterodactylus/wotns/main/Resolver.java @@ -91,20 +91,17 @@ public class Resolver { keyStart = shortName.substring(atSign + 1); } final OwnIdentity ownIdentity; - if ((this.ownIdentityId != null) && (identityManager.getOwnIdentity(this.ownIdentityId) != null)) { - ownIdentity = identityManager.getOwnIdentity(this.ownIdentityId); - } else if (this.ownIdentityId == null) { - Set ownIdentities = identityManager.getAllOwnIdentities(); - if (!ownIdentities.isEmpty()) { - ownIdentity = ownIdentities.iterator().next(); + if (this.ownIdentityId != null) { + if (identityManager.getOwnIdentity(this.ownIdentityId) != null) { + ownIdentity = identityManager.getOwnIdentity(this.ownIdentityId); } else { - ownIdentity = null; + ownIdentity = getFirstOwnIdentity(); } } else { - logger.log(Level.SEVERE, "Can not resolve “" + shortName + "” without a Web of Trust Identity!"); - ownIdentity = null; + ownIdentity = getFirstOwnIdentity(); } if (ownIdentity == null) { + logger.log(Level.SEVERE, "Can not resolve “" + shortName + "” without a Web of Trust Identity!"); return null; } System.out.println("using own identity " + ownIdentity + " to resolve " + shortName); -- 2.7.4