Changeset 915
- Timestamp:
- Dec 11, 2008, 10:16:56 PM (14 years ago)
- Location:
- extensions/net.sf.basedb.ftp/trunk
- Files:
-
- 5 added
- 3 deleted
- 8 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.ftp/trunk/META-INF/MANIFEST.MF
r741 r915 1 1 Manifest-Version: 1.0 2 Class-Path: lib/ftpserver/ftplet-api-1.0.0-M2.jar lib/ftpserver/ftpserver-core-1.0.0-M2.jar lib/ftpserver/mina-core-2.0.0-M2.jar lib/ftpserver/slf4j-api-1.5.2.jar lib/ftpserver/slf4j-log4j12-1.5.2.jar lib/ftpserver/spring-core-2.5.5.jar lib/ftpserver/spring-beans-2.5.5.jar 2 Class-Path: lib/ftpserver/ftplet-api-1.0.0-M4.jar 3 lib/ftpserver/ftpserver-core-1.0.0-M4.jar 4 lib/ftpserver/mina-core-2.0.0-M3.jar 5 lib/ftpserver/slf4j-api-1.5.2.jar 6 lib/ftpserver/slf4j-log4j12-1.5.2.jar 7 lib/ftpserver/spring-core-2.5.5.jar 8 lib/ftpserver/spring-beans-2.5.5.jar 9 lib/ftpserver/spring-context-2.5.5.jar 10 lib/ftpserver/aopalliance-1.0.jar -
extensions/net.sf.basedb.ftp/trunk/build.xml
r757 r915 81 81 prefix="${tar.prefix}" 82 82 preserveLeadingSlashes="true" 83 includes="${jar.name},README,LICENSE ,ftp-config.xml,lib/ftpserver/*"83 includes="${jar.name},README,LICENSE*,ftp-config.xml,lib/ftpserver/*" 84 84 /> 85 85 </tar> -
extensions/net.sf.basedb.ftp/trunk/ftp-config.xml
r741 r915 81 81 <!-- DO NOT CHANGE - filesystem is required to access files in BASE --> 82 82 <filesystem> 83 <beans:bean class="net.sf.basedb.clients.ftp.BaseFileSystem "/>83 <beans:bean class="net.sf.basedb.clients.ftp.BaseFileSystemFactory"/> 84 84 </filesystem> 85 85 </server> -
extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseFileSystemFactory.java
r914 r915 24 24 package net.sf.basedb.clients.ftp; 25 25 26 import org.apache.ftpserver.ftplet.FileSystem Manager;26 import org.apache.ftpserver.ftplet.FileSystemFactory; 27 27 import org.apache.ftpserver.ftplet.FileSystemView; 28 28 import org.apache.ftpserver.ftplet.FtpException; … … 34 34 @version 1.0 35 35 */ 36 public class BaseFileSystem 37 implements FileSystem Manager36 public class BaseFileSystemFactory 37 implements FileSystemFactory 38 38 { 39 39 … … 41 41 Creates the file system manager. 42 42 */ 43 public BaseFileSystem ()43 public BaseFileSystemFactory() 44 44 {} 45 45 -
extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseFileSystemView.java
r717 r915 29 29 import net.sf.basedb.core.Path; 30 30 31 import org.apache.ftpserver.ftplet.F ileObject;31 import org.apache.ftpserver.ftplet.FtpFile; 32 32 import org.apache.ftpserver.ftplet.FileSystemView; 33 33 import org.apache.ftpserver.ftplet.FtpException; … … 50 50 51 51 private BaseUser user; 52 private BaseF ileObjectcurrentDir;52 private BaseFtpFile currentDir; 53 53 54 54 /** … … 67 67 68 68 @Override 69 public F ileObject getCurrentDirectory()69 public FtpFile getWorkingDirectory() 70 70 throws FtpException 71 71 { … … 85 85 */ 86 86 @Override 87 public boolean change Directory(String path)87 public boolean changeWorkingDirectory(String path) 88 88 throws FtpException 89 89 { … … 104 104 { 105 105 // Move to parent directory 106 changeTo = new Path(currentDir.get FullName(), Path.Type.DIRECTORY).getParent();106 changeTo = new Path(currentDir.getAbsolutePath(), Path.Type.DIRECTORY).getParent(); 107 107 } 108 108 else 109 109 { 110 110 // Move to subdir within current directory 111 changeTo = new Path(append(currentDir.get FullName(), path), Path.Type.DIRECTORY);111 changeTo = new Path(append(currentDir.getAbsolutePath(), path), Path.Type.DIRECTORY); 112 112 } 113 113 if (log.isDebugEnabled()) … … 118 118 try 119 119 { 120 currentDir = new BaseF ileObject(user, Directory.getByPath(dc, changeTo));120 currentDir = new BaseFtpFile(user, Directory.getByPath(dc, changeTo)); 121 121 log.debug("Directory changed to: " + currentDir); 122 122 return true; … … 166 166 */ 167 167 @Override 168 public F ileObject getFileObject(String fileName)168 public FtpFile getFile(String fileName) 169 169 throws FtpException 170 170 { … … 179 179 if (fileName.startsWith("./")) 180 180 { 181 fileName = append(currentDir.get FullName(), fileName.substring(2));181 fileName = append(currentDir.getAbsolutePath(), fileName.substring(2)); 182 182 } 183 183 else if (!fileName.startsWith("/")) 184 184 { 185 fileName = append(currentDir.get FullName(), fileName);185 fileName = append(currentDir.getAbsolutePath(), fileName); 186 186 } 187 187 188 BaseF ileObjectfo = null;188 BaseFtpFile fo = null; 189 189 DbControl dc = user.sc.newDbControl(); 190 190 try … … 204 204 if (dc != null) dc.close(); 205 205 } 206 if (fo == null) fo = new BaseF ileObject(user, fileName);206 if (fo == null) fo = new BaseFtpFile(user, fileName); 207 207 if (log.isDebugEnabled()) 208 208 { … … 213 213 214 214 @Override 215 public F ileObjectgetHomeDirectory()215 public FtpFile getHomeDirectory() 216 216 throws FtpException 217 217 { … … 223 223 Try to load the given path as a BASE File object. 224 224 */ 225 private BaseF ileObjectgetFile(DbControl dc, String path)226 { 227 BaseF ileObjectfo = null;225 private BaseFtpFile getFile(DbControl dc, String path) 226 { 227 BaseFtpFile fo = null; 228 228 try 229 229 { 230 230 Path filePath = new Path(path, Path.Type.FILE); 231 231 File file = File.getByPath(dc, filePath, false); 232 fo = new BaseF ileObject(user, file);232 fo = new BaseFtpFile(user, file); 233 233 } 234 234 catch (Exception ex) … … 245 245 Try to load the given path as a BASE Directory object. 246 246 */ 247 private BaseF ileObjectgetDirectory(DbControl dc, String path)248 { 249 BaseF ileObjectfo = null;247 private BaseFtpFile getDirectory(DbControl dc, String path) 248 { 249 BaseFtpFile fo = null; 250 250 try 251 251 { 252 252 Path dirPath = new Path(path, Path.Type.DIRECTORY); 253 253 Directory dir = Directory.getByPath(dc, dirPath); 254 fo = new BaseF ileObject(user, dir);254 fo = new BaseFtpFile(user, dir); 255 255 } 256 256 catch (Exception ex) -
extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseFtpFile.java
r914 r915 42 42 import net.sf.basedb.core.query.Orders; 43 43 44 import org.apache.ftpserver.filesystem.NativeFileObject; 45 import org.apache.ftpserver.ftplet.FileObject; 44 import org.apache.ftpserver.ftplet.FtpFile; 46 45 import org.slf4j.Logger; 47 46 import org.slf4j.LoggerFactory; … … 58 57 @version 1.0 59 58 */ 60 public class BaseF ileObject61 implements F ileObject59 public class BaseFtpFile 60 implements FtpFile 62 61 { 63 private static final Logger log = LoggerFactory.getLogger(BaseF ileObject.class);62 private static final Logger log = LoggerFactory.getLogger(BaseFtpFile.class); 64 63 65 64 private BaseUser user; … … 74 73 the BASE server. 75 74 */ 76 public BaseF ileObject(BaseUser user, File file)75 public BaseFtpFile(BaseUser user, File file) 77 76 { 78 77 this.user = user; … … 87 86 the BASE server. 88 87 */ 89 public BaseF ileObject(BaseUser user, Directory directory)88 public BaseFtpFile(BaseUser user, Directory directory) 90 89 { 91 90 this.user = user; … … 100 99 directory. 101 100 */ 102 public BaseF ileObject(BaseUser user, String path)101 public BaseFtpFile(BaseUser user, String path) 103 102 { 104 103 this.user = user; … … 109 108 110 109 /* 111 From the F ileObjectinterface110 From the FtpFile interface 112 111 ------------------------------------------ 113 112 */ 114 113 @Override 115 public String get FullName()114 public String getAbsolutePath() 116 115 { 117 116 return path; … … 119 118 120 119 @Override 121 public String get ShortName()120 public String getName() 122 121 { 123 122 return name; … … 223 222 */ 224 223 @Override 225 public boolean hasReadPermission()224 public boolean isReadable() 226 225 { 227 226 return true; … … 233 232 */ 234 233 @Override 235 public boolean hasDeletePermission()234 public boolean isRemovable() 236 235 { 237 236 boolean permission = false; … … 252 251 */ 253 252 @Override 254 public boolean hasWritePermission()253 public boolean isWritable() 255 254 { 256 255 boolean permission = true; … … 271 270 */ 272 271 @Override 273 public FileObject[]listFiles()272 public List<FtpFile> listFiles() 274 273 { 275 274 if (log.isDebugEnabled()) … … 280 279 if (directory == null) return null; 281 280 282 List<F ileObject> all = new ArrayList<FileObject>();281 List<FtpFile> all = new ArrayList<FtpFile>(); 283 282 DbControl dc = user.sc.newDbControl(); 284 283 try … … 290 289 for (Directory dir : dirQuery.list(dc)) 291 290 { 292 all.add(new BaseF ileObject(user, dir));291 all.add(new BaseFtpFile(user, dir)); 293 292 } 294 293 // Add files … … 298 297 for (File file : fileQuery.list(dc)) 299 298 { 300 all.add(new BaseF ileObject(user, file));299 all.add(new BaseFtpFile(user, file)); 301 300 } 302 301 } … … 314 313 log.debug("List files ok: size=" + all.size()); 315 314 } 316 return all .toArray(new FileObject[all.size()]);315 return all; 317 316 } 318 317 … … 367 366 log.debug(" file/dir=" + this); 368 367 } 369 if (! hasDeletePermission()) return false;368 if (!isRemovable()) return false; 370 369 371 370 DbControl dc = user.sc.newDbControl(); … … 406 405 */ 407 406 @Override 408 public boolean move(F ileObjectdest)407 public boolean move(FtpFile dest) 409 408 { 410 409 if (log.isDebugEnabled()) … … 424 423 if (!hasSameParentDirectory(this, dest)) 425 424 { 426 Path to = new Path(dest.get FullName(), isDirectory() ? Path.Type.DIRECTORY : Path.Type.FILE);425 Path to = new Path(dest.getAbsolutePath(), isDirectory() ? Path.Type.DIRECTORY : Path.Type.FILE); 427 426 newParentDir = Directory.getByPath(dc, to.getParent()); 428 427 } … … 435 434 file = File.getById(dc, file.getId()); 436 435 if (newParentDir != null) file.setDirectory(newParentDir); 437 file.setName(dest.get ShortName());436 file.setName(dest.getName()); 438 437 } 439 438 else if (directory != null) … … 441 440 directory = Directory.getById(dc, directory.getId()); 442 441 if (newParentDir != null) directory.setParent(newParentDir); 443 directory.setName(dest.get ShortName());442 directory.setName(dest.getName()); 444 443 } 445 444 dc.commit(); … … 505 504 { 506 505 // Upload to a new file; always ignore offset 507 file = File.getByPath(dc, new Path(get FullName(), Path.Type.FILE), true);506 file = File.getByPath(dc, new Path(getAbsolutePath(), Path.Type.FILE), true); 508 507 dc.saveItem(file); 509 508 offset = 0; … … 561 560 type = "dir"; 562 561 } 563 return "BaseF ileObject[" + type + "=" + path + "]";562 return "BaseFtpFile[" + type + "=" + path + "]"; 564 563 } 565 564 // ------------------------------------------- … … 581 580 Check if two file objects are located in the same or different directories. 582 581 */ 583 private boolean hasSameParentDirectory(F ileObject fo1, FileObjectfo2)584 { 585 int index1 = fo1.get FullName().length() - fo1.getShortName().length();586 String parent1 = fo1.get FullName().substring(0, index1);587 int index2 = fo2.get FullName().length() - fo2.getShortName().length();588 String parent2 = fo2.get FullName().substring(0, index2);582 private boolean hasSameParentDirectory(FtpFile fo1, FtpFile fo2) 583 { 584 int index1 = fo1.getAbsolutePath().length() - fo1.getName().length(); 585 String parent1 = fo1.getAbsolutePath().substring(0, index1); 586 int index2 = fo2.getAbsolutePath().length() - fo2.getName().length(); 587 String parent2 = fo2.getAbsolutePath().substring(0, index2); 589 588 return parent1.equals(parent2); 590 589 } 590 591 @Override 592 public void setLastModified(long arg0) 593 { 594 // TODO Auto-generated method stub 595 596 } 591 597 592 598 } -
extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseFtpServer.java
r741 r915 55 55 <ul> 56 56 <li>User manager: {@link BaseUserManager} 57 <li>File system manager: {@link BaseFileSystem }57 <li>File system manager: {@link BaseFileSystemFactory} 58 58 <li>Ftplet: {@link BaseFtplet} 59 59 <li>Anonymous login is disabled -
extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseFtplet.java
r716 r915 30 30 import org.apache.ftpserver.ftplet.FtpSession; 31 31 import org.apache.ftpserver.ftplet.Ftplet; 32 import org.apache.ftpserver.ftplet.Ftplet Enum;32 import org.apache.ftpserver.ftplet.FtpletResult; 33 33 import org.apache.ftpserver.ftplet.User; 34 34 import org.slf4j.Logger; … … 61 61 */ 62 62 @Override 63 public Ftplet EnumonDisconnect(FtpSession session)63 public FtpletResult onDisconnect(FtpSession session) 64 64 throws FtpException, IOException 65 65 { … … 78 78 */ 79 79 @Override 80 public Ftplet EnumonConnect(FtpSession session)80 public FtpletResult onConnect(FtpSession session) 81 81 throws FtpException, IOException 82 82 { … … 84 84 { 85 85 log.debug("New connection from: " + session.getClientAddress()); 86 log.debug("Server address: " + session.getServerAddress() + ":" + session.getServerPort());86 log.debug("Server address: " + session.getServerAddress()); 87 87 } 88 88 return super.onConnect(session); -
extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseUser.java
r741 r915 54 54 55 55 private final String login; 56 private final Authority[]authorities;56 private final List<Authority> authorities; 57 57 58 58 SessionControl sc; 59 59 private User user; 60 private BaseF ileObjecthome;60 private BaseFtpFile home; 61 61 62 62 /** … … 66 66 @param authorities The permissions of the user 67 67 */ 68 public BaseUser(String login, Authority[]authorities)68 public BaseUser(String login, List<Authority> authorities) 69 69 { 70 70 this.login = login; … … 117 117 public String getHomeDirectory() 118 118 { 119 return home == null ? "/" : home.get FullName();119 return home == null ? "/" : home.getAbsolutePath(); 120 120 } 121 121 … … 171 171 172 172 @Override 173 public Authority[]getAuthorities()173 public List<Authority> getAuthorities() 174 174 { 175 175 return authorities; … … 177 177 178 178 @Override 179 public Authority[]getAuthorities(Class<? extends Authority> clazz)179 public List<Authority> getAuthorities(Class<? extends Authority> clazz) 180 180 { 181 181 List<Authority> selected = new ArrayList<Authority>(); … … 187 187 } 188 188 } 189 return selected .toArray(new Authority[0]);189 return selected; 190 190 } 191 191 // ------------------------ … … 245 245 this.sc = sc; 246 246 this.user = u; 247 this.home = new BaseF ileObject(this, homeDir);247 this.home = new BaseFtpFile(this, homeDir); 248 248 } 249 249 catch (RuntimeException ex) … … 287 287 if no user is logged in. 288 288 */ 289 public BaseF ileObjectgetHome()289 public BaseFtpFile getHome() 290 290 { 291 291 return home; -
extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseUserManager.java
r716 r915 23 23 */ 24 24 package net.sf.basedb.clients.ftp; 25 26 import java.util.ArrayList; 27 import java.util.List; 25 28 26 29 import org.apache.ftpserver.ftplet.Authentication; … … 31 34 import org.apache.ftpserver.ftplet.UserManager; 32 35 import org.apache.ftpserver.usermanager.AnonymousAuthentication; 33 import org.apache.ftpserver.usermanager.ConcurrentLoginPermission;34 import org.apache.ftpserver.usermanager.TransferRatePermission;35 36 import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication; 36 import org.apache.ftpserver.usermanager.WritePermission; 37 import org.apache.ftpserver.usermanager.impl.ConcurrentLoginPermission; 38 import org.apache.ftpserver.usermanager.impl.TransferRatePermission; 39 import org.apache.ftpserver.usermanager.impl.WritePermission; 37 40 import org.slf4j.Logger; 38 41 import org.slf4j.LoggerFactory; … … 274 277 log.debug("Transfer rate: upload=" + maxUploadRate + "; download=" + maxDownloadRate); 275 278 } 276 Authority[] auth = new Authority[3];277 auth [0] = new ConcurrentLoginPermission(0, 0);278 auth [1] = new WritePermission();279 auth [2] = new TransferRatePermission(maxDownloadRate, maxUploadRate);279 List<Authority> auth = new ArrayList<Authority>(); 280 auth.add(new ConcurrentLoginPermission(0, 0)); 281 auth.add(new WritePermission()); 282 auth.add(new TransferRatePermission(maxDownloadRate, maxUploadRate)); 280 283 BaseUser u = new BaseUser(login, auth); 281 284 return u;
Note: See TracChangeset
for help on using the changeset viewer.