1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.net.nntp;
17
18 /***
19 * NNTPReply stores a set of constants for NNTP reply codes. To interpret
20 * the meaning of the codes, familiarity with RFC 977 is assumed.
21 * The mnemonic constant names are transcriptions from the code descriptions
22 * of RFC 977. For those who think in terms of the actual reply code values,
23 * a set of CODE_NUM constants are provided where NUM is the numerical value
24 * of the code.
25 * <p>
26 * <p>
27 * @author Daniel F. Savarese
28 ***/
29
30 public final class NNTPReply
31 {
32
33 public static final int CODE_100 = 100;
34 public static final int CODE_199 = 199;
35 public static final int CODE_200 = 200;
36 public static final int CODE_201 = 201;
37 public static final int CODE_202 = 202;
38 public static final int CODE_205 = 205;
39 public static final int CODE_211 = 211;
40 public static final int CODE_215 = 215;
41 public static final int CODE_220 = 220;
42 public static final int CODE_221 = 221;
43 public static final int CODE_222 = 222;
44 public static final int CODE_223 = 223;
45 public static final int CODE_230 = 230;
46 public static final int CODE_231 = 231;
47 public static final int CODE_235 = 235;
48 public static final int CODE_240 = 240;
49 public static final int CODE_281 = 281;
50 public static final int CODE_335 = 335;
51 public static final int CODE_340 = 340;
52 public static final int CODE_381 = 381;
53 public static final int CODE_400 = 400;
54 public static final int CODE_408 = 408;
55 public static final int CODE_411 = 411;
56 public static final int CODE_412 = 412;
57 public static final int CODE_420 = 420;
58 public static final int CODE_421 = 421;
59 public static final int CODE_422 = 422;
60 public static final int CODE_423 = 423;
61 public static final int CODE_430 = 430;
62 public static final int CODE_435 = 435;
63 public static final int CODE_436 = 436;
64 public static final int CODE_437 = 437;
65 public static final int CODE_440 = 440;
66 public static final int CODE_441 = 441;
67 public static final int CODE_482 = 482;
68 public static final int CODE_500 = 500;
69 public static final int CODE_501 = 501;
70 public static final int CODE_502 = 502;
71 public static final int CODE_503 = 503;
72
73 public static final int HELP_TEXT_FOLLOWS = CODE_100;
74 public static final int DEBUG_OUTPUT = CODE_199;
75 public static final int SERVER_READY_POSTING_ALLOWED = CODE_200;
76 public static final int SERVER_READY_POSTING_NOT_ALLOWED = CODE_201;
77 public static final int SLAVE_STATUS_NOTED = CODE_202;
78 public static final int CLOSING_CONNECTION = CODE_205;
79 public static final int GROUP_SELECTED = CODE_211;
80 public static final int ARTICLE_RETRIEVED_HEAD_AND_BODY_FOLLOW = CODE_220;
81 public static final int ARTICLE_RETRIEVED_HEAD_FOLLOWS = CODE_221;
82 public static final int ARTICLE_RETRIEVED_BODY_FOLLOWS = CODE_222;
83 public static final int
84 ARTICLE_RETRIEVED_REQUEST_TEXT_SEPARATELY = CODE_223;
85 public static final int ARTICLE_LIST_BY_MESSAGE_ID_FOLLOWS = CODE_230;
86 public static final int NEW_NEWSGROUP_LIST_FOLLOWS = CODE_231;
87 public static final int ARTICLE_TRANSFERRED_OK = CODE_235;
88 public static final int ARTICLE_POSTED_OK = CODE_240;
89 public static final int AUTHENTICATION_ACCEPTED = CODE_281;
90 public static final int SEND_ARTICLE_TO_TRANSFER = CODE_335;
91 public static final int SEND_ARTICLE_TO_POST = CODE_340;
92 public static final int MORE_AUTH_INFO_REQUIRED = CODE_381;
93 public static final int SERVICE_DISCONTINUED = CODE_400;
94 public static final int NO_SUCH_NEWSGROUP = CODE_411;
95 public static final int AUTHENTICATION_REQUIRED = CODE_408;
96 public static final int NO_NEWSGROUP_SELECTED = CODE_412;
97 public static final int NO_CURRENT_ARTICLE_SELECTED = CODE_420;
98 public static final int NO_NEXT_ARTICLE = CODE_421;
99 public static final int NO_PREVIOUS_ARTICLE = CODE_422;
100 public static final int NO_SUCH_ARTICLE_NUMBER = CODE_423;
101 public static final int NO_SUCH_ARTICLE_FOUND = CODE_430;
102 public static final int ARTICLE_NOT_WANTED = CODE_435;
103 public static final int TRANSFER_FAILED = CODE_436;
104 public static final int ARTICLE_REJECTED = CODE_437;
105 public static final int POSTING_NOT_ALLOWED = CODE_440;
106 public static final int POSTING_FAILED = CODE_441;
107 public static final int AUTHENTICATION_REJECTED = CODE_482;
108 public static final int COMMAND_NOT_RECOGNIZED = CODE_500;
109 public static final int COMMAND_SYNTAX_ERROR = CODE_501;
110 public static final int PERMISSION_DENIED = CODE_502;
111 public static final int PROGRAM_FAULT = CODE_503;
112
113
114
115 private NNTPReply()
116 {}
117
118 /***
119 * Determine if a reply code is an informational response. All
120 * codes beginning with a 1 are positive informational responses.
121 * Informational responses are used to provide human readable
122 * information such as help text.
123 * <p>
124 * @param reply The reply code to test.
125 * @return True if a reply code is an informational response, false
126 * if not.
127 ***/
128 public static boolean isInformational(int reply)
129 {
130 return (reply >= 100 && reply < 200);
131 }
132
133 /***
134 * Determine if a reply code is a positive completion response. All
135 * codes beginning with a 2 are positive completion responses.
136 * The NNTP server will send a positive completion response on the final
137 * successful completion of a command.
138 * <p>
139 * @param reply The reply code to test.
140 * @return True if a reply code is a postive completion response, false
141 * if not.
142 ***/
143 public static boolean isPositiveCompletion(int reply)
144 {
145 return (reply >= 200 && reply < 300);
146 }
147
148 /***
149 * Determine if a reply code is a positive intermediate response. All
150 * codes beginning with a 3 are positive intermediate responses.
151 * The NNTP server will send a positive intermediate response on the
152 * successful completion of one part of a multi-part command or
153 * sequence of commands. For example, after a successful POST command,
154 * a positive intermediate response will be sent to indicate that the
155 * server is ready to receive the article to be posted.
156 * <p>
157 * @param reply The reply code to test.
158 * @return True if a reply code is a postive intermediate response, false
159 * if not.
160 ***/
161 public static boolean isPositiveIntermediate(int reply)
162 {
163 return (reply >= 300 && reply < 400);
164 }
165
166 /***
167 * Determine if a reply code is a negative transient response. All
168 * codes beginning with a 4 are negative transient responses.
169 * The NNTP server will send a negative transient response on the
170 * failure of a correctly formatted command that could not be performed
171 * for some reason. For example, retrieving an article that does not
172 * exist will result in a negative transient response.
173 * <p>
174 * @param reply The reply code to test.
175 * @return True if a reply code is a negative transient response, false
176 * if not.
177 ***/
178 public static boolean isNegativeTransient(int reply)
179 {
180 return (reply >= 400 && reply < 500);
181 }
182
183 /***
184 * Determine if a reply code is a negative permanent response. All
185 * codes beginning with a 5 are negative permanent responses.
186 * The NNTP server will send a negative permanent response when
187 * it does not implement a command, a command is incorrectly formatted,
188 * or a serious program error occurs.
189 * <p>
190 * @param reply The reply code to test.
191 * @return True if a reply code is a negative permanent response, false
192 * if not.
193 ***/
194 public static boolean isNegativePermanent(int reply)
195 {
196 return (reply >= 500 && reply < 600);
197 }
198
199 }
200
201
202
203
204
205
206
207