incubator-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ran...@apache.org
Subject cvs commit: incubator-ftpserver/src/java/org/apache/ftpserver/ftplet Component.java Configuration.java DefaultFtplet.java EmptyConfiguration.java FileObject.java FileSystemManager.java FileSystemView.java FtpConfig.java FtpException.java Ftplet.java FtpletEnum.java FtpRequest.java FtpResponse.java FtpStatistics.java Logger.java User.java UserManager.java
Date Wed, 07 Sep 2005 05:05:18 GMT
rana_b      2005/09/06 22:05:18

  Added:       src/java/org/apache/ftpserver/ftplet Component.java
                        Configuration.java DefaultFtplet.java
                        EmptyConfiguration.java FileObject.java
                        FileSystemManager.java FileSystemView.java
                        FtpConfig.java FtpException.java Ftplet.java
                        FtpletEnum.java FtpRequest.java FtpResponse.java
                        FtpStatistics.java Logger.java User.java
                        UserManager.java
  Log:
  Refactored - removed avalon entirely
  
  Revision  Changes    Path
  1.1                  incubator-ftpserver/src/java/org/apache/ftpserver/ftplet/Component.java
  
  Index: Component.java
  ===================================================================
  // $Id: Component.java,v 1.1 2005/09/07 05:05:17 rana_b Exp $
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.ftpserver.ftplet;
  
  /**
   * This interface abstracts the basic lifecycle method. 
   * <ol>
   *     <li>Default constructor will be called.</li>
   *     <li>Component.setLogger(Logger) will be set to set the appropriate logger.</li>
   *     <li>The component will be configured using Component.configure(Configuration)</li>
   *     <li>Other component specific methods will be called.</li>
   *     <li>Finnaly Component.dispose() method will be called.</li>
   * </ol>
   * 
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public 
  interface Component {
  
      /**
       * Set logger. 
       */
      void setLogger(Logger logger);
      
      /**
       * Configure the component.
       */
      void configure(Configuration config) throws FtpException;
      
      /**
       * Dispose component - release all the resources.
       */
      void dispose();
      
  }
  
  
  
  1.1                  incubator-ftpserver/src/java/org/apache/ftpserver/ftplet/Configuration.java
  
  Index: Configuration.java
  ===================================================================
  // $Id: Configuration.java,v 1.1 2005/09/07 05:05:17 rana_b Exp $
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.ftpserver.ftplet;
  
  /**
   * Configuration interface. 
   * 
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public 
  interface Configuration {
  
      /**
       * Get string - if not found throws FtpException.
       */
      String getString(String param) throws FtpException;
  
      /**
       * Get string - if not found returns the default value.
       */
      String getString(String param, String defaultVal);
  
      /**
       * Get integer - if not found throws FtpException.
       */
      int getInt(String param) throws FtpException;
          
      /**
       * Get integer - if not found returns the default value.
       */
      int getInt(String param, int defaultVal);
      
      /**
       * Get long - if not found throws FtpException.
       */
      long getLong(String param) throws FtpException;
      
      /**
       * Get long - if not found returns the default value.
       */
      long getLong(String param, long defaultVal);
      
      /**
       * Get boolean - if not found throws FtpException.
       */
      boolean getBoolean(String patram) throws FtpException;
      
      /**
       * Get boolean - if not found returns the default value.
       */
      boolean getBoolean(String param, boolean defaultVal);
      
      /**
       * Get double - if not found throws FtpException.
       */
      double getDouble(String param) throws FtpException;
      
      /**
       * Get double - if not found returns the default value.
       */
      double getDouble(String param, double defaultVal);
  
      /**
       * Get sub configuration - if not found throws FtpException.
       */
      Configuration getConfiguration(String param) throws FtpException;
      
      /**
       * Get sub configuration - if not found returns the default value.
       */
      Configuration getConfiguration(String param, Configuration defaultVal);
  }
  
  
  
  1.1                  incubator-ftpserver/src/java/org/apache/ftpserver/ftplet/DefaultFtplet.java
  
  Index: DefaultFtplet.java
  ===================================================================
  // $Id: DefaultFtplet.java,v 1.1 2005/09/07 05:05:17 rana_b Exp $
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.ftpserver.ftplet;
  
  import java.io.IOException;
  
  /**
   * Default ftplet implementation. All the callback method returns null. 
   * It is just an empty implementation. You can derive your ftplet implementation
   * from this class.
   * 
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public 
  class DefaultFtplet implements Ftplet {
  
      public void init(FtpConfig ftpConfig, Configuration config) throws FtpException {}
      public void destroy() {}
      
      public FtpletEnum onConnect(FtpRequest request, FtpResponse response) throws FtpException,
IOException {return null;}
      public FtpletEnum onDisconnect(FtpRequest request, FtpResponse response) throws FtpException,
IOException {return null;}
      public FtpletEnum onLogin(FtpRequest request, FtpResponse response) throws FtpException,
IOException {return null;}
      
      public FtpletEnum onDeleteStart(FtpRequest request, FtpResponse response) throws FtpException,
IOException {return null;}
      public FtpletEnum onDeleteEnd(FtpRequest request, FtpResponse response) throws FtpException,
IOException {return null;}
      
      public FtpletEnum onUploadStart(FtpRequest request, FtpResponse response) throws FtpException,
IOException {return null;}
      public FtpletEnum onUploadEnd(FtpRequest request, FtpResponse response) throws FtpException,
IOException {return null;}
      
      public FtpletEnum onDownloadStart(FtpRequest request, FtpResponse response) throws FtpException,
IOException {return null;}
      public FtpletEnum onDownloadEnd(FtpRequest request, FtpResponse response) throws FtpException,
IOException {return null;}
      
      public FtpletEnum onRmdirStart(FtpRequest request, FtpResponse response) throws FtpException,
IOException {return null;}
      public FtpletEnum onRmdirEnd(FtpRequest request, FtpResponse response) throws FtpException,
IOException {return null;}
      
      public FtpletEnum onMkdirStart(FtpRequest request, FtpResponse response) throws FtpException,
IOException {return null;}
      public FtpletEnum onMkdirEnd(FtpRequest request, FtpResponse response) throws FtpException,
IOException {return null;}
          
      public FtpletEnum onAppendStart(FtpRequest request, FtpResponse response) throws FtpException,
IOException {return null;}
      public FtpletEnum onAppendEnd(FtpRequest request, FtpResponse response) throws FtpException,
IOException {return null;}
      
      public FtpletEnum onUploadUniqueStart(FtpRequest request, FtpResponse response) throws
FtpException, IOException {return null;}
      public FtpletEnum onUploadUniqueEnd(FtpRequest request, FtpResponse response) throws
FtpException, IOException {return null;}
      
      public FtpletEnum onRenameStart(FtpRequest request, FtpResponse response) throws FtpException,
IOException {return null;}
      public FtpletEnum onRenameEnd(FtpRequest request, FtpResponse response) throws FtpException,
IOException {return null;}
      
      public FtpletEnum onSite(FtpRequest request, FtpResponse response) throws FtpException,
IOException {return null;}
  }
  
  
  
  1.1                  incubator-ftpserver/src/java/org/apache/ftpserver/ftplet/EmptyConfiguration.java
  
  Index: EmptyConfiguration.java
  ===================================================================
  // $Id: EmptyConfiguration.java,v 1.1 2005/09/07 05:05:17 rana_b Exp $
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.ftpserver.ftplet;
  
  /**
   * Empty configuration - always returns the default values.
   * 
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public 
  class EmptyConfiguration implements Configuration {
  
      /**
       * Throw exception.
       */
      public String getString(String param) throws FtpException {
          throw new FtpException();
      }
  
      /**
       * Return default value.
       */
      public String getString(String patram, String defaultVal) {
          return defaultVal;
      }
  
      /**
       * Throw exception.
       */
      public int getInt(String patram) throws FtpException {
          throw new FtpException();
      }
  
      /**
       * Return default value.
       */
      public int getInt(String patram, int defaultVal) {
          return defaultVal;
      }
  
      /**
       * Throw exception.
       */
      public long getLong(String param) throws FtpException {
          throw new FtpException();
      }
  
      /**
       * Return default value.
       */
      public long getLong(String param, long defaultVal) {
          return defaultVal;
      }
  
      /**
       * Throw exception.
       */
      public boolean getBoolean(String patram) throws FtpException {
          throw new FtpException();
      }
  
      /**
       * Return default value.
       */
      public boolean getBoolean(String patram, boolean defaultVal) {
          return defaultVal;
      }
  
      /**
       * Throw exception.
       */
      public double getDouble(String patram) throws FtpException {
          throw new FtpException();
      }
  
      /**
       * Get default value.
       */
      public double getDouble(String patram, double defaultVal) {
          return defaultVal;
      }
  
      /**
       * Throw exception.
       */
      public Configuration getConfiguration(String param) throws FtpException {
          throw new FtpException();
      }
  
      /**
       * Return the default value.
       */
      public Configuration getConfiguration(String param, Configuration defaultVal) {
          return defaultVal;
      }
  }
  
  
  
  1.1                  incubator-ftpserver/src/java/org/apache/ftpserver/ftplet/FileObject.java
  
  Index: FileObject.java
  ===================================================================
  // $Id: FileObject.java,v 1.1 2005/09/07 05:05:17 rana_b Exp $
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.ftpserver.ftplet;
  
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  
  /**
   * This is an abstraction over the file.
   * 
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public 
  interface FileObject {
      
      /**
       * Get the fully qualified name.
       */
      String getFullName();
      
      /**
       * Get the file short name.
       */
      String getShortName();
      
      /**
       * Is a hidden file?
       */
      boolean isHidden();
       
      /**
       * Is it a directory?
       */
      boolean isDirectory();
      
      /**
       * Is it a file?
       */
      boolean isFile();
      
      /**
       * Does this file exists?
       */
      boolean doesExist();
      
      /**
       * Has read permission?
       */ 
      boolean hasReadPermission();
      
      /**
       * Has write permission?
       */ 
      boolean hasWritePermission(); 
      
      /**
       * Has delete permission?
       */
      boolean hasDeletePermission();
      
      /**
       * Get the owner name.
       */ 
      String getOwnerName();
      
      /**
       * Get owner group name.
       */
      String getGroupName(); 
      
      /**
       * Get link count.
       */
      int getLinkCount();
      
      /**
       * Get last modified time.
       */ 
      long getLastModified();
      
      /**
       * Get file size.
       */
      long getSize();
      
      /**
       * Create directory.
       */
      boolean mkdir();
  
      /**
       * Delete file.
       */
      boolean delete();
      
      /**
       * Move file
       */
      boolean move(FileObject destination);
      
      /**
       * Create output stream for writing.
       */
      OutputStream createOutputStream(boolean append) throws IOException;
      
      /**
       * Create output stream for writing.
       */
      OutputStream createOutputStream(long offset) throws IOException;
      
      /**
       * Create input stream for reading.
       */
      InputStream createInputStream(long offset) throws IOException;
  }
  
  
  
  1.1                  incubator-ftpserver/src/java/org/apache/ftpserver/ftplet/FileSystemManager.java
  
  Index: FileSystemManager.java
  ===================================================================
  // $Id: FileSystemManager.java,v 1.1 2005/09/07 05:05:17 rana_b Exp $
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.ftpserver.ftplet;
  
  /**
   * This is the file system manager - it returns the file system 
   * view for user.
   * 
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public 
  interface FileSystemManager extends Component {
      
      /**
       * Get user file system view
       */
      FileSystemView createFileSystemView(User user) throws FtpException;
      
  }
  
  
  
  1.1                  incubator-ftpserver/src/java/org/apache/ftpserver/ftplet/FileSystemView.java
  
  Index: FileSystemView.java
  ===================================================================
  // $Id: FileSystemView.java,v 1.1 2005/09/07 05:05:17 rana_b Exp $
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.ftpserver.ftplet;
  
  
  /**
   * This is an abstraction over the user file system view.
   * 
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public
  interface FileSystemView {
  
      /**
       * Get the user root directory.
       */
      FileObject getRootDirectory() throws FtpException;
      
      /**
       * Get user current directory.
       */
      FileObject getCurrentDirectory() throws FtpException;
      
      /**
       * Change directory.
       */ 
      boolean changeDirectory(FileObject dir) throws FtpException;
      
      /**
       * Get file object.
       */
      FileObject getFileObject(String file) throws FtpException;
      
      /**
       * List file objects
       */
      FileObject[] listFiles(String file) throws FtpException;
  }
  
  
  
  1.1                  incubator-ftpserver/src/java/org/apache/ftpserver/ftplet/FtpConfig.java
  
  Index: FtpConfig.java
  ===================================================================
  // $Id: FtpConfig.java,v 1.1 2005/09/07 05:05:17 rana_b Exp $
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.ftpserver.ftplet;
  
  import java.net.InetAddress;
  
  /**
   * A ftplet configuration object used by a ftplet container used to pass 
   * information to a ftplet during initialization. The configuration information 
   * contains initialization parameters.
   * 
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public 
  interface FtpConfig {
  
      /**
       * Get the user manager.
       */
      UserManager getUserManager();
  
      /**
       * Get logger.
       */
      Logger getLogger();
       
      /**
       * Get file system manager
       */
      FileSystemManager getFileSystemManager();
       
      /**
       * Get ftp statistics.
       */
      FtpStatistics getFtpStatistics();
      
      /**
       * Get Ftplet.
       */
      Ftplet getFtplet(String name);
      
      /**
       * Get server address.
       */
      InetAddress getServerAddress();
          
      /**
       * Get server port.
       */ 
      int getServerPort();
  }
  
  
  
  1.1                  incubator-ftpserver/src/java/org/apache/ftpserver/ftplet/FtpException.java
  
  Index: FtpException.java
  ===================================================================
  // $Id: FtpException.java,v 1.1 2005/09/07 05:05:17 rana_b Exp $
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.ftpserver.ftplet;
  
  import java.io.PrintStream;
  import java.io.PrintWriter;
  
  /**
   * Ftplet exception class.
   * 
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public 
  class FtpException extends Exception {
  
      private static final long serialVersionUID = -1328383839915898987L;
      
      private Throwable m_throwable = null;
  
      /**
       * Default constructor.
       */
      public FtpException() {
          super();
      }
  
      /**
       * Constructs a <code>FtpException</code> object with a message.
       * 
       * @param msg a description of the exception 
       */
      public FtpException(String msg) {
          super(msg);
      }
  
      /**
       * Constructs a <code>FtpException</code> object with a 
       * <code>Throwable</code> cause.
       * 
       * @param th the original cause
       */
      public FtpException(Throwable th) {
          super(th.getMessage());
          m_throwable = th;
      }
  
      /**
       * Constructs a <code>BaseException</code> object with a 
       * <code>Throwable</code> cause.
       * 
       * @param th the original cause
       */
      public FtpException(String msg, Throwable th) {
          super(msg);
          m_throwable = th;
      }
      
      /**
       * Get the root cause.
       */
      public Throwable getRootCause() {
          return m_throwable;
      }
      
      /**
       * Print stack trace.
       */
      public void printStackTrace(PrintWriter pw) {
          if(m_throwable == null) {
              super.printStackTrace(pw);
          }
          else {
              m_throwable.printStackTrace(pw);
          }
      }
      
      /**
       * Print stack trace.
       */
      public void printStackTrace(PrintStream ps) {
          if(m_throwable == null) {
              super.printStackTrace(ps);
          }
          else {
              m_throwable.printStackTrace(ps);
          }
      }
      
      /**
       * Print stack trace.
       */
      public void printStackTrace() {
          if(m_throwable == null) {
              super.printStackTrace();
          }
          else {
              m_throwable.printStackTrace();
          }
      }
  }
  
  
  
  1.1                  incubator-ftpserver/src/java/org/apache/ftpserver/ftplet/Ftplet.java
  
  Index: Ftplet.java
  ===================================================================
  // $Id: Ftplet.java,v 1.1 2005/09/07 05:05:17 rana_b Exp $
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.ftpserver.ftplet;
  
  import java.io.IOException;
  
  /**
   * Defines methods that all ftplets must implement. 
   *
   * A servlet is a small Java program that runs within a FTP server. 
   * Ftplets receive and respond to requests from FTP clients.
   *
   * This interface defines methods to initialize a ftplet, to service requests, 
   * and to remove a ftplet from the server. These are known as life-cycle methods 
   * and are called in the following sequence: 
   *
   * <ol>
   *   <li>The ftplet is constructed.</li>
   *   <li>Then initialized with the init method.</li>
   *   <li>All the callback methods will be invoked.</li>
   *   <li>The ftplet is taken out of service, then destroyed with the destroy method.</li>
   *   <li>Then garbage collected and finalized.</li>
   * </ol>
   * 
   * All the callback methods return FtpletEnum. If it returns null FtpletEnum.RET_DEFAULT
   * will be assumed. If any ftplet callback method throws exception, that particular connection

   * will be disconnected. 
   * 
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public 
  interface Ftplet {
      
      /**
       * Called by the ftplet container to indicate to a ftplet that the ftplet 
       * is being placed into service. 
       * The ftplet container calls the init method exactly once after instantiating 
       * the ftplet. The init method must complete successfully before the ftplet can 
       * receive any requests.
       */
      void init(FtpConfig ftpConfig, Configuration config) throws FtpException;
      
      /**
       * Called by the servlet container to indicate to a ftplet that the ftplet is 
       * being taken out of service. This method is only called once all threads within 
       * the ftplet's service method have exited. After the ftplet container calls this 
       * method, callback methods will not be executed. If the ftplet initializarion 
       * method fails, this method will not be called. 
       */
      void destroy();
      
      /**
       * Client connect notification method.
       */
      FtpletEnum onConnect(FtpRequest request, FtpResponse response) throws FtpException,
