Portal Registry Classes Example

There are several actions you may want to perform using a PortalRegistry, such as adding a folder, changing permissions, and so on. The following examples discuss the most common tasks. In addition, there are example programs of accessing the PortalRegistry classes using language environments other than PeopleCode.

This example shows how to change the default template used by a PortalRegistry. The following is the complete code sample: the steps explain each line.

Local ApiObject &MySession;
Local ApiObject &MyPortal, &MyPortalColl;

/* Access the current session */

&MySession = %Session;
If NOT &MySession Then
   /* do error processing */
End-if;

&MyPortalColl = &MySession.FindPortalRegistries();

For &I = 1 to &MyPortalColl.Count

   &MyPortal = &MyPortalColl.Item(&I);

   If &MyPortal.DefaultTemplate = "HR99" Then
      &MyPortal.DefaultTemplate = "HR00"
      &MyPortal.Save();
   End-If

End-For;

To change PortalRegistry properties:

  1. Get a Session object.

    Before you can access a PortalRegistry object, you must get a session object. The session controls access to the registry, provides error tracing, enables you to set the runtime environment, and so on. Because you want to use the existing session, use the %Session system variable (instead of the GetSession function.)

    &MySession = %Session;
  2. Get a PortalRegistry collection.

    Use the FindPortalRegistries method with no parameters to return a collection of all the PortalRegistries because you want to check all the registries for the invalid template.

    &MyPortalColl = &MySession.FindPortalRegistries();

    Use the Count property on the collection to loop through all the registries.

    For &I = 1 to &MyPortalColl.Count
  3. Get a PortalRegistry object.

    You can access a PortalRegistry object from the PortalRegistry collection using the Item method.

    &MyPortal = &MyPortalColl.Item(&I);
  4. Check for the invalid template and correct if necessary.

    Use the DefaultTemplate property both to check for the invalid template name, and to set the correct template. Save the PortalRegistry when you make a correction.

    If &MyPortal.DefaultTemplate = "HR99" Then
       &MyPortal.DefaultTemplate = "HR00"
       &MyPortal.Save();
    End-If;

You may want to do error checking after you save the PortalRegistry.

The following example adds a ContentProvider to an existing PortalRegistry. The following is the complete code sample: the steps explain each line.

Local ApiObject &MyPortal;
Local ApiObject &MyCPColl, &MyCProvider;

&MyPortal = %Session.GetPortalRegistry();

If NOT &MyPortal.Open(MYRECORD.PORTAL_NAME) Then
   /* Do error handling */
End-if;

/* Add a ContentProvider */

&MyCPColl = &MyPortal.ContentProviders; 

&MyCProvider = &MyCPColl.InsertItem("HRMS_00");

&MyCProvider.URI = "http://MYMACHINE103100/servlets/iclientservlet/HRMS/";
&MyCProvider.DefaultTemplate = "MYPORTAL_HRMS";
&MyCProvider.Description = "Updated Content Provider for HRMS";

If NOT(&MyPortal.Save()) Then 
   &ErrorCol = &MySession.PSMessages;
   For &I = 1 to &ErrorCol.Count
      &Error = &ErrorCol.Item(&I);
   /* do error processing */
   End-For;
&ErrorCol.DeleteAll();
End-If;

