Move Sone-related FCP classes to different package.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 8 Apr 2011 13:20:08 +0000 (15:20 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 8 Apr 2011 13:20:08 +0000 (15:20 +0200)
src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java [new file with mode: 0644]
src/main/java/net/pterodactylus/sone/fcp/VersionCommand.java [new file with mode: 0644]
src/main/java/net/pterodactylus/sone/freenet/fcp/FcpInterface.java [deleted file]
src/main/java/net/pterodactylus/sone/freenet/fcp/VersionCommand.java [deleted file]
src/main/java/net/pterodactylus/sone/main/SonePlugin.java

diff --git a/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java b/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java
new file mode 100644 (file)
index 0000000..8841f63
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * Sone - FcpInterface.java - Copyright © 2011 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.fcp;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.pterodactylus.sone.core.Core;
+import net.pterodactylus.sone.freenet.fcp.Command;
+import net.pterodactylus.sone.freenet.fcp.FcpException;
+import net.pterodactylus.sone.freenet.fcp.Command.AccessType;
+import net.pterodactylus.sone.freenet.fcp.Command.Reply;
+import freenet.pluginmanager.FredPluginFCP;
+import freenet.pluginmanager.PluginNotFoundException;
+import freenet.pluginmanager.PluginReplySender;
+import freenet.support.SimpleFieldSet;
+import freenet.support.api.Bucket;
+
+/**
+ * Implementation of an FCP interface for other clients or plugins to
+ * communicate with Sone.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class FcpInterface {
+
+       /** All available FCP commands. */
+       private final Map<String, Command> commands = Collections.synchronizedMap(new HashMap<String, Command>());
+
+       /**
+        * Creates a new FCP interface.
+        *
+        * @param core
+        *            The core
+        */
+       public FcpInterface(Core core) {
+               commands.put("Version", new VersionCommand());
+               commands.put("GetPostFeed", new GetPostFeedCommand(core));
+       }
+
+       /**
+        * Handles a plugin FCP request.
+        *
+        * @param pluginReplySender
+        *            The reply sender
+        * @param parameters
+        *            The message parameters
+        * @param data
+        *            The message data (may be {@code null})
+        * @param accessType
+        *            One of {@link FredPluginFCP#ACCESS_DIRECT},
+        *            {@link FredPluginFCP#ACCESS_FCP_FULL},
+        *            {@link FredPluginFCP#ACCESS_FCP_RESTRICTED}
+        */
+       public void handle(PluginReplySender pluginReplySender, SimpleFieldSet parameters, Bucket data, int accessType) {
+               Command command = commands.get(parameters.get("Message"));
+               if (command == null) {
+                       /* TODO - return error? */
+                       return;
+               }
+               String identifier = parameters.get("Identifier");
+               if ((identifier == null) || (identifier.length() == 0)) {
+                       /* TODO - return error? */
+                       return;
+               }
+               try {
+                       Reply reply = command.execute(parameters, data, AccessType.values()[accessType]);
+                       SimpleFieldSet replyParameters = reply.getReplyParameters();
+                       replyParameters.putOverwrite("Identifier", identifier);
+                       if (reply.hasData()) {
+                               pluginReplySender.send(replyParameters, reply.getData());
+                       } else if (reply.hasBucket()) {
+                               pluginReplySender.send(replyParameters, reply.getBucket());
+                       } else {
+                               pluginReplySender.send(replyParameters);
+                       }
+               } catch (FcpException fe1) {
+                       /* TODO - log, report */
+               } catch (PluginNotFoundException pnfe1) {
+                       /* TODO - log */
+               }
+       }
+
+}
diff --git a/src/main/java/net/pterodactylus/sone/fcp/VersionCommand.java b/src/main/java/net/pterodactylus/sone/fcp/VersionCommand.java
new file mode 100644 (file)
index 0000000..a370cbf
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Sone - VersionCommand.java - Copyright © 2011 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.fcp;
+
+import net.pterodactylus.sone.freenet.SimpleFieldSetBuilder;
+import net.pterodactylus.sone.freenet.fcp.Command;
+import net.pterodactylus.sone.freenet.fcp.Command.AccessType;
+import net.pterodactylus.sone.freenet.fcp.Command.Reply;
+import net.pterodactylus.sone.main.SonePlugin;
+import freenet.support.SimpleFieldSet;
+import freenet.support.api.Bucket;
+
+/**
+ * Returns version information about the Sone plugin.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class VersionCommand implements Command {
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public Reply execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) {
+               return new Reply(new SimpleFieldSetBuilder().put("Version", SonePlugin.VERSION.toString()).put("ProtocolVersion", 1).get());
+       }
+
+}
diff --git a/src/main/java/net/pterodactylus/sone/freenet/fcp/FcpInterface.java b/src/main/java/net/pterodactylus/sone/freenet/fcp/FcpInterface.java
deleted file mode 100644 (file)
index 8da41ed..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Sone - FcpInterface.java - Copyright © 2011 David Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.freenet.fcp;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import net.pterodactylus.sone.core.Core;
-import net.pterodactylus.sone.freenet.fcp.Command.AccessType;
-import net.pterodactylus.sone.freenet.fcp.Command.Reply;
-import freenet.pluginmanager.FredPluginFCP;
-import freenet.pluginmanager.PluginNotFoundException;
-import freenet.pluginmanager.PluginReplySender;
-import freenet.support.SimpleFieldSet;
-import freenet.support.api.Bucket;
-
-/**
- * Implementation of an FCP interface for other clients or plugins to
- * communicate with Sone.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public class FcpInterface {
-
-       /** All available FCP commands. */
-       private final Map<String, Command> commands = Collections.synchronizedMap(new HashMap<String, Command>());
-
-       /**
-        * Creates a new FCP interface.
-        *
-        * @param core
-        *            The core
-        */
-       public FcpInterface(Core core) {
-               commands.put("Version", new VersionCommand());
-               commands.put("GetPostFeed", new GetPostFeedCommand(core));
-       }
-
-       /**
-        * Handles a plugin FCP request.
-        *
-        * @param pluginReplySender
-        *            The reply sender
-        * @param parameters
-        *            The message parameters
-        * @param data
-        *            The message data (may be {@code null})
-        * @param accessType
-        *            One of {@link FredPluginFCP#ACCESS_DIRECT},
-        *            {@link FredPluginFCP#ACCESS_FCP_FULL},
-        *            {@link FredPluginFCP#ACCESS_FCP_RESTRICTED}
-        */
-       public void handle(PluginReplySender pluginReplySender, SimpleFieldSet parameters, Bucket data, int accessType) {
-               Command command = commands.get(parameters.get("Message"));
-               if (command == null) {
-                       /* TODO - return error? */
-                       return;
-               }
-               String identifier = parameters.get("Identifier");
-               if ((identifier == null) || (identifier.length() == 0)) {
-                       /* TODO - return error? */
-                       return;
-               }
-               try {
-                       Reply reply = command.execute(parameters, data, AccessType.values()[accessType]);
-                       SimpleFieldSet replyParameters = reply.getReplyParameters();
-                       replyParameters.putOverwrite("Identifier", identifier);
-                       if (reply.hasData()) {
-                               pluginReplySender.send(replyParameters, reply.getData());
-                       } else if (reply.hasBucket()) {
-                               pluginReplySender.send(replyParameters, reply.getBucket());
-                       } else {
-                               pluginReplySender.send(replyParameters);
-                       }
-               } catch (FcpException fe1) {
-                       /* TODO - log, report */
-               } catch (PluginNotFoundException pnfe1) {
-                       /* TODO - log */
-               }
-       }
-
-}
diff --git a/src/main/java/net/pterodactylus/sone/freenet/fcp/VersionCommand.java b/src/main/java/net/pterodactylus/sone/freenet/fcp/VersionCommand.java
deleted file mode 100644 (file)
index a765135..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Sone - VersionCommand.java - Copyright © 2011 David Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.freenet.fcp;
-
-import net.pterodactylus.sone.freenet.SimpleFieldSetBuilder;
-import net.pterodactylus.sone.main.SonePlugin;
-import freenet.support.SimpleFieldSet;
-import freenet.support.api.Bucket;
-
-/**
- * Returns version information about the Sone plugin.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public class VersionCommand implements Command {
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       public Reply execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) {
-               return new Reply(new SimpleFieldSetBuilder().put("Version", SonePlugin.VERSION.toString()).put("ProtocolVersion", 1).get());
-       }
-
-}
index 05b8403..0a28656 100644 (file)
@@ -24,8 +24,8 @@ import java.util.logging.Logger;
 
 import net.pterodactylus.sone.core.Core;
 import net.pterodactylus.sone.core.FreenetInterface;
+import net.pterodactylus.sone.fcp.FcpInterface;
 import net.pterodactylus.sone.freenet.PluginStoreConfigurationBackend;
-import net.pterodactylus.sone.freenet.fcp.FcpInterface;
 import net.pterodactylus.sone.freenet.plugin.PluginConnector;
 import net.pterodactylus.sone.freenet.wot.IdentityManager;
 import net.pterodactylus.sone.freenet.wot.WebOfTrustConnector;