1.1 --- a/org/sonews/daemon/command/ListGroupCommand.java Fri Jun 26 16:48:50 2009 +0200
1.2 +++ b/org/sonews/daemon/command/ListGroupCommand.java Fri Aug 21 17:40:54 2009 +0200
1.3 @@ -19,10 +19,10 @@
1.4 package org.sonews.daemon.command;
1.5
1.6 import java.io.IOException;
1.7 -import java.sql.SQLException;
1.8 import java.util.List;
1.9 import org.sonews.daemon.NNTPConnection;
1.10 -import org.sonews.daemon.storage.Group;
1.11 +import org.sonews.storage.Channel;
1.12 +import org.sonews.storage.StorageBackendException;
1.13
1.14 /**
1.15 * Class handling the LISTGROUP command.
1.16 @@ -30,12 +30,13 @@
1.17 * @author Dennis Schwerdel
1.18 * @since n3tpd/0.1
1.19 */
1.20 -public class ListGroupCommand extends AbstractCommand
1.21 +public class ListGroupCommand implements Command
1.22 {
1.23
1.24 - public ListGroupCommand(final NNTPConnection conn)
1.25 + @Override
1.26 + public String[] getSupportedCommandStrings()
1.27 {
1.28 - super(conn);
1.29 + return new String[]{"LISTGROUP"};
1.30 }
1.31
1.32 @Override
1.33 @@ -45,37 +46,43 @@
1.34 }
1.35
1.36 @Override
1.37 - public void processLine(final String commandName)
1.38 - throws IOException, SQLException
1.39 + public boolean isStateful()
1.40 + {
1.41 + return false;
1.42 + }
1.43 +
1.44 + @Override
1.45 + public void processLine(NNTPConnection conn, final String commandName, byte[] raw)
1.46 + throws IOException, StorageBackendException
1.47 {
1.48 final String[] command = commandName.split(" ");
1.49
1.50 - Group group;
1.51 + Channel group;
1.52 if(command.length >= 2)
1.53 {
1.54 - group = Group.getByName(command[1]);
1.55 + group = Channel.getByName(command[1]);
1.56 }
1.57 else
1.58 {
1.59 - group = getCurrentGroup();
1.60 + group = conn.getCurrentChannel();
1.61 }
1.62
1.63 if (group == null)
1.64 {
1.65 - printStatus(412, "no group selected; use GROUP <group> command");
1.66 + conn.println("412 no group selected; use GROUP <group> command");
1.67 return;
1.68 }
1.69
1.70 List<Long> ids = group.getArticleNumbers();
1.71 - printStatus(211, ids.size() + " " +
1.72 + conn.println("211 " + ids.size() + " " +
1.73 group.getFirstArticleNumber() + " " +
1.74 group.getLastArticleNumber() + " list of article numbers follow");
1.75 for(long id : ids)
1.76 {
1.77 // One index number per line
1.78 - println(Long.toString(id));
1.79 + conn.println(Long.toString(id));
1.80 }
1.81 - println(".");
1.82 + conn.println(".");
1.83 }
1.84
1.85 }