1 /* 2 * This file is part of Waarp Project (named also Waarp or GG). 3 * 4 * Copyright (c) 2019, Waarp SAS, and individual contributors by the @author 5 * tags. See the COPYRIGHT.txt in the distribution for a full listing of 6 * individual contributors. 7 * 8 * All Waarp Project is free software: you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or (at your 11 * option) any later version. 12 * 13 * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY 14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 15 * A PARTICULAR PURPOSE. See the GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License along with 18 * Waarp . If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 package org.waarp.ftp.client; 22 23 import java.io.InputStream; 24 import java.io.OutputStream; 25 26 public interface WaarpFtpClientInterface { 27 String CANNOT_EXECUTE_OPERATION_SITE = "Cannot execute operation Site"; 28 String CANNOT_EXECUTE_OPERATION_FEATURE = "Cannot execute operation Feature"; 29 String CANNOT_FINALIZE_TRANSFER_OPERATION = 30 "Cannot finalize transfer operation"; 31 String CHDIR_IN_ERROR = "CHDIR in error"; 32 String MKDIR_IN_ERROR = "MKDIR in error"; 33 String DISCONNECTION_IN_ERROR = "Disconnection in error"; 34 String LOGIN_IN_ERROR = "Login in error"; 35 String CONNECTION_IN_ERROR = "Connection in error"; 36 String SET_BINARY_IN_ERROR = "Set BINARY in error"; 37 String CANNOT_FINALIZE_STORE_LIKE_OPERATION = 38 "Cannot finalize store like operation"; 39 String CANNOT_FINALIZE_RETRIEVE_LIKE_OPERATION = 40 "Cannot finalize retrieve like operation"; 41 String FILE_TYPE_IN_ERROR = "FileType in error"; 42 String NOOP_ERROR = "NoOp error"; 43 44 /** 45 * @param ipAddress the external IP address to report in EPRT/PORT commands 46 * in active mode. 47 */ 48 void setReportActiveExternalIPAddress(String ipAddress); 49 50 /** 51 * @param from the first port to used 52 * @param to the last port to used 53 */ 54 void setActiveDataTransferPortRange(int from, int to); 55 56 /** 57 * @return the result associated with the last command if any error 58 */ 59 String getResult(); 60 61 /** 62 * Try to connect to the server and goes with the authentication 63 * 64 * @return True if connected and authenticated, else False 65 */ 66 boolean connect(); 67 68 /** 69 * QUIT the control connection 70 */ 71 void logout(); 72 73 /** 74 * Disconnect the Ftp Client 75 */ 76 void disconnect(); 77 78 /** 79 * Create a new directory 80 * 81 * @param newDir 82 * 83 * @return True if created 84 */ 85 boolean makeDir(String newDir); 86 87 /** 88 * Change remote directory 89 * 90 * @param newDir 91 * 92 * @return True if the change is OK 93 */ 94 boolean changeDir(String newDir); 95 96 /** 97 * Change the FileType of Transfer (Binary true, ASCII false) 98 * 99 * @param binaryTransfer 100 * 101 * @return True if the change is OK 102 */ 103 boolean changeFileType(boolean binaryTransfer); 104 105 /** 106 * Change to passive (true) or active (false) mode 107 * 108 * @param passive 109 */ 110 void changeMode(boolean passive); 111 112 /** 113 * Change to ZLIB compression (true) or inactive (false) mode. 114 * Only if supported. 115 * 116 * @param compression 117 */ 118 void compressionMode(boolean compression); 119 120 /** 121 * Store File 122 * 123 * @param local local filepath (full path) 124 * @param remote filename (basename) 125 * 126 * @return True if the file is correctly transferred 127 */ 128 boolean store(String local, String remote); 129 130 /** 131 * Store File 132 * 133 * @param local local InputStream 134 * @param remote filename (basename) 135 * 136 * @return True if the file is correctly transferred 137 */ 138 boolean store(InputStream local, String remote); 139 140 /** 141 * Store File as Append 142 * 143 * @param local local filepath (full path) 144 * @param remote filename (basename) 145 * 146 * @return True if the file is correctly transferred 147 */ 148 boolean append(String local, String remote); 149 150 /** 151 * Store File as Append 152 * 153 * @param local local InputStream 154 * @param remote filename (basename) 155 * 156 * @return True if the file is correctly transferred 157 */ 158 boolean append(InputStream local, String remote); 159 160 /** 161 * Retrieve File 162 * 163 * @param local local filepath (full path) 164 * @param remote filename (basename) 165 * 166 * @return True if the file is correctly transferred 167 */ 168 boolean retrieve(String local, String remote); 169 170 /** 171 * Retrieve File 172 * 173 * @param local local OutputStream 174 * @param remote filename (basename) 175 * 176 * @return True if the file is correctly transferred 177 */ 178 boolean retrieve(OutputStream local, String remote); 179 180 /** 181 * Ask to transfer a file 182 * 183 * @param local local filepath (full path) 184 * @param remote filename (basename) 185 * @param getStoreOrAppend -1 = get, 1 = store, 2 = append 186 * 187 * @return True if the file is correctly transferred 188 */ 189 boolean transferFile(String local, String remote, int getStoreOrAppend); 190 191 /** 192 * Ask to transfer a file as STORE or APPEND 193 * 194 * @param local local outputStream 195 * @param remote filename (basename) 196 * @param getStoreOrAppend 1 = store, 2 = append 197 * 198 * @return True if the file is correctly transferred 199 */ 200 boolean transferFile(InputStream local, String remote, int getStoreOrAppend); 201 202 /** 203 * Ask to transfer a file as GET 204 * 205 * @param local local outputStream (or NullStream) 206 * @param remote filename (basename) 207 * 208 * @return True if the file is correctly transferred 209 */ 210 boolean transferFile(OutputStream local, String remote); 211 212 /** 213 * @param remote remote file spec 214 * 215 * @return the list of Files as given by FTP 216 */ 217 String[] listFiles(String remote); 218 219 /** 220 * @return the list of Files as given by FTP 221 */ 222 String[] listFiles(); 223 224 /** 225 * @param remote remote file spec 226 * 227 * @return the list of Files as given by FTP in MLSD format 228 */ 229 String[] mlistFiles(String remote); 230 231 /** 232 * @return the list of Files as given by FTP in MLSD format 233 */ 234 String[] mlistFiles(); 235 236 /** 237 * @return the list of Features as String 238 */ 239 String[] features(); 240 241 /** 242 * @param feature 243 * 244 * @return True if the given feature is listed 245 */ 246 boolean featureEnabled(String feature); 247 248 /** 249 * @param remote 250 * 251 * @return True if deleted 252 */ 253 boolean deleteFile(String remote); 254 255 /** 256 * @param params 257 * 258 * @return the string lines result for the command params 259 */ 260 String[] executeCommand(String params); 261 262 /** 263 * @param params command without SITE in front 264 * 265 * @return the string lines result for the SITE command params 266 */ 267 String[] executeSiteCommand(String params); 268 269 /** 270 * Sends a No Op command 271 */ 272 void noop(); 273 }