To add a ContentProvider:

  1. Get a Session object and a PortalRegistry.

    Before you can access a PortalRegistry object, you must get a session object. The session controls access to the registry, provides error tracing, enables you to set the runtime environment, and so on. Because you want to use the existing session, use the %Session system variable (instead of the GetSession function.) In addition, you want to get a PortalRegistry. Using the GetPortalRegistry method returns a reference to an unpopulated PortalRegistry object.

    &MyPortal = %Session.GetPortalRegistry();
  2. Open the PortalRegistry.

    After you get a PortalRegistry object, you want to open it, that is, populate it with data. Use the Open method to do this. The Open method returns a Boolean value, and this example uses that value to do error checking to make sure that the PortalRegistry is actually opened. In addition, the name of the PortalRegistry is kept in the record MYRECORD, in the field PORTAL_NAME.

    If NOT &MyPortal.Open(MYRECORD.PORTAL_NAME) Then
       /* Do error handling */
    End-if;
  3. Access the ContentProvider collection.

    You can only add a ContentProvider to a ContentProvider collection. So you must access a ContentProvider collection first, using the ContentProviders property on a PortalRegistry.

    &MyCPColl = &MyPortal.ContentProviders; 
  4. Add the ContentProvider.

    You must use the name of the ContentProvider with the InsertItem method. This example uses HRMS_00. This method does not execute automatically, that is, the ContentProvider isn't actually inserted into the database until the PortalRegistry is saved.

    &MyCProvider = &MyCPColl.InsertItem("HRMS_00");
  5. Further define the ContentProvider.

    The URI of a ContentProvider is used in conjunction with content references to define the location of content. So you should define the URI. If a template isn't found for any of the content references on a page at runtime, the system next tries to use the DefaultTemplate defined for a ContentProvider, so you should define a default template.

    &MyCProvider.URI = "http://MYMACHINE103100/servlets/iclientservlet/HRMS/";
    &MyCProvider.DefaultTemplate = "MYPORTAL_HRMS";
    &MyCProvider.Description = "Updated Content Provider for HRMS";
  6. Save the PortalRegistry and check for errors.

    Because there is no Save method with a ContentProvider, you must save the PortalRegistry to complete your changes.

    You can check if there were any errors using the PSMessages property on the session object.

    If NOT(&MyPortal.Save()) Then
       /* save didn’t complete */
       &ErrorCol = &MySession.PSMessages;
       For &I = 1 to &ErrorCol.Count
          &Error = &ErrorCol.Item(&I);
          /* do error processing */
       End-For;
       &ErrorCol.DeleteAll();
    End-if;

    If there are multiple errors, all errors are logged to the PSMessages collection, not just the first occurrence of an error. As you correct each error, delete it from the PSMessages collection.

    Note: If you've called the portal registry API from an Application Engine program, all errors are also logged in the Application Engine error log tables.

See Error Handling.

The following example checks to see if a folder for a user exists. If it doesn't, it creates one.

The folder hierarchy for this example is as follows. The Users folder is where the portal stores things such as user homepages:

Root folder
   Users folder
      UserId1 folder
      UserId2 folder
      UserId3 folder
      . . .

The following is the complete code sample: the steps explain each line.

Local ApiObject &MyPortal;
Local ApiObject &UserFldrColl, &UserFldr;

&MyPortal = %Session.GetPortalRegistry();

If NOT &MyPortal.Open(MYRECORD.PORTAL_NAME) Then
   /* Do error handling */
End-if;

&UserFldrColl = &MyPortal.RootFolder.Folders.ItemByName("Users").Folders;

&UserFldr = &UserFldrColl.ItemByName(%UserId);
      
If &UserFldr = Null Then

/* add Folder */

   &UserFldr = &UserFldrColl.InsertItem(%UserId, %UserId);
   &UserFldr.Description = %UserId;

/* Set dates */

   &UserFldr.ValidFrom = %Date;
   &ToDate = AddToDate(%Date, 1, 1, 0);
   &UserFldr.ValidTo = &ToDate;

/* Set properties */

   &UserFldr.PublicAccess = True;

/* save the folder */

   &UserFldr.Save();

End-If;

