List of usage examples for org.apache.commons.net.ftp FTPReply isNegativePermanent
public static boolean isNegativePermanent(int reply)
From source file:com.clickha.nifi.processors.util.FTPTransferV2.java
public void sendCommands(final List<String> commands, final FlowFile flowFile) throws IOException { if (commands.isEmpty()) { return;//from ww w . j a v a 2s .co m } final FTPClient client = getClient(flowFile); for (String cmd : commands) { if (!cmd.isEmpty()) { int result; result = client.sendCommand(cmd); logger.debug(this + " sent command to the FTP server: " + cmd + " for " + flowFile); if (FTPReply.isNegativePermanent(result) || FTPReply.isNegativeTransient(result)) { throw new IOException(this + " negative reply back from FTP server cmd: " + cmd + " reply:" + result + ": " + client.getReplyString() + " for " + flowFile); } } } }
From source file:org.alfresco.filesys.FTPServerTest.java
/** * Simple negative test that connects to the inbuilt ftp server and attempts to * log on with the wrong password./*from w w w . j a v a 2 s .c o m*/ * * @throws Exception */ public void testFTPConnectNegative() throws Exception { logger.debug("Start testFTPConnectNegative"); FTPClient ftp = connectClient(); try { int reply = ftp.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { fail("FTP server refused connection."); } boolean login = ftp.login(USER_ADMIN, "garbage"); assertFalse("admin login successful", login); // now attempt to list the files and check that the command does not // succeed FTPFile[] files = ftp.listFiles(); assertNotNull(files); assertTrue(files.length == 0); reply = ftp.getReplyCode(); assertTrue(FTPReply.isNegativePermanent(reply)); } finally { ftp.disconnect(); } }
From source file:org.alfresco.filesys.FTPServerTest.java
/** * Test CWD for FTP server//from w ww . ja va 2s .c om * * @throws Exception */ public void testCWD() throws Exception { logger.debug("Start testCWD"); FTPClient ftp = connectClient(); try { int reply = ftp.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { fail("FTP server refused connection."); } boolean login = ftp.login(USER_ADMIN, PASSWORD_ADMIN); assertTrue("admin login successful", login); FTPFile[] files = ftp.listFiles(); reply = ftp.getReplyCode(); assertTrue(FTPReply.isPositiveCompletion(reply)); assertTrue(files.length == 1); boolean foundAlfresco = false; for (FTPFile file : files) { logger.debug("file name=" + file.getName()); assertTrue(file.isDirectory()); if (file.getName().equalsIgnoreCase("Alfresco")) { foundAlfresco = true; } } assertTrue(foundAlfresco); // Change to Alfresco Dir that we know exists reply = ftp.cwd("/Alfresco"); assertTrue(FTPReply.isPositiveCompletion(reply)); // relative path with space char reply = ftp.cwd("Data Dictionary"); assertTrue(FTPReply.isPositiveCompletion(reply)); // non existant absolute reply = ftp.cwd("/Garbage"); assertTrue(FTPReply.isNegativePermanent(reply)); reply = ftp.cwd("/Alfresco/User Homes"); assertTrue(FTPReply.isPositiveCompletion(reply)); // Wild card reply = ftp.cwd("/Alfresco/User*Homes"); assertTrue("unable to change to /Alfresco User*Homes/", FTPReply.isPositiveCompletion(reply)); // // Single char pattern match // reply = ftp.cwd("/Alfre?co"); // assertTrue("Unable to match single char /Alfre?co", FTPReply.isPositiveCompletion(reply)); // two level folder reply = ftp.cwd("/Alfresco/Data Dictionary"); assertTrue("unable to change to /Alfresco/Data Dictionary", FTPReply.isPositiveCompletion(reply)); // go up one reply = ftp.cwd(".."); assertTrue("unable to change to ..", FTPReply.isPositiveCompletion(reply)); reply = ftp.pwd(); ftp.getStatus(); assertTrue("unable to get status", FTPReply.isPositiveCompletion(reply)); // check we are at the correct point in the tree reply = ftp.cwd("Data Dictionary"); assertTrue(FTPReply.isPositiveCompletion(reply)); } finally { ftp.disconnect(); } }
From source file:org.apache.ftpserver.clienttests.DirectoryTest.java
public void testMkdirExisting() throws Exception { TEST_DIR1.mkdirs();/*from w w w . ja va 2s . c om*/ assertTrue(TEST_DIR1.exists()); assertTrue(FTPReply.isNegativePermanent(client.mkd(TEST_DIR1.getName()))); assertTrue(TEST_DIR1.exists()); }
From source file:org.apache.ftpserver.clienttests.DirectoryTest.java
public void testMkdirExistingFile() throws Exception { TEST_DIR1.createNewFile();/*from w ww.ja v a 2 s.co m*/ assertTrue(TEST_DIR1.exists()); assertTrue(FTPReply.isNegativePermanent(client.mkd(TEST_DIR1.getName()))); assertTrue(TEST_DIR1.exists()); }
From source file:org.apache.ftpserver.clienttests.DirectoryTest.java
public void testMkdirWithoutWriteAccess() throws Exception { client.rein();// www. ja v a 2 s . co m client.login(ANONYMOUS_USERNAME, ANONYMOUS_PASSWORD); assertFalse(TEST_DIR1.exists()); assertTrue(FTPReply.isNegativePermanent(client.mkd(TEST_DIR1.getName()))); assertFalse(TEST_DIR1.exists()); }
From source file:org.apache.ftpserver.clienttests.LoginTest.java
public void testReLoginWithOnlyPass() throws Exception { assertFalse(client.login(ADMIN_USERNAME, UNKNOWN_PASSWORD)); int reply = client.pass(ADMIN_PASSWORD); assertTrue(FTPReply.isNegativePermanent(reply)); }
From source file:org.apache.ftpserver.clienttests.LoginTest.java
public void testOnlyPass() throws Exception { int reply = client.pass(ADMIN_PASSWORD); assertTrue(FTPReply.isNegativePermanent(reply)); }
From source file:org.apache.ftpserver.clienttests.RenameTest.java
public void testRenameWithNoopInBetween() throws Exception { TEST_FILE1.createNewFile();//from w ww . j av a 2s . c o m 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 testRenameOnlyRnto() throws Exception { assertTrue(FTPReply.isNegativePermanent(client.rnto(TEST_FILE2.getName()))); }