The following advanced configuration properties are provided:

Character Encoding

Applies to...
  • Operational Mode: Input, Output, Out->In.
  • Connection Type: FTP, FTPS, SFTP.

Character Encoding sets the character encoding for the control channel. If you are using file names or directory names that are outside the standard ASCII character set, you may need to set this to make sure that the remote server can correctly interpret the data you are sending. In this case, you should also ensure the encoding you are using is accepted by the remote server and/or the OS it is running on.

It defaults to ASCII.

Active Mode IP Address

Applies to...
  • Operational Mode: Input, Output, Out->In.
  • Connection Type: FTP, FTPS.
  • Connection Mode: Active.

Active Mode IP Address sets the local IP address to send to the remote server when using FTP in active mode. This should be a valid IPv4 address. This can be left blank if not required, in which case the communication point would use a sensible default.

Active Mode Port Range

Applies to...
  • Operational Mode: Input, Output, Out->In.
  • Connection Type: FTP, FTPS.
  • Connection Mode: Active.

Active Mode Port Range sets the range of ports that will be used when using FTP in active mode. This can be left blank if not required, in which case the communication point will use a sensible default. The port range should be specified as two valid port numbers, separated by a dash, for example 23456-34567.

FTP Options

Applies to...
  • Operational Mode: Input, Output, Out->In.
  • Connection Type: FTP, FTPS.

The FTP options are a set of optional settings that may be required for compatibility with certain servers.

Property Option Description
Automatically substitute the remote host IP in passive mode When operating in FTP passive mode, the configured hostname is always used instead of any value the remote server returns. This option can be used to work around issues with connectivity or issues with remote servers that return incorrect IP addresses.
Enable Mode Z compression

Then compression is enabled on all transfers with the remote server.

Force unique names The remote server is instructed to generate unique names for all files that you transfer to it (this option is only applicable to Output mode). In other words, the server uses the STOU command instead of the STOR command.

None enabled by default.

Rhapsody already has extensive checking for unique filenames, and therefore to utilize this property fully you may want to set Duplicate Filename Behaviour to Don't check for duplicates.

FTPS Options

Applies to...
  • Operational Mode: Input, Output, Out->In.
  • Connection Type: FTPS.

FTPS Options provides options to work around some known bugs in various FTPS servers. A number of FTPS servers do not correctly close SSL channels when closing either the data or control sockets. This can manifest itself as either the client communication point freezing until a timeout occurs or raising connection errors when attempting to close data or control sockets. If this occurs then the appropriate options can then be enabled. Note that these options should not be enabled unless required to fix a specific FTPS server issue otherwise as they instruct the FTP communication point to use non-standard SSL closure mechanisms.

Property Option Description
Start with clear data channels
Private data channels are used once the encrypted connection has been negotiated. The communication point always enables encryption on the control channel immediately after establishing the SSL connection and prior to the login. If this option is enabled, then the commands to enable encryption on data channels are not sent until after the login has been completed. If this option is disabled then the data channel encryption commands are sent immediately. The data channels are never used unencrypted regardless of whether this option is enabled or not.
Disable control SSL closure

The communication point forces the SSL closure on the control channel to be done in a non-standard way. This is usually only required if the client or server freezes when the connection is closed.

Disable control wait on close The communication point stops the client waiting for SSL closure acknowledgment on the control channel. This is usually only required if the client freezes when the connection is closed. This is not required to be set if Disable control SSL closure is set.
Disable data SSL closure The communication point forces the SSL closure on the data channel to be done in a non-standard way. This is usually only required if the client or server freeze when data transfer has completed.
Disable data wait on close The communication point stops the client waiting for SSL closure acknowledgment on the data channel. This is usually only required if the client freezes after data transfer has completed. This is not required to be set if Disable data SSL closure is set.
Disable SSL session resumption A new SSL session is established for each data transfer.

† Default option.

Input Locales

Applies to...
  • Operational Mode: Input, Out->In.
  • Connection Type: FTP, FTPS.

Input Locales holds the ordered list of Java locales to use when required for parsing input directory listings. If set, the specified locales are used in the ordered specified until one is successful. If not, this is equivalent to setting English first followed by the Rhapsody locale. Refer to JDK 8 and JRE 8 Supported Locales for details.

