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 com.so.news.NNTPConnection; chris@0: import com.so.news.storage.Article; chris@0: import com.so.news.storage.Group; chris@0: chris@0: /** chris@0: * Class handling the NEXT and LAST command. chris@0: * @author Christian Lins chris@0: * @author Dennis Schwerdel chris@0: */ chris@0: public class NextCommand extends Command chris@0: { chris@0: public NextCommand(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("NEXT") || commandName chris@0: .equalsIgnoreCase("LAST"))) chris@0: return false; chris@0: // untested, RFC977 complient chris@0: Article currA = getCurrentArticle(); chris@0: Group currG = getCurrentGroup(); chris@0: if (currA == null) chris@0: { chris@0: printStatus(420, "no current article has been selected"); chris@0: return true; chris@0: } chris@0: if (currG == null) chris@0: { chris@0: printStatus(412, "no newsgroup selected"); chris@0: return true; chris@0: } chris@0: Article article; chris@0: if (commandName.equalsIgnoreCase("NEXT")) chris@0: { chris@0: article = currA.nextArticleInGroup(); chris@0: if (article == null) chris@0: { chris@0: printStatus(421, "no next article in this group"); chris@0: return true; chris@0: } chris@0: } chris@0: else chris@0: { chris@0: article = currA.prevArticleInGroup(); chris@0: if (article == null) chris@0: { chris@0: printStatus(422, "no previous article in this group"); chris@0: return true; chris@0: } chris@0: } chris@0: setCurrentArticle(article); chris@0: printStatus(223, article.getNumberInGroup() + " " + article.getMessageID() chris@0: + " article retrieved - request text separately"); chris@0: return true; chris@0: } chris@0: chris@0: }