How to Use the SAS Java Metadata Interface


Example 2: Get Repositories

This is an example of how to list the repositories contained in the SAS Metadata Repository.

   /**
    * This example retrieves a list of the repositories registered on the server.
    * @return the list of available repository (list of CMetadata objects)
    */
   public List getRepositories()
   {
      try
      {
         // Get a list of repositories.
         System.out.println("\nThe repositories contained on this server are: ");

         MdOMIUtil omiUtil = _factory.getOMIUtil();
         List reposList = omiUtil.getRepositories();
         Iterator iter = reposList.iterator();
         while (iter.hasNext())
         {
            //print the name and id of each repository
            CMetadata repository = (CMetadata) iter.next();
            System.out.println("Repository: " +
                               repository.getName()
                               + " (" + repository.getFQID() +")");
         }
         return reposList;
      }
      catch (MdException e)
      {
         e.printStackTrace();
      }
      catch (RemoteException e)
      {
         e.printStackTrace();
      }
      return new ArrayList();
   }


The following is sample output from this method:

The repositories contained in this SAS Metadata Server are:
Repository: Foundation (A0000001.A5K2EL3N)
Repository: MyCustom (A0000001.A50TC1Z2)