chris@0: /* chris@0: * StarOffice News Server chris@0: * see AUTHORS for the list of contributors chris@0: * chris@0: * This program is free software: you can redistribute it and/or modify chris@0: * it under the terms of the GNU General Public License as published by chris@0: * the Free Software Foundation, either version 3 of the License, or chris@0: * (at your option) any later version. chris@0: * chris@0: * This program is distributed in the hope that it will be useful, chris@0: * but WITHOUT ANY WARRANTY; without even the implied warranty of chris@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the chris@0: * GNU General Public License for more details. chris@0: * chris@0: * You should have received a copy of the GNU General Public License chris@0: * along with this program. If not, see . chris@0: */ chris@0: chris@0: package com.so.news.command; chris@0: chris@0: import java.io.IOException; chris@0: import java.util.ArrayList; chris@0: import com.so.news.NNTPConnection; chris@0: import com.so.news.storage.Group; chris@0: chris@0: /** chris@0: * Class handling the NEWGROUPS command. chris@0: * @author Christian Lins chris@0: * @author Dennis Schwerdel chris@0: */ chris@0: public class NewGroupsCommand extends Command chris@0: { chris@0: public NewGroupsCommand(NNTPConnection conn) chris@0: { chris@0: super(conn); chris@0: } chris@0: chris@0: public boolean process(String[] command) throws IOException chris@0: { chris@0: String commandName = command[0]; chris@0: if (!commandName.equalsIgnoreCase("NEWGROUPS")) chris@0: return false; chris@0: if (command.length != 3) chris@0: return false; chris@0: // untested, not RFC977 complient chris@0: try chris@0: { chris@0: // Timestamp date = new Timestamp ( new SimpleDateFormat ("yyMMdd chris@0: // HHmmss").parse(command[1] + " " + command[2] ).getTime()) ; chris@0: printStatus(231, "list of new newsgroups follows"); chris@0: ArrayList list = Group.getAll();// (date) ; chris@0: for (Group g : list) chris@0: { chris@0: printTextLine(g.getName() + " " + g.getLastArticle() + " " chris@0: + g.getFirstArticle() + " y"); chris@0: } chris@0: println("."); chris@0: flush(); chris@0: return true; chris@0: } chris@0: catch (Exception e) chris@0: { chris@0: printStatus(511, "listing failed - invalid date format"); chris@0: return true; chris@0: } chris@0: } chris@0: chris@0: }