org/sonews/daemon/command/ListCommand.java
changeset 14 efce4ec25564
parent 3 2fdc9cc89502
child 17 4ae6ada7ea23
     1.1 --- a/org/sonews/daemon/command/ListCommand.java	Wed Jul 22 14:04:05 2009 +0200
     1.2 +++ b/org/sonews/daemon/command/ListCommand.java	Thu Aug 20 16:57:38 2009 +0200
     1.3 @@ -57,15 +57,15 @@
     1.4    {
     1.5      final String[] command = line.split(" ");
     1.6      
     1.7 -    if (command.length >= 2)
     1.8 +    if(command.length >= 2)
     1.9      {
    1.10 -      if (command[1].equalsIgnoreCase("OVERVIEW.FMT"))
    1.11 +      if(command[1].equalsIgnoreCase("OVERVIEW.FMT"))
    1.12        {
    1.13          conn.println("215 information follows");
    1.14          conn.println("Subject:\nFrom:\nDate:\nMessage-ID:\nReferences:\nBytes:\nLines:\nXref");
    1.15          conn.println(".");
    1.16        }
    1.17 -      else if (command[1].equalsIgnoreCase("NEWSGROUPS"))
    1.18 +      else if(command[1].equalsIgnoreCase("NEWSGROUPS"))
    1.19        {
    1.20          conn.println("215 information follows");
    1.21          final List<Channel> list = Channel.getAll();
    1.22 @@ -75,12 +75,12 @@
    1.23          }
    1.24          conn.println(".");
    1.25        }
    1.26 -      else if (command[1].equalsIgnoreCase("SUBSCRIPTIONS"))
    1.27 +      else if(command[1].equalsIgnoreCase("SUBSCRIPTIONS"))
    1.28        {
    1.29          conn.println("215 information follows");
    1.30          conn.println(".");
    1.31        }
    1.32 -      else if (command[1].equalsIgnoreCase("EXTENSIONS"))
    1.33 +      else if(command[1].equalsIgnoreCase("EXTENSIONS"))
    1.34        {
    1.35          conn.println("202 Supported NNTP extensions.");
    1.36          conn.println("LISTGROUP");
    1.37 @@ -88,6 +88,11 @@
    1.38          conn.println("XPAT");
    1.39          conn.println(".");
    1.40        }
    1.41 +      else if(command[1].equalsIgnoreCase("ACTIVE"))
    1.42 +      {
    1.43 +        // TODO: Implement wildcards for LIST ACTIVE
    1.44 +        printGroupInfo(conn);
    1.45 +      }
    1.46        else
    1.47        {
    1.48          conn.println("500 unknown argument to LIST command");
    1.49 @@ -95,26 +100,31 @@
    1.50      }
    1.51      else
    1.52      {
    1.53 -      final List<Channel> groups = Channel.getAll();
    1.54 -      if(groups != null)
    1.55 +      printGroupInfo(conn);
    1.56 +    }
    1.57 +  }
    1.58 +
    1.59 +  private void printGroupInfo(NNTPConnection conn)
    1.60 +    throws IOException, StorageBackendException
    1.61 +  {
    1.62 +    final List<Channel> groups = Channel.getAll();
    1.63 +    if (groups != null)
    1.64 +    {
    1.65 +      conn.println("215 list of newsgroups follows");
    1.66 +      for (Channel g : groups)
    1.67        {
    1.68 -        conn.println("215 list of newsgroups follows");
    1.69 -        for (Channel g : groups)
    1.70 +        if (!g.isDeleted())
    1.71          {
    1.72 -          if(!g.isDeleted())
    1.73 -          {
    1.74 -            String writeable = g.isWriteable() ? " y" : " n";
    1.75 -            // Indeed first the higher article number then the lower
    1.76 -            conn.println(g.getName() + " " + g.getLastArticleNumber() + " "
    1.77 -                + g.getFirstArticleNumber() + writeable);
    1.78 -          }
    1.79 +          String writeable = g.isWriteable() ? " y" : " n";
    1.80 +          // Indeed first the higher article number then the lower
    1.81 +          conn.println(g.getName() + " " + g.getLastArticleNumber() + " " + g.getFirstArticleNumber() + writeable);
    1.82          }
    1.83 -        conn.println(".");
    1.84        }
    1.85 -      else
    1.86 -      {
    1.87 -        conn.println("500 server database malfunction");
    1.88 -      }
    1.89 +      conn.println(".");
    1.90 +    }
    1.91 +    else
    1.92 +    {
    1.93 +      conn.println("500 server database malfunction");
    1.94      }
    1.95    }
    1.96