Listing application groups in a folder

An object of the class ODFolder represents a Content Manager OnDemand folder.

About this task

The following example uses ODFolder methods to display the number of application groups that can be searched from the folder and display the name of each application group.

This example demonstrates the following ODFolder methods:
  • getApplGroupNames
  • getNumApplGroups
  • close
This example also uses ODServer methods to prepare for logon, open the specified folder, and log off. This example demonstrates the following ODServer methods:
  • getApplicationGroup
  • initialize
  • logoff
  • logon
  • openFolder
  • terminate
This example uses the following runtime parameters:
  • Folder name
  • Password
  • Port
  • Server name
  • User Id
Example of listing the application groups in a folder:
import java.util.*;
import java.io.*;
import com.ibm.edms.od.*;

public class TcApplGrp
{
  public static void main ( String argv[] )
  {
    ODServer odServer;
    ODFolder odFolder;
    String[] appls;
    int j;
    long agid=0;
   
    //----------
    // If too few parameters, display syntax and get out
    //----------
    if ( argv.length < 5 )
    {
      System.out.println( "usage: java TcApplGrp <server> <port> <userid> <password> <folder>" );
      return;
    }

    try
    {
      //----------
      // Set the stage
      //----------
      System.out.println( "Test case TcApplGrp started." );
      System.out.println( "This test case should:" );
      System.out.println( "  Logon to the specified server" );
      System.out.println( "  Open the specified folder" );
      System.out.println( "  Display the folder name" );
      System.out.println( "  Display the number of application groups" );
      System.out.println( "  Display the name of each application group" );
      System.out.println( "  Get application group by name and display" );
      System.out.println( "  Get application group by application group id and display" );
      System.out.println( "" );
      System.out.println( "---------------------------------------------------" );
      System.out.println( "" );

      //----------
      // Logon to the specified server
      //----------
      ODConfig odConfig = new ODConfig();

      if (odConfig != null)
      {
         odServer = new ODServer(odConfig );
         odServer.initialize(  "TcApplGrp.java" );
		       odServer.setPort(Integer.parseInt(argv[1]));
         System.out.println( "Logging on to " + argv[0]  + " server with user " + argv[2] + "..." );
         odServer.logon( argv[0], argv[2], argv[3]);

         //----------
         // Open the specified folder
         //----------
         System.out.println( "Opening " + argv[4] + " folder..." );
         odFolder = odServer.openFolder( argv[4] );

         //----------
         // Display number and names of application groups
         //----------
         System.out.println( "There is(are) " + odFolder.getNumApplGroups( ) + " application group(s) in the folder:" );
         Object[] appl_grps = odFolder.getApplGroupNames( );
         String agname =  appl_grps[0].toString();
         for ( j = 0; j < appl_grps.length; j++ )
             System.out.println( "  " + appl_grps[j] );

         System.out.println("\nGet the Application Group by name: " + agname);
         ODApplicationGroup odAG1 = odServer.getApplicationGroup(agname);
         System.out.println("Application Group Name = " + odAG1.getName());
         System.out.println("Application Group Description = " + odAG1.getDescription());
         System.out.println("Application Group ID = " + odAG1.getId());
         System.out.println("Application Group ID Permissions = " + odAG1.getIdPerms());
         System.out.println("isRMEnabled = " + odAG1.isRMEnabled());
         System.out.println("isHoldEnabled = " + odAG1.isHoldEnabled());
         System.out.println("isCFSODEnabled = " + odAG1.isCFSODEnabled());
         System.out.println("Mapped Applications:");
         appls = odAG1.getApplicationNames();
         for (int i = 0; i < appls.length; i++)
             System.out.println("   " +appls[i]);

                System.out.println("Display AGField details");
                Enumeration AGFields = odAG1.getFields();
                //System.out.println(" There are " + AGFields.size() + " fields in the AG");
                
                while(AGFields.hasMoreElements())
                {
                   ODApplicationGroupField field = (ODApplicationGroupField)AGFields.nextElement();
                   System.out.println(" Name= " + field.getName());
                   System.out.println("   Mask= " + field.getMask());
                   System.out.println("   Type= " + field.getType());
                   System.out.println("   Qual= " + field.getQual());
                   if (field.getType() == ODConstant.OD_FLD_STRING)
                      System.out.println("The field type is STRING");
                }
                agid =  odAG1.getId();
                System.out.println("Application Group ID = " + agid);
                
                //8410_20_03 enhancement to list all Application Groups for this user/server
                System.out.println("List Application Group Names Based on Criteria");
                String[] agNames = odServer.getApplicationGroupNames("%");
                for(int i = 0; i < agNames.length; i++)
                {
                    System.out.println("  " + agNames[i]);
                }

         //----------
         // Cleanup
         //----------
         odFolder.close( );
         odServer.logoff( );
         odServer.terminate( );
      }
      else
      {
         System.out.println( "" );
         System.out.println( "Test case TcApplGrp failed  -" );
         System.out.println( "  ODConfig could not be initialized.  " );
         System.out.println( "  Probable cause: " );
         System.out.println( "    File arswww.props is not found in directory " +  argv[5] );
         System.out.println( "" );
      }

      System.out.println("Re-Logon and attempt to get the Application Group using Application Group ID saved above.");
      odConfig = new ODConfig();

      if (odConfig != null)
      {
         odServer = new ODServer(odConfig );
         odServer.initialize(  "TcApplGrp.java" );
         System.out.println( "Logging on to " + argv[0]  + " server with user " + argv[2] + "..." );
         odServer.logon( argv[0], argv[2], argv[3] );
         System.out.println( "Opening " + argv[4] + " folder..." );
         odFolder = odServer.openFolder( argv[4] );

         System.out.println("\nGet the Application Group for id " + agid);
         ODApplicationGroup odAG = odServer.getApplicationGroup(agid);
         System.out.println("Application Group Name = " + odAG.getName());
         System.out.println("Application Group Description = " + odAG.getDescription());
         System.out.println("Application Group ID = " + odAG.getId());
         System.out.println("isRMEnabled = " + odAG.isRMEnabled());
         System.out.println("isHoldEnabled = " + odAG.isHoldEnabled());
         System.out.println("isCFSODEnabled = " + odAG.isCFSODEnabled());
         System.out.println("Mapped Applications:");
         appls = odAG.getApplicationNames();
         for (int i = 0; i < appls.length; i++)
             System.out.println("   " +appls[i]);

         //----------
         // Cleanup
         //----------
         odFolder.close( );
         odServer.logoff( );
         odServer.terminate( );
         System.out.println( "" );
         System.out.println( "---------------------------------------------------" );
         System.out.println( "" );
         System.out.println( "Testcase TcApplGrp completed. - analyze results if required" );
	        System.out.println( "" );
      }
      else
      {
         System.out.println( "" );
         System.out.println( "Testcase TcApplGrp failed  -" );
         System.out.println( "  ODConfig could not be initialized.  " );
         System.out.println( "  Probable cause: " );
         System.out.println( "    File arswww.props is not found in directory " +  argv[5] );
         System.out.println( "" );
      }

    }

    catch ( ODException e )
    {
        System.out.println( "ODException: " + e );
        System.out.println( "   id = " + e.getErrorId( ) );
        System.out.println( "  msg = " + e.getErrorMsg( ) );
        e.printStackTrace( );
    }

    catch ( Exception e2 )
    {
        System.out.println( "exception: " + e2 );
        e2.printStackTrace( );
    }
  }
}