Displaying folder criteria information

You use methods from the ODServer class to open a folder on a specified server, then display the folder name and description. Then, you write code that prints the folder criteria information.

About this task

The following example uses ODServer methods to open a folder on a specified server, displays the folder name and description, and prints the folder criteria information. The folder criteria includes:
  • Name
  • Default operator
  • Valid operators
  • Field Type
  • Default values
  • Fixed values
To display folder criteria information, ensure that:
  • None of the operators indicate Unknown operator.
  • None of the field types indicate Unknown type.
  • For each method, the default values are the same.
  • The folder criteria information that is displayed by ODWEK API matches what is displayed by the Content Manager OnDemand client.
This example demonstrates the following ODServer methods:
  • initialize
  • logon
  • getNumFolders
  • getFolderNames
  • getFolderDescription
  • logoff
  • terminate
This example uses the following runtime parameters:
  • Server name
  • Port
  • User ID
  • Password
  • Folder criteria
This example uses the following runtime parameters:
  • Server name
  • User ID
  • Password
  • Folder name
Example of listing folders and folder information:
import java.util.*;
import java.io.*;
import com.ibm.edms.od.*;
public class TcListFoldersByCrit
{
  public static void main ( String argv[] )
  {
     ODServer odServer;
     Enumeration folders_enum;
     String folder_name;
     String folder_desc;
     int num_folders;
     //----------
     // If too few parameters, display syntax and get out
     //----------
     if ( argv.length < 5 )
     {
         System.out.println( "usage: java TcListFoldersByCrit <server> <port> <userid> <password> <Folder Criteria>" );
         return;
     }
     try
     {
          //----------
          // Set the stage
          //----------
          System.out.println( "Testcase TcListFoldersByCrit started." );
          System.out.println( "This testcase should:" );
          System.out.println( "  Log onto the server.");
          System.out.println( "  Display the total number of folders available for the user.");
          System.out.println( "  Display the number of folders available for the user with criteria.");
          System.out.println( "  Display one line for each folder retrieved from search criteria, ");
          System.out.println( "          showing name and description" );
          System.out.println( "" );
          System.out.println( "The information should be the same as that displayed using the Windows Client" );
          System.out.println( "(with the 'All' button checked if available), but the sequence of the folders" );
          System.out.println( "may be different depending on the server specified" );
          System.out.println( "" );
          System.out.println( "---------------------------------------------------" );
          System.out.println( "" );
          //----------
          // Logon to specified server
          //----------
          ODConfig odConfig = new ODConfig();
          if(odConfig != null)
          {
             odServer = new ODServer(odConfig );
             odServer.initialize(  "TcListFolders.java" );
             System.out.println( "Logging on to " + argv[0]  + " server with user " + argv[2] + "..." );
             odServer.setPort(Integer.parseInt(argv[1]));
             odServer.logon( argv[0], argv[2], argv[3]);

             //----------
             // Display the total number of folders available.
             //----------
             num_folders = odServer.getNumFolders( );
             System.out.println( "" );
             System.out.println( "There are " + num_folders + " folders available to user " + argv[2]);
             System.out.println( "      on server " + argv[0] + "." );

             //----------
             // Display the number of folders available with search criteria.
             //----------
             num_folders = odServer.getNumFolders(argv[4]);
             System.out.println( "" );
             System.out.println( "There are " + num_folders + " folders with criteria " + argv[4] );
             System.out.println( "      available to user " + argv[2] + " on server " + argv[0] + "." );

             //----------
             // Display the folder names and descriptions
             //----------
             int i = 1;
             // get a limited folder list based on search criteria
             System.out.println( "" );
             System.out.println("List folders found using search criteria... " + argv[4] + ":");
             System.out.println( "" );
             i = 1;
             for (Enumeration folders_enum2 = odServer.getFolderNames(argv[4]); folders_enum2.hasMoreElements( ); )
	          {
		         folder_name = (String)folders_enum2.nextElement( );
		         folder_desc = odServer.getFolderDescription( folder_name );
		         System.out.println(i++ + "  " + folder_name + "  ---  " + folder_desc );
		       }

             //----------
             // Cleanup
             //----------
             odServer.logoff( );
             odServer.terminate( );
             System.out.println( "" );
             System.out.println( "---------------------------------------------------" );
             System.out.println( "" );
             System.out.println( "Testcase TcListFoldersByCrit completed - ");
             System.out.println("          compare results to Windows Client if required" );
             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( );
     }
  }
}