To add a folder:

  1. Get a Session object and a PortalRegistry.

    Before you can access a PortalRegistry object, you must get a session object. The session controls access to the registry, provides error tracing, enables you to set the runtime environment, and so on. Because you want to use the existing session, use the %Session system variable (instead of the GetSession function.) In addition, you want to get a PortalRegistry. Using the GetPortalRegistry method returns a reference to an unpopulated PortalRegistry object.

    &MyPortal = %Session.GetPortalRegistry();
  2. Open the PortalRegistry.

    After you get a PortalRegistry object, you want to open it, that is, populate it with data. Use the Open method to do this. The Open method returns a Boolean value, and this example uses that value to do error checking to make sure that the PortalRegistry is actually opened. In addition, the name of the PortalRegistry is kept in the record MYRECORD, in the field PORTAL_NAME.

    If NOT &MyPortal.Open(MYRECORD.PORTAL_NAME) Then
       /* Do error handling */
    End-if;
  3. Access the User folder collection.

    One of the strengths of dot notation is being able to string together many methods and properties into a single line of code. The result of this single line of code is to return a reference to the folder collection within the Users folder.

    &UserFldrColl = &MyPortal.RootFolder.Folders.ItemByName("Users").Folders;

    Note that in this kind of code, you must access the RootFolder for the PortalRegistry before you can access the folders collection.

    If there were additional folders in your hierarchy, you could continue in the same way, using ItemByName and Folders.

  4. Check if the user already has a folder.

    The system variable %UserId returns the user ID of the current user. Then this example uses the ItemByName method on the folder collection to see if the user already has a folder. This assumes that the user folders are names according to the UserId. The ItemByName method returns a reference to the folder if it exists. If the folder does not exist, ItemByName returns NULL.

    &UserFldr = &UserFldrColl.ItemByName(%UserId);
    
    If &UserFldr = Null Then
  5. Add a folder if one doesn't exist.

    Use the UserId as the name of the folder, as well as for the label and the description.

    &UserFldr = &UserFldrColl.InsertItem(%UserId, %UserId);
    &UserFldr.Description = %UserId;
  6. Set the ValidFrom and ValidTo dates.

    For this example, the folder should be accessible from the date it's created, so the example sets the ValidFrom property to be today's date.

    When you first create a folder, the ValidTo date, that is, the date that this folder "expires", is set to null, that is an empty string. This means it never expires. In this example, we set the ValidTo date to one year and one day after the current date.

       &UserFldr.ValidFrom = %Date;
       &ToDate = AddToDate(%Date, 1, 1, 0);
       &UserFldr.ValidTo = &ToDate;
  7. Set permissions for the folder.

    There are several properties that work together to determine the access of a folder or content reference. This example sets the PublicAccess property to True, which means that everyone has access to it, and it's included in all collections of folders.

       &UserFldr.PublicAccess = True;

    This example sets only the permission properties on the folder. It doesn't set all the possible permissions, such as the PermissionValue objects for the folder.

  8. Save the folder.

    After you have finished your changes to the folder, save it.

    &UserFldr.Save();

    You may want to check for errors after you save each folder.

See Using Security.

The following code example adds a content reference that's a target component to the Approve Expenses folder.

The folder hierarchy for this example is:

Root folder
   Expenses folder
      Create Expenses folder
      Review Expenses folder
      Approve Expenses folder

The following is the complete code sample: the steps explain each line.

Local ApiObject &MyPortal;
Local ApiObject &CRef, &CRefColl;
Local ApiObject &Fldr;

&MyPortal = %Session.GetPortalRegistry();

If NOT &MyPortal.Open(MYRECORD.PORTAL_NAME) Then
   /* Do error handling */
End-if;
   
&Fldr = &MyPortal.RootFolder.Folders.ItemByName("Expenses").Folders.ItemByName("Approve Expenses");

/* add content reference */

&CRef = &Fldr.ContentRefs.InsertItem(&CRefname, MYCP, MYRECORD.MYURL);
   &CRef.Description = &CRefname;

/* Set dates */
&CRef.ValidFrom = %Date;
&ToDate = AddToDate(%Date, 1, 1, 0);
&CRef.ValidTo = &ToDate;