The extended directory listings requested by the FTP communication point normally include a last modified date in the listing. While this date is not actually used by the communication point, the directory listing parsers still need to be able to parse these dates correctly. Most date formats are locale-dependent (for example 04/05/2013 could be interpreted as 5 April 2013 or 4 May 2013) and sometimes even included month names in the default language of the FTP server. As there is no FTP command to ask an FTP server what locale it is using, this needs to be configured on the communication point. By default the FTP communication point will try English first, followed by the Rhapsody system locale. This is likely to work correctly in many cases, however it can be configured using the Input Locales configuration property on the communication point. This configuration property is set as a list of strings representing Java locales. If it is set, then each specified locale is attempted in the order that they are configured until one of them is successful.

Directory Listing Parser

Applies to...
  • Operational Mode: Input, Out->In.
  • Connection Type: FTP, FTPS.

Directory Listing Parser selects a directory listing parser to parse directory listings returned from the FTP server.

An FTP client retrieves the contents of a directory from an FTP server using either the LIST or NLIST commands. These commands return a formatted directory listing, but the format of this listing is entirely determined by the FTP server in use. As a result, the FTP client needs a mechanism to parse these returned values in order to interpret them, as it expects a list of files and sub-directories.

The (S)FTP communication point has a number of directory listing parsers built in corresponding to commonly used formats. The following list refers to the directory listing format and not necessarily the operating system that the FTP server is running on. For example, FileZilla Server returns Unix style directory listings even when running on Windows.

Property Option Description
Auto Detect Selects the auto-detect directory listing parser. This parser is suitable for most scenarios. It works by sending the SYSTEM command to the FTP server and then using the result of that command to pick which parser should be attempted first. If the first attempt fails, then all the other parsers are tried until one of them is successful. Therefore, it is only necessary to select a specific directory parser if another default parsers being attempted first incorrectly parses the directory listing.
Unix

Selects the UNIX directory listing parser.

Windows Selects the Windows directory listing parser.
VMS
Selects the VMS directory listing parser.
NetWare Selects the NetWare directory listing parser.
MVS Selects the MVS directory listing parser.

OS/400

Selects the OS/400 directory listing parser.
Custom JavaScript Parser

Selects the Custom JavaScript Parser directory listing parser.

† Default option.

If a specific directory listing parser is selected:

  • The selected parser is the only parser that will be used for directory listings – the other available parsers are completely ignored.
  • It is very important to test the configuration to verify that it is working correctly as an incorrect parser is likely to prevent the communication point from retrieving any files from the FTP server.

JavaScript Directory Parser

Applies to...
  • Operational Mode: Input, Out->In.
  • Connection Type: FTP, FTPS.
  • Parsing Directory Listings: Custom JavaScript Parser.

JavaScript Directory Parser is the custom JavaScript used to parse directory listings returned from the FTP server.

If the default directory listing parsers are not sufficient for particular FTP server purposes, then it is possible to write a custom directory listing parser using JavaScript. To enable the custom directory listing parser, the Parsing Directory Listings configuration property should be set to Custom JavaScript Parser. The JavaScript parser can then be configured in the JavaScript Directory Parser configuration property.

The configured JavaScript is executed once for each line returned by the FTP server in its directory listing. It is completely up to the custom JavaScript parser as to how it interprets this line and whether it recognizes it as a file, sub-directory, or symbolic link. Compilation errors in the script prevent the communication point being successfully configured, and any runtime errors are treated as a connection error within the communication point.

JavaScript Variables

The following JavaScript variables are placed into the scope of the custom JavaScript directory parser:

Name
Type
Description
directoryPath String The full path of the directory that is being listed, as returned by the FTP server in response to the PWD command.
log Logger The communication point logger. This is the same logger object as is available in the JavaScript filter within Rhapsody.
contents DirectoryContents A custom object that is used to add and modify the objects that have been parsed for this directory. See below for a description of the properties and methods available on this object.
line String The raw line of the directory listing that needs to be parsed by the script.

DirectoryContents Object

The contents JavaScript variable is a DirectoryContents object as described in the following table. The same instance of the DirectoryContents object is used for each line when parsing a directory listing.

Name
Type
Description
length Number The number of files that have been added to this DirectoryContents object. It will start at zero and increase as files are added. This is a read-only property.

[index]

File

A read-only indexer property that allows previously added files to be retrieved from the DirectoryContents object. It is accessed in the same way as an array (for example, var file = contents[0];). Referencing a valid index returns the appropriate file object that then can be examined and modified within the script. An error is raised if an invalid index is used.
add(File) File The add(File) method is used to add a new file to the directory contents and should be based on information extracted from the line variable. An error is raised if a File object is created without a name, however, all other attributes are optional. The return value is the inserted File object which is a different object to that provided as a parameter to the method. It is the same object that would be returned if the appropriate indexer was used to retrieve the newly added object.

File Object

