FtpCopy

Configuration file

sample_ftp_copy.xml (siehe auch ./conf/samples/FtpCopy_howto.txt)

Class name

com.ebd.hub.datawizard.util.FtpCopy

Description


This class collects mass data via FTP and stores it locally or on another FTP server. Alternatively, the files can be collected from a network drive or local directory (see notes for parameter channel of element account). Note: You can use system constants for the values of the following parameters in the configuration file: host, port, user, passwd, domain, channel, source_dir, pattern, destination_host, destination_port, destination_dir, destination_user, destination_passwd, destination_domain, destination_channel. Example: host="%MY_CONSTANT%"


Element "<account>"

Superordinate element. General settings for the copying. Attributes of the element:


Attribute

Description

host

The address of the FTP server. Delete this attribute, if the copying targets a network drive or local directory.

port

The port of the FTP server.

user

User of the FTP server.

passwd

Password of the FTP user.

domain

Domain of the FTP user.

ctrl_file

If the option is set, a directory is processed only if the specified control file exists. The control file is deleted on source side and not transferred. See example.

smb

Support for Samba directories. Use UNC notation (source_dir="\\myServer\share\copy). Parameters channel and destination_channel for SMB channels. See examples.

delete_files

If true, the copied files will be deleted.

source_dir

The source directory (mandatory). Even if the option delete_dir=true is set, this directory will not be deleted.

destination_dir

The target directory (mandatory). Even if the option delete_dir=true is set, this directory will not be deleted.

destination_user

Target user.

destination_passwd

Password of target user.

destination_domain

Domain of target user.

destination_host

Address of the target FTP server, if the copying destination is an FTP server.

destination_port

Port of the target FTP server, if the copying destination is an FTP server.

destination_sftp

true, if the server to which the data is sent is an SFTP server. Default: false.

destination_channel

ID of the destination channel from the Partner Administration. The user, password and the encryption are taken from the SSH or FTP channel from the Partner Administration (Remote ID).

mode

active or passive. FTP transfer mode.

pattern

The file pattern of the files to be copied.

force_uppercase

If true, the file names in the target directory will be written in uppercase.

force_lowercase

If true, the file names in the target directory will be written in lowercase.

extract_zip

If true, ZIP files will be extracted in the copying process.

verbose

Attention: Applies to FTP and SFTP. If true, debug messages are displayed in the console. If the Integration Server runs on a Windows system as a service, the messages will be forwarded to the file logs/wrapper.log. If the integration server runs in the background on a Unix/Linux system, the messages will be forwarded to the file hub.txt.

delete_dir

If true, the copied directory will be deleted as well. Only works if the directory is empty, especially with local directories.

delete_target_dir

If true, the target directory (if it exists) is attempted to be deleted before copying it. This is only possible if the directory is an FTP directory and does not apply to the root directory.

binary

If true, the binary mode is used for the transfer.

sftp

true, if the server from which the data is sent is an SFTP server. Default: false.

channel

ID of the channel from the Partner Administration. The user, password and the encryption are taken from the SSH or FTP channel from the Partner Administration (Local ID).

Attention: The parameter must not be used when fetching from a network drive or local directory.

Element "<exclude_dir>" or optionally "<include_dir>"

With <exclude_dir> you are able to define directories, which should be excluded from the transfer. Optionally, you can include directories with <include_dir>. Attributes of the two elements:


Attribute

Description

delete

true or false. Defines if the directory should be deleted.

Element "<exclude_file>"

With <exclude_file> you can define files, which should be excluded from the transfer. Attributes of the element:


Attribute

Description

delete

true or false. Defines if the file should be deleted.

Element "<replace>"

With this element, you can specify replacements in file names. This replacement does not work on directory names. Attributes of the element:


Attribute

Description

old_value

Characters to be replaced.

new_value

Replacement characters .

Example


sample_ftp_copy.xml
<config>
<!-- force_lowercase="true" forces the destination file name to be written in lower case; force_uppercase="true" for upper case -->
<account enter_empty_dir="false" host="localhost" port="21" user="ftp" passwd="ftp" delete_files="true" source_dir="/" destination_dir="/tmp/ftp" mode="passive" pattern="*" force_uppercase="false" force_lowercase="false" binary="true">
<!-- do not copy folders with the following names... -->
<exclude_dir>test</exclude_dir>
<exclude_dir>invoices</exclude_dir>
<!-- here are replacements instructions -->
<replace old_value=" " new_value="_"/>
<replace old_value="ä" new_value="ae"/>
<replace old_value="hello" new_value="world"/>
<!-- here is an exclude list of file pattern and wether to delete it or not -->
<exclude_file delete="true">~*</exclude_file> <!-- do not copy ~files and remove it locally -->
<exclude_file delete="false">*.tmp</exclude_file> <!-- do not copy *.tmp files and do not delete it locally -->
</account>
</config>

Output


The output is a CSV file with 8859_1 encoding. For each <account> element, a record will be created. Following is an example of the output format.


HOST;localhost;a_user;/
OK;/fäle1.txt;/tmp/ftp/faele1.txt
OK;/dir1/file2.txt;/tmp/ftp/dir1/file2.txt
ERR;/file3.txt;some error messages
OK;/file_4.txt;/tmp/ftp/file_4.txt


Each record starts with a HOST line, which includes the host name, username and the source directory. This line is followed by n lines, starting with OK or ERR, depending on success or failure of the transfer and followed by the file name. The OK line also includes the source file name and the destination file name. The ERR line includes the file name and the error message.