/* Set content reference  types */
&CRef.UsageType = "TARG";   /* Target content reference */
&CRef.URLType = "UPGE";     /* Component type of content reference */
&CRef.StorageType = "RMTE";  /* Template is remote. */
&CRef.Template = "EXPENSES_TEMPLATE";      /* name of template */
&CRef.TemplateType = "HTML";   /* type of Template */
/* Set URL */
&CRef.URL = "ICType=Panel&Menu=MANAGE_EXPENSES&Market=GBL&Component=APPROVE_FINAL"

/* Save the content reference */

&CRef.Save();

To add a content reference:

  1. Get a Session object and a PortalRegistry.

    Before you can access a PortalRegistry object, you must get a session object. The session controls access to the registry, provides error tracing, enables you to set the runtime environment, and so on. Because you want to use the existing session, use the %Session system variable (instead of the GetSession function.) In addition, you want to get a PortalRegistry. Using the GetPortalRegistry method returns a reference to an unpopulated PortalRegistry object.

    &MyPortal = %Session.GetPortalRegistry();
  2. Open the PortalRegistry.

    After you get a PortalRegistry object, you want to open it, that is, populate it with data. Use the Open method to do this. The Open method returns a Boolean value, and this example uses that value to do error checking to make sure that the PortalRegistry is actually opened. In addition, the name of the PortalRegistry is kept in the record MYRECORD, in the field PORTAL_NAME.

    If NOT &MyPortal.Open(MYRECORD.PORTAL_NAME) Then
       /* Do error handling */
    End-if;
  3. Access the folder collection.

    One of the strengths of dot notation is being able to string together many methods and properties into a single line of code. The result of this single line of code is to return a reference to the folder collection within the folder.

    &Fldr = &MyPortal.RootFolder.Folders.ItemByName("Expenses").Folders.ItemByName("Approve Expenses");

    The Adding a Folder example has more explanation on the break down of this line of code.

  4. Add the content reference.

    You can only add content references from the collection of content references for the folder. After you have the content reference collection, use the InsertItem method to add the content reference. The ContentProvider for this content reference is named MYCP. The URL is stored in the record MYRECORD in the field MYURL.

    &CRef = &Fldr.ContentRefs.InsertItem(&CRefname, MYCP, MYRECORD.MYURL);
    &CRef.Description = &CRefname;

    Note that the InsertItem method adds the content reference to the database as soon as it's executed. You could check for errors at this point to see if the content reference was added correctly.

  5. Set the ValidFrom and ValidTo dates.

    For this example, the content reference should be accessible from the date it's created, so the example sets the ValidFrom property to be today's date.

    When you first create a content reference, the ValidTo date, that is, the date that this content reference "expires", is set to null, that is an empty string. This means it never expires. In this example, we set the ValidTo date to one year and one day after the current date.

    &CRef.ValidFrom = %Date;
    &ToDate = AddToDate(%Date, 1, 1, 0);
    &CRef.ValidTo = &ToDate;
  6. Set the type parameters.

    Many content reference properties work together to set the type of content reference.

    In this example, the content reference is a target. It's a component type of content reference, which means it's a PeopleSoft definition. The template to be used for displaying this content reference is stored remotely, its name is EXPENSES_TEMPLATE, and it's an HTML template.

    &CRef.UsageType = "TARG"; /* Target content reference */
    &CRef.URLType = "UPGE"; /* Component type of content reference */
    &CRef.StorageType = "RMTE"; /* Template is remote. */
    &CRef.Template = "EXPENSES_TEMPLATE"; /* name of template */
    &CRef.TemplateType = "HTML"; /* type of Template */
  7. Set the URL.

    The URL property of the content reference indicates where the content actually is. As this content reference is referencing a page, the URL has a specific format to indicate which page.

    &CRef.URL = "ICType=Panel&Menu=MANAGE_EXPENSES&Market=GBL&Component=APPROVE_FINAL"
  8. Save the content reference.

    After you have finished adding the content reference, you should save it.

       &CRef.Save();

    You may want to check for errors after you save each content reference.

See Adding a Folder.

The following code example adds permissions for a folder through the PermissionValue object.

