    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *      http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017
    018package org.apache.commons.net.nntp;
    019
    020/***
    021 * NNTPReply stores a set of constants for NNTP reply codes.  To interpret
    022 * the meaning of the codes, familiarity with RFC 977 is assumed.
    023 * The mnemonic constant names are transcriptions from the code descriptions
    024 * of RFC 977.
    025 ***/
    026
    027public final class NNTPReply
    028{
    029
    030    public static final int HELP_TEXT_FOLLOWS                = 100;
    031    public static final int DEBUG_OUTPUT                     = 199;
    032    public static final int SERVER_READY_POSTING_ALLOWED     = 200;
    033    public static final int SERVER_READY_POSTING_NOT_ALLOWED = 201;
    034    public static final int SLAVE_STATUS_NOTED               = 202;
    035    public static final int CLOSING_CONNECTION               = 205;
    036    public static final int GROUP_SELECTED                   = 211;
    037    public static final int ARTICLE_RETRIEVED_HEAD_AND_BODY_FOLLOW = 220;
    038    public static final int ARTICLE_RETRIEVED_HEAD_FOLLOWS = 221;
    039    public static final int ARTICLE_RETRIEVED_BODY_FOLLOWS = 222;
    040    public static final int ARTICLE_RETRIEVED_REQUEST_TEXT_SEPARATELY = 223;
    041    public static final int ARTICLE_LIST_BY_MESSAGE_ID_FOLLOWS = 230;
    042    public static final int NEW_NEWSGROUP_LIST_FOLLOWS         = 231;
    043    public static final int ARTICLE_TRANSFERRED_OK             = 235;
    044    public static final int ARTICLE_POSTED_OK                  = 240;
    045    public static final int AUTHENTICATION_ACCEPTED            = 281;
    046    public static final int SEND_ARTICLE_TO_TRANSFER           = 335;
    047    public static final int SEND_ARTICLE_TO_POST               = 340;
    048    public static final int MORE_AUTH_INFO_REQUIRED            = 381;
    049    public static final int SERVICE_DISCONTINUED               = 400;
    050    public static final int NO_SUCH_NEWSGROUP                  = 411;
    051    public static final int NO_NEWSGROUP_SELECTED              = 412;
    052    public static final int NO_CURRENT_ARTICLE_SELECTED        = 420;
    053    public static final int NO_NEXT_ARTICLE                    = 421;
    054    public static final int NO_PREVIOUS_ARTICLE                = 422;
    055    public static final int NO_SUCH_ARTICLE_NUMBER             = 423;
    056    public static final int NO_SUCH_ARTICLE_FOUND              = 430;
    057    public static final int ARTICLE_NOT_WANTED                 = 435;
    058    public static final int TRANSFER_FAILED                    = 436;
    059    public static final int ARTICLE_REJECTED                   = 437;
    060    public static final int POSTING_NOT_ALLOWED                = 440;
    061    public static final int POSTING_FAILED                     = 441;
    062    /** @since 2.2 - corrected value to 480 */
    063    public static final int AUTHENTICATION_REQUIRED            = 480;
    064    public static final int AUTHENTICATION_REJECTED            = 482;
    065    public static final int COMMAND_NOT_RECOGNIZED             = 500;
    066    public static final int COMMAND_SYNTAX_ERROR               = 501;
    067    public static final int PERMISSION_DENIED                  = 502;
    068    public static final int PROGRAM_FAULT                      = 503;
    069
    070    // Cannot be instantiated
    071
    072    private NNTPReply()
    073    {}
    074
    075    /***
    076     * Determine if a reply code is an informational response.  All
    077     * codes beginning with a 1 are positive informational responses.
    078     * Informational responses are used to provide human readable
    079     * information such as help text.
    080     * <p>
    081     * @param reply  The reply code to test.
    082     * @return True if a reply code is an informational response, false
    083     *         if not.
    084     ***/
    085    public static boolean isInformational(int reply)
    086    {
    087        return (reply >= 100 && reply < 200);
    088    }
    089
    090    /***
    091     * Determine if a reply code is a positive completion response.  All
    092     * codes beginning with a 2 are positive completion responses.
    093     * The NNTP server will send a positive completion response on the final
    094     * successful completion of a command.
    095     * <p>
    096     * @param reply  The reply code to test.
    097     * @return True if a reply code is a postive completion response, false
    098     *         if not.
    099     ***/
    100    public static boolean isPositiveCompletion(int reply)
    101    {
    102        return (reply >= 200 && reply < 300);
    103    }
    104
    105    /***
    106     * Determine if a reply code is a positive intermediate response.  All
    107     * codes beginning with a 3 are positive intermediate responses.
    108     * The NNTP server will send a positive intermediate response on the
    109     * successful completion of one part of a multi-part command or
    110     * sequence of commands.  For example, after a successful POST command,
    111     * a positive intermediate response will be sent to indicate that the
    112     * server is ready to receive the article to be posted.
    113     * <p>
    114     * @param reply  The reply code to test.
    115     * @return True if a reply code is a postive intermediate response, false
    116     *         if not.
    117     ***/
    118    public static boolean isPositiveIntermediate(int reply)
    119    {
    120        return (reply >= 300 && reply < 400);
    121    }
    122
    123    /***
    124     * Determine if a reply code is a negative transient response.  All
    125     * codes beginning with a 4 are negative transient responses.
    126     * The NNTP server will send a negative transient response on the
    127     * failure of a correctly formatted command that could not be performed
    128     * for some reason.  For example, retrieving an article that does not
    129     * exist will result in a negative transient response.
    130     * <p>
    131     * @param reply  The reply code to test.
    132     * @return True if a reply code is a negative transient response, false
    133     *         if not.
    134     ***/
    135    public static boolean isNegativeTransient(int reply)
    136    {
    137        return (reply >= 400 && reply < 500);
    138    }
    139
    140    /***
    141     * Determine if a reply code is a negative permanent response.  All
    142     * codes beginning with a 5 are negative permanent responses.
    143     * The NNTP server will send a negative permanent response when
    144     * it does not implement a command, a command is incorrectly formatted,
    145     * or a serious program error occurs.
    146     * <p>
    147     * @param reply  The reply code to test.
    148     * @return True if a reply code is a negative permanent response, false
    149     *         if not.
    150     ***/
    151    public static boolean isNegativePermanent(int reply)
    152    {
    153        return (reply >= 500 && reply < 600);
    154    }
    155
    156}
    157
    158/* Emacs configuration
    159 * Local variables:        **
    160 * mode:             java  **
    161 * c-basic-offset:   4     **
    162 * indent-tabs-mode: nil   **
    163 * End:                    **
    164 */