From: David ‘Bombe’ Roden Date: Tue, 7 Jan 2025 20:21:53 +0000 (+0100) Subject: ♻️ Extract plugin name into a constant X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=aa035014c4b208f5609a05a8a89316eeadf6ead3;p=jFCPlib.git ♻️ Extract plugin name into a constant --- diff --git a/src/main/java/net/pterodactylus/fcp/plugin/WebOfTrustPlugin.java b/src/main/java/net/pterodactylus/fcp/plugin/WebOfTrustPlugin.java index 22584ee..cd9c8a6 100644 --- a/src/main/java/net/pterodactylus/fcp/plugin/WebOfTrustPlugin.java +++ b/src/main/java/net/pterodactylus/fcp/plugin/WebOfTrustPlugin.java @@ -95,7 +95,7 @@ public class WebOfTrustPlugin { parameters.put("RequestURI", requestUri); parameters.put("InsertURI", insertUri); } - Map replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", parameters); + Map replies = fcpClient.sendPluginMessage(webOfTrustPluginName, parameters); if (!replies.get("Message").equals("IdentityCreated")) { throw new FcpException("WebOfTrust Plugin did not reply with “IdentityCreated” message!"); } @@ -116,7 +116,7 @@ public class WebOfTrustPlugin { * if an FCP error occurs */ public Set getOwnIdentites() throws IOException, FcpException { - Map replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "GetOwnIdentities")); + Map replies = fcpClient.sendPluginMessage(webOfTrustPluginName, createParameters("Message", "GetOwnIdentities")); if (!replies.get("Message").equals("OwnIdentities")) { throw new FcpException("WebOfTrust Plugin did not reply with “OwnIdentities” message!"); } @@ -146,7 +146,7 @@ public class WebOfTrustPlugin { * if an FCP error occurs */ public CalculatedTrust getIdentityTrust(OwnIdentity ownIdentity, String identifier) throws IOException, FcpException { - Map replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "GetIdentity", "TreeOwner", ownIdentity.getIdentifier(), "Identity", identifier)); + Map replies = fcpClient.sendPluginMessage(webOfTrustPluginName, createParameters("Message", "GetIdentity", "TreeOwner", ownIdentity.getIdentifier(), "Identity", identifier)); if (!replies.get("Message").equals("Identity")) { throw new FcpException("WebOfTrust Plugin did not reply with “Identity” message!"); } @@ -183,7 +183,7 @@ public class WebOfTrustPlugin { * if an FCP error occurs */ public Identity addIdentity(String requestUri) throws IOException, FcpException { - Map replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "AddIdentity", "RequestURI", requestUri)); + Map replies = fcpClient.sendPluginMessage(webOfTrustPluginName, createParameters("Message", "AddIdentity", "RequestURI", requestUri)); if (!replies.get("Message").equals("IdentityAdded")) { throw new FcpException("WebOfTrust Plugin did not reply with “IdentityAdded” message!"); } @@ -210,7 +210,7 @@ public class WebOfTrustPlugin { * if an FCP error occurs */ public Set getIdentitesByScore(OwnIdentity ownIdentity, String context, Boolean positive) throws IOException, FcpException { - Map replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "GetIdentitiesByScore", "TreeOwner", ownIdentity.getIdentifier(), "Context", context, "Selection", ((positive == null) ? "0" : (positive ? "+" : "-")))); + Map replies = fcpClient.sendPluginMessage(webOfTrustPluginName, createParameters("Message", "GetIdentitiesByScore", "TreeOwner", ownIdentity.getIdentifier(), "Context", context, "Selection", ((positive == null) ? "0" : (positive ? "+" : "-")))); if (!replies.get("Message").equals("Identities")) { throw new FcpException("WebOfTrust Plugin did not reply with “Identities” message!"); } @@ -238,7 +238,7 @@ public class WebOfTrustPlugin { * if an FCP error occurs */ public Map getTrusters(Identity identity, String context) throws IOException, FcpException { - Map replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "GetTrusters", "Identity", identity.getIdentifier(), "Context", context)); + Map replies = fcpClient.sendPluginMessage(webOfTrustPluginName, createParameters("Message", "GetTrusters", "Identity", identity.getIdentifier(), "Context", context)); if (!replies.get("Message").equals("Identities")) { throw new FcpException("WebOfTrust Plugin did not reply with “Identities” message!"); } @@ -268,7 +268,7 @@ public class WebOfTrustPlugin { * if an FCP error occurs */ public Map getTrustees(Identity identity, String context) throws IOException, FcpException { - Map replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "GetTrustees", "Identity", identity.getIdentifier(), "Context", context)); + Map replies = fcpClient.sendPluginMessage(webOfTrustPluginName, createParameters("Message", "GetTrustees", "Identity", identity.getIdentifier(), "Context", context)); if (!replies.get("Message").equals("Identities")) { throw new FcpException("WebOfTrust Plugin did not reply with “Identities” message!"); } @@ -301,7 +301,7 @@ public class WebOfTrustPlugin { * if an FCP error occurs */ public void setTrust(OwnIdentity ownIdentity, Identity identity, byte trust, String comment) throws IOException, FcpException { - Map replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "SetTrust", "Truster", ownIdentity.getIdentifier(), "Trustee", identity.getIdentifier(), "Value", String.valueOf(trust), "Comment", comment)); + Map replies = fcpClient.sendPluginMessage(webOfTrustPluginName, createParameters("Message", "SetTrust", "Truster", ownIdentity.getIdentifier(), "Trustee", identity.getIdentifier(), "Value", String.valueOf(trust), "Comment", comment)); if (!replies.get("Message").equals("TrustSet")) { throw new FcpException("WebOfTrust Plugin did not reply with “TrustSet” message!"); } @@ -320,7 +320,7 @@ public class WebOfTrustPlugin { * if an FCP error occurs */ public void addContext(OwnIdentity ownIdentity, String context) throws IOException, FcpException { - Map replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "AddContext", "Identity", ownIdentity.getIdentifier(), "Context", context)); + Map replies = fcpClient.sendPluginMessage(webOfTrustPluginName, createParameters("Message", "AddContext", "Identity", ownIdentity.getIdentifier(), "Context", context)); if (!replies.get("Message").equals("ContextAdded")) { throw new FcpException("WebOfTrust Plugin did not reply with “ContextAdded” message!"); } @@ -339,7 +339,7 @@ public class WebOfTrustPlugin { * if an FCP error occurs */ public void removeContext(OwnIdentity ownIdentity, String context) throws IOException, FcpException { - Map replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "RemoveContext", "Identity", ownIdentity.getIdentifier(), "Context", context)); + Map replies = fcpClient.sendPluginMessage(webOfTrustPluginName, createParameters("Message", "RemoveContext", "Identity", ownIdentity.getIdentifier(), "Context", context)); if (!replies.get("Message").equals("ContextRemoved")) { throw new FcpException("WebOfTrust Plugin did not reply with “ContextRemoved” message!"); } @@ -360,7 +360,7 @@ public class WebOfTrustPlugin { * if an FCP error occurs */ public void setProperty(OwnIdentity ownIdentity, String property, String value) throws IOException, FcpException { - Map replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "SetProperty", "Identity", ownIdentity.getIdentifier(), "Property", property, "Value", value)); + Map replies = fcpClient.sendPluginMessage(webOfTrustPluginName, createParameters("Message", "SetProperty", "Identity", ownIdentity.getIdentifier(), "Property", property, "Value", value)); if (!replies.get("Message").equals("PropertyAdded")) { throw new FcpException("WebOfTrust Plugin did not reply with “PropertyAdded” message!"); } @@ -380,7 +380,7 @@ public class WebOfTrustPlugin { * if an FCP error occurs */ public String getProperty(OwnIdentity ownIdentity, String property) throws IOException, FcpException { - Map replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "GetProperty", "Identity", ownIdentity.getIdentifier(), "Property", property)); + Map replies = fcpClient.sendPluginMessage(webOfTrustPluginName, createParameters("Message", "GetProperty", "Identity", ownIdentity.getIdentifier(), "Property", property)); if (!replies.get("Message").equals("PropertyValue")) { throw new FcpException("WebOfTrust Plugin did not reply with “PropertyValue” message!"); } @@ -400,7 +400,7 @@ public class WebOfTrustPlugin { * if an FCP error occurs */ public void removeProperty(OwnIdentity ownIdentity, String property) throws IOException, FcpException { - Map replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "RemoveProperty", "Identity", ownIdentity.getIdentifier(), "Property", property)); + Map replies = fcpClient.sendPluginMessage(webOfTrustPluginName, createParameters("Message", "RemoveProperty", "Identity", ownIdentity.getIdentifier(), "Property", property)); if (!replies.get("Message").equals("PropertyRemoved")) { throw new FcpException("WebOfTrust Plugin did not reply with “PropertyRemoved” message!"); } @@ -428,4 +428,6 @@ public class WebOfTrustPlugin { return parameterMap; } + private static final String webOfTrustPluginName = "plugins.WoT.WoT"; + }