Drupal: vyhození zbytečností.
3 * see AUTHORS for the list of contributors
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package org.sonews.daemon.command;
20 import java.io.IOException;
21 import org.sonews.storage.Article;
22 import org.sonews.daemon.NNTPConnection;
23 import org.sonews.storage.StorageBackendException;
26 * Implementation of the STAT command.
27 * @author Christian Lins
30 public class StatCommand implements Command {
33 public String[] getSupportedCommandStrings() {
34 return new String[]{"STAT"};
38 public boolean hasFinished() {
43 public String impliedCapability() {
48 public boolean isStateful() {
52 // TODO: Method has various exit points => Refactor!
54 public void processLine(NNTPConnection conn, final String line, byte[] raw)
55 throws IOException, StorageBackendException {
56 final String[] command = line.split(" ");
58 Article article = null;
59 if (command.length == 1) {
60 article = conn.getCurrentArticle();
61 if (article == null) {
62 conn.println("420 no current article has been selected");
65 } else if (command[1].matches(NNTPConnection.MESSAGE_ID_PATTERN)) {
67 article = Article.getByMessageID(command[1]);
68 if (article == null) {
69 conn.println("430 no such article found");
75 long aid = Long.parseLong(command[1]);
76 article = conn.getCurrentChannel().getArticle(aid);
77 } catch (NumberFormatException ex) {
79 } catch (StorageBackendException ex) {
82 if (article == null) {
83 conn.println("423 no such article number in this group");
86 conn.setCurrentArticle(article);
89 conn.println("223 " + conn.getCurrentChannel().getIndexOf(article) + " "
90 + article.getMessageID()
91 + " article retrieved - request text separately");