Fix ALL the logging!
[Sone.git] / src / main / java / net / pterodactylus / sone / freenet / wot / WebOfTrustConnector.java
index b4ea53d..5cacb68 100644 (file)
@@ -70,6 +70,16 @@ public class WebOfTrustConnector implements ConnectorListener {
        //
 
        /**
+        * Stops the web of trust connector.
+        */
+       public void stop() {
+               pluginConnector.removeConnectorListener(WOT_PLUGIN_NAME, PLUGIN_CONNECTION_IDENTIFIER, this);
+               synchronized (reply) {
+                       reply.notifyAll();
+               }
+       }
+
+       /**
         * Loads all own identities from the Web of Trust plugin.
         *
         * @return All own identity
@@ -77,7 +87,6 @@ public class WebOfTrustConnector implements ConnectorListener {
         *             if the own identities can not be loaded
         */
        public Set<OwnIdentity> loadAllOwnIdentities() throws WebOfTrustException {
-               @SuppressWarnings("hiding")
                Reply reply = performRequest(SimpleFieldSetConstructor.create().put("Message", "GetOwnIdentities").get());
                SimpleFieldSet fields = reply.getFields();
                int ownIdentityCounter = -1;
@@ -125,7 +134,6 @@ public class WebOfTrustConnector implements ConnectorListener {
         *             if an error occured talking to the Web of Trust plugin
         */
        public Set<Identity> loadTrustedIdentities(OwnIdentity ownIdentity, String context) throws PluginException {
-               @SuppressWarnings("hiding")
                Reply reply = performRequest(SimpleFieldSetConstructor.create().put("Message", "GetIdentitiesByScore").put("TreeOwner", ownIdentity.getId()).put("Selection", "+").put("Context", (context == null) ? "" : context).get());
                SimpleFieldSet fields = reply.getFields();
                Set<Identity> identities = new HashSet<Identity>();
@@ -185,7 +193,6 @@ public class WebOfTrustConnector implements ConnectorListener {
         *             if an error occured talking to the Web of Trust plugin
         */
        public String getProperty(Identity identity, String name) throws PluginException {
-               @SuppressWarnings("hiding")
                Reply reply = performRequest(SimpleFieldSetConstructor.create().put("Message", "GetProperty").put("Identity", identity.getId()).put("Property", name).get());
                return reply.getFields().get("Property");
        }
@@ -375,16 +382,16 @@ public class WebOfTrustConnector implements ConnectorListener {
         */
        private synchronized Reply performRequest(SimpleFieldSet fields, Bucket data) throws PluginException {
                reply = new Reply();
-               logger.log(Level.FINE, "Sending FCP Request: " + fields.get("Message"));
+               logger.log(Level.FINE, String.format("Sending FCP Request: %s", fields.get("Message")));
                synchronized (reply) {
                        pluginConnector.sendRequest(WOT_PLUGIN_NAME, PLUGIN_CONNECTION_IDENTIFIER, fields, data);
                        try {
                                reply.wait();
                        } catch (InterruptedException ie1) {
-                               logger.log(Level.WARNING, "Got interrupted while waiting for reply on " + fields.get("Message") + ".", ie1);
+                               logger.log(Level.WARNING, String.format("Got interrupted while waiting for reply on %s.", fields.get("Message")), ie1);
                        }
                }
-               logger.log(Level.FINEST, "Received FCP Response for %s: %s", new Object[] { fields.get("Message"), (reply.getFields() != null) ? reply.getFields().get("Message") : null });
+               logger.log(Level.FINEST, String.format("Received FCP Response for %s: %s", fields.get("Message"), (reply.getFields() != null) ? reply.getFields().get("Message") : null));
                if ((reply.getFields() == null) || "Error".equals(reply.getFields().get("Message"))) {
                        throw new PluginException("Could not perform request for " + fields.get("Message"));
                }
@@ -399,9 +406,9 @@ public class WebOfTrustConnector implements ConnectorListener {
         * {@inheritDoc}
         */
        @Override
-       public void receivedReply(@SuppressWarnings("hiding") PluginConnector pluginConnector, SimpleFieldSet fields, Bucket data) {
+       public void receivedReply(PluginConnector pluginConnector, SimpleFieldSet fields, Bucket data) {
                String messageName = fields.get("Message");
-               logger.log(Level.FINEST, "Received Reply from Plugin: " + messageName);
+               logger.log(Level.FINEST, String.format("Received Reply from Plugin: %s", messageName));
                synchronized (reply) {
                        reply.setFields(fields);
                        reply.setData(data);