From a35ee51bd08096b0e52cf90116a779a9a0574ba7 Mon Sep 17 00:00:00 2001 From: Javier Montalvo Orus Date: Tue, 17 Oct 2006 13:40:53 +0000 Subject: [PATCH] Fixing 161211 - Cannot expand /pub folder as anonymous on ftp.wacom.com --- .../rse/services/files/ftp/FTPHostFile.java | 17 ++++++--- .../rse/services/files/ftp/FTPService.java | 38 +++++++++++++++---- 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPHostFile.java b/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPHostFile.java index aca401c44f3..4b519f411be 100644 --- a/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPHostFile.java +++ b/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPHostFile.java @@ -13,6 +13,8 @@ * Contributors: * Michael Berger (IBM) - Fixing 140408 - FTP upload does not work * Javier Montalvo Orús (Symbian) - Migrate to jakarta commons net FTP client + * Javier Montalvo Orus (Symbian) - Fixing 161211 - Cannot expand /pub folder as + * anonymous on ftp.wacom.com ********************************************************************************/ package org.eclipse.rse.services.files.ftp; @@ -33,8 +35,8 @@ public class FTPHostFile implements IHostFile private boolean _isArchive; private long _lastModified; private long _size; - private boolean _canRead; - private boolean _canWrite; + private boolean _canRead = true; + private boolean _canWrite = true; private boolean _isRoot; private boolean _exists; @@ -52,7 +54,7 @@ public class FTPHostFile implements IHostFile _exists = exists; } - public FTPHostFile(String parentPath, FTPFile ftpFile) + public FTPHostFile(String parentPath, FTPFile ftpFile, String systemName) { _parentPath = parentPath; _name = ftpFile.getName(); @@ -60,8 +62,13 @@ public class FTPHostFile implements IHostFile _lastModified = ftpFile.getTimestamp().getTimeInMillis(); _size = ftpFile.getSize(); _isArchive = internalIsArchive(); - _canRead = ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION); - _canWrite = ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION); + + if(!systemName.toUpperCase().startsWith("WINDOWS")) + { + _canRead = ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION); + _canWrite = ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION); + } + _isRoot = false; _exists = true; } diff --git a/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPService.java b/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPService.java index 5b154dc4078..393f007b461 100644 --- a/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPService.java +++ b/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPService.java @@ -12,11 +12,13 @@ * * Contributors: * Michael Berger (IBM) - Fixing 140408 - FTP upload does not work - * Javier Montalvo Orús (Symbian) - Fixing 140323 - provided implementation for + * Javier Montalvo Orus (Symbian) - Fixing 140323 - provided implementation for * delete, move and rename. - * Javier Montalvo Orús (Symbian) - Bug 140348 - FTP did not use port number + * Javier Montalvo Orus (Symbian) - Bug 140348 - FTP did not use port number * Michael Berger (IBM) - Fixing 140404 - FTP new file creation does not work - * Javier Montalvo Orús (Symbian) - Migrate to jakarta commons net FTP client + * Javier Montalvo Orus (Symbian) - Migrate to jakarta commons net FTP client + * Javier Montalvo Orus (Symbian) - Fixing 161211 - Cannot expand /pub folder as + * anonymous on ftp.wacom.com ********************************************************************************/ package org.eclipse.rse.services.files.ftp; @@ -190,7 +192,12 @@ public class FTPService extends AbstractFileService implements IFileService, IFT ftp = getFTPClient(); } - ftp.changeWorkingDirectory(parentPath); + if(!ftp.changeWorkingDirectory(parentPath)) + { + return null; + } + + String systemName = ftp.getSystemName(); FTPFile[] ftpFiles = ftp.listFiles(); @@ -198,7 +205,7 @@ public class FTPService extends AbstractFileService implements IFileService, IFT { if(filematcher.matches(ftpFiles[i].getName())) { - results.add(new FTPHostFile(parentPath,ftpFiles[i])); + results.add(new FTPHostFile(parentPath,ftpFiles[i],systemName)); } } } @@ -337,8 +344,15 @@ public class FTPService extends AbstractFileService implements IFileService, IFT try { getFTPClient().cwd(remoteParent); - int returnedValue = getFTPClient().dele(fileName); - hasSucceeded = (returnedValue > 0); + + //attempt to remove an empty folder folder + hasSucceeded = getFTPClient().removeDirectory(fileName); + + if(!hasSucceeded) + { + //attempt to remove a file + hasSucceeded = getFTPClient().deleteFile(fileName); + } } catch (IOException e) { // Changing folder raised an exception @@ -355,7 +369,15 @@ public class FTPService extends AbstractFileService implements IFileService, IFT try { - getFTPClient().rename(remoteParent + getSeparator() + oldName, remoteParent + getSeparator() + newName); + if(newName.startsWith("/")) + { + getFTPClient().rename(remoteParent + getSeparator() + oldName, newName); + } + else + { + getFTPClient().rename(remoteParent + getSeparator() + oldName, remoteParent + getSeparator() + newName); + } + } catch (IOException e) { return false;