The File object is a simple JavaScript hash with the properties listed in the following table. It is expected that these are created inline within the JavaScript method and all available attributes are provided at construction time.

Name
Type
Description
name String The name of the file, sub-directory, or symbolic link within the current directory. This name must not include either the forward or backslash characters. It is mandatory to provide a non-empty name for all added files. This is a read/write property.
isDirectory Boolean True if this file represents another directory or false if it represents a file. It defaults to false if not set. This is a read/write property.
isSymLink Boolean

True if this file represents a symbolic link or false if it is a real file or directory. This is a read-only property - a symbolic link is set using the symLinkTarget property instead.

symLinkTarget String This is set to the target of the symbolic link or null/empty/undefined if it is not a symbolic link. It defaults to null if not set. There is no need to set the isDirectory property (but there is no harm in doing so) as the communication point will subsequently check to see if it is a directory or not if it is configured to follow symbolic links.
size Long The size of the file in bytes. It defaults to 0 if not set. This is a read/write property.

Raising Connection Errors

Connection errors are raised by throwing an exception within the script. Normally this is done by throwing a string describing the problem, for example:

throw 'Failed to parse line \"' + line + '\".';

There is no need to raise an error if a line should not correspond to a file - simply do not call the contents.add() method and no file object will be created for it.

Additional Information

Examples

Simple Windows Regular Expression Directory Parser

This sample parses a directory listing like the following:

07/06/2013  02:57 PM             2,113 .bash_history
05/09/2012  10:26 AM                 0 .cookies
20/08/2012  08:08 PM    <DIR>          .dia
23/08/2012  04:25 PM    <DIR>          .eclipse
30/05/2013  08:34 AM    <DIR>          .fop
03/06/2013  10:17 AM    <DIR>          .gimp-2.8
05/06/2013  10:24 AM               346 .gitconfig
07/06/2013  06:44 AM                62 .hgrc

The regular expression is configured so that if it matches, group 5 contains the file name and group 2 contains either the file size in bytes (with the thousands separators) or <DIR> if it is a directory.

var pattern = /(\d{2}\/\d{2}\/\d{4}\s+\d{2}:\d{2}\s*[AP]M)\s+(([\d,]+)|(<DIR>))\s+([^\s]+)/g;
var match = pattern.exec(line);
if (!match) {
  // Pattern didn't match - panic (connection error)
  throw 'Failed to parse line \"' + line + '\".';
} else {
  // Add the file
  contents.add({
    name: match[5],
    isDirectory: '<DIR>' == match[2]
  });
}

Simple Unix Fixed Width Directory Parser

This sample will parse a directory listing like the following:

drwxr-xr-x 1 ftp ftp              0 Jun 13  15:09 dir
-rw-r--r-- 1 ftp ftp            417 Mar 12  2013 request.txt
-rw-r--r-- 1 ftp ftp           2021 Mar 12  2013 request2.txt
-rw-r--r-- 1 ftp ftp           2307 Mar 12  2013 request3.txt

The first character contains the type and d is for a directory, and the file name starts at position 49 (zero-based):

if (line.length > 49) { 
  contents.add({
    name: line.substring(49),
    isDirectory: line[0] == 'd'
  });
}

This example does not handle symbolic links.

Output Directory Navigation Mode

Applies to...
  • Operational Mode: Output.
  • Connection Type: FTP, FTPS, SFTP.

Output Directory Navigation Mode specifies whether the communication point should use FTP commands to traverse the target directory path and create the target directory if required during the file upload, or perform a direct file upload to the target directory.

This property is disabled when the Duplicate Filename Behaviour property is set to Rename the file or Append date and time to filename.

Property Option Description
Upload after navigating to target

The communication point attempts to access the target directory by using the change directory command. If the target directory does not exist, it traverses the directory path during the file upload from the home directory to the target directory using the change directory command, and creates any directories along the directory path that do not exist using the make directory command.

Upload without navigating to target

The communication point performs a direct file upload to an existing target directory in environments where FTP commands are restricted. An error is raised if the target directory does not exist.

† Default option.

Input Directory Navigation Mode

Applies to...
  • Operational Mode: Input, Out->In.
  • Connection Type: FTP, FTPS, SFTP.

Input Directory Navigation Mode specifies whether the communication point should use FTP commands to access the target directory directly to download, or via home directory.

This property is not enforced when the Input Directory property is using an absolute path (in other words, when the input directory path begins with a forward slash).

Property Option Description
Change directly to target The communication point attempts to access the target directory by using the change directory command. 
Navigate home directory before target The communication point attempts to access the home directory by using the change directory command before accessing the target. 

† Default option.