Interface IFileListResultsHandler
Results handler for the file list retrieval operation.
Inherited Members
Namespace: OpenText.Fusion.AdapterSdk.Api
Assembly: OpenText.Fusion.AdapterSdk.Api.dll
Syntax
public interface IFileListResultsHandler : IFailureRegistration
Remarks
This results handler allows queueing of repository files discovered during scan. Usually just quick and cheap to obtain metadata would be queued for a file and no content. The second request to obtain file data, should query for specified files and provide contents or potentially more expensive to obtain metadata properties.
Methods
QueueFileAsync(IFileMetadata, String, CancellationToken)
Queues a repository file discovered during scan operation.
Declaration
ValueTask QueueFileAsync(IFileMetadata fileMetadata, string partitionHint, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
IFileMetadata | fileMetadata | Repository file properties. |
System.String | partitionHint | Partitioning information for distributed processing. |
CancellationToken | cancellationToken | The task cancellation token. |
Returns
Type | Description |
---|---|
ValueTask | A ValueTask instance. |
Remarks
The partitionHint
parameter should be an identifier of the repository partition during distributed
processing. For example, in a scenario where network file system is scanned, a folder name could be the partition hint
because performance could potentially be improved if the folders are on different drives.
Examples
Use the QueueFileAsync
method to add basic information about the files that were discovered in the
repository.
A default IFileMetadata is FileMetadata class.
public async Task RetrieveFileListAsync(RetrieveFileListRequest request, IFileListResultsHandler handler, CancellationToken cancellationToken)
{
// Get the repository option provided in UI, the location to scan
var location = request.RepositoryProperties.RepositoryOptions["Location"].ToString();
// Retrieve a list of files in the location
foreach (var file in new DirectoryInfo(location).EnumerateFiles("*", SearchOption.AllDirectories))
{
// Queue files for further processing
await handler.QueueFileAsync(new FileMetadata(file.Name, file.FullName)
{
Size = file.Length,
ModifiedTime = file.LastWriteTimeUtc,
AccessedTime = file.LastAccessTimeUtc,
CreatedTime = file.CreationTimeUtc
},
file.DirectoryName ?? string.Empty,
cancellationToken);
}
}
Exceptions
Type | Condition |
---|---|
AbortRequestedException | Processing of the current operation should be aborted. |