IOException;
      
      /**
       * Client disconnect notification method. This is the last callback method.
       */
      FtpletEnum onDisconnect(FtpRequest request, FtpResponse response) throws FtpException,
IOException;
      
      /**
       * Client successful login notification method.
       */
      FtpletEnum onLogin(FtpRequest request, FtpResponse response) throws FtpException, IOException;
              
      /**
       * File delete request notification method.
       */
      FtpletEnum onDeleteStart(FtpRequest request, FtpResponse response) throws FtpException,
IOException;
      
      /**
       * File delete success notification method.
       */
      FtpletEnum onDeleteEnd(FtpRequest request, FtpResponse response) throws FtpException,
IOException;
      
      /**
       * File upload request notification method.
       */
      FtpletEnum onUploadStart(FtpRequest request, FtpResponse response) throws FtpException,
IOException;
  
      /**
       * File upload success notification method.
       */
      FtpletEnum onUploadEnd(FtpRequest request, FtpResponse response) throws FtpException,
IOException;
      
      /**
       * File download request notification method.
       */
      FtpletEnum onDownloadStart(FtpRequest request, FtpResponse response) throws FtpException,
IOException;
      
      /**
       * File download success notification method.
       */
      FtpletEnum onDownloadEnd(FtpRequest request, FtpResponse response) throws FtpException,
