projects
/
WoTNS.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Set version to 0.0.6.
[WoTNS.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
wotns
/
main
/
Resolver.java
diff --git
a/src/main/java/net/pterodactylus/wotns/main/Resolver.java
b/src/main/java/net/pterodactylus/wotns/main/Resolver.java
index
0150f45
..
94a098e
100644
(file)
--- a/
src/main/java/net/pterodactylus/wotns/main/Resolver.java
+++ b/
src/main/java/net/pterodactylus/wotns/main/Resolver.java
@@
-23,7
+23,10
@@
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.object.Default;
import net.pterodactylus.wotns.freenet.wot.Identity;
import net.pterodactylus.wotns.freenet.wot.IdentityManager;
import net.pterodactylus.util.object.Default;
import net.pterodactylus.wotns.freenet.wot.Identity;
import net.pterodactylus.wotns.freenet.wot.IdentityManager;
@@
-38,6
+41,8
@@
import freenet.keys.FreenetURI;
*/
public class Resolver {
*/
public class Resolver {
+ private static final Logger logger = Logging.getLogger(Resolver.class);
+
private final IdentityManager identityManager;
private String ownIdentityId;
private final IdentityManager identityManager;
private String ownIdentityId;
@@
-85,19
+90,18
@@
public class Resolver {
identityName = shortName.substring(0, atSign);
keyStart = shortName.substring(atSign + 1);
}
identityName = shortName.substring(0, atSign);
keyStart = shortName.substring(atSign + 1);
}
- @SuppressWarnings("hiding")
final OwnIdentity ownIdentity;
final OwnIdentity ownIdentity;
- if (this.ownIdentityId == null) {
- Set<OwnIdentity> 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 {
} else {
- ownIdentity =
null
;
+ ownIdentity =
getFirstOwnIdentity()
;
}
} else {
}
} else {
- ownIdentity =
identityManager.getOwnIdentity(ownIdentityId
);
+ ownIdentity =
getFirstOwnIdentity(
);
}
if (ownIdentity == null) {
}
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);
return null;
}
System.out.println("using own identity " + ownIdentity + " to resolve " + shortName);
@@
-126,4
+130,12
@@
public class Resolver {
return matchingIdentities.get(0);
}
return matchingIdentities.get(0);
}
+ private OwnIdentity getFirstOwnIdentity() {
+ Set<OwnIdentity> ownIdentities = identityManager.getAllOwnIdentities();
+ if (!ownIdentities.isEmpty()) {
+ return ownIdentities.iterator().next();
+ }
+ return null;
+ }
+
}
}