X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2Fwot%2FWebOfTrustConnector.java;h=49c76d7d7988537ff5ca3898aac29d76f46691fa;hb=d196ff9daeaf1661c48060bdeb426b051a0c1ef3;hp=20c0b50aa80701375bf5f9bbe044477862fb8dab;hpb=732fe4fc507605a73f7162cfcd808f8db6076950;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java b/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java index 20c0b50..49c76d7 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java @@ -188,6 +188,52 @@ public class WebOfTrustConnector implements ConnectorListener { performRequest(SimpleFieldSetConstructor.create().put("Message", "RemoveContext").put("Identity", ownIdentity.getId()).put("Context", context).get(), "ContextRemoved"); } + /** + * Returns the value of the property with the given name. + * + * @param identity + * The identity whose properties to check + * @param name + * The name of the property to return + * @return The value of the property, or {@code null} if there is no value + * @throws PluginException + * if an error occured talking to the Web of Trust plugin + */ + public String getProperty(Identity identity, String name) throws PluginException { + Reply reply = performRequest(SimpleFieldSetConstructor.create().put("Message", "GetProperty").put("Identity", identity.getId()).put("Property", name).get(), "PropertyValue", "Error"); + return reply.getFields().get("Property"); + } + + /** + * Sets the property with the given name to the given value. + * + * @param ownIdentity + * The identity to set the property on + * @param name + * The name of the property to set + * @param value + * The value to set + * @throws PluginException + * if an error occured talking to the Web of Trust plugin + */ + public void setProperty(OwnIdentity ownIdentity, String name, String value) throws PluginException { + performRequest(SimpleFieldSetConstructor.create().put("Message", "SetProperty").put("Identity", ownIdentity.getId()).put("Property", name).put("Value", value).get(), "PropertyAdded"); + } + + /** + * Removes the property with the given name. + * + * @param ownIdentity + * The identity to remove the property from + * @param name + * The name of the property to remove + * @throws PluginException + * if an error occured talking to the Web of Trust plugin + */ + public void removeProperty(OwnIdentity ownIdentity, String name) throws PluginException { + performRequest(SimpleFieldSetConstructor.create().put("Message", "RemoveProperty").put("Identity", ownIdentity.getId()).put("Property", name).get(), "PropertyRemoved"); + } + // // PRIVATE ACTIONS //