IOException;
      
      /**
       * Remove directory request notification method.
       */
      FtpletEnum onRmdirStart(FtpRequest request, FtpResponse response) throws FtpException,
IOException;
      
      /**
       * Directory removal success notification method.
       */
      FtpletEnum onRmdirEnd(FtpRequest request, FtpResponse response) throws FtpException,
IOException;
      
      /**
       * Directory creation request notification method.
       */
      FtpletEnum onMkdirStart(FtpRequest request, FtpResponse response) throws FtpException,
IOException;
      
      /**
       * Directory creation success notification method.
       */
      FtpletEnum onMkdirEnd(FtpRequest request, FtpResponse response) throws FtpException,
IOException;
              
      /**
       * File append request notification method.
       */
      FtpletEnum onAppendStart(FtpRequest request, FtpResponse response) throws FtpException,
IOException;
      
      /**
       * File append success notification method.
       */
      FtpletEnum onAppendEnd(FtpRequest request, FtpResponse response) throws FtpException,
IOException;
      
      /**
       * Unique file create request notification method.
       */
      FtpletEnum onUploadUniqueStart(FtpRequest request, FtpResponse response) throws FtpException,
IOException;
      
      /**
       * Unique file create success notification method.
       */
      FtpletEnum onUploadUniqueEnd(FtpRequest request, FtpResponse response) throws FtpException,
