EnsLib.FTP.InboundAdapter
class EnsLib.FTP.InboundAdapter extends EnsLib.File.InboundAdapter, EnsLib.FTP.Common
Adapter that receives files via the FTP protocol.Property Inventory
- %completeFileSpec
- %currentFileSpec
- %fileSpecHasMulti
- %multiFileSpec
- AppendTimestamp
- ArchivePath
- Charset
- CheckModifiedBeforeDelete
- ConfirmComplete
- DeleteFromServer
- FTPAscending
- FTPFileOrder
- FilePath
- FileSpec
- FileSpecDelimiter
- FilenameExpression
- IsDirExpression
- RenameFilename
- RetryableErrors
- SFTPAscending
- SFTPFileOrder
- ServerListStyle
- SizeExpression
- StayConnected
- TimestampExpression
- UseFileStream
Method Inventory
- TakeFromCol()
- delete()
- isDeleteStillNeeded()
- rename()
- retrieveFile()
- testDeleteAndRename()
- testPaths()
Parameters
parameter DOMAIN = Ensemble;
Use our own domain for localization
parameter SETTINGS = RegistryID:Basic:selector?context={Ens.ServiceRegistry.External.ContextSearch/Services?Protocols_1=FTP},FilePath:Basic,DeleteFromServer:Basic,CheckModifiedBeforeDelete:Basic,FileSpecDelimiter:Basic,UseFileStream,-WorkPath,ServerListStyle,-SFTPFileAccessMode,-SFTPSetFileAccessModeByClient,RetryableErrors,RenameFilename:Additional,SFTPFileOrder:SFTP,SFTPAscending:SFTP,MLSD:FTP,FTPFileOrder:FTP,FTPAscending:FTP;
Inherited description: List of properties can be set as settings in the configuration file
format is a comma separated list of property names
Properties
property %completeFileSpec as %String [ Transient ];
When multiple wildcards in the File Specification this contains the original
File Specification setting value
Property methods: %completeFileSpecDisplayToLogical(), %completeFileSpecGet(), %completeFileSpecIsValid(), %completeFileSpecLogicalToDisplay(), %completeFileSpecLogicalToOdbc(), %completeFileSpecNormalize(), %completeFileSpecSet()
property %currentFileSpec as %String [ Transient ];
When multiple wildcards in the File Specification this is the current file specification being used
Property methods: %currentFileSpecDisplayToLogical(), %currentFileSpecGet(), %currentFileSpecIsValid(), %currentFileSpecLogicalToDisplay(), %currentFileSpecLogicalToOdbc(), %currentFileSpecNormalize(), %currentFileSpecSet()
property %fileSpecHasMulti as %Boolean [ InitialExpression = 0 , Transient ];
Internal flag to indicate multiple wild cards in FileSpec
Property methods: %fileSpecHasMultiDisplayToLogical(), %fileSpecHasMultiGet(), %fileSpecHasMultiIsValid(), %fileSpecHasMultiLogicalToDisplay(), %fileSpecHasMultiNormalize(), %fileSpecHasMultiSet()
property %multiFileSpec as %String [ MultiDimensional ];
Property methods: %multiFileSpecDisplayToLogical(), %multiFileSpecGet(), %multiFileSpecIsValid(), %multiFileSpecLogicalToDisplay(), %multiFileSpecLogicalToOdbc(), %multiFileSpecNormalize(), %multiFileSpecSet()
property AppendTimestamp as %String [ InitialExpression = 1 ];
Append a timestamp to Archive filenames in order to prevent possible name collisions on repeated processing of the same filename.
If this value is empty or 0, no timestamp will be appended. If it is 1, then the standard timestamped filename specification template '%f_%Q' will be used.
Any other value will be used directly as a timestamped filename specification template.
Property methods: AppendTimestampDisplayToLogical(), AppendTimestampGet(), AppendTimestampIsValid(), AppendTimestampLogicalToDisplay(), AppendTimestampLogicalToOdbc(), AppendTimestampNormalize(), AppendTimestampSet()
property ArchivePath as %String (MAXLEN = 1000);
Path on the InterSystems IRIS server to save a copy of each file received from the FTP server. If not given, the local copy of the file will be stored in a temporary location and then deleted after processing is completed.
Note that the AppendTimestamp option must be used to avoid name collisions in the archive directory if the same filename will be retrieved repeatedly.
Property methods: ArchivePathDisplayToLogical(), ArchivePathGet(), ArchivePathIsValid(), ArchivePathLogicalToDisplay(), ArchivePathLogicalToOdbc(), ArchivePathNormalize()
property Charset as %String [ InitialExpression = "Binary" ];
Use the named Character encoding to translate characters from the file.
A * prepended to any of the charset names will cause a binary FTP transfer with the resulting data then translated using the specified encoding.
Note that Binary should be chosen for binary files and other cases when special characters such as line terminators must be preserved.
Other settings may be useful when transferring text documents via FTP. Choices include:
Binary - binary transfer
Ascii - Ascii mode FTP transfer but no character encoding translation
Native - the default character encoding of the installed locale of the InterSystems IRIS server
latin1 - the ISO Latin1 8-bit encoding
ISO-8859-1 - the ISO Latin1 8-bit encoding
UTF-8 - the Unicode 8-bit encoding
Unicode - the Unicode 16-bit encoding (Little-Endian)
UnicodeBig - the Unicode 16-bit encoding (Big-Endian)
@<ttable> - <ttable> means a raw InterSystems character translation table name. A prefix of '@' means to use the named table.
A * prepended to any of the charset names will cause a binary FTP transfer with the resulting data then translated using the specified encoding.
Note that Binary should be chosen for binary files and other cases when special characters such as line terminators must be preserved.
Other settings may be useful when transferring text documents via FTP. Choices include:
Binary - binary transfer
Ascii - Ascii mode FTP transfer but no character encoding translation
Native - the default character encoding of the installed locale of the InterSystems IRIS server
latin1 - the ISO Latin1 8-bit encoding
ISO-8859-1 - the ISO Latin1 8-bit encoding
UTF-8 - the Unicode 8-bit encoding
Unicode - the Unicode 16-bit encoding (Little-Endian)
UnicodeBig - the Unicode 16-bit encoding (Big-Endian)
@<ttable> - <ttable> means a raw InterSystems character translation table name. A prefix of '@' means to use the named table.
Property methods: CharsetDisplayToLogical(), CharsetGet(), CharsetIsValid(), CharsetLogicalToDisplay(), CharsetLogicalToOdbc(), CharsetNormalize()
property CheckModifiedBeforeDelete as %String (DISPLAYLIST = ",Never,Deferred,Always", VALUELIST = ",0,1,2") [ InitialExpression = 1 ];
When DeleteFromServer is enabled, this optional flag can be used to influence checking
whether a file has been modified since initial listing for download and then processing
This Switch is applied when both of the following conditions are true:
- Setting "DeleteFromServer" is enabled
- Setting ConfirmComplete is by "Size"
- No - Never Check. Just attempt to delete.
- Deferred - If the delete gets deferred then check the modified value (Default).
- Yes - Always check if modified before an attempt to delete.
Property methods: CheckModifiedBeforeDeleteDisplayToLogical(), CheckModifiedBeforeDeleteGet(), CheckModifiedBeforeDeleteIsValid(), CheckModifiedBeforeDeleteLogicalToDisplay(), CheckModifiedBeforeDeleteLogicalToOdbc(), CheckModifiedBeforeDeleteNormalize(), CheckModifiedBeforeDeleteSet()
property ConfirmComplete as %Integer (DISPLAYLIST = ",None,Size,Rename,Size & Rename", VALUELIST = ",0,1,2,3") [ InitialExpression = "1" ];
Confirm complete receipt of file if possible, in case it is not completely available on the server at the time downloading begins.
'None' offers the fastest performance for small files because no extra FTP directory listing needs to be retrieved for each file download attempt
'Size' means keep reading more data for a file until the file size reported by the server directory listing does not increase
This option is only reliable for Charset='binary' transfers (In text mode the file position used for downloading may get corrupted by the insertion or removal of Linefeed characters)
This option alone may not be sufficient if the FTP server or source application is sluggish. If the server reports the same
size for the file 2 times in a row, 2 seconds apart, then InterSystems IRIS will consider the download complete. Therefore the 'Size & Rename' setting is preferable if the server supports 'Rename'.
This option relies on correct results from the Adapter.SizeExpression string set in the OnInit() method of the Business Service. 'Rename' means keep trying to read more data for a file until the server allows us to rename it
This option will only work if the FTP server grants Rename privilege to InterSystems IRIS for the download directory, using the Credentials
configured on this adapter, and if the file permissions on the file itself are set so that the FTP server has privilege to rename it.
If not then the Rename attempt will always fail and the InterSystems IRIS download will never complete
This option is only reliable for Charset='binary' transfers (In text mode the file position used for downloading may get corrupted by the insertion or removal of Linefeed characters)
This option alone may not be sufficient if the FTP server or source application is sluggish. If the server reports the same
size for the file 2 times in a row, 2 seconds apart, then InterSystems IRIS will consider the download complete. Therefore the 'Size & Rename' setting is preferable if the server supports 'Rename'.
This option relies on correct results from the Adapter.SizeExpression string set in the OnInit() method of the Business Service. 'Rename' means keep trying to read more data for a file until the server allows us to rename it
This option will only work if the FTP server grants Rename privilege to InterSystems IRIS for the download directory, using the Credentials
configured on this adapter, and if the file permissions on the file itself are set so that the FTP server has privilege to rename it.
If not then the Rename attempt will always fail and the InterSystems IRIS download will never complete
Property methods: ConfirmCompleteDisplayToLogical(), ConfirmCompleteGet(), ConfirmCompleteIsValid(), ConfirmCompleteLogicalToDisplay(), ConfirmCompleteNormalize(), ConfirmCompleteSet()
property DeleteFromServer as %Boolean [ InitialExpression = 1 ];
Specifies whether or not to delete files from the FTP server after successful processing
If not deleted, the adapter will ignore files already processed until something else removes them from the FTP server.
If not deleted, the adapter will ignore files already processed until something else removes them from the FTP server.
Property methods: DeleteFromServerDisplayToLogical(), DeleteFromServerGet(), DeleteFromServerIsValid(), DeleteFromServerLogicalToDisplay(), DeleteFromServerNormalize(), DeleteFromServerSet()
property FTPAscending as %Boolean [ InitialExpression = 1 ];
This checkbox controls ascending vs descending order for FTP File Order specifically. It has no impact on SFTP File Order.
Leaving this box checked will cause files to be processed in ascending order. Unchecking it will cause files to be processed in descending order.
The FTP File Order setting must not be left blank in order to use this setting.
Leaving this box checked will cause files to be processed in ascending order. Unchecking it will cause files to be processed in descending order.
The FTP File Order setting must not be left blank in order to use this setting.
Property methods: FTPAscendingDisplayToLogical(), FTPAscendingGet(), FTPAscendingIsValid(), FTPAscendingLogicalToDisplay(), FTPAscendingNormalize(), FTPAscendingSet()
property FTPFileOrder as %String (DISPLAYLIST = ",Filename,File Size,Date Created,Last Modified", VALUELIST = ",NameCompare,SizeCompare,DateCreatedCompare,LastModifiedCompare");
FTP only - The order that files are processed if multiple are found at once. This is blank by default, which means that files will be processed in the order given to us by the FTP server,
which is typically the same as the Filename option. If left blank, it is unaffected by the FTP Ascending setting.
MLSD must be checked in order to use this setting.
MLSD must be checked in order to use this setting.
Property methods: FTPFileOrderDisplayToLogical(), FTPFileOrderGet(), FTPFileOrderIsValid(), FTPFileOrderLogicalToDisplay(), FTPFileOrderLogicalToOdbc(), FTPFileOrderNormalize(), FTPFileOrderSet()
property FilePath as %String (MAXLEN = 1000) [ Required ];
Directory on the FTP server in which to effect FTP operations.
This setting cannot be blank if SubdirectoryLevels is greater than 0.
This setting cannot be blank if SubdirectoryLevels is greater than 0.
Property methods: FilePathDisplayToLogical(), FilePathGet(), FilePathIsValid(), FilePathLogicalToDisplay(), FilePathLogicalToOdbc(), FilePathNormalize()
property FileSpec as %String (MAXLEN = 2000);
Filename or wildcard file specification for file(s) to retrieve from the FTP server. The format for the FileSpec depends on the protocol being used.
If FTP is selected in the Protocol dropdown setting:
It is necessary to enter the delimiter used in the File Specification Delimiter setting. Enter the FileSpec as one line. Maximum length is 2000 characters.
This setting must be given and not be blank.
If FTP is selected in the Protocol dropdown setting:
- The FileSpec format depends on if the MLSD setting - located in the FTP section - is checked or unchecked. It is left unchecked by default because not all FTP servers support the MLSD command.
- If MLSD is unchecked, the FileSpec will be interpreted as shell globs, meaning that the specific format that can be passed in depends on the operating system of the FTP server being used.
- See hereOpens in a new tab for more information on shell glob syntax.
- If MLSD is checked, regex will be used instead. Take note that MLSD can pick up hidden files if they match the FileSpec. This may cause unintended behavior, such as processing metadata files put into a directory by the operating system. Be sure to consider this when writing your FileSpec.
- The format depends on whether or not the Use Regex box in the SFTP settings section is checked.
- If it is, regex will be used to match filenames to determine which to process.
- If it is not, a more limited version of shell globs will be used. This format can recognize * as a wildcard for zero or more characters and ? as a wildcard for exactly one character, but it cannot recognize any more complex patterns.
It is necessary to enter the delimiter used in the File Specification Delimiter setting. Enter the FileSpec as one line. Maximum length is 2000 characters.
This setting must be given and not be blank.
Property methods: FileSpecDisplayToLogical(), FileSpecGet(), FileSpecIsValid(), FileSpecLogicalToDisplay(), FileSpecLogicalToOdbc(), FileSpecNormalize(), FileSpecSet()
property FileSpecDelimiter as %String;
If this is non empty then it will be used as the delimiter
to split the File Specification setting into multiple filename/wild card searches.
Property methods: FileSpecDelimiterDisplayToLogical(), FileSpecDelimiterGet(), FileSpecDelimiterIsValid(), FileSpecDelimiterLogicalToDisplay(), FileSpecDelimiterLogicalToOdbc(), FileSpecDelimiterNormalize(), FileSpecDelimiterSet()
property FilenameExpression as %String;
Expression for extracting the filename portion of a line of the FTP directory listing (%line)
Property methods: FilenameExpressionDisplayToLogical(), FilenameExpressionGet(), FilenameExpressionIsValid(), FilenameExpressionLogicalToDisplay(), FilenameExpressionLogicalToOdbc(), FilenameExpressionNormalize(), FilenameExpressionSet()
property IsDirExpression as %String;
Expression for extracting the is-a-directory flag from the FTP directory listing (%line)
Property methods: IsDirExpressionDisplayToLogical(), IsDirExpressionGet(), IsDirExpressionIsValid(), IsDirExpressionLogicalToDisplay(), IsDirExpressionLogicalToOdbc(), IsDirExpressionNormalize(), IsDirExpressionSet()
property RenameFilename as %String (MAXLEN = 1000);
Name of file to rename the document(s) to after processing. May include timestamp specifiers. The %f specifier if present will be
replaced with the name of the document's original source filename (stripped of characters illegal in target filenames).
See the method FormatDateTime() in Ens.Util.Time for documentation of timestamping options. In order to use this functionality, DeleteFromServer must be unchecked.
Property methods: RenameFilenameDisplayToLogical(), RenameFilenameGet(), RenameFilenameIsValid(), RenameFilenameLogicalToDisplay(), RenameFilenameLogicalToOdbc(), RenameFilenameNormalize(), RenameFilenameSet()
property RetryableErrors as %String;
This setting needs to be a comma-separated list of error types that should be ignored and should not cause a file to be skipped in the future.
Example:ErrGeneral,AnotherError
Example:
Property methods: RetryableErrorsDisplayToLogical(), RetryableErrorsGet(), RetryableErrorsIsValid(), RetryableErrorsLogicalToDisplay(), RetryableErrorsLogicalToOdbc(), RetryableErrorsNormalize(), RetryableErrorsSet()
property SFTPAscending as %Boolean [ InitialExpression = 1 ];
This checkbox controls ascending vs descending order for SFTP File Order specifically. It has no impact on FTP File Order.
Leaving this box checked will cause files to be processed in ascending order. Unchecking it will cause files to be processed in descending order.
The SFTP File Order setting must not be left blank in order to use this setting.
Leaving this box checked will cause files to be processed in ascending order. Unchecking it will cause files to be processed in descending order.
The SFTP File Order setting must not be left blank in order to use this setting.
Property methods: SFTPAscendingDisplayToLogical(), SFTPAscendingGet(), SFTPAscendingIsValid(), SFTPAscendingLogicalToDisplay(), SFTPAscendingNormalize(), SFTPAscendingSet()
property SFTPFileOrder as %String (DISPLAYLIST = ",Filename,File Size,Last Access,Last Modified", VALUELIST = ",FilenameCompare,SizeCompare,LastAccessCompare,LastModifiedCompare");
SFTP only - The order that files are processed if multiple are found at once. This is blank by default, which means that files will be processed in the order given to us by the SFTP server,
which is typically the same as the Filename option. If left blank, it is unaffected by the SFTP Ascending setting.
Property methods: SFTPFileOrderDisplayToLogical(), SFTPFileOrderGet(), SFTPFileOrderIsValid(), SFTPFileOrderLogicalToDisplay(), SFTPFileOrderLogicalToOdbc(), SFTPFileOrderNormalize(), SFTPFileOrderSet()
property ServerListStyle as %String (VALUELIST = ",Unix,MSDOS,AS/400,VMS,VMSAllVersions,NetWare") [ InitialExpression = "Unix" ];
Type of listing format returned by the FTP server.
'VMSAllVersions' means on VMS FTP servers, retrieve all versions listed, not only the latest VMS version of the file
This value is not pertinent if the protocol is SFTP.
This value is not pertinent if the protocol is SFTP.
Property methods: ServerListStyleDisplayToLogical(), ServerListStyleGet(), ServerListStyleIsValid(), ServerListStyleLogicalToDisplay(), ServerListStyleLogicalToOdbc(), ServerListStyleNormalize(), ServerListStyleSet()
property SizeExpression as %String;
Expression for extracting the file size from the FTP directory listing (%line); if present used for detecting download complete status
Property methods: SizeExpressionDisplayToLogical(), SizeExpressionGet(), SizeExpressionIsValid(), SizeExpressionLogicalToDisplay(), SizeExpressionLogicalToOdbc(), SizeExpressionNormalize(), SizeExpressionSet()
property StayConnected as %Numeric (MINVAL = -1, VALUELIST = ",0,-1") [ InitialExpression = -1 ];
If zero, disconnect from the remote FTP server between attempts to retrieve a directory listing. A value of -1 means never disconnect.
Property methods: StayConnectedDisplayToLogical(), StayConnectedGet(), StayConnectedIsValid(), StayConnectedLogicalToDisplay(), StayConnectedNormalize(), StayConnectedSet()
property TimestampExpression as %String;
Expression for extracting the timestamp portion of a line of the FTP directory listing (%line)
Property methods: TimestampExpressionDisplayToLogical(), TimestampExpressionGet(), TimestampExpressionIsValid(), TimestampExpressionLogicalToDisplay(), TimestampExpressionLogicalToOdbc(), TimestampExpressionNormalize(), TimestampExpressionSet()
property UseFileStream as %Boolean [ InitialExpression = 0 ];
Should the adapter construct a FileStream or a GlobalStream for data received?
Note that regardless of this setting a FileStream will be used if ArchivePath or ArchiveIO is set.
Note that regardless of this setting a FileStream will be used if ArchivePath or ArchiveIO is set.
Property methods: UseFileStreamDisplayToLogical(), UseFileStreamGet(), UseFileStreamIsValid(), UseFileStreamLogicalToDisplay(), UseFileStreamNormalize(), UseFileStreamSet()
Methods
classmethod TakeFromCol(s, col)
method isDeleteStillNeeded(pFilename As %String, pFileDir As %String, pModifiedTimeAtDownload As %String, checkLevel As %Integer, ByRef defer As %Boolean, retry=0) as %Boolean
Checks whether a file should still be deleted based on testing for changed modified datetime of file on FTP Server
Recursive check to cater for disconnect via Retry parameter
method retrieveFile(pFilename As %String, pStream As %AbstractStream, pFileDir As %String, pRetry As %Boolean) as %Status
Inherited Members
Inherited Properties
- %CredentialsObj
- %SFTPPassphraseCredentialsObj
- %WarnedLatest
- %logTransfers
- BusinessHost
- CallInterval
- CommandTranslateTable
- ConnectTimeout
- Credentials
- FTPPort
- FTPServer
- FileAccessTimeout
- KeepaliveInterval
- MLSD
- Protocol
- RegistryID
- SFTPAuthenticationMethods
- SFTPFileAccessMode
- SFTPInteractiveDTL
- SFTPKexAlgorithm
- SFTPLocalCharset
- SFTPPassphraseCredentials
- SFTPPrivateKeyFile
- SFTPPublicKeyFile
- SFTPRemoteCharset
- SFTPSetFileAccessModeByClient
- SSLCheckServerIdentity
- SSLConfig
- SSLUseSessionResumption
- SemaphoreSpec
- SubdirectoryLevels
- TranslateTable
- UsePASV
- UseRegex
- VMSLatestVersionOnly
- WorkPath
Inherited Methods
- %AddToSaveSet()
- %ClassIsLatestVersion()
- %ClassName()
- %ConstructClone()
- %DispatchClassMethod()
- %DispatchGetModified()
- %DispatchGetProperty()
- %DispatchMethod()
- %DispatchSetModified()
- %DispatchSetMultidimProperty()
- %DispatchSetProperty()
- %Extends()
- %GetParameter()
- %IsA()
- %IsModified()
- %New()
- %NormalizeObject()
- %ObjectModified()
- %OriginalNamespace()
- %PackageName()
- %RemoveFromSaveSet()
- %SerializeObject()
- %SetModified()
- %ValidateObject()
- AssignOneSetting()
- AuthenticateSSH()
- BetterParseMLSD()
- ClearAllAppData()
- ClearRuntimeAppData()
- ClearStaticAppData()
- Connect()
- ConnectSSH()
- CorrespondingSemaphoreExists()
- CreateTimestamp()
- DateCreatedCompare()
- DeepListClose()
- DeepListExecute()
- DeepListFetch()
- Disconnect()
- EnumerateSettingsClose()
- EnumerateSettingsExecute()
- EnumerateSettingsFetch()
- FileLikePattern()
- FileListClose()
- FileListExecute()
- FileListFetch()
- FileListSSHClose()
- FileListSSHExecute()
- FileListSSHFetch()
- FileStringParseMLSD()
- GenerateSemaphoreFilename()
- GetSettings()
- IsVMSLatestVersion()
- LastModifiedCompare()
- LinkFileStream()
- NameCompare()
- NormalizeDirectory()
- OnKeepalive()
- SFTPPassphraseCredentialsSet()
- SemaphoreFileExists()
- SizeCompare()
- System()
- TestConnection()
- TestConnectionSSH()
- fixPath()
- handleLIST()
- handleMLSD()