Example usage for org.apache.commons.net.nntp NNTPClient retrieveArticle

List of usage examples for org.apache.commons.net.nntp NNTPClient retrieveArticle

Introduction

In this page you can find the example usage for org.apache.commons.net.nntp NNTPClient retrieveArticle.

Prototype

@Deprecated
public Reader retrieveArticle(int a) throws IOException 

Source Link

Usage

From source file:org.ossmeter.platform.communicationchannel.nntp.NntpManager.java

@Override
public Date getFirstDate(DB db, NntpNewsGroup newsgroup) throws Exception {
    NNTPClient nntpClient = NntpUtil.connectToNntpServer(newsgroup);
    NewsgroupInfo newsgroupInfo = NntpUtil.selectNewsgroup(nntpClient, newsgroup);
    int firstArticleNumber = newsgroupInfo.getFirstArticle();

    if (firstArticleNumber == 0) {
        return null; // This is to deal with message-less newsgroups.
    }//www.  ja  v  a  2  s  .co  m

    Reader reader = nntpClient.retrieveArticle(firstArticleNumber);
    while (reader == null) {
        firstArticleNumber++;
        reader = nntpClient.retrieveArticle(firstArticleNumber);
        if (firstArticleNumber >= newsgroupInfo.getLastArticle())
            break;
    }

    ArticleHeader articleHeader = new ArticleHeader(reader);
    //      Article article = NntpUtil.getArticleInfo(nntpClient, articleId);
    nntpClient.disconnect();
    //      String date = article.getDate();

    return new Date(NntpUtil.parseDate(articleHeader.getDate().trim()));
}