diff -r ed84c8bdd87b -r 5d7d1adf387f src/org/sonews/daemon/command/StatCommand.java --- a/src/org/sonews/daemon/command/StatCommand.java Sun Aug 29 17:28:58 2010 +0200 +++ b/src/org/sonews/daemon/command/StatCommand.java Tue Jun 07 11:55:22 2011 +0200 @@ -31,84 +31,70 @@ public class StatCommand implements Command { - @Override - public String[] getSupportedCommandStrings() - { - return new String[]{"STAT"}; - } + @Override + public String[] getSupportedCommandStrings() + { + return new String[] {"STAT"}; + } - @Override - public boolean hasFinished() - { - return true; - } + @Override + public boolean hasFinished() + { + return true; + } - @Override - public String impliedCapability() - { - return null; - } + @Override + public String impliedCapability() + { + return null; + } - @Override - public boolean isStateful() - { - return false; - } + @Override + public boolean isStateful() + { + return false; + } - // TODO: Method has various exit points => Refactor! - @Override - public void processLine(NNTPConnection conn, final String line, byte[] raw) - throws IOException, StorageBackendException - { - final String[] command = line.split(" "); + // TODO: Method has various exit points => Refactor! + @Override + public void processLine(NNTPConnection conn, final String line, byte[] raw) + throws IOException, StorageBackendException + { + final String[] command = line.split(" "); - Article article = null; - if(command.length == 1) - { - article = conn.getCurrentArticle(); - if(article == null) - { - conn.println("420 no current article has been selected"); - return; - } - } - else if(command[1].matches(NNTPConnection.MESSAGE_ID_PATTERN)) - { - // Message-ID - article = Article.getByMessageID(command[1]); - if (article == null) - { - conn.println("430 no such article found"); - return; - } - } - else - { - // Message Number - try - { - long aid = Long.parseLong(command[1]); - article = conn.getCurrentChannel().getArticle(aid); - } - catch(NumberFormatException ex) - { - ex.printStackTrace(); - } - catch(StorageBackendException ex) - { - ex.printStackTrace(); - } - if (article == null) - { - conn.println("423 no such article number in this group"); - return; - } - conn.setCurrentArticle(article); - } - - conn.println("223 " + conn.getCurrentChannel().getIndexOf(article) + " " - + article.getMessageID() - + " article retrieved - request text separately"); - } - + Article article = null; + if (command.length == 1) { + article = conn.getCurrentArticle(); + if (article == null) { + conn.println("420 no current article has been selected"); + return; + } + } else if (command[1].matches(NNTPConnection.MESSAGE_ID_PATTERN)) { + // Message-ID + article = Article.getByMessageID(command[1]); + if (article == null) { + conn.println("430 no such article found"); + return; + } + } else { + // Message Number + try { + long aid = Long.parseLong(command[1]); + article = conn.getCurrentChannel().getArticle(aid); + } catch (NumberFormatException ex) { + ex.printStackTrace(); + } catch (StorageBackendException ex) { + ex.printStackTrace(); + } + if (article == null) { + conn.println("423 no such article number in this group"); + return; + } + conn.setCurrentArticle(article); + } + + conn.println("223 " + conn.getCurrentChannel().getIndexOf(article) + " " + + article.getMessageID() + + " article retrieved - request text separately"); + } }