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/message FtpStatus.properties MessageResourceImpl.java
Date Wed, 07 Sep 2005 05:02:58 GMT
rana_b      2005/09/06 22:02:58

  Added:       src/java/org/apache/ftpserver/message FtpStatus.properties
                        MessageResourceImpl.java
  Log:
  Refactored - removed avalon entirely
  
  Revision  Changes    Path
  1.1                  incubator-ftpserver/src/java/org/apache/ftpserver/message/FtpStatus.properties
  
  Index: FtpStatus.properties
  ===================================================================
  # Ftp server status properties
  
  #110=Restart marker reply.
  #120=Service ready in {output.msg} minutes.
  #125=Data connection already open; transfer starting.
  #150=File status okay; about to open data connection.
  #200=Command {request.cmd} okay.
  #211=System status, or system help reply.
  #212=Directory status.
  #213=File status.
  #220=Service ready for new user.
  #221=Service closing control connection.
  #225=Can't open data connection.
  #226=Closing data connection.
  #230=User logged in, proceed.
  #250=Requested file action okay, completed.
  #332=Need account for login.
  #350=Requested file action pending further information.
  #425=Can't open data connection.
  #450=Requested file action not taken.
  #500=Syntax error, command {request.cmd} unrecognized.
  #501=Syntax error in parameters or arguments.
  #502=Command not implemented.
  #504=Command {request.cmd} not implemented for that parameter.
  #530=Access denied.
  #550=Requested action not taken.
  #552=Requested file action aborted.
  #553=Requested action not taken.
  
  550=Requested action not taken.
  
  502.not.implemented=Command not implemented.
  530.permission.denied=Access denied.
  530.ip.restricted=No server access from the IP {client.ip}.
  530.connection.limit=Maximum server connection has been reached.
  220.connection.welcome=Service ready for new user.
  
  226.ABOR=ABOR command successful.
  
  501.APPE=Syntax error in parameters or arguments.
  550.APPE.file.invalid={output.msg}: Not a plain file.
  550.APPE.no.permission={output.msg}: Permission denied.
  150.APPE=File status okay; about to open data connection.
  425.APPE=Can't open data connection.
  426.APPE=Data connection error.
  551.APPE={output.msg}: Error on output file.
  226.APPE=Transfer complete.
  
  501.AUTH=Syntax error in parameters or arguments.
  234.AUTH.SSL=Command AUTH okay; starting SSL connection.
  502.AUTH=Command not implemented.
  431.AUTH=Service is unavailable.
  
  250.CDUP=Directory changed to {output.msg}.
  550.CDUP=No such directory.
  
  250.CWD=Directory changed to {output.msg}
  550.CWD=No such directory.
  
  501.DELE=Syntax error in parameters or arguments.
  550.DELE.file.invalid=Not a valid file \"{output.msg}\".
  450.DELE.no.permission=No permission to delete {output.msg}.
  250.DELE=Requested file action okay, deleted {output.msg}.
  450.DELE=Can't delete file {output.msg}.
  
  501.EPRT=Syntax error in parameters or arguments.
  510.EPRT=Syntax error in parameters.
  510.EPRT.disabled=EPRT is disabled.
  510.EPRT.IP.mismatch=EPRT IP is not same as {client.ip}.
  553.EPRT.host.unknown=Host unknown.
  552.EPRT.number.invalid=Not a valid port number.
  200.EPRT=Command EPRT okay.
  
  425.EPSV=Can't open passive connection.
  229.EPSV=Entering Passive Mode ({output.msg})
  
  211.FEAT=Extensions supported\nAUTH SSL\nMODE Z\nUTF8\nEnd
  
  214=The following commands are implemented.\nABOR  APPE  CDUP  CWD   DELE  HELP  LIST  MDTM\nMKD
  MODE  NLST  NOOP  PASS  PASV  PORT  PWD\nQUIT  REST  RETR  RMD   RNFR  RNTO  SITE  SIZE\nSTAT
 STOR  STOU  STRU  SYST  TYPE  USER\nEnd of help.
  214.ABOR=Syntax: ABOR
  214.APPE=Syntax: APPE <sp> <pathname>
  214.CDUP=Syntax: CDUP
  214.CWD=Syntax: CWD <sp> <pathname>
  214.DELE=Syntax: DELE <sp> <pathname>
  214.EPRT=Syntax: EPRT<space><d><net-prt><d><net-addr><d><tcp-port><d>
  214.HELP=Syntax: HELP [<sp> <string>]
  214.LIST=Syntax: LIST [<sp> <pathname>]
  214.MDTM=Syntax: MDTM <sp> <pathname>
  214.MKD=Syntax: MKD <sp> <pathname>
  214.MODE=Syntax: MODE <sp> <mode-code>
  214.NLST=Syntax: NLST [<sp> <pathname>]
  214.NOOP=Syntax: NOOP
  214.PASS=Syntax: PASS <sp> <password>
  214.PASV=Syntax: PASV
  214.PORT=Syntax: PORT <sp> <host-port>
  214.PWD=Syntax: PWD
  214.QUIT=Syntax: QUIT
  214.REST=Syntax: RETR <sp> <marker>
  214.RETR=Syntax: RETR <sp> <pathname>
  214.RMD=Syntax: RMD <sp> <pathname>
  214.RNFR=Syntax: RNFR <sp> <pathname>
  214.RNTO=Syntax: RNTO <sp> <pathname>
  214.SITE=Syntax: SITE <sp> <string>    
  214.STOR=Syntax: STOR <sp> <pathname>
  214.STOU=Syntax: STOU
  214.SYST=Syntax: SYST
  214.TYPE=Syntax: TYPE <sp> <type-code>
  214.USER=Syntax: USER <sp> <username>
  
  502.LANG=Command not implemented.
  
  150.LIST=File status okay; about to open data connection.
  425.LIST=Can't open data connection.
  426.LIST=Data connection error.
  551.LIST=File listing failed.
  501.LIST=Syntax error in parameters or arguments.
  226.LIST=Closing data connection.
  
  501.MDTM=Syntax error in parameters or arguments.
  213.MDTM={output.msg}
  550.MDTM=File {output.msg} unavailable.
  
  501.MKD=Syntax error in parameters or arguments.
  550.MKD.invalid.file={output.msg}\: not a valid file.
  550.MKD.exists={output.msg}\: already exists.
  550.MKD.no.permission=No permission to create {output.msg}.
  250.MKD=\"{output.msg}\" created.
  550.MKD=Can't create directory {output.msg}.
  
  501.MODE=Syntax error in parameters or arguments.
  200.MODE=Command MODE okay.
  504.MODE=Command MODE not implemented for the parameter {request.arg}.
  
  150.NLST=File status okay; about to open data connection.
  425.NLST=Can't open data connection.
  426.NLST=Data connection error.
  551.NLST=File listing failed.
  501.NLST=Syntax error in parameters or arguments.
  226.NLST=Closing data connection.
  
  200.NOOP=Command NOOP okay.
  
  501.PASS=Syntax error in parameters or arguments.
  503.PASS=Login with USER first.
  202.PASS=Already logged-in.
  421.PASS.anonymous.limit=Maximum anonymous login limit has been reached.
  421.PASS.login.limit=Maximum login limit has been reached.
  530.PASS=Authentication failed.
  230.PASS=User logged in, proceed.
  
  425.PASV=Can't open passive connection.
  227.PASV=Entering Passive Mode ({output.msg})
  
  200.PBSZ=Command PBSZ okay.
  
  501.PORT=Syntax error in parameters or arguments.
  510.PORT=Syntax error in parameters.
  510.PORT.disabled=PORT is disabled.
  510.PORT.IP.mismatch=PORT IP is not same as {client.ip}.
  553.PORT.host.unknown=Host unknown.
  552.PORT.number.invalid=Not a valid port number.
  200.PORT=Command PORT okay.
  
  501.PROT=Syntax error in parameters or arguments.
  200.PROT=Command PROT okay.
  504.PROT=Server does not understand the specified protection level.
  431.PROT=Security is disabled.
  
  257.PWD=\"{output.msg}\" is current directory.
  
  221.QUIT=Goodbye.
  
  501.REST=Syntax error in parameters or arguments.
  501.REST.number.invalid=Not a valid marker.
  501.REST.number.negetive=Marker can't be negetive.
  350.REST=Restarting at {request.arg}. Send STORE or RETRIEVE to initiate transfer.
  
  501.RETR=Syntax error in parameters or arguments.
  550.RETR.file.not.exist={output.msg}: No such file or directory.
  550.RETR.file.invalid={output.msg}: Not a plain file.
  550.RETR.no.permission={output.msg}: Permission denied.
  150.RETR=File status okay; about to open data connection.
  425.RETR=Can't open data connection.
  426.RETR=Data connection error.
  551.RETR={output.msg}: Error on input file.
  226.RETR=Transfer complete.
  
  501.RMD=Syntax error in parameters or arguments.
  550.RMD.no.permission=No permission to create {output.msg}.
  550.RMD.directory.invalid=Not a valid directory \"{output.msg}\".
  250.RMD=\"{output.msg}\" removed.
  550.RMD=Can't remove directory {output.msg}.
  
  501.RNFR=Syntax error in parameters or arguments.
  550.RNFR={output.msg}: File unavailable.
  350.RNFR=Requested file action pending further information.
  
  501.RNTO=Syntax error in parameters or arguments.
  503.RNTO=Can't find the file which has to be renamed.
  553.RNTO.no.permission=No permission to rename.
  553.RNTO.not.valid=Not a valid file name.
  553.RNTO.file.not.exist={output.msg}: No such file or directory.
  250.RNTO=Requested file action okay, file renamed.
  553.RNTO=Can't rename file.
  
  200.SITE=Command SITE okay. Use SITE HELP to get more information.
  502.SITE=Command SITE not implemented for {output.msg}.
  500.SITE=Execution failed.
  530.SITE=Access denied.
  200.SITE.HELP=\nDESCUSER \: display user information.\nHELP     \: display this message.\nSTAT
    \: show statistics.\nWHO      \: display all connected users.\nZONE     \: display timezone.\nEnd
