Remove exception from Identity interface, let null signal an error.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / Core.java
index 2349481..053e042 100644 (file)
@@ -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
@@ -912,12 +914,7 @@ public class Core implements IdentityListener {
                        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());
        }
 
        /**
@@ -957,6 +954,42 @@ public class Core implements IdentityListener {
        }
 
        /**
+        * Assigns the configured positive trust value for the given target.
+        *
+        * @param origin
+        *            The trust origin
+        * @param target
+        *            The trust target
+        */
+       public void trustSone(Sone origin, Sone target) {
+               setTrust(origin, target, options.getIntegerOption("PositiveTrust").get());
+       }
+
+       /**
+        * Assigns the configured negative trust value for the given target.
+        *
+        * @param origin
+        *            The trust origin
+        * @param target
+        *            The trust target
+        */
+       public void distrustSone(Sone origin, Sone target) {
+               setTrust(origin, target, options.getIntegerOption("NegativeTrust").get());
+       }
+
+       /**
+        * Removes the trust assignment for the given target.
+        *
+        * @param origin
+        *            The trust origin
+        * @param target
+        *            The trust target
+        */
+       public void untrustSone(Sone origin, Sone target) {
+               removeTrust(origin, target);
+       }
+
+       /**
         * Updates the stores Sone with the given Sone.
         *
         * @param sone
@@ -1706,6 +1739,7 @@ public class Core implements IdentityListener {
                        @SuppressWarnings("synthetic-access")
                        public void run() {
                                Sone sone = getRemoteSone(identity.getId());
+                               sone.setIdentity(identity);
                                soneDownloader.fetchSone(sone);
                        }
                }).start();