Getting Information about Repositories

Before you can read or write metadata, you must identify the repositories that are registered on a SAS Metadata Server. You should be familiar with the repository identifiers to indicate which repository to access. You can list the repositories that are defined on a SAS Metadata Server by using the getRepositories method on the MdOMIUtil interface.
   /**
    * The following statements list the repositories that are registered
    * on the SAS Metadata Server.
    * @return the list of available repository (list of CMetadata objects)
    */
   public List<CMetadata> getAllRepositories()
   {
      try
      {
         System.out.println("\nThe repositories contained on this SAS Metadata " +
           "Server are:");
         
         // The getRepositories method lists all repositories.
         MdOMIUtil omiUtil = _factory.getOMIUtil();
         List<CMetadata> reposList = omiUtil.getRepositories();
         for (CMetadata repository : reposList)
         {
            // Print the name and id of each repository.
            System.out.println("Repository: " + 
                               repository.getName() 
                               + " (" + repository.getFQID() +")");
         }
         return reposList;
      }
      catch (MdException e)
      {
         e.printStackTrace();
      }
      catch (RemoteException e)
      {
         e.printStackTrace();
      }
      return Collections.emptyList();
   }
Here is an example of the output that might be returned by the GetRepositories method:
The repositories contained on this SAS Metadata Server are:
Repository: Foundation (A0000001.A5PCE796)
Repository: MyProject (A0000001.A5RVLQQ9)
Repository: Custom1 (A0000001.A5T27ER8)
Repository: Custom2 (A0000001.A5IUI1BI)
The two-part number in each line is the repository identifier. The first part of the number (A0000001) is the SAS Repository Manager identifier and is the same for all repositories. The second part of the number is the unique repository ID. This is the identifier that we will use to create and read metadata.
The CMetadata interface is the base interface that is used to describe all metadata objects.