Example usage for org.apache.commons.net.nntp NewGroupsOrNewsQuery getDistributions

List of usage examples for org.apache.commons.net.nntp NewGroupsOrNewsQuery getDistributions

Introduction

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

Prototype

public String getDistributions() 

Source Link

Document

Return the comma separated list of distributions.

Usage

From source file:net.longfalcon.newsj.nntp.client.CustomNNTPClient.java

/**
 * List all new newsgroups added to the NNTP server since a particular
 * date subject to the conditions of the specified query.  If no new
 * newsgroups were added, no entries will be returned.
 * This uses the "NEWGROUPS" command.//from  ww  w  . j av  a2 s.c o m
 * <p>
 * @param query  The query restricting how to search for new newsgroups.
 * @return An iterable of Strings containing the raw information
 *    for each new newsgroup added to the NNTP server.   If no newsgroups
 *    were added, no entries will be returned.
 * @exception NNTPConnectionClosedException
 *      If the NNTP server prematurely closes the connection as a result
 *      of the client being idle or some other reason causing the server
 *      to send NNTP reply code 400.  This exception may be caught either
 *      as an IOException or independently as itself.
 * @exception IOException  If an I/O error occurs while either sending a
 *      command to the server or receiving a reply from the server.
 * @since 3.0
 */
@Override
public Iterable<String> iterateNewNewsgroupListing(NewGroupsOrNewsQuery query) throws IOException {
    if (NNTPReply.isPositiveCompletion(
            newgroups(query.getDate(), query.getTime(), query.isGMT(), query.getDistributions()))) {
        return new ReplyIterator(_reader_);
    }
    throw new IOException("NEWGROUPS command failed: " + getReplyString());
}

From source file:net.longfalcon.newsj.nntp.client.CustomNNTPClient.java

/***
 * List all new newsgroups added to the NNTP server since a particular
 * date subject to the conditions of the specified query.  If no new
 * newsgroups were added, a zero length array will be returned.  If the
 * command fails, null will be returned.
 * This uses the "NEWGROUPS" command.// www .  j a  v a  2s. c o m
 * <p>
 * @param query  The query restricting how to search for new newsgroups.
 * @return An array of NewsgroupInfo instances containing the information
 *    for each new newsgroup added to the NNTP server.   If no newsgroups
 *    were added, a zero length array will be returned.  If the command
 *    fails, null will be returned.
 * @exception NNTPConnectionClosedException
 *      If the NNTP server prematurely closes the connection as a result
 *      of the client being idle or some other reason causing the server
 *      to send NNTP reply code 400.  This exception may be caught either
 *      as an IOException or independently as itself.
 * @exception IOException  If an I/O error occurs while either sending a
 *      command to the server or receiving a reply from the server.
 * @see #iterateNewNewsgroups(NewGroupsOrNewsQuery)
 * @see #iterateNewNewsgroupListing(NewGroupsOrNewsQuery)
 ***/
@Override
public NewsgroupInfo[] listNewNewsgroups(NewGroupsOrNewsQuery query) throws IOException {
    if (!NNTPReply.isPositiveCompletion(
            newgroups(query.getDate(), query.getTime(), query.isGMT(), query.getDistributions()))) {
        return null;
    }

    return __readNewsgroupListing();
}

From source file:net.longfalcon.newsj.nntp.client.CustomNNTPClient.java

/**
 * List all new articles added to the NNTP server since a particular
 * date subject to the conditions of the specified query.  If no new
 * new news is found, no entries will be returned.
 * This uses the "NEWNEWS" command./*from   w  ww .  jav  a2 s  . c  o  m*/
 * You must add at least one newsgroup to the query, else the command will fail.
 * Each String which is returned is a unique message identifier including the
 * enclosing &lt and &gt.
 * <p>
 * @param query  The query restricting how to search for new news.  You
 *    must add at least one newsgroup to the query.
 * @return An iterator of String instances containing the unique message
 *    identifiers for each new article added to the NNTP server.  If no
 *    new news is found, no strings will be returned.
 * @exception NNTPConnectionClosedException
 *      If the NNTP server prematurely closes the connection as a result
 *      of the client being idle or some other reason causing the server
 *      to send NNTP reply code 400.  This exception may be caught either
 *      as an IOException or independently as itself.
 * @exception IOException  If an I/O error occurs while either sending a
 *      command to the server or receiving a reply from the server.
 * @since 3.0
 */
@Override
public Iterable<String> iterateNewNews(NewGroupsOrNewsQuery query) throws IOException {
    if (NNTPReply.isPositiveCompletion(newnews(query.getNewsgroups(), query.getDate(), query.getTime(),
            query.isGMT(), query.getDistributions()))) {
        return new ReplyIterator(_reader_);
    }
    throw new IOException("NEWNEWS command failed: " + getReplyString());
}

From source file:net.longfalcon.newsj.nntp.client.CustomNNTPClient.java

/***
 * List all new articles added to the NNTP server since a particular
 * date subject to the conditions of the specified query.  If no new
 * new news is found, a zero length array will be returned.  If the
 * command fails, null will be returned.  You must add at least one
 * newsgroup to the query, else the command will fail.  Each String
 * in the returned array is a unique message identifier including the
 * enclosing &lt and &gt.// w w w . j  a  v  a  2 s  .  co m
 * This uses the "NEWNEWS" command.
 * <p>
 * @param query  The query restricting how to search for new news.  You
 *    must add at least one newsgroup to the query.
 * @return An array of String instances containing the unique message
 *    identifiers for each new article added to the NNTP server.  If no
 *    new news is found, a zero length array will be returned.  If the
 *    command fails, null will be returned.
 * @exception NNTPConnectionClosedException
 *      If the NNTP server prematurely closes the connection as a result
 *      of the client being idle or some other reason causing the server
 *      to send NNTP reply code 400.  This exception may be caught either
 *      as an IOException or independently as itself.
 * @exception IOException  If an I/O error occurs while either sending a
 *      command to the server or receiving a reply from the server.
 *
 * @see #iterateNewNews(NewGroupsOrNewsQuery)
 ***/
@Override
public String[] listNewNews(NewGroupsOrNewsQuery query) throws IOException {
    if (!NNTPReply.isPositiveCompletion(newnews(query.getNewsgroups(), query.getDate(), query.getTime(),
            query.isGMT(), query.getDistributions()))) {
        return null;
    }

    Vector<String> list = new Vector<String>();
    BufferedReader reader = new DotTerminatedMessageReader(_reader_);

    String line;
    try {
        while ((line = reader.readLine()) != null) {
            list.addElement(line);
        }
    } finally {
        reader.close();
    }

    int size = list.size();
    if (size < 1) {
        return new String[0];
    }

    String[] result = new String[size];
    list.copyInto(result);

    return result;
}