projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f2814a2
)
Remove exception from Identity interface, let null signal an error.
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Tue, 4 Jan 2011 08:03:57 +0000
(09:03 +0100)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Tue, 4 Jan 2011 08:03:57 +0000
(09:03 +0100)
src/main/java/net/pterodactylus/sone/core/Core.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
patch
|
blob
|
history
diff --git
a/src/main/java/net/pterodactylus/sone/core/Core.java
b/src/main/java/net/pterodactylus/sone/core/Core.java
index
763b024
..
053e042
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/core/Core.java
+++ b/
src/main/java/net/pterodactylus/sone/core/Core.java
@@
-899,8
+899,10
@@
public class Core implements IdentityListener {
}
/**
}
/**
- * Retrieves the trust relationship from the origin to the target.
+ * Retrieves the trust relationship from the origin to the target. If the
+ * trust relationship can not be retrieved, {@code null} is returned.
*
*
+ * @see Identity#getTrust(OwnIdentity)
* @param origin
* The origin of the trust tree
* @param target
* @param origin
* The origin of the trust tree
* @param target
@@
-912,12
+914,7
@@
public class Core implements IdentityListener {
logger.log(Level.WARNING, "Tried to get trust from remote Sone: %s", origin);
return null;
}
logger.log(Level.WARNING, "Tried to get trust from remote Sone: %s", origin);
return null;
}
- try {
- return target.getIdentity().getTrust((OwnIdentity) origin.getIdentity());
- } catch (WebOfTrustException wote1) {
- logger.log(Level.WARNING, "Could not get trust for Sone: " + target, wote1);
- return null;
- }
+ return target.getIdentity().getTrust((OwnIdentity) origin.getIdentity());
}
/**
}
/**
diff --git
a/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java
b/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java
index
f00fa4e
..
3f4e66a
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java
+++ b/
src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java
@@
-22,6
+22,8
@@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import net.pterodactylus.sone.freenet.plugin.PluginException;
import net.pterodactylus.util.cache.CacheException;
import net.pterodactylus.sone.freenet.plugin.PluginException;
import net.pterodactylus.util.cache.CacheException;
@@
-31,6
+33,7
@@
import net.pterodactylus.util.cache.MemoryCache;
import net.pterodactylus.util.cache.ValueRetriever;
import net.pterodactylus.util.cache.WritableCache;
import net.pterodactylus.util.collection.TimedMap;
import net.pterodactylus.util.cache.ValueRetriever;
import net.pterodactylus.util.cache.WritableCache;
import net.pterodactylus.util.collection.TimedMap;
+import net.pterodactylus.util.logging.Logging;
/**
* A Web of Trust identity.
/**
* A Web of Trust identity.
@@
-39,6
+42,9
@@
import net.pterodactylus.util.collection.TimedMap;
*/
public class DefaultIdentity implements Identity {
*/
public class DefaultIdentity implements Identity {
+ /** The logger. */
+ private static final Logger logger = Logging.getLogger(DefaultIdentity.class);
+
/** The web of trust connector. */
private final WebOfTrustConnector webOfTrustConnector;
/** The web of trust connector. */
private final WebOfTrustConnector webOfTrustConnector;
@@
-241,11
+247,12
@@
public class DefaultIdentity implements Identity {
* {@inheritDoc}
*/
@Override
* {@inheritDoc}
*/
@Override
- public Trust getTrust(OwnIdentity ownIdentity)
throws WebOfTrustException
{
+ public Trust getTrust(OwnIdentity ownIdentity) {
try {
return trustCache.get(ownIdentity);
} catch (CacheException ce1) {
try {
return trustCache.get(ownIdentity);
} catch (CacheException ce1) {
- throw new WebOfTrustException("Could not get trust for OwnIdentity: " + ownIdentity, ce1);
+ logger.log(Level.WARNING, "Could not get trust for OwnIdentity: " + ownIdentity, ce1);
+ return null;
}
}
}
}
diff --git
a/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java
b/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java
index
6364b6f
..
1cf1644
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java
+++ b/
src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java
@@
-85,14
+85,15
@@
public interface Identity {
/**
* Retrieves the trust that this identity receives from the given own
/**
* Retrieves the trust that this identity receives from the given own
- * identity.
+ * identity. If this identity is not in the own identity’s trust tree, a
+ * {@link Trust} is returned that has all its elements set to {@code null}.
+ * If the trust can not be retrieved, {@code null} is returned.
*
* @param ownIdentity
* The own identity to get the trust for
*
* @param ownIdentity
* The own identity to get the trust for
- * @return The trust assigned to this identity
- * @throws WebOfTrustException
- * if an error occurs retrieving the trust
+ * @return The trust assigned to this identity, or {@code null} if the trust
+ * could not be retrieved
*/
*/
- public Trust getTrust(OwnIdentity ownIdentity)
throws WebOfTrustException
;
+ public Trust getTrust(OwnIdentity ownIdentity);
}
}
diff --git
a/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
b/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
index
c4eac6c
..
0cb92ff
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
+++ b/
src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
@@
-21,6
+21,7
@@
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.core.Core.SoneStatus;
import net.pterodactylus.sone.data.Profile;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.core.Core.SoneStatus;
import net.pterodactylus.sone.data.Profile;
import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.freenet.wot.Trust;
import net.pterodactylus.util.template.Accessor;
import net.pterodactylus.util.template.DataProvider;
import net.pterodactylus.util.template.ReflectionAccessor;
import net.pterodactylus.util.template.Accessor;
import net.pterodactylus.util.template.DataProvider;
import net.pterodactylus.util.template.ReflectionAccessor;
@@
-91,7
+92,10
@@
public class SoneAccessor extends ReflectionAccessor {
return core.isLocked(sone);
} else if (member.equals("trust")) {
Sone currentSone = (Sone) dataProvider.getData("currentSone");
return core.isLocked(sone);
} else if (member.equals("trust")) {
Sone currentSone = (Sone) dataProvider.getData("currentSone");
- return core.getTrust(currentSone, sone);
+ Trust trust = core.getTrust(currentSone, sone);
+ if (trust == null) {
+ return new Trust(null, null, null);
+ }
}
return super.get(dataProvider, object, member);
}
}
return super.get(dataProvider, object, member);
}