Show / Hide Table of Contents

Interface IRepositoryAdapter

The adapter interface.

Namespace: OpenText.Fusion.AdapterSdk.Api
Assembly: OpenText.Fusion.AdapterSdk.Api.dll
Syntax
public interface IRepositoryAdapter
Remarks

Implementation of IRepositoryAdapter represents the adapter code with specific methods handling different types of repository (source) operations.

Methods

CreateDescriptorAsync(CancellationToken)

Creates the descriptor object which contains information about the Adapter.

Declaration
Task<IAdapterDescriptor> CreateDescriptorAsync(CancellationToken cancellationToken)
Parameters
Type Name Description
CancellationToken cancellationToken

The cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns
Type Description
Task<IAdapterDescriptor>

IAdapterDescriptor instance which contains information about the Adapter.

Remarks

IAdapterDescriptor contains the adapter type name and expected configuration properties.

Examples

Example below defines a descriptor with "MyCustomAdapter" Fusion type name and 3 required properties with string values.
When a task is received, SDK will validate that all of them are present and will decrypt encrypted values.

public IAdapterDescriptor CreateDescriptor()
{
  return new AdapterDescriptor("MyCustomAdapter",
                               new List&lt;RepositorySettingDefinition&gt;
                               {
                                   new("Location", TypeCode.String, true, false),
                                   new("UserName", TypeCode.String, true, false),
                                   new("Password", TypeCode.String, true, true)
                               });
}
See Also
IAdapterDescriptor

RetrieveFileListAsync(RetrieveFileListRequest, IFileListResultsHandler, CancellationToken)

Retrieves a list of files (or repository files) including basic metadata like title and timestamps.

Declaration
Task RetrieveFileListAsync(RetrieveFileListRequest request, IFileListResultsHandler handler, CancellationToken cancellationToken)
Parameters
Type Name Description
RetrieveFileListRequest request

The request.

IFileListResultsHandler handler

The handler.

CancellationToken cancellationToken

The cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns
Type Description
Task

A Task representing the asynchronous operation.

Examples

Example of a simple implementation that queues file system files in a folder.

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);
}
}

RetrieveFilesDataAsync(RepositoryFilesRequest, IFileDataResultsHandler, CancellationToken)

Retrieves the content and expensive metadata for the files provided in the request.

Declaration
Task RetrieveFilesDataAsync(RepositoryFilesRequest request, IFileDataResultsHandler handler, CancellationToken cancellationToken)
Parameters
Type Name Description
RepositoryFilesRequest request

The request.

IFileDataResultsHandler handler

The handler.

CancellationToken cancellationToken

The cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns
Type Description
Task

A Task representing the asynchronous operation.

Examples

Below is an example of the RetrieveFilesDataAsync method and the handler.QueueFileAsync.

The fileId parameter should be taken directly from a repository file being processed.

Func<Stream> used to pass the file contents.

public async Task RetrieveFilesDataAsync(RetrieveFilesDataRequest request, IFileDataResultsHandler handler, CancellationToken cancellationToken)
{
  foreach (var repositoryFile in request.Files)
  {
      var file = new FileInfo(repositoryFile.Metadata.FileLocation);
      var fileStream = file.OpenRead();
      repositoryFile.Metadata.AdditionalMetadata.Add("custom_property", 123);
      handler.QueueFileAsync(repositoryFile.FileId, new FileContents(fileStream), repositoryFile.Metadata);
  }
}
In This Article
Back to top Generated by DocFX