# How to Use the SAS Java Metadata Interface

- Package Description
- Example 1: Server Connection
- Example 2: Get Repositories
- Example 3: Get Metadata Types
- Example 4: Create Objects
- Example 5: Read Objects
- Example 6: Delete Objects
- Example 7: Get all objects of a particular type
- Example 8: Get an existing object
- Sample Program

## 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)