1.1 --- a/src/org/sonews/daemon/command/XDaemonCommand.java Wed Sep 14 22:39:22 2011 +0200
1.2 +++ b/src/org/sonews/daemon/command/XDaemonCommand.java Wed Sep 14 23:25:00 2011 +0200
1.3 @@ -15,7 +15,6 @@
1.4 * You should have received a copy of the GNU General Public License
1.5 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1.6 */
1.7 -
1.8 package org.sonews.daemon.command;
1.9
1.10 import java.io.IOException;
1.11 @@ -39,36 +38,30 @@
1.12 * @author Christian Lins
1.13 * @since sonews/0.5.0
1.14 */
1.15 -public class XDaemonCommand implements Command
1.16 -{
1.17 +public class XDaemonCommand implements Command {
1.18
1.19 @Override
1.20 - public String[] getSupportedCommandStrings()
1.21 - {
1.22 - return new String[] {"XDAEMON"};
1.23 + public String[] getSupportedCommandStrings() {
1.24 + return new String[]{"XDAEMON"};
1.25 }
1.26
1.27 @Override
1.28 - public boolean hasFinished()
1.29 - {
1.30 + public boolean hasFinished() {
1.31 return true;
1.32 }
1.33
1.34 @Override
1.35 - public String impliedCapability()
1.36 - {
1.37 + public String impliedCapability() {
1.38 return null;
1.39 }
1.40
1.41 @Override
1.42 - public boolean isStateful()
1.43 - {
1.44 + public boolean isStateful() {
1.45 return false;
1.46 }
1.47
1.48 private void channelAdd(String[] commands, NNTPConnection conn)
1.49 - throws IOException, StorageBackendException
1.50 - {
1.51 + throws IOException, StorageBackendException {
1.52 String groupName = commands[2];
1.53 if (StorageManager.current().isGroupExisting(groupName)) {
1.54 conn.println("400 group " + groupName + " already existing!");
1.55 @@ -81,11 +74,11 @@
1.56 // TODO: Refactor this method to reduce complexity!
1.57 @Override
1.58 public void processLine(NNTPConnection conn, String line, byte[] raw)
1.59 - throws IOException, StorageBackendException
1.60 - {
1.61 - InetSocketAddress addr = (InetSocketAddress) conn.getSocketChannel().socket().getRemoteSocketAddress();
1.62 + throws IOException, StorageBackendException {
1.63 + InetSocketAddress addr = (InetSocketAddress)conn.getSocketChannel()
1.64 + .socket().getRemoteSocketAddress();
1.65 if (addr.getHostName().equals(
1.66 - Config.inst().get(Config.XDAEMON_HOST, "localhost"))) {
1.67 + Config.inst().get(Config.XDAEMON_HOST, "localhost"))) {
1.68 String[] commands = line.split(" ", 4);
1.69 if (commands.length == 3 && commands[1].equalsIgnoreCase("LIST")) {
1.70 if (commands[2].equalsIgnoreCase("CONFIGKEYS")) {
1.71 @@ -96,17 +89,17 @@
1.72 conn.println(".");
1.73 } else if (commands[2].equalsIgnoreCase("PEERINGRULES")) {
1.74 List<Subscription> pull =
1.75 - StorageManager.current().getSubscriptions(FeedManager.TYPE_PULL);
1.76 + StorageManager.current().getSubscriptions(FeedManager.TYPE_PULL);
1.77 List<Subscription> push =
1.78 - StorageManager.current().getSubscriptions(FeedManager.TYPE_PUSH);
1.79 + StorageManager.current().getSubscriptions(FeedManager.TYPE_PUSH);
1.80 conn.println("100 list of peering rules follows");
1.81 for (Subscription sub : pull) {
1.82 conn.println("PULL " + sub.getHost() + ":" + sub.getPort()
1.83 - + " " + sub.getGroup());
1.84 + + " " + sub.getGroup());
1.85 }
1.86 for (Subscription sub : push) {
1.87 conn.println("PUSH " + sub.getHost() + ":" + sub.getPort()
1.88 - + " " + sub.getGroup());
1.89 + + " " + sub.getGroup());
1.90 }
1.91 conn.println(".");
1.92 } else {
1.93 @@ -126,23 +119,23 @@
1.94 group.update();
1.95 conn.println("200 group " + commands[2] + " marked as deleted");
1.96 }
1.97 - } else if(commands.length == 5 && commands[1].equalsIgnoreCase("GROUPFLAG")) {
1.98 + } else if (commands.length == 5 && commands[1].equalsIgnoreCase("GROUPFLAG")) {
1.99 Group group = StorageManager.current().getGroup(commands[2]);
1.100 String flagName = commands[4];
1.101 - if(commands[3].equalsIgnoreCase("SET")) {
1.102 - if(flagName.equals("MAILINGLIST")) {
1.103 + if (commands[3].equalsIgnoreCase("SET")) {
1.104 + if (flagName.equals("MAILINGLIST")) {
1.105 group.setFlag(Group.MAILINGLIST);
1.106 - } else if(flagName.equals("DELETED")) {
1.107 + } else if (flagName.equals("DELETED")) {
1.108 group.setFlag(Group.DELETED);
1.109 - } else if(flagName.equals("READONLY")) {
1.110 + } else if (flagName.equals("READONLY")) {
1.111 group.setFlag(Group.READONLY);
1.112 }
1.113 - } else if(commands[3].equalsIgnoreCase("UNSET")) {
1.114 - if(flagName.equals("MAILINGLIST")) {
1.115 + } else if (commands[3].equalsIgnoreCase("UNSET")) {
1.116 + if (flagName.equals("MAILINGLIST")) {
1.117 group.unsetFlag(Group.MAILINGLIST);
1.118 - } else if(flagName.equals("DELETED")) {
1.119 + } else if (flagName.equals("DELETED")) {
1.120 group.unsetFlag(Group.DELETED);
1.121 - } else if(flagName.equals("READONLY")) {
1.122 + } else if (flagName.equals("READONLY")) {
1.123 group.unsetFlag(Group.READONLY);
1.124 }
1.125 } else {