Examples of NNTPArticle


Examples of org.apache.james.nntpserver.repository.NNTPArticle

     *        If no parameter is provided, the current selected
     *        article is used.
     */
    private void doSTAT(String param) {
        // section 9.2.4
        NNTPArticle article = null;
        if (isMessageId(param)) {
            article = theConfigData.getNNTPRepository().getArticleFromID(param);
            if ( article == null ) {
                writeLoggedFlushedResponse("430 no such article");
                return;
            } else {
                StringBuffer respBuffer =
                    new StringBuffer(64)
                            .append("223 0 ")
                            .append(param);
                writeLoggedFlushedResponse(respBuffer.toString());
            }
        } else {
            int newArticleNumber = currentArticleNumber;
            if ( group == null ) {
                writeLoggedFlushedResponse("412 no newsgroup selected");
                return;
            } else {
                if ( param == null ) {
                    if ( currentArticleNumber < 0 ) {
                        writeLoggedFlushedResponse("420 no current article selected");
                        return;
                    } else {
                        article = group.getArticle(currentArticleNumber);
                    }
                }
                else {
                    newArticleNumber = Integer.parseInt(param);
                    article = group.getArticle(newArticleNumber);
                }
                if ( article == null ) {
                    writeLoggedFlushedResponse("423 no such article number in this group");
                    return;
                } else {
                    currentArticleNumber = newArticleNumber;
                    String articleID = article.getUniqueID();
                    if (articleID == null) {
                        articleID = "<0>";
                    }
                    StringBuffer respBuffer =
                        new StringBuffer(128)
                                .append("223 ")
                                .append(article.getArticleNumber())
                                .append(" ")
                                .append(articleID);
                    writeLoggedFlushedResponse(respBuffer.toString());
                }
            }
View Full Code Here

Examples of org.apache.james.nntpserver.repository.NNTPArticle

        // see section 9.3.2.1
        if (!isMessageId(id)) {
            writeLoggedFlushedResponse("501 command syntax error");
            return;
        }
        NNTPArticle article = theConfigData.getNNTPRepository().getArticleFromID(id);
        if ( article != null ) {
            writeLoggedFlushedResponse("435 article not wanted - do not send it");
        } else {
            writeLoggedFlushedResponse("335 send article to be transferred. End with <CR-LF>.<CR-LF>");
            try {
View Full Code Here

Examples of org.apache.james.nntpserver.repository.NNTPArticle

     *        If no parameter is provided, the current selected
     *        article is used.
     */
    private void doSTAT(String param) {
        // section 9.2.4
        NNTPArticle article = null;
        if (isMessageId(param)) {
            article = theConfigData.getNNTPRepository().getArticleFromID(param);
            if ( article == null ) {
                writeLoggedFlushedResponse("430 no such article");
                return;
            } else {
                StringBuffer respBuffer =
                    new StringBuffer(64)
                            .append("223 0 ")
                            .append(param);
                writeLoggedFlushedResponse(respBuffer.toString());
            }
        } else {
            int newArticleNumber = currentArticleNumber;
            if ( group == null ) {
                writeLoggedFlushedResponse("412 no newsgroup selected");
                return;
            } else {
                if ( param == null ) {
                    if ( currentArticleNumber < 0 ) {
                        writeLoggedFlushedResponse("420 no current article selected");
                        return;
                    } else {
                        article = group.getArticle(currentArticleNumber);
                    }
                }
                else {
                    newArticleNumber = Integer.parseInt(param);
                    article = group.getArticle(newArticleNumber);
                }
                if ( article == null ) {
                    writeLoggedFlushedResponse("423 no such article number in this group");
                    return;
                } else {
                    currentArticleNumber = newArticleNumber;
                    String articleID = article.getUniqueID();
                    if (articleID == null) {
                        articleID = "<0>";
                    }
                    StringBuffer respBuffer =
                        new StringBuffer(128)
                                .append("223 ")
                                .append(article.getArticleNumber())
                                .append(" ")
                                .append(articleID);
                    writeLoggedFlushedResponse(respBuffer.toString());
                }
            }
View Full Code Here

Examples of org.apache.james.nntpserver.repository.NNTPArticle

     *        If no parameter is provided, the current selected
     *        article is used.
     */
    private void doBODY(String param) {
        // section 9.2.3
        NNTPArticle article = null;
        if (isMessageId(param)) {
            article = theConfigData.getNNTPRepository().getArticleFromID(param);
            if ( article == null ) {
                writeLoggedFlushedResponse("430 no such article");
                return;
            } else {
                StringBuffer respBuffer =
                    new StringBuffer(64)
                            .append("222 0 ")
                            .append(param);
                writeLoggedFlushedResponse(respBuffer.toString());
            }
        } else {
            int newArticleNumber = currentArticleNumber;
            if ( group == null ) {
                writeLoggedFlushedResponse("412 no newsgroup selected");
                return;
            } else {
                if ( param == null ) {
                    if ( currentArticleNumber < 0 ) {
                        writeLoggedFlushedResponse("420 no current article selected");
                        return;
                    } else {
                        article = group.getArticle(currentArticleNumber);
                    }
                }
                else {
                    newArticleNumber = Integer.parseInt(param);
                    article = group.getArticle(newArticleNumber);
                }
                if ( article == null ) {
                    writeLoggedFlushedResponse("423 no such article number in this group");
                    return;
                } else {
                    currentArticleNumber = newArticleNumber;
                    String articleID = article.getUniqueID();
                    if (articleID == null) {
                        articleID = "<0>";
                    }
                    StringBuffer respBuffer =
                        new StringBuffer(128)
                                .append("222 ")
                                .append(article.getArticleNumber())
                                .append(" ")
                                .append(articleID);
                    writeLoggedFlushedResponse(respBuffer.toString());
                }
            }
        }
        if (article != null) {
            writer.flush();
            article.writeBody(new ExtraDotOutputStream(outs));
            writeLoggedFlushedResponse("\r\n.");
        }
    }
View Full Code Here

Examples of org.apache.james.nntpserver.repository.NNTPArticle

     *        If no parameter is provided, the current selected
     *        article is used.
     */
    private void doHEAD(String param) {
        // section 9.2.2
        NNTPArticle article = null;
        if (isMessageId(param)) {
            article = theConfigData.getNNTPRepository().getArticleFromID(param);
            if ( article == null ) {
                writeLoggedFlushedResponse("430 no such article");
                return;
            } else {
                StringBuffer respBuffer =
                    new StringBuffer(64)
                            .append("221 0 ")
                            .append(param);
                writeLoggedFlushedResponse(respBuffer.toString());
            }
        } else {
            int newArticleNumber = currentArticleNumber;
            if ( group == null ) {
                writeLoggedFlushedResponse("412 no newsgroup selected");
                return;
            } else {
                if ( param == null ) {
                    if ( currentArticleNumber < 0 ) {
                        writeLoggedFlushedResponse("420 no current article selected");
                        return;
                    } else {
                        article = group.getArticle(currentArticleNumber);
                    }
                }
                else {
                    newArticleNumber = Integer.parseInt(param);
                    article = group.getArticle(newArticleNumber);
                }
                if ( article == null ) {
                    writeLoggedFlushedResponse("423 no such article number in this group");
                    return;
                } else {
                    currentArticleNumber = newArticleNumber;
                    String articleID = article.getUniqueID();
                    if (articleID == null) {
                        articleID = "<0>";
                    }
                    StringBuffer respBuffer =
                        new StringBuffer(128)
                                .append("221 ")
                                .append(article.getArticleNumber())
                                .append(" ")
                                .append(articleID);
                    writeLoggedFlushedResponse(respBuffer.toString());
                }
            }
        }
        if (article != null) {
            writer.flush();
            article.writeHead(new ExtraDotOutputStream(outs));
            writeLoggedFlushedResponse(".");
        }
    }
View Full Code Here

Examples of org.apache.james.nntpserver.repository.NNTPArticle

     *        If no parameter is provided, the current selected
     *        article is used.
     */
    private void doARTICLE(String param) {
        // section 9.2.1
        NNTPArticle article = null;
        if (isMessageId(param)) {
            article = theConfigData.getNNTPRepository().getArticleFromID(param);
            if ( article == null ) {
                writeLoggedFlushedResponse("430 no such article");
                return;
            } else {
                StringBuffer respBuffer =
                    new StringBuffer(64)
                            .append("220 0 ")
                            .append(param);
                writeLoggedResponse(respBuffer.toString());
            }
        } else {
            int newArticleNumber = currentArticleNumber;
            if ( group == null ) {
                writeLoggedFlushedResponse("412 no newsgroup selected");
                return;
            } else {
                if ( param == null ) {
                    if ( currentArticleNumber < 0 ) {
                        writeLoggedFlushedResponse("420 no current article selected");
                        return;
                    } else {
                        article = group.getArticle(currentArticleNumber);
                    }
                }
                else {
                    newArticleNumber = Integer.parseInt(param);
                    article = group.getArticle(newArticleNumber);
                }
                if ( article == null ) {
                    writeLoggedFlushedResponse("423 no such article number in this group");
                    return;
                } else {
                    currentArticleNumber = newArticleNumber;
                    String articleID = article.getUniqueID();
                    if (articleID == null) {
                        articleID = "<0>";
                    }
                    StringBuffer respBuffer =
                        new StringBuffer(128)
                                .append("220 ")
                                .append(article.getArticleNumber())
                                .append(" ")
                                .append(articleID);
                    writeLoggedFlushedResponse(respBuffer.toString());
                }
            }
        }
        if (article != null) {
            writer.flush();
            article.writeArticle(new ExtraDotOutputStream(outs));
            // see jira JAMES-311 for an explanation of the "\r\n"
            writeLoggedFlushedResponse("\r\n.");
        }
    }
View Full Code Here

Examples of org.apache.james.nntpserver.repository.NNTPArticle

            writeLoggedFlushedResponse("420 no current article has been selected");
        } else if ( currentArticleNumber >= group.getLastArticleNumber() ) {
            writeLoggedFlushedResponse("421 no next article in this group");
        } else {
            currentArticleNumber++;
            NNTPArticle article = group.getArticle(currentArticleNumber);
            StringBuffer respBuffer =
                new StringBuffer(64)
                        .append("223 ")
                        .append(article.getArticleNumber())
                        .append(" ")
                        .append(article.getUniqueID());
            writeLoggedFlushedResponse(respBuffer.toString());
        }
    }
View Full Code Here

Examples of org.apache.james.nntpserver.repository.NNTPArticle

            writeLoggedFlushedResponse("420 no current article has been selected");
        } else if ( currentArticleNumber <= group.getFirstArticleNumber() ) {
            writeLoggedFlushedResponse("422 no previous article in this group");
        } else {
            currentArticleNumber--;
            NNTPArticle article = group.getArticle(currentArticleNumber);
            StringBuffer respBuffer =
                new StringBuffer(64)
                        .append("223 ")
                        .append(article.getArticleNumber())
                        .append(" ")
                        .append(article.getUniqueID());
            writeLoggedFlushedResponse(respBuffer.toString());
        }
    }
View Full Code Here

Examples of org.apache.james.nntpserver.repository.NNTPArticle

            writeLoggedFlushedResponse("211 list of article numbers follow");

            Iterator iter = group.getArticles();
            while (iter.hasNext()) {
                NNTPArticle article = (NNTPArticle)iter.next();
                writeLoggedResponse(article.getArticleNumber() + "");
            }
            writeLoggedFlushedResponse(".");
        }
    }
View Full Code Here

Examples of org.apache.james.nntpserver.repository.NNTPArticle

     * fetch the list of articles
     */
    private NNTPArticle[] getRange(String range) {
        // check for msg id
        if ( isMessageId(range)) {
            NNTPArticle article = theConfigData.getNNTPRepository().getArticleFromID(range);
            return ( article == null )
                ? new NNTPArticle[0] : new NNTPArticle[] { article };
        }

        if ( range == null ) {
            range = "" + currentArticleNumber;
        }

        int start = -1;
        int end = -1;
        int idx = range.indexOf('-');
        if ( idx == -1 ) {
            start = Integer.parseInt(range);
            end = start;
        } else {
            start = Integer.parseInt(range.substring(0,idx));
            if ( (idx + 1) == range.length() ) {
                end = group.getLastArticleNumber();
            } else {
                end = Integer.parseInt(range.substring(idx + 1));
            }
        }
        List list = new ArrayList();
        for ( int i = start ; i <= end ; i++ ) {
            NNTPArticle article = group.getArticle(i);
            if ( article != null ) {
                list.add(article);
            }
        }
        return (NNTPArticle[])list.toArray(new NNTPArticle[0]);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.