Package org.apache.commons.net.nntp

Examples of org.apache.commons.net.nntp.NewsgroupInfo


      if (monitor.isCanceled())
        return null;

      /* Select Newsgroup */
      String newsgroup = link.getPath().replace("/", "");
      NewsgroupInfo groupInfo = new NewsgroupInfo();
      boolean selected = client.selectNewsgroup(newsgroup, groupInfo);

      /* Check Authentication Required */
      checkAuthenticationRequired(client);

      /* Check Newsgroup Selected */
      if (!selected)
        throwConnectionException("Unable to select Newsgroup", client);

      /* Support early cancellation */
      if (monitor.isCanceled())
        return null;

      /* First reload: Retrieve an initial amount of News */
      if (lastArticleId == null) {

        /* Set Article Pointer to last Article */
        int status = client.stat(groupInfo.getLastArticle());
        if (status != STATUS_ARTICLE_POINTER_OK)
          throwConnectionException("Unable to retrieve any News", client);

        /* Retrieve initial news */
        for (int i = 0; i < INITIAL_NEWS && !monitor.isCanceled(); i++) {
          createNews(client.retrieveArticle(), feed, monitor);

          /* Goto previous news if provided */
          int result = client.last();
          if (result != STATUS_ARTICLE_POINTER_OK)
            break;
        }
      }

      /* Subsequent reload: Set pointer to last retrieved News */
      else {

        /* Set Article Pointer to last retrieved News */
        int status = client.stat(lastArticleId);
        if (status != STATUS_ARTICLE_POINTER_OK)
          throwConnectionException("Unable to retrieve any News", client);

        /* Retrieve all the following News */
        while (client.next() == STATUS_ARTICLE_POINTER_OK && !monitor.isCanceled())
          createNews(client.retrieveArticle(), feed, monitor);
      }

      /* Remember last article's ID */
      lastArticleId = groupInfo.getLastArticle();
    }

    /* Wrap Exceptions */
    catch (IOException e) {
      throw new ConnectionException(Activator.getDefault().createErrorStatus(e.getMessage(), e));
View Full Code Here


                    System.out.println("Authentication failed, error =" +
                                       client.getReplyString());
    }
 
      // XOVER
      NewsgroupInfo testGroup = new NewsgroupInfo();
            client.selectNewsgroup("alt.test", testGroup);
            int lowArticleNumber = testGroup.getFirstArticle();
            int highArticleNumber = testGroup.getLastArticle();
      Article[] articles =
                getArticleInfo(lowArticleNumber, highArticleNumber);
     
      for(int i =0; i < articles.length; ++i)
                {
View Full Code Here

        if(!client.authenticate(user, password)) {
            System.out.println("Authentication failed for user " + user + "!");
            System.exit(1);
        }
       
        NewsgroupInfo group = new NewsgroupInfo();
        client.selectNewsgroup("comp.lang.lisp", group);
       
        int lowArticleNumber = group.getFirstArticle();
        int highArticleNumber = lowArticleNumber + 100;
       
        System.out.println("Retrieving articles between [" + lowArticleNumber + "] and [" + highArticleNumber + "]");
        Article[] articles = NNTPUtils.getArticleInfo(client, lowArticleNumber, highArticleNumber);
       
View Full Code Here

            } else {
                System.out.println("Authentication failed, error =" + client.getReplyString());
            }

            // XOVER
            NewsgroupInfo testGroup = new NewsgroupInfo();
            client.selectNewsgroup("alt.test", testGroup);
            int lowArticleNumber = testGroup.getFirstArticle();
            int highArticleNumber = lowArticleNumber + 100;
            Article[] articles = NNTPUtils.getArticleInfo(client, lowArticleNumber, highArticleNumber);

            for (int i = 0; i < articles.length; ++i) {
                System.out.println(articles[i].getSubject());
View Full Code Here

      if (monitor.isCanceled())
        return null;

      /* Select Newsgroup */
      String newsgroup = link.getPath().replace("/", ""); //$NON-NLS-1$ //$NON-NLS-2$
      NewsgroupInfo groupInfo = new NewsgroupInfo();
      boolean selected = client.selectNewsgroup(newsgroup, groupInfo);

      /* Check Authentication Required */
      checkAuthenticationRequired(client, link);

      /* Check Newsgroup Selected */
      if (!selected)
        throwConnectionException(Messages.NewsGroupHandler_ERROR_SELECT_NEWSGROUP, client);

      /* Support early cancellation */
      if (monitor.isCanceled())
        return null;

      boolean downloadWithoutPointer = (lastArticleId == null); //Last article servers as pointer

      /* Subsequent reload: Set pointer to last retrieved News and go from there */
      if (lastArticleId != null) {

        /* Set Article Pointer to last retrieved News */
        int status = client.stat(lastArticleId);
        if (status == NO_SUCH_ARTICLE_ERROR)
          downloadWithoutPointer = true; //This can happen if the last article id was not found, grab the latest news then
        else if (status != STATUS_ARTICLE_POINTER_OK)
          throwConnectionException(Messages.NewsGroupHandler_ERROR_RETRIEVE_NEWS, client);

        /* Retrieve all the following News */
        if (!downloadWithoutPointer) {
          while (client.next() == STATUS_ARTICLE_POINTER_OK && !monitor.isCanceled())
            createNews(client.retrieveArticle(), feed, monitor);
        }
      }

      /* Retrieve the last 50 News of the group */
      if (downloadWithoutPointer) {

        /* Set Article Pointer to last Article */
        int status = client.stat(groupInfo.getLastArticle());
        if (status != STATUS_ARTICLE_POINTER_OK)
          throwConnectionException(Messages.NewsGroupHandler_ERROR_RETRIEVE_NEWS, client);

        /* Retrieve initial news */
        for (int i = 0; i < INITIAL_NEWS && !monitor.isCanceled(); i++) {
          createNews(client.retrieveArticle(), feed, monitor);

          /* Goto previous news if provided */
          int result = client.last();
          if (result != STATUS_ARTICLE_POINTER_OK)
            break;
        }
      }

      /* Remember last article's ID */
      lastArticleId = groupInfo.getLastArticle();
    }

    /* Wrap Exceptions */
    catch (IOException e) {
      throw new ConnectionException(Activator.createErrorStatus(e.getMessage(), e));
View Full Code Here

                    System.out.println("Authentication failed, error =" + client.getReplyString());
                }
            }

            // XOVER
            NewsgroupInfo testGroup = new NewsgroupInfo();
            client.selectNewsgroup("alt.test", testGroup);
            long lowArticleNumber = testGroup.getFirstArticleLong();
            long  highArticleNumber = lowArticleNumber + 100;
            Iterable<Article> articles = client.iterateArticleInfo(lowArticleNumber, highArticleNumber);

            for (Article article : articles) {
                if (article.isDummy()) { // Subject will contain raw response
View Full Code Here

                    System.out.println("Authentication failed, error =" +
                                       client.getReplyString());
        }

        // XOVER
        NewsgroupInfo testGroup = new NewsgroupInfo();
            client.selectNewsgroup("alt.test", testGroup);
            int lowArticleNumber = testGroup.getFirstArticle();
            int highArticleNumber = testGroup.getLastArticle();
        Article[] articles =
                getArticleInfo(lowArticleNumber, highArticleNumber);

        for(int i =0; i < articles.length; ++i)
                {
View Full Code Here

    if(!client.authenticate(user, password)) {
      System.out.println("Authentication failed for user " + user + "!");
      System.exit(1);
    }
   
    NewsgroupInfo group = new NewsgroupInfo();
    client.selectNewsgroup("comp.lang.lisp", group);
   
    int lowArticleNumber = group.getFirstArticle();
    int highArticleNumber = lowArticleNumber + 100;
   
    System.out.println("Retrieving articles between [" + lowArticleNumber + "] and [" + highArticleNumber + "]");
    Article[] articles = NNTPUtils.getArticleInfo(client, lowArticleNumber, highArticleNumber);
   
View Full Code Here

      } else {
        System.out.println("Authentication failed, error =" + client.getReplyString());
      }

      // XOVER
      NewsgroupInfo testGroup = new NewsgroupInfo();
      client.selectNewsgroup("alt.test", testGroup);
      int lowArticleNumber = testGroup.getFirstArticle();
      int highArticleNumber = lowArticleNumber + 100;
      Article[] articles = NNTPUtils.getArticleInfo(client, lowArticleNumber, highArticleNumber);

      for (int i = 0; i < articles.length; ++i) {
        System.out.println(articles[i].getSubject());
View Full Code Here

                System.out.println(s);
            }
        } else {
            System.out.println("Failed to get OVERVIEW.FMT");
        }
        NewsgroupInfo group = new NewsgroupInfo();
        client.selectNewsgroup(newsgroup, group);

        long lowArticleNumber = group.getFirstArticleLong();
        long highArticleNumber = lowArticleNumber + 5000;

        System.out.println("Retrieving articles between [" + lowArticleNumber + "] and [" + highArticleNumber + "]");
        Iterable<Article> articles = client.iterateArticleInfo(lowArticleNumber, highArticleNumber);
View Full Code Here

TOP

Related Classes of org.apache.commons.net.nntp.NewsgroupInfo

Copyright © 2018 www.massapicom. 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.