+ * The identity receiving the trust
+ * @param score
+ * The new level of trust (from -100 to 100, may be {@code null} to remove
+ * the trust completely)
+ * @param comment
+ * The comment of the trust relation
+ */
+ public void setTrust(OwnIdentity truster, Identity trustee, Integer score, String comment) {
+ SetTrustJob setTrustJob = new SetTrustJob(truster, trustee, score, comment);
+ if (updateJobs.contains(setTrustJob)) {
+ updateJobs.remove(setTrustJob);
+ }
+ logger.log(Level.FINER, "Adding Trust Update Job: " + setTrustJob);
+ try {
+ updateJobs.put(setTrustJob);
+ } catch (InterruptedException e) {
+ /* the queue is unbounded so it should never block. */
+ }
+ }
+
+ /**
+ * Adds the given context to the given own identity.
+ *
+ * @param ownIdentity
+ * The own identity to add the context to
+ * @param context
+ * The context to add
+ */
+ public void addContext(OwnIdentity ownIdentity, String context) {
+ addContextWait(ownIdentity, context, false);
+ }
+
+ /**
+ * Adds the given context to the given own identity, waiting for completion of
+ * the operation.
+ *
+ * @param ownIdentity
+ * The own identity to add the context to
+ * @param context
+ * The context to add
+ * @return {@code true} if the context was added successfully, {@code false}
+ * otherwise
+ */
+ public boolean addContextWait(OwnIdentity ownIdentity, String context) {
+ return addContextWait(ownIdentity, context, true);
+ }
+
+ /**
+ * Adds the given context to the given own identity, waiting for completion of
+ * the operation.
+ *
+ * @param ownIdentity
+ * The own identity to add the context to
+ * @param context
+ * The context to add
+ * @param wait
+ * {@code true} to wait for the end of the operation, {@code false} to return
+ * immediately
+ * @return {@code true} if the context was added successfully, {@code false} if
+ * the context was not added successfully, or if the job should not
+ * wait for completion