1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.apache.commons.net.ftp;
  17. /***
  18. * FTPReply stores a set of constants for FTP reply codes. To interpret
  19. * the meaning of the codes, familiarity with RFC 959 is assumed.
  20. * The mnemonic constant names are transcriptions from the code descriptions
  21. * of RFC 959. For those who think in terms of the actual reply code values,
  22. * a set of CODE_NUM constants are provided where NUM is the numerical value
  23. * of the code.
  24. * <p>
  25. * <p>
  26. * @author Daniel F. Savarese
  27. ***/
  28. public final class FTPReply
  29. {
  30. public static final int CODE_110 = 110;
  31. public static final int CODE_120 = 120;
  32. public static final int CODE_125 = 125;
  33. public static final int CODE_150 = 150;
  34. public static final int CODE_200 = 200;
  35. public static final int CODE_202 = 202;
  36. public static final int CODE_211 = 211;
  37. public static final int CODE_212 = 212;
  38. public static final int CODE_213 = 213;
  39. public static final int CODE_214 = 214;
  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_225 = 225;
  44. public static final int CODE_226 = 226;
  45. public static final int CODE_227 = 227;
  46. public static final int CODE_230 = 230;
  47. public static final int CODE_250 = 250;
  48. public static final int CODE_257 = 257;
  49. public static final int CODE_331 = 331;
  50. public static final int CODE_332 = 332;
  51. public static final int CODE_350 = 350;
  52. public static final int CODE_421 = 421;
  53. public static final int CODE_425 = 425;
  54. public static final int CODE_426 = 426;
  55. public static final int CODE_450 = 450;
  56. public static final int CODE_451 = 451;
  57. public static final int CODE_452 = 452;
  58. public static final int CODE_500 = 500;
  59. public static final int CODE_501 = 501;
  60. public static final int CODE_502 = 502;
  61. public static final int CODE_503 = 503;
  62. public static final int CODE_504 = 504;
  63. public static final int CODE_530 = 530;
  64. public static final int CODE_532 = 532;
  65. public static final int CODE_550 = 550;
  66. public static final int CODE_551 = 551;
  67. public static final int CODE_552 = 552;
  68. public static final int CODE_553 = 553;
  69. public static final int RESTART_MARKER = CODE_110;
  70. public static final int SERVICE_NOT_READY = CODE_120;
  71. public static final int DATA_CONNECTION_ALREADY_OPEN = CODE_125;
  72. public static final int FILE_STATUS_OK = CODE_150;
  73. public static final int COMMAND_OK = CODE_200;
  74. public static final int COMMAND_IS_SUPERFLUOUS = CODE_202;
  75. public static final int SYSTEM_STATUS = CODE_211;
  76. public static final int DIRECTORY_STATUS = CODE_212;
  77. public static final int FILE_STATUS = CODE_213;
  78. public static final int HELP_MESSAGE = CODE_214;
  79. public static final int NAME_SYSTEM_TYPE = CODE_215;
  80. public static final int SERVICE_READY = CODE_220;
  81. public static final int SERVICE_CLOSING_CONTROL_CONNECTION = CODE_221;
  82. public static final int DATA_CONNECTION_OPEN = CODE_225;
  83. public static final int CLOSING_DATA_CONNECTION = CODE_226;
  84. public static final int ENTERING_PASSIVE_MODE = CODE_227;
  85. public static final int USER_LOGGED_IN = CODE_230;
  86. public static final int FILE_ACTION_OK = CODE_250;
  87. public static final int PATHNAME_CREATED = CODE_257;
  88. public static final int NEED_PASSWORD = CODE_331;
  89. public static final int NEED_ACCOUNT = CODE_332;
  90. public static final int FILE_ACTION_PENDING = CODE_350;
  91. public static final int SERVICE_NOT_AVAILABLE = CODE_421;
  92. public static final int CANNOT_OPEN_DATA_CONNECTION = CODE_425;
  93. public static final int TRANSFER_ABORTED = CODE_426;
  94. public static final int FILE_ACTION_NOT_TAKEN = CODE_450;
  95. public static final int ACTION_ABORTED = CODE_451;
  96. public static final int INSUFFICIENT_STORAGE = CODE_452;
  97. public static final int UNRECOGNIZED_COMMAND = CODE_500;
  98. public static final int SYNTAX_ERROR_IN_ARGUMENTS = CODE_501;
  99. public static final int COMMAND_NOT_IMPLEMENTED = CODE_502;
  100. public static final int BAD_COMMAND_SEQUENCE = CODE_503;
  101. public static final int COMMAND_NOT_IMPLEMENTED_FOR_PARAMETER = CODE_504;
  102. public static final int NOT_LOGGED_IN = CODE_530;
  103. public static final int NEED_ACCOUNT_FOR_STORING_FILES = CODE_532;
  104. public static final int FILE_UNAVAILABLE = CODE_550;
  105. public static final int PAGE_TYPE_UNKNOWN = CODE_551;
  106. public static final int STORAGE_ALLOCATION_EXCEEDED = CODE_552;
  107. public static final int FILE_NAME_NOT_ALLOWED = CODE_553;
  108. // Cannot be instantiated
  109. private FTPReply()
  110. {}
  111. /***
  112. * Determine if a reply code is a positive preliminary response. All
  113. * codes beginning with a 1 are positive preliminary responses.
  114. * Postitive preliminary responses are used to indicate tentative success.
  115. * No further commands can be issued to the FTP server after a positive
  116. * preliminary response until a follow up response is received from the
  117. * server.
  118. * <p>
  119. * @param reply The reply code to test.
  120. * @return True if a reply code is a postive preliminary response, false
  121. * if not.
  122. ***/
  123. public static boolean isPositivePreliminary(int reply)
  124. {
  125. return (reply >= 100 && reply < 200);
  126. }
  127. /***
  128. * Determine if a reply code is a positive completion response. All
  129. * codes beginning with a 2 are positive completion responses.
  130. * The FTP server will send a positive completion response on the final
  131. * successful completion of a command.
  132. * <p>
  133. * @param reply The reply code to test.
  134. * @return True if a reply code is a postive completion response, false
  135. * if not.
  136. ***/
  137. public static boolean isPositiveCompletion(int reply)
  138. {
  139. return (reply >= 200 && reply < 300);
  140. }
  141. /***
  142. * Determine if a reply code is a positive intermediate response. All
  143. * codes beginning with a 3 are positive intermediate responses.
  144. * The FTP server will send a positive intermediate response on the
  145. * successful completion of one part of a multi-part sequence of
  146. * commands. For example, after a successful USER command, a positive
  147. * intermediate response will be sent to indicate that the server is
  148. * ready for the PASS command.
  149. * <p>
  150. * @param reply The reply code to test.
  151. * @return True if a reply code is a postive intermediate response, false
  152. * if not.
  153. ***/
  154. public static boolean isPositiveIntermediate(int reply)
  155. {
  156. return (reply >= 300 && reply < 400);
  157. }
  158. /***
  159. * Determine if a reply code is a negative transient response. All
  160. * codes beginning with a 4 are negative transient responses.
  161. * The FTP server will send a negative transient response on the
  162. * failure of a command that can be reattempted with success.
  163. * <p>
  164. * @param reply The reply code to test.
  165. * @return True if a reply code is a negative transient response, false
  166. * if not.
  167. ***/
  168. public static boolean isNegativeTransient(int reply)
  169. {
  170. return (reply >= 400 && reply < 500);
  171. }
  172. /***
  173. * Determine if a reply code is a negative permanent response. All
  174. * codes beginning with a 5 are negative permanent responses.
  175. * The FTP server will send a negative permanent response on the
  176. * failure of a command that cannot be reattempted with success.
  177. * <p>
  178. * @param reply The reply code to test.
  179. * @return True if a reply code is a negative permanent response, false
  180. * if not.
  181. ***/
  182. public static boolean isNegativePermanent(int reply)
  183. {
  184. return (reply >= 500 && reply < 600);
  185. }
  186. }