Ignore:
Timestamp:
Dec 11, 2008, 10:16:56 PM (13 years ago)
Author:
Nicklas Nordborg
Message:

References #127: Update to final release of Apache Mina FTP server

I have now updated to Apache FTP Server 1.0-M4. According to the developers the code is now feature freezed
and the API will be kept stable. Only bugfixes remains before the final release.

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  
    11Manifest-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
     2Class-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  
    8181        prefix="${tar.prefix}"
    8282        preserveLeadingSlashes="true"
    83         includes="${jar.name},README,LICENSE,ftp-config.xml,lib/ftpserver/*"
     83        includes="${jar.name},README,LICENSE*,ftp-config.xml,lib/ftpserver/*"
    8484      />
    8585    </tar>
  • extensions/net.sf.basedb.ftp/trunk/ftp-config.xml

    r741 r915  
    8181  <!--  DO NOT CHANGE - filesystem is required to access files in BASE -->
    8282  <filesystem>
    83     <beans:bean class="net.sf.basedb.clients.ftp.BaseFileSystem"/>
     83    <beans:bean class="net.sf.basedb.clients.ftp.BaseFileSystemFactory"/>
    8484  </filesystem>
    8585</server>
  • extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseFileSystemFactory.java

    r914 r915  
    2424package net.sf.basedb.clients.ftp;
    2525
    26 import org.apache.ftpserver.ftplet.FileSystemManager;
     26import org.apache.ftpserver.ftplet.FileSystemFactory;
    2727import org.apache.ftpserver.ftplet.FileSystemView;
    2828import org.apache.ftpserver.ftplet.FtpException;
     
    3434  @version 1.0
    3535*/
    36 public class BaseFileSystem
    37   implements FileSystemManager
     36public class BaseFileSystemFactory
     37  implements FileSystemFactory
    3838{
    3939
     
    4141    Creates the file system manager.
    4242  */
    43   public BaseFileSystem()
     43  public BaseFileSystemFactory()
    4444  {}
    4545 
  • extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseFileSystemView.java

    r717 r915  
    2929import net.sf.basedb.core.Path;
    3030
    31 import org.apache.ftpserver.ftplet.FileObject;
     31import org.apache.ftpserver.ftplet.FtpFile;
    3232import org.apache.ftpserver.ftplet.FileSystemView;
    3333import org.apache.ftpserver.ftplet.FtpException;
     
    5050
    5151  private BaseUser user;
    52   private BaseFileObject currentDir;
     52  private BaseFtpFile currentDir;
    5353 
    5454  /**
     
    6767 
    6868  @Override
    69   public FileObject getCurrentDirectory()
     69  public FtpFile getWorkingDirectory()
    7070    throws FtpException
    7171  {
     
    8585  */
    8686  @Override
    87   public boolean changeDirectory(String path)
     87  public boolean changeWorkingDirectory(String path)
    8888    throws FtpException
    8989  {
     
    104104    {
    105105      // Move to parent directory
    106       changeTo = new Path(currentDir.getFullName(), Path.Type.DIRECTORY).getParent();
     106      changeTo = new Path(currentDir.getAbsolutePath(), Path.Type.DIRECTORY).getParent();
    107107    }
    108108    else
    109109    {
    110110      // Move to subdir within current directory
    111       changeTo = new Path(append(currentDir.getFullName(), path), Path.Type.DIRECTORY);
     111      changeTo = new Path(append(currentDir.getAbsolutePath(), path), Path.Type.DIRECTORY);
    112112    }
    113113    if (log.isDebugEnabled())
     
    118118    try
    119119    {
    120       currentDir = new BaseFileObject(user, Directory.getByPath(dc, changeTo));
     120      currentDir = new BaseFtpFile(user, Directory.getByPath(dc, changeTo));
    121121      log.debug("Directory changed to: " + currentDir);
    122122      return true;
     
    166166  */
    167167  @Override
    168   public FileObject getFileObject(String fileName)
     168  public FtpFile getFile(String fileName)
    169169    throws FtpException
    170170  {
     
    179179    if (fileName.startsWith("./"))
    180180    {
    181       fileName = append(currentDir.getFullName(), fileName.substring(2));
     181      fileName = append(currentDir.getAbsolutePath(), fileName.substring(2));
    182182    }
    183183    else if (!fileName.startsWith("/"))
    184184    {
    185       fileName = append(currentDir.getFullName(), fileName);
     185      fileName = append(currentDir.getAbsolutePath(), fileName);
    186186    }
    187187   
    188     BaseFileObject fo = null;
     188    BaseFtpFile fo = null;
    189189    DbControl dc = user.sc.newDbControl();
    190190    try
     
    204204      if (dc != null) dc.close();
    205205    }
    206     if (fo == null) fo = new BaseFileObject(user, fileName);
     206    if (fo == null) fo = new BaseFtpFile(user, fileName);
    207207    if (log.isDebugEnabled())
    208208    {
     
    213213
    214214  @Override
    215   public FileObject getHomeDirectory()
     215  public FtpFile getHomeDirectory()
    216216    throws FtpException
    217217  {
     
    223223    Try to load the given path as a BASE File object.
    224224  */
    225   private BaseFileObject getFile(DbControl dc, String path)
    226   {
    227     BaseFileObject fo = null;
     225  private BaseFtpFile getFile(DbControl dc, String path)
     226  {
     227    BaseFtpFile fo = null;
    228228    try
    229229    {
    230230      Path filePath = new Path(path, Path.Type.FILE);
    231231      File file = File.getByPath(dc, filePath, false);
    232       fo = new BaseFileObject(user, file);
     232      fo = new BaseFtpFile(user, file);
    233233    }
    234234    catch (Exception ex)
     
    245245    Try to load the given path as a BASE Directory object.
    246246  */
    247   private BaseFileObject getDirectory(DbControl dc, String path)
    248   {
    249     BaseFileObject fo = null;
     247  private BaseFtpFile getDirectory(DbControl dc, String path)
     248  {
     249    BaseFtpFile fo = null;
    250250    try
    251251    {
    252252      Path dirPath = new Path(path, Path.Type.DIRECTORY);
    253253      Directory dir = Directory.getByPath(dc, dirPath);
    254       fo = new BaseFileObject(user, dir);
     254      fo = new BaseFtpFile(user, dir);
    255255    }
    256256    catch (Exception ex)
  • extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseFtpFile.java

    r914 r915  
    4242import net.sf.basedb.core.query.Orders;
    4343
    44 import org.apache.ftpserver.filesystem.NativeFileObject;
    45 import org.apache.ftpserver.ftplet.FileObject;
     44import org.apache.ftpserver.ftplet.FtpFile;
    4645import org.slf4j.Logger;
    4746import org.slf4j.LoggerFactory;
     
    5857  @version 1.0
    5958*/
    60 public class BaseFileObject
    61   implements FileObject
     59public class BaseFtpFile
     60  implements FtpFile
    6261{
    63   private static final Logger log = LoggerFactory.getLogger(BaseFileObject.class);
     62  private static final Logger log = LoggerFactory.getLogger(BaseFtpFile.class);
    6463
    6564  private BaseUser user;
     
    7473    the BASE server.
    7574  */
    76   public BaseFileObject(BaseUser user, File file)
     75  public BaseFtpFile(BaseUser user, File file)
    7776  {
    7877    this.user = user;
     
    8786    the BASE server.
    8887  */
    89   public BaseFileObject(BaseUser user, Directory directory)
     88  public BaseFtpFile(BaseUser user, Directory directory)
    9089  {
    9190    this.user = user;
     
    10099    directory.
    101100  */
    102   public BaseFileObject(BaseUser user, String path)
     101  public BaseFtpFile(BaseUser user, String path)
    103102  {
    104103    this.user = user;
     
    109108 
    110109  /*
    111     From the FileObject interface
     110    From the FtpFile interface
    112111    ------------------------------------------
    113112  */
    114113  @Override
    115   public String getFullName()
     114  public String getAbsolutePath()
    116115  {
    117116    return path;
     
    119118 
    120119  @Override
    121   public String getShortName()
     120  public String getName()
    122121  {
    123122    return name;
     
    223222  */
    224223  @Override
    225   public boolean hasReadPermission()
     224  public boolean isReadable()
    226225  {
    227226    return true;
     
    233232  */
    234233  @Override
    235   public boolean hasDeletePermission()
     234  public boolean isRemovable()
    236235  {
    237236    boolean permission = false;
     
    252251  */
    253252  @Override
    254   public boolean hasWritePermission()
     253  public boolean isWritable()
    255254  {
    256255    boolean permission = true;
     
    271270  */
    272271  @Override
    273   public FileObject[] listFiles()
     272  public List<FtpFile> listFiles()
    274273  {
    275274    if (log.isDebugEnabled())
     
    280279    if (directory == null) return null;
    281280   
    282     List<FileObject> all = new ArrayList<FileObject>();
     281    List<FtpFile> all = new ArrayList<FtpFile>();
    283282    DbControl dc = user.sc.newDbControl();
    284283    try
     
    290289      for (Directory dir : dirQuery.list(dc))
    291290      {
    292         all.add(new BaseFileObject(user, dir));
     291        all.add(new BaseFtpFile(user, dir));
    293292      }
    294293      // Add files
     
    298297      for (File file : fileQuery.list(dc))
    299298      {
    300         all.add(new BaseFileObject(user, file));
     299        all.add(new BaseFtpFile(user, file));
    301300      }
    302301    }
     
    314313      log.debug("List files ok: size=" + all.size());
    315314    }
    316     return all.toArray(new FileObject[all.size()]);
     315    return all;
    317316  }
    318317 
     
    367366      log.debug("   file/dir=" + this);
    368367    }
    369     if (!hasDeletePermission()) return false;
     368    if (!isRemovable()) return false;
    370369   
    371370    DbControl dc = user.sc.newDbControl();
     
    406405  */
    407406  @Override
    408   public boolean move(FileObject dest)
     407  public boolean move(FtpFile dest)
    409408  {
    410409    if (log.isDebugEnabled())
     
    424423      if (!hasSameParentDirectory(this, dest))
    425424      {
    426         Path to = new Path(dest.getFullName(), isDirectory() ? Path.Type.DIRECTORY : Path.Type.FILE);
     425        Path to = new Path(dest.getAbsolutePath(), isDirectory() ? Path.Type.DIRECTORY : Path.Type.FILE);
    427426        newParentDir = Directory.getByPath(dc, to.getParent());
    428427      }
     
    435434        file = File.getById(dc, file.getId());
    436435        if (newParentDir != null) file.setDirectory(newParentDir);
    437         file.setName(dest.getShortName());
     436        file.setName(dest.getName());
    438437      }
    439438      else if (directory != null)
     
    441440        directory = Directory.getById(dc, directory.getId());
    442441        if (newParentDir != null) directory.setParent(newParentDir);
    443         directory.setName(dest.getShortName());
     442        directory.setName(dest.getName());
    444443      }
    445444      dc.commit();
     
    505504      {
    506505        // Upload to a new file; always ignore offset
    507         file = File.getByPath(dc, new Path(getFullName(), Path.Type.FILE), true);
     506        file = File.getByPath(dc, new Path(getAbsolutePath(), Path.Type.FILE), true);
    508507        dc.saveItem(file);
    509508        offset = 0;
     
    561560      type = "dir";
    562561    }
    563     return "BaseFileObject[" + type + "=" + path + "]";
     562    return "BaseFtpFile[" + type + "=" + path + "]";
    564563  }
    565564  // -------------------------------------------
     
    581580    Check if two file objects are located in the same or different directories.
    582581  */
    583   private boolean hasSameParentDirectory(FileObject fo1, FileObject fo2)
    584   {
    585     int index1 = fo1.getFullName().length() - fo1.getShortName().length();
    586     String parent1 = fo1.getFullName().substring(0, index1);
    587     int index2 = fo2.getFullName().length() - fo2.getShortName().length();
    588     String parent2 = fo2.getFullName().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);
    589588    return parent1.equals(parent2);
    590589  }
     590
     591  @Override
     592  public void setLastModified(long arg0)
     593  {
     594    // TODO Auto-generated method stub
     595   
     596  }
    591597 
    592598}
  • extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseFtpServer.java

    r741 r915  
    5555  <ul>
    5656  <li>User manager: {@link BaseUserManager}
    57   <li>File system manager: {@link BaseFileSystem}
     57  <li>File system manager: {@link BaseFileSystemFactory}
    5858  <li>Ftplet: {@link BaseFtplet}
    5959  <li>Anonymous login is disabled
  • extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseFtplet.java

    r716 r915  
    3030import org.apache.ftpserver.ftplet.FtpSession;
    3131import org.apache.ftpserver.ftplet.Ftplet;
    32 import org.apache.ftpserver.ftplet.FtpletEnum;
     32import org.apache.ftpserver.ftplet.FtpletResult;
    3333import org.apache.ftpserver.ftplet.User;
    3434import org.slf4j.Logger;
     
    6161  */
    6262  @Override
    63   public FtpletEnum onDisconnect(FtpSession session)
     63  public FtpletResult onDisconnect(FtpSession session)
    6464    throws FtpException, IOException
    6565  {
     
    7878  */
    7979  @Override
    80   public FtpletEnum onConnect(FtpSession session)
     80  public FtpletResult onConnect(FtpSession session)
    8181    throws FtpException, IOException
    8282  {
     
    8484    {
    8585      log.debug("New connection from: " + session.getClientAddress());
    86       log.debug("Server address: " + session.getServerAddress() + ":" + session.getServerPort());
     86      log.debug("Server address: " + session.getServerAddress());
    8787    }
    8888    return super.onConnect(session);
  • extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseUser.java

    r741 r915  
    5454
    5555  private final String login;
    56   private final Authority[] authorities;
     56  private final List<Authority> authorities;
    5757 
    5858  SessionControl sc;
    5959  private User user;
    60   private BaseFileObject home;
     60  private BaseFtpFile home;
    6161 
    6262  /**
     
    6666    @param authorities The permissions of the user
    6767  */
    68   public BaseUser(String login, Authority[] authorities)
     68  public BaseUser(String login, List<Authority> authorities)
    6969  {
    7070    this.login = login;
     
    117117  public String getHomeDirectory()
    118118  {
    119     return home == null ? "/" : home.getFullName();
     119    return home == null ? "/" : home.getAbsolutePath();
    120120  }
    121121 
     
    171171 
    172172  @Override
    173   public Authority[] getAuthorities()
     173  public List<Authority> getAuthorities()
    174174  {
    175175    return authorities;
     
    177177
    178178  @Override
    179   public Authority[] getAuthorities(Class<? extends Authority> clazz)
     179  public List<Authority> getAuthorities(Class<? extends Authority> clazz)
    180180  {
    181181    List<Authority> selected = new ArrayList<Authority>();
     
    187187          }
    188188        }
    189         return selected.toArray(new Authority[0])
     189        return selected
    190190  }
    191191  // ------------------------
     
    245245      this.sc = sc;
    246246      this.user = u;
    247       this.home = new BaseFileObject(this, homeDir);
     247      this.home = new BaseFtpFile(this, homeDir);
    248248    }
    249249    catch (RuntimeException ex)
     
    287287    if no user is logged in.
    288288  */
    289   public BaseFileObject getHome()
     289  public BaseFtpFile getHome()
    290290  {
    291291    return home;
  • extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseUserManager.java

    r716 r915  
    2323*/
    2424package net.sf.basedb.clients.ftp;
     25
     26import java.util.ArrayList;
     27import java.util.List;
    2528
    2629import org.apache.ftpserver.ftplet.Authentication;
     
    3134import org.apache.ftpserver.ftplet.UserManager;
    3235import org.apache.ftpserver.usermanager.AnonymousAuthentication;
    33 import org.apache.ftpserver.usermanager.ConcurrentLoginPermission;
    34 import org.apache.ftpserver.usermanager.TransferRatePermission;
    3536import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication;
    36 import org.apache.ftpserver.usermanager.WritePermission;
     37import org.apache.ftpserver.usermanager.impl.ConcurrentLoginPermission;
     38import org.apache.ftpserver.usermanager.impl.TransferRatePermission;
     39import org.apache.ftpserver.usermanager.impl.WritePermission;
    3740import org.slf4j.Logger;
    3841import org.slf4j.LoggerFactory;
     
    274277      log.debug("Transfer rate: upload=" + maxUploadRate + "; download=" + maxDownloadRate);
    275278    }
    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));
    280283    BaseUser u = new BaseUser(login, auth);   
    281284    return u;
Note: See TracChangeset for help on using the changeset viewer.