The following is the complete code sample: the steps explain each line.

Local ApiObject &MyPortal;
Local ApiObject &UserFldr;
Local ApiObject &PermV, &PermVColl;

&MyPortal = %Session.GetPortalRegistry();

If NOT &MyPortal.Open(MYRECORD.PORTAL_NAME) Then
   /* Do error handling */
End-if;
   
&UserFldr = &MyPortal.RootFolder.Folders.ItemByName("Users");

&CascadedColl = &UserFldr.CascadedPermissions;

&PermV = &CascadedColl.ItemByName("VENDOR1");

If NOT &PermV Then
   &PermVColl = &UserFldr.Permissions;
   &PermVColl.InsertItem("VENDOR1");
   &UserFldr.Save();
End-If;

To set permissions for a folder, using the PermissionValue object:

  1. Get a Session object and a PortalRegistry.

    Before you can access a PortalRegistry object, you must get a session object. The session controls access to the registry, provides error tracing, enables you to set the runtime environment, and so on. Because you want to use the existing session, use the %Session system variable (instead of the GetSession function.) In addition, you want to get a PortalRegistry. Using the GetPortalRegistry method returns a reference to an unpopulated PortalRegistry object.

    &MyPortal = %Session.GetPortalRegistry();
  2. Open the PortalRegistry.

    After you get a PortalRegistry object, you want to open it, that is, populate it with data. Use the Open method to do this. The Open method returns a Boolean value, and this example uses that value to do error checking to make sure that the PortalRegistry is actually opened. In addition, the name of the PortalRegistry is kept in the record MYRECORD, in the field PORTAL_NAME.

    If NOT &MyPortal.Open(MYRECORD.PORTAL_NAME) Then
       /* Do error handling */
    End-if;
  3. Access the User folder.

    One of the strengths of dot notation is being able to string together many methods and properties into a single line of code. The result of this single line of code is to return a reference to the folder named Users.

    &UserFldr = &MyPortal.RootFolder.Folders.ItemByName("Users");
  4. Access the entire, cascaded PermissionValue collection.

    There are two types of PermissionValue collections you can access for a folder.

    • One contains only the permission list values that are set at that folder. This collection is returned with the Permissions property.

    • The other contains all the permission list values for folder, that is, it contains any permission list values set in any parent folder and cascaded. This collection is returned with the CascadedPermissions property.

Note: You cannot add any PermissionValue objects to a collection returned by the CascadedPermissions property. You can add values only to the collection returned by the Permissions property.

This example uses the CascadedPermissions collection to check if the permission exists, because we don’t want to add a permission if it already exists. Then it uses the Permissions collection to add the value.

&CascadedColl = &UserFldr.CascadedPermissions;
  1. Check to see if the permission list value exits.

    Before adding the new PermissionValue object, you want to make sure one by that name doesn't already exist.

    &PermV = &CascadedColl.ItemByName("VENDOR1");
  2. If the PermissionValue doesn't exist, add it.

    The ItemByName returns a reference to a PermissionValue object if it exists, or NULL if it doesn't. So this example checks for NULL, and adds the PermissionValue if it doesn't exist.

    Notice that this example is not changing the Cascaded property with the PermissionValue object. The default value for a new PermissionValue object is False. As this example does not want to cascade the permissions for this permission list, it retains the default value.

    In addition, if the PermissionValue object is added, the folder is saved. The InsertItem method executes only after the parent object, the folder, is saved.

    If NOT &PermV Then
       &PermVColl = &UserFldr.Permissions;
       &PermVColl.InsertItem("VENDOR1");
       &UserFldr.Save();
    End-If;

    You may want to check for errors after you save the folder.

See Permissions, CascadedPermissions.

See Using PermissionValue, RolePermissionValue, Cascading Permissions and CascadingRolePermissions.

The following example uses attributes for a folder to determine what is displayed to an end-user. The end-user still has access to the content, however, it isn't displayed. This program doesn't discuss how to hide or display content: it just shows the function used to determine if a folder should be displayed.

