The change would allow a programmer [user] to add site-specific [SITE] commands as mentioned in RFC 959.
The attached example provides a CHMOD command, ie., SITE CHMOD. The code is very generic and can be used or adapted to support almost any local OS command. A user can for example, add exotic commands such as DUAL for dual hashing a file with both MD5 and SHA1 [or whatever algorithms they chose]. Note: If any one is interested in the DUAL command I will post the code.
The user-SITE "structure" follows the existing ftplet as far as configuration.
Here is a snippet from a properties configuration: ##------------------------------------------------------------------------------ ## All SITE commands ##------------------------------------------------------------------------------ #config.sitecmds=s1,s2 config.sitecmds=s1 ##------------------------------------------------------------------------------ ## Site command s1 configuration, CHMOD a file ##------------------------------------------------------------------------------ config.site.s1.class=org.apache.ftptest.command.SITE_CHMOD config.site.s1.cmdname=CHMOD ##------------------------------------------------------------------------------ ## Site command s2 configuration, DUAL Hash a file, MD5 and SHA-1 ##------------------------------------------------------------------------------ #config.site.s2.class=org.apache.ftptest.command.SITE_DUAL #config.site.s2.cmdname=DUALUsers can call the command using what-ever name or naming style they like. The 'cmdname=' just maps the user-supplied name to the command class. The example SITE CHMOD could be SITE CHM or any other user-name.
The user must define a command class, this class uses the same structure as all of the existing command classes. The class name must start with the key characters 'SITE_' followed by some user-descriptive name. In the example above, the chmod command class was called SITE_CHMOD. In addition the user must extent or modify their FileOject code to allow the FileManager to implement the command. The details are provided in the pdf and the example code, very easy to do.
The implementation of the SITE change is also easy, only three core classes are altered. All of them have additional methods added, and one implements the CommandFactory.
Keep in mind there are many ways to achieve this, the code supplied here is just one approach.
Comments? Suggestions? Thank you, Andy Thomson ---Attached is a compressed tar file that contains the proposal details in pdf format, patches for the core code, the actual files to the core code, and a user example.
site_cmd.tar.bz2
Description: application/bzip
