♻️ Extract plugin name into a constant
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Tue, 7 Jan 2025 20:21:53 +0000 (21:21 +0100)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Tue, 7 Jan 2025 20:21:53 +0000 (21:21 +0100)
src/main/java/net/pterodactylus/fcp/plugin/WebOfTrustPlugin.java

index 22584ee..cd9c8a6 100644 (file)
@@ -95,7 +95,7 @@ public class WebOfTrustPlugin {
                        parameters.put("RequestURI", requestUri);
                        parameters.put("InsertURI", insertUri);
                }
-               Map<String, String> replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", parameters);
+               Map<String, String> 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<OwnIdentity> getOwnIdentites() throws IOException, FcpException {
-               Map<String, String> replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "GetOwnIdentities"));
+               Map<String, String> 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<String, String> replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "GetIdentity", "TreeOwner", ownIdentity.getIdentifier(), "Identity", identifier));
+               Map<String, String> 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<String, String> replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "AddIdentity", "RequestURI", requestUri));
+               Map<String, String> 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<Identity> getIdentitesByScore(OwnIdentity ownIdentity, String context, Boolean positive) throws IOException, FcpException {
-               Map<String, String> replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "GetIdentitiesByScore", "TreeOwner", ownIdentity.getIdentifier(), "Context", context, "Selection", ((positive == null) ? "0" : (positive ? "+" : "-"))));
+               Map<String, String> 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<Identity, IdentityTrust> getTrusters(Identity identity, String context) throws IOException, FcpException {
-               Map<String, String> replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "GetTrusters", "Identity", identity.getIdentifier(), "Context", context));
+               Map<String, String> 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<Identity, IdentityTrust> getTrustees(Identity identity, String context) throws IOException, FcpException {
-               Map<String, String> replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "GetTrustees", "Identity", identity.getIdentifier(), "Context", context));
+               Map<String, String> 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<String, String> replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "SetTrust", "Truster", ownIdentity.getIdentifier(), "Trustee", identity.getIdentifier(), "Value", String.valueOf(trust), "Comment", comment));
+               Map<String, String> 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<String, String> replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "AddContext", "Identity", ownIdentity.getIdentifier(), "Context", context));
+               Map<String, String> 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<String, String> replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "RemoveContext", "Identity", ownIdentity.getIdentifier(), "Context", context));
+               Map<String, String> 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<String, String> replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "SetProperty", "Identity", ownIdentity.getIdentifier(), "Property", property, "Value", value));
+               Map<String, String> 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<String, String> replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "GetProperty", "Identity", ownIdentity.getIdentifier(), "Property", property));
+               Map<String, String> 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<String, String> replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "RemoveProperty", "Identity", ownIdentity.getIdentifier(), "Property", property));
+               Map<String, String> 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";
+
 }