}
/**
- * 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
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());
}
/**
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.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.
*/
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;
* {@inheritDoc}
*/
@Override
- public Trust getTrust(OwnIdentity ownIdentity) throws WebOfTrustException {
+ public Trust getTrust(OwnIdentity ownIdentity) {
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;
}
}
/**
* 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
- * @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);
}
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;
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);
}