The following is the complete code sample: the steps explain each line.

Function checkVisible(&FolderId As ApiObject) Returns Boolean 
   &colAttrib = &FolderId.Attributes;
   
   If &colAttrib.ItemByName("PORTAL_HIDE_FROM_NAV") <> Null Then
      If &colAttrib.ItemByName("PORTAL_HIDE_FROM_NAV").value = "TRUE" Then
             &display = False;
      End-If;
   End-If;

    Return &display;

End-Function;

To use attributes for a folder:

  1. Access the folder attribute collection.

    A reference to a folder is passed into the function. Then the example uses the Attributes property on the folder to access the attribute collection for the folder.

    &colAttrib = &FolderId.Attributes;
  2. Check to see if the folder should be hidden.

    This step is actually two checks. The first check is to see if there is an attribute with the folder called PORTAL_HIDE_FROM_NAV. If the folder has such an attribute, the second check determines the value of this attribute. If both are true, the folder should be hidden, so the variable &display is set to True, and returned.

    If &colAttrib.ItemByName("PORTAL_HIDE_FROM_NAV") <> Null Then
          If &colAttrib.ItemByName("PORTAL_HIDE_FROM_NAV").value = "TRUE" Then
                 &display = False;
          End-If;
       End-If;
    
        Return &display;

The following is an example referencing a PortalRegistry object using Visual Basic.

Dim oCref As ContentRef
Dim oCrefColl As ContentRefCollection

Set oSession = CreateObject("PeopleSoft.Session")
iResult = oSession.Connect(1, AppServStr, OperID, OperPasswd, 0)
    
Set oPortal = oSession.GetPortalRegistry
iResult = oPortal.Open("PORTAL")
    
Set oCrefColl = oPortal.RootFolder.ContentRefs
Set oCref = oCrefColl.InsertItem("papi012")
iResult = oPortal.Close
    
iResult = oPortal.Open("PORTAL")
    
Set oCref = oPortal.FindCRefByName("papi012")   
    
oPortal.Close
oSession.Disconnect
Exit Sub

The following is a C/C++ example.

/***********************************************************************
*                                                                      *
* psportal_test.cpp                                                    *
*                                                                      *
************************************************************************
*                                                                      *
*               Confidentiality Information:                           *
*                                                                      *
* This module is the confidential and proprietary information of      
* PeopleSoft, Inc.; it is not to be copied, reproduced, or 
* transmitted in any form, by any means, in whole or in part, 
* nor is it to be used for any purpose other than that for which it 
* is expressly provided without the written 
* permission of PeopleSoft.                        
*                                                                      *
* Copyright (c) 1988-1999 PeopleSoft, Inc.  All Rights Reserved.       *
*                                                                      *
************************************************************************
*                                                                      *
* SourceSafe Information:                                              *
*                                                                      *
* $Logfile::                                                          $*
* $Revision::                                                         $*
* $Date::                                                             $*
*                                                                      *
***********************************************************************/
/***********************************************************************
*       includes                                                       *
***********************************************************************/

#ifdef PS_WIN32
#include "stdafx.h"
#endif

#include "bcdef.h"
#include "apiadapterdef.h"
#include "peoplesoft_peoplesoft_i.h"

#include <stdio.h>
#include <iostream.h>
#include <wchar.h>

/***********************************************************************
*       general defines and macros                                     *
***********************************************************************/

/***********************************************************************
*       globals                                                        *
***********************************************************************/
HPSAPI_SESSION                                              hSession;


/***********************************************************************
*       function prototypes                                            *
***********************************************************************/
void DisconnectSession();
void GetFolder(HPSAPI_SESSION hSession, LPTSTR pszPortalName);
void OutError(HPSAPI_SESSION hSession);

