1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.apache.commons.net.nntp;
19
20 /***
21 * NNTPReply stores a set of constants for NNTP reply codes. To interpret
22 * the meaning of the codes, familiarity with RFC 977 is assumed.
23 * The mnemonic constant names are transcriptions from the code descriptions
24 * of RFC 977.
25 ***/
26
27 public final class NNTPReply
28 {
29
30 public static final int HELP_TEXT_FOLLOWS = 100;
31 public static final int DEBUG_OUTPUT = 199;
32 public static final int SERVER_READY_POSTING_ALLOWED = 200;
33 public static final int SERVER_READY_POSTING_NOT_ALLOWED = 201;
34 public static final int SLAVE_STATUS_NOTED = 202;
35 public static final int CLOSING_CONNECTION = 205;
36 public static final int GROUP_SELECTED = 211;
37 public static final int ARTICLE_RETRIEVED_HEAD_AND_BODY_FOLLOW = 220;
38 public static final int ARTICLE_RETRIEVED_HEAD_FOLLOWS = 221;
39 public static final int ARTICLE_RETRIEVED_BODY_FOLLOWS = 222;
40 public static final int ARTICLE_RETRIEVED_REQUEST_TEXT_SEPARATELY = 223;
41 public static final int ARTICLE_LIST_BY_MESSAGE_ID_FOLLOWS = 230;
42 public static final int NEW_NEWSGROUP_LIST_FOLLOWS = 231;
43 public static final int ARTICLE_TRANSFERRED_OK = 235;
44 public static final int ARTICLE_POSTED_OK = 240;
45 public static final int AUTHENTICATION_ACCEPTED = 281;
46 public static final int SEND_ARTICLE_TO_TRANSFER = 335;
47 public static final int SEND_ARTICLE_TO_POST = 340;
48 public static final int MORE_AUTH_INFO_REQUIRED = 381;
49 public static final int SERVICE_DISCONTINUED = 400;
50 public static final int NO_SUCH_NEWSGROUP = 411;
51 public static final int NO_NEWSGROUP_SELECTED = 412;
52 public static final int NO_CURRENT_ARTICLE_SELECTED = 420;
53 public static final int NO_NEXT_ARTICLE = 421;
54 public static final int NO_PREVIOUS_ARTICLE = 422;
55 public static final int NO_SUCH_ARTICLE_NUMBER = 423;
56 public static final int NO_SUCH_ARTICLE_FOUND = 430;
57 public static final int ARTICLE_NOT_WANTED = 435;
58 public static final int TRANSFER_FAILED = 436;
59 public static final int ARTICLE_REJECTED = 437;
60 public static final int POSTING_NOT_ALLOWED = 440;
61 public static final int POSTING_FAILED = 441;
62 /** @since 2.2 - corrected value to 480 */
63 public static final int AUTHENTICATION_REQUIRED = 480;
64 public static final int AUTHENTICATION_REJECTED = 482;
65 public static final int COMMAND_NOT_RECOGNIZED = 500;
66 public static final int COMMAND_SYNTAX_ERROR = 501;
67 public static final int PERMISSION_DENIED = 502;
68 public static final int PROGRAM_FAULT = 503;
69
70 // Cannot be instantiated
71
72 private NNTPReply()
73 {}
74
75 /***
76 * Determine if a reply code is an informational response. All
77 * codes beginning with a 1 are positive informational responses.
78 * Informational responses are used to provide human readable
79 * information such as help text.
80 * <p>
81 * @param reply The reply code to test.
82 * @return True if a reply code is an informational response, false
83 * if not.
84 ***/
85 public static boolean isInformational(int reply)
86 {
87 return (reply >= 100 && reply < 200);
88 }
89
90 /***
91 * Determine if a reply code is a positive completion response. All
92 * codes beginning with a 2 are positive completion responses.
93 * The NNTP server will send a positive completion response on the final
94 * successful completion of a command.
95 * <p>
96 * @param reply The reply code to test.
97 * @return True if a reply code is a postive completion response, false
98 * if not.
99 ***/
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 */