of help.
  503.SITE.DESCUSER=Can't find the user name.
  501.SITE.DESCUSER.not.exist={output.msg} \: User not found. 
  
  501.SIZE=Syntax error in parameters or arguments.
  550.SIZE.file.not.exist={output.msg}: No such file or directory.
  550.SIZE.file.invalid={output.msg}: Not a plain file.
  213.SIZE={output.msg}
  
  211.STAT=Apache FTP Server\nConnected to {server.ip}\nConnected from {client.ip}\nLogged
in as {client.login}\nEnd of status.
  
  501.STOR=Syntax error in parameters or arguments.
  550.STOR.path.invalid={output.msg}: Invalid path.
  550.STOR.no.permission={output.msg}: Permission denied.
  150.STOR=File status okay; about to open data connection.
  425.STOR=Can't open data connection.
  426.STOR=Data connection error.
  551.STOR={output.msg}: Error on output file.
  226.STOR=Transfer complete.
  
  550.STOU=Unique file name error.
  550.STOU.no.permission=Permission denied.
  150.STOU=File status okay; about to open data connection.
  425.STOU=Can't open data connection.
  250.STOU={output.msg}\: Transfer started.
  426.STOU=Data connection error.
  551.STOU=Error on output file.
  226.STOU={output.msg}\: Transfer complete.
  
  501.STRU=Syntax error in parameters or arguments.
  200.STRU=Command STRU okay.
  504.STRU=Command STRU not implemented for the parameter {request.arg}.
  
  215.SYST=UNIX Type\: Apache FTP Server
  
  501.TYPE=Syntax error in parameters or arguments.
  200.TYPE=Command TYPE okay.
  504.TYPE=Command TYPE not implemented for the parameter {request.arg}.
  
  501.USER=Syntax error in parameters or arguments.
  230.USER=Already logged-in.
  530.USER.user.invalid=Invalid user name.
  530.USER.no.anonymous.support=Anonymous connection is not allowed.
  421.USER.anonymous.limit=Maximum anonymous login limit has been reached.
  421.USER.login.limit=Maximum login limit has been reached.
  331.USER.anonymous=Guest login okay, send your complete e-mail address as password.
  331.USER=User name okay, need password for {client.login.name}.
  
  
  
  1.1                  incubator-ftpserver/src/java/org/apache/ftpserver/message/MessageResourceImpl.java
  
  Index: MessageResourceImpl.java
  ===================================================================
  // $Id: MessageResourceImpl.java,v 1.1 2005/09/07 05:02:57 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.message;
  
  import org.apache.ftpserver.ftplet.Configuration;
  import org.apache.ftpserver.ftplet.FtpException;
  import org.apache.ftpserver.ftplet.Logger;
  import org.apache.ftpserver.interfaces.IMessageResource;
  import org.apache.ftpserver.util.IoUtils;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  import java.util.Enumeration;
  import java.util.Properties;
  
  /**
   * Class to get ftp server reply messages.
   * 
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public 
  class MessageResourceImpl implements IMessageResource {
  
      private final static String RESOURCE = "org/apache/ftpserver/message/FtpStatus.properties";
      
      private String m_customMessageFile;
      private Properties m_messages;
      private Properties m_customMessages;
      private Logger m_logger;
      
      
      /**
       * Set logger
       */
      public void setLogger(Logger logger) {
          m_logger = logger;
      }
      
      /**
       * Configure - load properties file.
       */
      public void configure(Configuration config) throws FtpException {
          
          // load default messages 
          InputStream in = null;
          try {
              in = getClass().getClassLoader().getResourceAsStream(RESOURCE);
              m_messages = new Properties();
              m_messages.load(in);
          }
          catch(IOException ex) {
              m_logger.error("MessageResourceImpl.configure()", ex);
              throw new FtpException("MessageResourceImpl.configure()", ex);
          }
          finally {
              IoUtils.close(in);
          }
          
          // load custom messages
          m_customMessageFile = config.getString("custom-message-file", "./res/messages.gen");
          in = null;
          try {
              m_customMessages = new Properties();
              File file = new File(m_customMessageFile);
              if(file.isFile()) {
                  in = new FileInputStream(m_customMessageFile);
                  m_customMessages.load(in);
              }
          }
          catch(IOException ex) {
              m_logger.error("MessageResourceImpl.configure()", ex);
              throw new FtpException("MessageResourceImpl.configure()", ex);
          }
          finally {
              IoUtils.close(in);
          }
      }
      
      /**
       * Get all the available languages.
       */
      public String[] getAvailableLanguages() {
          return null;
      }
      
      /**
       * Get the message.
       */
      public String getMessage(int code, String subId, String language) {
          String msg = null;
          String codeStr = String.valueOf(code);
          
          // first try to get property for code.subId
          if(subId != null) {
              String key = codeStr + '.' + subId;
              msg = m_customMessages.getProperty(key);
              if(msg == null) {
                  msg = m_messages.getProperty(key);
              }
          }
          
          // if not found get it for code
          if(msg == null) {
              msg = m_customMessages.getProperty(codeStr);
              if(msg == null) {
                  msg = m_messages.getProperty(codeStr);
              }
          }
          
          // not found return empty string
          if(msg == null) {
              msg = "";
          }
          return msg;
      }
      
      /**
       * Get all messages.
       */
      public Properties getMessages(String language) {
          Properties messages = new Properties(m_messages);
          messages.putAll(m_customMessages);
          return messages;
      }
      
      /**
       * Save properties in file.
       */
      public void save(Properties prop, String language) throws FtpException {
          if(prop == null) {
              return;
          }
          
          // get only the new or modified properties
          Properties customMessages = new Properties();
          Enumeration props = prop.propertyNames();
          while( props.hasMoreElements() ) {
              String key = (String)props.nextElement();
              String newVal = prop.getProperty(key);
              String val = m_messages.getProperty(key);
              if( (val == null) || (!val.equals(newVal)) ) {
                  customMessages.setProperty(key, newVal);
              }
          }
          
          // save the newly created properties
          OutputStream out = null;
          try {
              out = new FileOutputStream(m_customMessageFile);
              customMessages.store(out, "Custom Messages");
          }
          catch(IOException ex) {
              m_logger.error("MessageResourceImpl.save()", ex);
              throw new FtpException("MessageResourceImpl.save()", ex);
          }
          finally {
              IoUtils.close(out);
          }
          
          // assign the new custom properties
          m_customMessages = customMessages;
      }
      
      /**
       * Dispose component - clear properties.
       */
      public void dispose() {
          if(m_messages != null) {
              m_messages.clear();
              m_messages = null;
          }
          if(m_customMessages != null) {
              m_customMessages.clear();
              m_customMessages = null;
          }
      }
  }
  
  
  

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


Mime
View raw message