Open topic with navigation

# Browse a Repository

The `identifiers` fetch action provides information that can be used to browse a repository. It retrieves a list of documents that are present in the repository and generates an identifier for each document.

Action | Description | Method to override
--- | --- | ---
`/action=fetch&fetchaction=Identifiers` | Retrieve a list of documents that are present in the repository. | `identifiers`

## Declare the Types of Identifiers

Before implementing the action, you must specify the types of identifier that the connector can return. For example, a connector that retrieves information from a file system might return identifiers that represent folders and identifiers that represent files.

Declare each `IdentifierType` as `public static readonly` in the main connector class:

       public class FileSystemConnector : ConnectorBase
       {
          public static readonly IdentifierType IdFolder = new IdentifierType("Folder", IdAttr.Container);
          public static readonly IdentifierType IdFile = new IdentifierType("File", IdAttr.Document);
          ...
       }

These fields are automatically found by the default implementation of the `GetIdentifierTypes()` function on the `ConnectorBase` class:

       virtual public IIdentifierTypes GetIdentifierTypes();

The default implementation means there is no need for you to implement this function.

You can verify the identifier types you have declared by running `/action=GetStatus`, which returns the list of `IdentifierTypes` and attributes.

## Implement the Identifiers Action

To implement the `identifiers` action, override the `identifiers` method.

When you implement the action, you can choose whether your users must set the parameter `ParentIdentifiers` in the `identifiers` action request.

The parameter `ParentIdentifiers` accepts a comma-separated list of identifiers. The action should return identifiers for items that exist below the parent identifiers in the repository. For example, the user might specify an identifier for a folder and would expect the action to return identifiers for folders and files contained within that folder. Alternatively, the user might specify the root of the repository by including the special identifier `ROOT`. The following sample code demonstrates how to implement the `identifiers` action and handle these cases.

       public override void identifiers( IIdentifiersTask task )
       {
         // Check whether we are expanding provided Parent identifiers.
         // If no Parent Identifiers are provided (when task.UsingParentIdentifiers == false),
         //  the implementation may choose to return Identifiers using some other criteria.
         if ( task.UsingParentIdentifiers )
         {
           // The special Identifier "ROOT" is used to request the top level
           // Identifiers in the repository. The task.parentIdentifierIsRoot()
           //  returns true if this special Identifier is present in the request.
           if ( task.ParentIdentifierIsRoot )
           {
             // Add root Identifiers.
             // The parameters are the Identifier, and a name for display purposes.
             // The task.MakeId() function returns an IdentifierBuilder that can be
             // used to build up the Identifier.
             task.AddIdentifier( task.MakeId().Reference("/Root").Type(IdFolder).Get(), "RootReference" );
           }

           // Loop over all parent Identifiers (excluding ROOT)
           foreach ( IParentIdentifier parentIdentifier in task.Parents )
           {
             try
             {
               // Retrieve the children (may throw).  Add child Identifiers.
               // This call is the same structure as the root Identifier call except
               // for the additional first argument being the parent Identifier.
               task.AddIdentifier( parentIdentifier, task.MakeId().Reference("/Root/Child").Type(IdFile).Get(), "ChildReference" );
             }
             catch ( Exception e )
             {
               // If an error occurs while retrieving the children, this error can be
               // reported as associated with the parent Identifier.
               // You can report general errors throughout the task by omitting
               // the parentIdentifier parameter.
               task.AddError( parentIdentifier, e.Message );
             }
           }
         }
       }

© 2018 Micro Focus or one of its affiliates | Send documentation feedback to Micro Focus Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a web mail client, and send this email to swpdl.idoldocsfeedback@microfocus.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_FT_HTML5_bannerTitle.htm