Purpose

Here is a Pluggable Java Component that allows to manage a FTP connection.

It is based on the Calvin Tai ftpbean.

simpleFTP bean


The Java source

     SimpleFTP.java



The implementation class of the Bean Area

     oracle.forms.fd.SimpleFTP


The methods you can set

  • managing connection


-- connect the FTP host --
Set_Custom_Property('BL.BEAN', 1, 'CONNECT', 'host_name,user[,password]' );

-- set the port number (if <> 21)
Set_Custom_Property('BL.BEAN', 1, 'SET_PORT', 'port_number' );

-- set the socket timeout number --
Set_Custom_Property('BL.BEAN', 1, 'SET_SOCKET_TIMEOUT', 'number' );

-- set the passive mode (default true) --
Set_Custom_Property('BL.BEAN', 1, 'SET_PASSIVE_MODE_TRANSFER, 'true|false');'

-- close the connection --
Set_Custom_Property('BL.BEAN', 1, 'CLOSE', '' );


  • managing content


-- change host directory --
Set_Custom_Property('BL.BEAN', 1, 'SET_DIRECTORY', 'remote_directory' );

-- get the host directory list --
Set_Custom_Property('BL.BEAN', 1, 'DIRECTORY_LIST', 'remote_directory' );

-- get a binary file --
Set_Custom_Property('BL.BEAN', 1, 'GET_BINARY_FILE', 'remote_filename,local_filename[,remote_file_size][,...]' );

You can provide multiple pairs of remote/local/file_size:
Set_Custom_Property('BL.BEAN',1,'GET_BINARY_FILE','file1.jpg,d:\file1.jpg,0,file2.jpg,d:\file2.jpg,0

If the remote_file_size is not provided, the progress bar will not display the exact values.

-- get an ascii file --
Set_Custom_Property('BL.BEAN', 1, 'GET_ACSII_FILE', 'remote_filename,local_filename[,remote_file_size]' );

If the remote_file_size is not provided, the progress bar will not display the exact values.

-- put a binary file --
Set_Custom_Property('BL.BEAN', 1, 'PUT_BINARY_FILE', 'locale_filename,remote_filename[,...]' );

You can provide multiple pairs of remote/local/file_size:

Set_Custom_Property('BL.BEAN',1,'PUT_BINARY_FILE','d:\file1.jpg,file1.jpg,d:\file2.jpg,file2.jpg


-- change to the parent host directory --
Set_Custom_Property('BL.BEAN', 1, 'TO_PARENT_DIR', '' );

-- create a host directory --
Set_Custom_Property('BL.BEAN', 1, 'MAKE_DIRECTORY', 'remote_directory' );

-- remove a host directory --
Set_Custom_Property('BL.BEAN', 1, 'REMOVE_DIRECTORY', 'remote_directory' );

-- delete a remote file --
Set_Custom_Property('BL.BEAN', 1, 'FILE_DELETE', 'remote_filename' );     

-- rename a remote file --
Set_Custom_Property('BL.BEAN', 1, 'FILE_RENAME', 'remote_filename' );

-- execute a command --
Set_Custom_Property('BL.BEAN', 1, 'EXECUTE', 'command' );


  • progress bar

To not just making the wrapper around the great Calvin work, I have added a nice progress bar you can display while transfering files.
The progress bar can be as simple as possible to include it in your existing design, but it can also have a titled border.
All the dimensions must be given in pixel.

-- display/hide the file transfer progress bar --
Set_Custom_Property('BL.BEAN', 1, 'SET_PROGRESS_BAR, 'true|false');'

-- set the progress bar location --
Set_Custom_Property('BL.BEAN', 1, 'SET_PROGRESS_BAR_LOCATION', 'X_POS,Y_POS' );

The coordinates are pixel based, and relative to the upper-left corner of the canvas.
If it is not provided or equals to -1,-1  the progress bar is centered to the canvas.

-- set the progress bar size --
Set_Custom_Property('BL.BEAN', 1, 'SET_PROGRESS_BAR_SIZE', 'width,height' );

If it is not provided, the default values are : 200,16

-- set the progress bar title --
Set_Custom_Property('BL.BEAN', 1, 'SET_PROGRESS_BAR_TITLE', 'title' );

If it is not provided, the progress bar is displayed without any titled border

-- switch on/off the Java console loggin --
Set_Custom_Property('BL.BEAN', 1, 'SET_LOG', 'true|false');


The methods you can get

-- get the message corresponding to the last FTP order --
var := Get_Custom_Property('BL.BEAN', 1, 'GET_MESSAGE');

Generally used after every FTP order to check the execution status.
Returns "OK" if the command succeeded, else returns the error message.

-- get the file list --
var := Get_Custom_Property('BL.BEAN', 1, 'GET_FILE_LIST');

Returns a delimited string of all records founds. The fields are separated by a CHR(9), and the records are separated by a CHR(10).

The record is composed by the following:
 - File type (DIR | FILE | LINK | OTHER)
 - File name
 - File size
 - File date

-- get the FTP reply string --
var := Get_Custom_Property('BL.BEAN', 1, 'GET_REPLY');

It is composed by the FTP code and the FTP message.

-- get the FTP port number --
var := Get_Custom_Property('BL.BEAN', 1, 'GET_PORT');

-- get the FTP socket timeout value --
var := Get_Custom_Property('BL.BEAN', 1, 'GET_SOCKET_TIMEOUT');

-- get the host server name --
var := Get_Custom_Property('BL.BEAN', 1, 'GET_SERVER_NAME');


The events raised by the bean

PROGRESS_MESSAGE
Is raised by the bean by the progress bar

PROGRESS_VALUE
is the current progress bar value

-- example of When-Custom-Item-Event trigger --
DECLARE
    eventName varchar2(30) := :system.custom_item_event;
    eventValues ParamList;
    eventValueType number;
    LC$Value  varchar2(1000);
BEGIN
   IF (eventName='PROGRESS_MESSAGE') THEN
      eventValues := get_parameter_list(:system.custom_item_event_parameters);
      get_parameter_attr(eventValues,'PROGRESS_VALUE',eventValueType, LC$Value);  
      -- display the current transfert percentage --
      :BL.PROGRESS := LC$Value || '%' ;
      Synchronize;
   END IF;
END;



The sample dialog


     . Download the simpleFTP.zip file
     . Unzip the file
     . copy the ftpbean.jar and simpleFTP.jar files in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file
     archive_jini=f90all_jinit.jar,ftpbean.jar,simpleFTP.jar
     archive=f90all.jar,ftpbean.jar,simpleFTP.jar

     . Open the simpleFTP.fmb module (Oracle Forms 9.0.2)
     . Compile all and run the module

In the sample dialog, when you are connected to the FTP server, double-clicking one line of the file content table-block will open and display the new folder if the file type is DIR, or download the underlying file on the c:/ folder if the file type is FILE.


The two JAR files have to be signed.
Those, shipped with the zip file are already signed.