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 033 public static final int CODE_110 = 110; 034 public static final int CODE_120 = 120; 035 public static final int CODE_125 = 125; 036 public static final int CODE_150 = 150; 037 public static final int CODE_200 = 200; 038 public static final int CODE_202 = 202; 039 public static final int CODE_211 = 211; 040 public static final int CODE_212 = 212; 041 public static final int CODE_213 = 213; 042 public static final int CODE_214 = 214; 043 public static final int CODE_215 = 215; 044 public static final int CODE_220 = 220; 045 public static final int CODE_221 = 221; 046 public static final int CODE_225 = 225; 047 public static final int CODE_226 = 226; 048 public static final int CODE_227 = 227; 049 public static final int CODE_230 = 230; 050 public static final int CODE_250 = 250; 051 public static final int CODE_257 = 257; 052 public static final int CODE_331 = 331; 053 public static final int CODE_332 = 332; 054 public static final int CODE_350 = 350; 055 public static final int CODE_421 = 421; 056 public static final int CODE_425 = 425; 057 public static final int CODE_426 = 426; 058 public static final int CODE_450 = 450; 059 public static final int CODE_451 = 451; 060 public static final int CODE_452 = 452; 061 public static final int CODE_500 = 500; 062 public static final int CODE_501 = 501; 063 public static final int CODE_502 = 502; 064 public static final int CODE_503 = 503; 065 public static final int CODE_504 = 504; 066 public static final int CODE_521 = 521; 067 public static final int CODE_530 = 530; 068 public static final int CODE_532 = 532; 069 public static final int CODE_550 = 550; 070 public static final int CODE_551 = 551; 071 public static final int CODE_552 = 552; 072 public static final int CODE_553 = 553; 073 074 public static final int RESTART_MARKER = CODE_110; 075 public static final int SERVICE_NOT_READY = CODE_120; 076 public static final int DATA_CONNECTION_ALREADY_OPEN = CODE_125; 077 public static final int FILE_STATUS_OK = CODE_150; 078 public static final int COMMAND_OK = CODE_200; 079 public static final int COMMAND_IS_SUPERFLUOUS = CODE_202; 080 public static final int SYSTEM_STATUS = CODE_211; 081 public static final int DIRECTORY_STATUS = CODE_212; 082 public static final int FILE_STATUS = CODE_213; 083 public static final int HELP_MESSAGE = CODE_214; 084 public static final int NAME_SYSTEM_TYPE = CODE_215; 085 public static final int SERVICE_READY = CODE_220; 086 public static final int SERVICE_CLOSING_CONTROL_CONNECTION = CODE_221; 087 public static final int DATA_CONNECTION_OPEN = CODE_225; 088 public static final int CLOSING_DATA_CONNECTION = CODE_226; 089 public static final int ENTERING_PASSIVE_MODE = CODE_227; 090 public static final int USER_LOGGED_IN = CODE_230; 091 public static final int FILE_ACTION_OK = CODE_250; 092 public static final int PATHNAME_CREATED = CODE_257; 093 public static final int NEED_PASSWORD = CODE_331; 094 public static final int NEED_ACCOUNT = CODE_332; 095 public static final int FILE_ACTION_PENDING = CODE_350; 096 public static final int SERVICE_NOT_AVAILABLE = CODE_421; 097 public static final int CANNOT_OPEN_DATA_CONNECTION = CODE_425; 098 public static final int TRANSFER_ABORTED = CODE_426; 099 public static final int FILE_ACTION_NOT_TAKEN = CODE_450; 100 public static final int ACTION_ABORTED = CODE_451; 101 public static final int INSUFFICIENT_STORAGE = CODE_452; 102 public static final int UNRECOGNIZED_COMMAND = CODE_500; 103 public static final int SYNTAX_ERROR_IN_ARGUMENTS = CODE_501; 104 public static final int COMMAND_NOT_IMPLEMENTED = CODE_502; 105 public static final int BAD_COMMAND_SEQUENCE = CODE_503; 106 public static final int COMMAND_NOT_IMPLEMENTED_FOR_PARAMETER = CODE_504; 107 public static final int NOT_LOGGED_IN = CODE_530; 108 public static final int NEED_ACCOUNT_FOR_STORING_FILES = CODE_532; 109 public static final int FILE_UNAVAILABLE = CODE_550; 110 public static final int PAGE_TYPE_UNKNOWN = CODE_551; 111 public static final int STORAGE_ALLOCATION_EXCEEDED = CODE_552; 112 public static final int FILE_NAME_NOT_ALLOWED = CODE_553; 113 114 // Cannot be instantiated 115 private FTPReply() 116 {} 117 118 /*** 119 * Determine if a reply code is a positive preliminary response. All 120 * codes beginning with a 1 are positive preliminary responses. 121 * Postitive preliminary responses are used to indicate tentative success. 122 * No further commands can be issued to the FTP server after a positive 123 * preliminary response until a follow up response is received from the 124 * server. 125 * <p> 126 * @param reply The reply code to test. 127 * @return True if a reply code is a postive preliminary response, false 128 * if not. 129 ***/ 130 public static boolean isPositivePreliminary(int reply) 131 { 132 return (reply >= 100 && reply < 200); 133 } 134 135 /*** 136 * Determine if a reply code is a positive completion response. All 137 * codes beginning with a 2 are positive completion responses. 138 * The FTP server will send a positive completion response on the final 139 * successful completion of a command. 140 * <p> 141 * @param reply The reply code to test. 142 * @return True if a reply code is a postive completion response, false 143 * if not. 144 ***/ 145 public static boolean isPositiveCompletion(int reply) 146 { 147 return (reply >= 200 && reply < 300); 148 } 149 150 /*** 151 * Determine if a reply code is a positive intermediate response. All 152 * codes beginning with a 3 are positive intermediate responses. 153 * The FTP server will send a positive intermediate response on the 154 * successful completion of one part of a multi-part sequence of 155 * commands. For example, after a successful USER command, a positive 156 * intermediate response will be sent to indicate that the server is 157 * ready for the PASS command. 158 * <p> 159 * @param reply The reply code to test. 160 * @return True if a reply code is a postive intermediate response, false 161 * if not. 162 ***/ 163 public static boolean isPositiveIntermediate(int reply) 164 { 165 return (reply >= 300 && reply < 400); 166 } 167 168 /*** 169 * Determine if a reply code is a negative transient response. All 170 * codes beginning with a 4 are negative transient responses. 171 * The FTP server will send a negative transient response on the 172 * failure of a command that can be reattempted with success. 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 FTP server will send a negative permanent response on the 187 * failure of a command that cannot be reattempted with success. 188 * <p> 189 * @param reply The reply code to test. 190 * @return True if a reply code is a negative permanent response, false 191 * if not. 192 ***/ 193 public static boolean isNegativePermanent(int reply) 194 { 195 return (reply >= 500 && reply < 600); 196 } 197 198 }