From: David ‘Bombe’ Roden Date: Sun, 2 Jan 2011 12:47:51 +0000 (+0100) Subject: Add methods to set and remove trust for identities. X-Git-Tag: 0.4^2~8^2~33 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=2e5acf14a60c491cdbae99ce7bcbae5369070d7f Add methods to set and remove trust for identities. --- diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultOwnIdentity.java b/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultOwnIdentity.java index f89ddda..3af8b38 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultOwnIdentity.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultOwnIdentity.java @@ -21,6 +21,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import net.pterodactylus.util.validation.Validation; + /** * An own identity is an identity that the owner of the node has full control * over. @@ -135,4 +137,22 @@ public class DefaultOwnIdentity extends DefaultIdentity implements OwnIdentity { } } + /** + * {@inheritDoc} + */ + @Override + public void setTrust(Identity target, int trustValue, String comment) throws WebOfTrustException { + Validation.begin().isNotNull("Trust Target", target).isNotNull("Trust Comment", comment).isLessOrEqual("Trust Value", trustValue, 100).isGreaterOrEqual("Trust Value", trustValue, -100).check(); + webOfTrustConnector.setTrust(this, target, trustValue, comment); + } + + /** + * {@inheritDoc} + */ + @Override + public void removeTrust(Identity target) throws WebOfTrustException { + Validation.begin().isNotNull("Trust Target", target).check(); + webOfTrustConnector.removeTrust(this, target); + } + } diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/OwnIdentity.java b/src/main/java/net/pterodactylus/sone/freenet/wot/OwnIdentity.java index deaf25c..68a10f4 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/OwnIdentity.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/OwnIdentity.java @@ -108,4 +108,28 @@ public interface OwnIdentity extends Identity { */ public void removeProperty(String name) throws WebOfTrustException; + /** + * Sets the trust for the given target identity. + * + * @param target + * The target to set the trust for + * @param trustValue + * The new trust value (from {@code -100} or {@code 100}) + * @param comment + * The comment for the trust assignment + * @throws WebOfTrustException + * if an error occurs + */ + public void setTrust(Identity target, int trustValue, String comment) throws WebOfTrustException; + + /** + * Removes any trust assignment for the given target identity. + * + * @param target + * The targe to remove the trust assignment for + * @throws WebOfTrustException + * if an error occurs + */ + public void removeTrust(Identity target) throws WebOfTrustException; + }