/***********************************************************************
* Function:     main                                                   *
*                                                                      *
* Description:                                                         *
*                                                                      *
* Returns:                                                             *
***********************************************************************/
void main(int argc, char* argv[])
{
    // Declare variables 
    PSAPIVARBLOB    blobExtra;
    TCHAR szServer[80] = _T("//LCHE0110:900");
    TCHAR szUserid[30] = _T("PTMO");
    TCHAR szUserPswd[80] = _T("PT");
    TCHAR szPortalName[80] = _T("PORTAL");    
   
    memset(&blobExtra, 0, sizeof(PSAPIVARBLOB));

    // Establish a PeopleSoft Session.
   HPSAPI_SESSION hSession = PeopleSoft_Session_Create();
    
    if (PeopleSoft_Session_Connect(hSession, 1, szServer, szUserid, szUserPswd, blobExtra))
    {
        GetFolder(hSession, szPortalName);
   }
   else
    {
      // Connect to AppServer Failed. Error out.
        if (PeopleSoft_Session_GetErrorPending(hSession))
      {
         wprintf(L"\nConnect to AppServer Failed.\n");
         OutError(hSession);
      }
      else
         wprintf(L"No error pending from session.\n");
    }
    DisconnectSession();
}


/***********************************************************************
*       function implementations                                       *
***********************************************************************/
/***********************************************************************
* Function:     DisconnectSession                                      *
*                                                                      *
* Description:  Disconnects the Session object.                        *
*                                                                      *
* Returns:      None                                                   *
***********************************************************************/
void DisconnectSession()
{
    // Disconnect current session to free memory and session variables.
    if (hSession)
    {
        if (PeopleSoft_Session_Disconnect(hSession))
        {
            PeopleSoft_Session_Release(hSession);
        }
        else
        {
            wprintf(L"Disconnect to AppServer Failed.\n");
        }
    }
}


/***********************************************************************
* Function:     GetFolder                                              *
*                                                                      *
* Description:  Get root folder and display folder name                *
*                                                                      *
* Returns:      None                                                   *
***********************************************************************/
void GetFolder(HPSAPI_SESSION hSession, LPTSTR pszPortalName)
{
    LPTSTR                  szStr;
    HPSAPI_PORTALREGISTRY   hPortal;
    HPSAPI_FOLDER           hRootFolder;
    
    hPortal=(HPSAPI_PORTALREGISTRY) PeopleSoft_Session_GetPortalRegistry(hSession);
    PortalRegistry_PortalRegistry_Open(hPortal, pszPortalName);
    if (PortalRegistry_PortalRegistry_Open(hPortal, pszPortalName) == false)
        _tprintf(_T("Open portal failed\n"));
    else
    {        
        hRootFolder = PortalRegistry_PortalRegistry_GetRootFolder(hPortal);
        szStr = PortalRegistry_Folder_GetName(hRootFolder);
        _tprintf(_T("root folder name = %s\n"), szStr);
    }
}


/***********************************************************************
* Function:     OutError                                               *
*                                                                      *
* Description:  Output error message from session psMessage object     *
*                                                                      *
* Returns:      None                                                   *
***********************************************************************/
void OutError(HPSAPI_SESSION hSession)
{
    LPTSTR                  szStr;
    HPSAPI_PSMESSAGECOLLECTION hMsgColl;
   HPSAPI_PSMESSAGE hMsg;
   
    
    hMsgColl=(HPSAPI_PSMESSAGECOLLECTION) PeopleSoft_Session_GetPSMessages(hSession);

   wprintf(L"Get psMessage collection ok.\n");

   int i;
   PSI32 count;
   count=(PSI32) PeopleSoft_PSMessageCollection_GetCount;
   wprintf(L"Count= %d\n", count);

   for (i=0; i<count; i++)
   {
      hMsg=(HPSAPI_PSMESSAGE) PeopleSoft_PSMessageCollection_Item(hMsgColl, i);
      szStr=PeopleSoft_PSMessage_GetText(hMsg);
      wprintf(L"\nMessage from session: %s\n",szStr);      
   }

}