001: /*
002: * Copyright 2001-2005 The Apache Software Foundation
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.apache.commons.net.ftp;
017:
018: /***
019: * FTPReply stores a set of constants for FTP reply codes. To interpret
020: * the meaning of the codes, familiarity with RFC 959 is assumed.
021: * The mnemonic constant names are transcriptions from the code descriptions
022: * of RFC 959. For those who think in terms of the actual reply code values,
023: * a set of CODE_NUM constants are provided where NUM is the numerical value
024: * of the code.
025: * <p>
026: * <p>
027: * @author Daniel F. Savarese
028: ***/
029:
030: public final class FTPReply {
031:
032: public static final int CODE_110 = 110;
033: public static final int CODE_120 = 120;
034: public static final int CODE_125 = 125;
035: public static final int CODE_150 = 150;
036: public static final int CODE_200 = 200;
037: public static final int CODE_202 = 202;
038: public static final int CODE_211 = 211;
039: public static final int CODE_212 = 212;
040: public static final int CODE_213 = 213;
041: public static final int CODE_214 = 214;
042: public static final int CODE_215 = 215;
043: public static final int CODE_220 = 220;
044: public static final int CODE_221 = 221;
045: public static final int CODE_225 = 225;
046: public static final int CODE_226 = 226;
047: public static final int CODE_227 = 227;
048: public static final int CODE_230 = 230;
049: public static final int CODE_250 = 250;
050: public static final int CODE_257 = 257;
051: public static final int CODE_331 = 331;
052: public static final int CODE_332 = 332;
053: public static final int CODE_350 = 350;
054: public static final int CODE_421 = 421;
055: public static final int CODE_425 = 425;
056: public static final int CODE_426 = 426;
057: public static final int CODE_450 = 450;
058: public static final int CODE_451 = 451;
059: public static final int CODE_452 = 452;
060: public static final int CODE_500 = 500;
061: public static final int CODE_501 = 501;
062: public static final int CODE_502 = 502;
063: public static final int CODE_503 = 503;
064: public static final int CODE_504 = 504;
065: public static final int CODE_521 = 521;
066: public static final int CODE_530 = 530;
067: public static final int CODE_532 = 532;
068: public static final int CODE_550 = 550;
069: public static final int CODE_551 = 551;
070: public static final int CODE_552 = 552;
071: public static final int CODE_553 = 553;
072:
073: public static final int RESTART_MARKER = CODE_110;
074: public static final int SERVICE_NOT_READY = CODE_120;
075: public static final int DATA_CONNECTION_ALREADY_OPEN = CODE_125;
076: public static final int FILE_STATUS_OK = CODE_150;
077: public static final int COMMAND_OK = CODE_200;
078: public static final int COMMAND_IS_SUPERFLUOUS = CODE_202;
079: public static final int SYSTEM_STATUS = CODE_211;
080: public static final int DIRECTORY_STATUS = CODE_212;
081: public static final int FILE_STATUS = CODE_213;
082: public static final int HELP_MESSAGE = CODE_214;
083: public static final int NAME_SYSTEM_TYPE = CODE_215;
084: public static final int SERVICE_READY = CODE_220;
085: public static final int SERVICE_CLOSING_CONTROL_CONNECTION = CODE_221;
086: public static final int DATA_CONNECTION_OPEN = CODE_225;
087: public static final int CLOSING_DATA_CONNECTION = CODE_226;
088: public static final int ENTERING_PASSIVE_MODE = CODE_227;
089: public static final int USER_LOGGED_IN = CODE_230;
090: public static final int FILE_ACTION_OK = CODE_250;
091: public static final int PATHNAME_CREATED = CODE_257;
092: public static final int NEED_PASSWORD = CODE_331;
093: public static final int NEED_ACCOUNT = CODE_332;
094: public static final int FILE_ACTION_PENDING = CODE_350;
095: public static final int SERVICE_NOT_AVAILABLE = CODE_421;
096: public static final int CANNOT_OPEN_DATA_CONNECTION = CODE_425;
097: public static final int TRANSFER_ABORTED = CODE_426;
098: public static final int FILE_ACTION_NOT_TAKEN = CODE_450;
099: public static final int ACTION_ABORTED = CODE_451;
100: public static final int INSUFFICIENT_STORAGE = CODE_452;
101: public static final int UNRECOGNIZED_COMMAND = CODE_500;
102: public static final int SYNTAX_ERROR_IN_ARGUMENTS = CODE_501;
103: public static final int COMMAND_NOT_IMPLEMENTED = CODE_502;
104: public static final int BAD_COMMAND_SEQUENCE = CODE_503;
105: public static final int COMMAND_NOT_IMPLEMENTED_FOR_PARAMETER = CODE_504;
106: public static final int NOT_LOGGED_IN = CODE_530;
107: public static final int NEED_ACCOUNT_FOR_STORING_FILES = CODE_532;
108: public static final int FILE_UNAVAILABLE = CODE_550;
109: public static final int PAGE_TYPE_UNKNOWN = CODE_551;
110: public static final int STORAGE_ALLOCATION_EXCEEDED = CODE_552;
111: public static final int FILE_NAME_NOT_ALLOWED = CODE_553;
112:
113: // Cannot be instantiated
114: private FTPReply() {
115: }
116:
117: /***
118: * Determine if a reply code is a positive preliminary response. All
119: * codes beginning with a 1 are positive preliminary responses.
120: * Postitive preliminary responses are used to indicate tentative success.
121: * No further commands can be issued to the FTP server after a positive
122: * preliminary response until a follow up response is received from the
123: * server.
124: * <p>
125: * @param reply The reply code to test.
126: * @return True if a reply code is a postive preliminary response, false
127: * if not.
128: ***/
129: public static boolean isPositivePreliminary(int reply) {
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 FTP 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: return (reply >= 200 && reply < 300);
145: }
146:
147: /***
148: * Determine if a reply code is a positive intermediate response. All
149: * codes beginning with a 3 are positive intermediate responses.
150: * The FTP server will send a positive intermediate response on the
151: * successful completion of one part of a multi-part sequence of
152: * commands. For example, after a successful USER command, a positive
153: * intermediate response will be sent to indicate that the server is
154: * ready for the PASS command.
155: * <p>
156: * @param reply The reply code to test.
157: * @return True if a reply code is a postive intermediate response, false
158: * if not.
159: ***/
160: public static boolean isPositiveIntermediate(int reply) {
161: return (reply >= 300 && reply < 400);
162: }
163:
164: /***
165: * Determine if a reply code is a negative transient response. All
166: * codes beginning with a 4 are negative transient responses.
167: * The FTP server will send a negative transient response on the
168: * failure of a command that can be reattempted with success.
169: * <p>
170: * @param reply The reply code to test.
171: * @return True if a reply code is a negative transient response, false
172: * if not.
173: ***/
174: public static boolean isNegativeTransient(int reply) {
175: return (reply >= 400 && reply < 500);
176: }
177:
178: /***
179: * Determine if a reply code is a negative permanent response. All
180: * codes beginning with a 5 are negative permanent responses.
181: * The FTP server will send a negative permanent response on the
182: * failure of a command that cannot be reattempted with success.
183: * <p>
184: * @param reply The reply code to test.
185: * @return True if a reply code is a negative permanent response, false
186: * if not.
187: ***/
188: public static boolean isNegativePermanent(int reply) {
189: return (reply >= 500 && reply < 600);
190: }
191:
192: }
|