List of usage examples for org.apache.commons.net.ftp FTPReply isPositiveIntermediate
public static boolean isPositiveIntermediate(int reply)
From source file:net.paissad.jcamstream.utils.FTPUtils.java
/** * Logout and then disconnect from the FTP server. * /* w w w. jav a 2s .c o m*/ * @throws IOException * * @see org.apache.commons.net.ftp.FTPClient#logout() * @see org.apache.commons.net.ftp.FTPClient#disconnect() */ public void logoutAndDisconnect() throws IOException { FTPClient client = this.getFtpClient(); if (client.isConnected() && !FTPReply.isPositiveIntermediate(client.getReplyCode())) { client.logout(); client.disconnect(); System.out.println("Disconnected successfully from FTP server."); } if (client.isConnected() && !client.completePendingCommand()) { System.err.println("Something failed !"); } }
From source file:hd3gtv.storage.AbstractFileBridgeFtp.java
public AbstractFile moveTo(String newpath) { if (configurator.readonly) { return null; }/*from www .j ava2 s. com*/ if (newpath.startsWith("/") == false) { newpath = "/" + newpath; } try { String newpath_ = (root_path + newpath).replaceAll("//", "/"); if (FTPReply.isPositiveIntermediate(ftpclient.rnfr(root_path + path))) { if (FTPReply.isPositiveCompletion(ftpclient.rnto(newpath_))) { return new AbstractFileBridgeFtp(this, getRandomFtpFile(newpath_), newpath); } else { throw new IOException("Can't rename, set to new name"); } } else { throw new IOException("Can't rename, prepare name"); } } catch (IOException e) { /** Maybe a security problem */ Log2.log.error("Can't access to file", e, this); return null; } }
From source file:com.atomicleopard.thundr.ftp.commons.FTPClient.java
/** * Login to the FTP server using the provided username and password. * <p>/*w w w. j a va2s . co m*/ * @param username The username to login under. * @param password The password to use. * @return True if successfully completed, false if not. * @exception FTPConnectionClosedException * If the FTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send FTP reply code 421. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending a * command to the server or receiving a reply from the server. */ public boolean login(String username, String password) throws IOException { user(username); if (FTPReply.isPositiveCompletion(_replyCode)) { return true; } // If we get here, we either have an error code, or an intermmediate // reply requesting password. if (!FTPReply.isPositiveIntermediate(_replyCode)) { return false; } return FTPReply.isPositiveCompletion(pass(password)); }
From source file:com.atomicleopard.thundr.ftp.commons.FTPClient.java
/** * Login to the FTP server using the provided username, password, * and account. If no account is required by the server, only * the username and password, the account information is not used. * <p>/* ww w . ja v a2 s . c o m*/ * @param username The username to login under. * @param password The password to use. * @param account The account to use. * @return True if successfully completed, false if not. * @exception FTPConnectionClosedException * If the FTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send FTP reply code 421. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending a * command to the server or receiving a reply from the server. */ public boolean login(String username, String password, String account) throws IOException { user(username); if (FTPReply.isPositiveCompletion(_replyCode)) { return true; } // If we get here, we either have an error code, or an intermmediate // reply requesting password. if (!FTPReply.isPositiveIntermediate(_replyCode)) { return false; } pass(password); if (FTPReply.isPositiveCompletion(_replyCode)) { return true; } if (!FTPReply.isPositiveIntermediate(_replyCode)) { return false; } return FTPReply.isPositiveCompletion(acct(account)); }
From source file:com.atomicleopard.thundr.ftp.commons.FTPClient.java
/** * Restart a <code>STREAM_TRANSFER_MODE</code> file transfer starting * from the given offset. This will only work on FTP servers supporting * the REST comand for the stream transfer mode. However, most FTP * servers support this. Any subsequent file transfer will start * reading or writing the remote file from the indicated offset. * <p>/*from w w w . j a v a2 s. c om*/ * @param offset The offset into the remote file at which to start the * next file transfer. * @return True if successfully completed, false if not. * @exception FTPConnectionClosedException * If the FTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send FTP reply code 421. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending a * command to the server or receiving a reply from the server. * @since 3.1 (changed from private to protected) */ protected boolean restart(long offset) throws IOException { __restartOffset = 0; return FTPReply.isPositiveIntermediate(rest(Long.toString(offset))); }
From source file:com.atomicleopard.thundr.ftp.commons.FTPClient.java
/** * Renames a remote file./*from w w w .ja v a 2s . c o m*/ * <p> * @param from The name of the remote file to rename. * @param to The new name of the remote file. * @return True if successfully completed, false if not. * @exception FTPConnectionClosedException * If the FTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send FTP reply code 421. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending a * command to the server or receiving a reply from the server. */ public boolean rename(String from, String to) throws IOException { if (!FTPReply.isPositiveIntermediate(rnfr(from))) { return false; } return FTPReply.isPositiveCompletion(rnto(to)); }
From source file:org.apache.ftpserver.clienttests.LoginTest.java
public void testLoginWithEmptyPassword() throws Exception { assertTrue(FTPReply.isPositiveIntermediate(client.user(ADMIN_USERNAME))); assertEquals(530, client.sendCommand("PASS")); }
From source file:org.apache.ftpserver.clienttests.LoginTest.java
public void testLoginWithEmptyCorrectPassword() throws Exception { assertTrue(FTPReply.isPositiveIntermediate(client.user("testuser3"))); assertTrue(FTPReply.isPositiveCompletion(client.sendCommand("PASS"))); }
From source file:org.apache.ftpserver.clienttests.RenameTest.java
public void testRenameWithNoopInBetween() throws Exception { TEST_FILE1.createNewFile();/*w w w.jav a 2 s . c om*/ assertTrue(TEST_FILE1.exists()); assertFalse(TEST_FILE2.exists()); assertTrue(FTPReply.isPositiveIntermediate(client.rnfr(TEST_FILE1.getName()))); assertTrue(FTPReply.isPositiveCompletion(client.noop())); assertTrue(FTPReply.isNegativePermanent(client.rnto(TEST_FILE2.getName()))); assertTrue(TEST_FILE1.exists()); assertFalse(TEST_FILE2.exists()); }
From source file:org.apache.ftpserver.clienttests.RenameTest.java
public void testRenameWithDoubleRnfr() throws Exception { TEST_FILE1.createNewFile();/* w w w.j a v a 2 s. c om*/ TEST_FILE3.createNewFile(); assertTrue(TEST_FILE1.exists()); assertFalse(TEST_FILE2.exists()); assertTrue(TEST_FILE3.exists()); assertTrue(FTPReply.isPositiveIntermediate(client.rnfr(TEST_FILE1.getName()))); assertTrue(FTPReply.isPositiveIntermediate(client.rnfr(TEST_FILE3.getName()))); assertTrue(FTPReply.isPositiveCompletion(client.rnto(TEST_FILE2.getName()))); assertTrue(TEST_FILE1.exists()); assertTrue(TEST_FILE2.exists()); assertFalse(TEST_FILE3.exists()); }