IOException;
      
      /**
       * Rename start notification method.
       */
      FtpletEnum onRenameStart(FtpRequest request, FtpResponse response) throws FtpException,
IOException;
      
      /**
       * Rename end notification method.
       */
      FtpletEnum onRenameEnd(FtpRequest request, FtpResponse response) throws FtpException,
IOException;
      
      /**
       * SITE command notification method.
       */
      FtpletEnum onSite(FtpRequest request, FtpResponse response) throws FtpException, IOException;
  }
  
  
  
  1.1                  incubator-ftpserver/src/java/org/apache/ftpserver/ftplet/FtpletEnum.java
  
  Index: FtpletEnum.java
  ===================================================================
  // $Id: FtpletEnum.java,v 1.1 2005/09/07 05:05:17 rana_b Exp $
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.ftpserver.ftplet;
  
  
  /**
   * This class encapsulates the return values of the ftplet methods. 
   * 
   * RET_DEFAULT < RET_NO_FTPLET < RET_SKIP < RET_DISCONNECT
   * 
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public 
  final class FtpletEnum {
  
  
       /**
        * This return value indicates that the next ftplet method will 
        * be called. If no other ftplet is available, the ftpserver will
        * process the request.
        */
       public static final FtpletEnum RET_DEFAULT = new FtpletEnum(0);
  
  
       /**
        * This return value indicates that the other ftplet methods will
        * not be called but the ftpserver will continue processing this 
        * request.
        */
       public static final FtpletEnum RET_NO_FTPLET = new FtpletEnum(1); 
        
        
       /**
        * It indicates that the ftpserver will skip everything. No further 
        * processing (both ftplet and server) will be done for this request.
        */ 
       public static final FtpletEnum RET_SKIP = new FtpletEnum(2);
       
       
       /**
        * It indicates that the server will skip and disconnect the client.
        * No other request from the same client will be served.
        */
       public static final FtpletEnum RET_DISCONNECT = new FtpletEnum(3);
  
  
       private int m_type;
  
  
       /**
        * Private constructor - set the type
        */
       private FtpletEnum(int type) {
           m_type = type;
       }
  
       /**
        * Equality check
        */
       public boolean equals(Object obj) {
           if(obj instanceof Ftplet) {
               return m_type == ((FtpletEnum)obj).m_type;
           }
           return false;
       }
  
       /**
        * String representation
        */
       public String toString() {
           return String.valueOf(m_type);
       }
  
  }
  
  
  
  1.1                  incubator-ftpserver/src/java/org/apache/ftpserver/ftplet/FtpRequest.java
  
  Index: FtpRequest.java
  ===================================================================
  // $Id: FtpRequest.java,v 1.1 2005/09/07 05:05:17 rana_b Exp $
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.ftpserver.ftplet;
  
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  import java.net.InetAddress;
  import java.util.Date;
  
  /**
   * Defines an object to provide client request information to a ftplet.
   * Ftplet methods will always get the same instance of Ftplet request.
   * So the attributes set by <code>setAttribute()</code> will be always 
   * available later unless that attribute is removed.
   * 
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public 
  interface FtpRequest {
  
      /**
       * Get the client request string.
       */
      String getRequestLine();
      
      /**
       * Returns the ftp request command.
       */
      String getCommand();
  
      /**
       * Get the ftp request argument.
       */
      String getArgument();
      
      /**
       * Returns the IP address of the client that sent the request.
       */
      InetAddress getRemoteAddress();
      
      /**
       * Get connection time.
       */
      Date getConnectionTime();
      
      /**
       * Get the login time.
       */
      Date getLoginTime();
      
      /**
       * Get last access time.
       */
      Date getLastAccessTime();
      
      /**
       * Get user object.
       */
      User getUser();
      
      /**
       * Get the requested language.
       */
      String getLanguage();
      
      /**
       * Is the user logged in?
       */
      boolean isLoggedIn();
  
      /**
       * Get user file system view.
       */
      FileSystemView getFileSystemView();
      
      /**
       * Get file upload/download offset.
       */
      long getFileOffset();
      
      /**
       * Get rename from file object.
       */
      FileObject getRenameFrom();
      
      /**
       * Get data input stream.
       */
      InputStream getDataInputStream() throws IOException;
      
      /**
       * Get data output stream.
       */
      OutputStream getDataOutputStream() throws IOException;
      
      /**
       * Returns the value of the named attribute as an Object, 
       * or null if no attribute of the given name exists.
       */
      Object getAttribute(String name);
      
      /**
       * Stores an attribute in this request. It will be available 
       * until it was removed or when the connection ends. 
       */
      void setAttribute(String name, Object value);
      
      /**
       * Removes an attribute from this request.
       */
      void removeAttribute(String name);
      
      /**
       * Clear all attributes
       */
      void clear();
  }
  
  
  
  1.1                  incubator-ftpserver/src/java/org/apache/ftpserver/ftplet/FtpResponse.java
  
  Index: FtpResponse.java
  ===================================================================
  // $Id: FtpResponse.java,v 1.1 2005/09/07 05:05:17 rana_b Exp $
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.ftpserver.ftplet;
  
  import java.io.IOException;
  
  /**
   * Ftp response interface. Ftplets can use this to send custom messges to client. 
   * 
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public 
  interface FtpResponse {
  
      /**
       * Send the ftp server reply code to client.
       */
      void write(int code) throws IOException;
      
      
      /**
       * Send the ftp code and message to client
       */
      void write(int code, String msg) throws IOException;
  }
  
  
  
  1.1                  incubator-ftpserver/src/java/org/apache/ftpserver/ftplet/FtpStatistics.java
  
  Index: FtpStatistics.java
  ===================================================================
  // $Id: FtpStatistics.java,v 1.1 2005/09/07 05:05:17 rana_b Exp $
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.ftpserver.ftplet;
  
  import java.util.Date;
  
  /**
   * This interface holds all the ftp server statistical information. 
   * 
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public 
  interface FtpStatistics {
  
      /**
       * Get the server start time.
       */
      Date getStartTime();
      
      /**
       * Get number of files uploaded.
       */
      int getTotalUploadNumber();
      
      /**
       * Get number of files downloaded.
       */
      int getTotalDownloadNumber();
      
      /**
       * Get number of files deleted.
       */
      int getTotalDeleteNumber();
      
      /**
       * Get total number of bytes uploaded.
       */
      long getTotalUploadSize();
      
      /**
       * Get total number of bytes downloaded.
       */
      long getTotalDownloadSize();
      
      /**
       * Get total directory created.
       */
      int getTotalDirectoryCreated();
      
      /**
       * Get total directory removed.
       */
      int getTotalDirectoryRemoved();
      
      /**
       * Get total number of connections
       */
      int getTotalConnectionNumber();
      
      /**
       * Get current number of connections.
       */
      int getCurrentConnectionNumber();
      
      /**
       * Get total login number.
       */
      int getTotalLoginNumber();
      
      /**
       * Get current login number
       */
      int getCurrentLoginNumber();
      
      /**
       * Get total anonymous login number.
       */
      int getTotalAnonymousLoginNumber();
      
      /**
       * Get current anonymous login number.
       */
      int getCurrentAnonymousLoginNumber();
  }
  
  
  
  1.1                  incubator-ftpserver/src/java/org/apache/ftpserver/ftplet/Logger.java
  
  Index: Logger.java
  ===================================================================
  // $Id: Logger.java,v 1.1 2005/09/07 05:05:17 rana_b Exp $
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.ftpserver.ftplet;
  
  /**
   * Basic logger interface.
   * 
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public 
  interface Logger extends Component {
  
      /**
       * Write debug mesaage.
       */
      void debug(String msg);    
      
      /**
       * Write debug throwable.
       */
      void debug(String msg, Throwable th);
  
      /**
       * Write information mesaage.
       */
      void info(String msg);
      
      /**
       * Write information throwable.
       */
      void info(String msg, Throwable th);
      
      /**
       * Write warning mesaage.
       */
      void warn(String msg);
      
      /**
       * Write warning throwable.
       */
      void warn(String msg, Throwable th);
      
      /**
       * Write errpor mesaage.
       */
      void error(String msg);
      
      /**
       * Write warning throwable.
       */
      void error(String msg, Throwable th);
  }
  
  
  
  1.1                  incubator-ftpserver/src/java/org/apache/ftpserver/ftplet/User.java
  
  Index: User.java
  ===================================================================
  // $Id: User.java,v 1.1 2005/09/07 05:05:17 rana_b Exp $
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.ftpserver.ftplet;
  
  /**
   * Basic user interface.
   * 
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public 
  interface User {
      
      /**
       * Get the user name.
       */
      String getName();
      
      /**
       * Get password.
       */
      String getPassword();
      
      /**
       * Get the maximum idle time in seconds. Zero or less idle time means no limit.
       */
      int getMaxIdleTime();
      
      /**
       * Get the user enable status.
       */
      boolean getEnabled();
      
      /**
       * Get maximum user upload rate in bytes/sec. Zero or less means no limit.
       */
      int getMaxUploadRate();
      
      /**
       * Get maximum user download rate in bytes/sec. Zero or less means no limit.
       */
      int getMaxDownloadRate();
      
      /**
       * get user home directory
       */
      String getHomeDirectory();
      
      /**
       * Get write permission
       */
      boolean getWritePermission();
  }
  
  
  
  1.1                  incubator-ftpserver/src/java/org/apache/ftpserver/ftplet/UserManager.java
  
  Index: UserManager.java
  ===================================================================
  // $Id: UserManager.java,v 1.1 2005/09/07 05:05:17 rana_b Exp $
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.ftpserver.ftplet;
  
  import java.util.Collection;
  
  /**
   * User manager interface.
   * 
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public 
  interface UserManager extends Component {
  
      /**
       * Get user by name.
       */
      User getUserByName(String login) throws FtpException;
      
      /**
       * Get all user names in the system.
       */
      Collection getAllUserNames() throws FtpException;
      
      /**
       * Delete the user from the system.
       */
      void delete(String login) throws FtpException;
      
      /**
       * Save user. If a new user, create it else update the existing user.
       */
      void save(User user) throws FtpException;
      
      /**
       * User existance check.
       */
      boolean doesExist(String login) throws FtpException;
      
      /**
       * Authenticate user
       */
      boolean authenticate(String login, String password) throws FtpException;
      
      /**
       * Get admin user name
       */
      String getAdminName() throws FtpException;
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@incubator.apache.org
For additional commands, e-mail: cvs-help@incubator.apache.org


Mime
View raw message