Sun Identity Manager Deployment Reference

Tips on FormUtil Usage

Some of the trickiest common implementation of the FormUtil methods involve retrieving objects, particularly using the following methods.

This section introduces basic hints for using these methods.

Using getObject to Fetch Objects from the Repository

The getObject method is the most commonly used method for retrieving an object from within the repository. When using this method, remember that you are fetching actual (Java) objects. To access attributes from that object, you must wrap the object in an invocation that calls the object’s getter methods. Because each object uses particular get operations, refer to the individual object’s Javadoc for more detail.

When working with the WSUser object, you can use the WSUser object’s toHashMap() method. This method converts the object into a GenericObject, which is equivalent to a Java HashMap, as shown in the following example:


<set name=’wsUserObj’>
   <invoke name=’getObject’>
<!-- typically, a value such as :display.session would go here;
instead, call the handy rule -->
       <rule name=’Get Context’/>
       <s>User</s.
       <s>SamUser</s>
   </invoke>
</set>
<set name=’wsGenericObj’>
   <invoke name=’toHashMap’>
   <ref>wsUserObj</ref>
   </invoke>
</set>

To retrieve the accountId from the WSUser object, use the following

<invoke name=’getAccountId’>
 <ref>wsUserObj</ref>
</invoke>

However, when you are working with a user, this method can become tedious. The same thing via the WSUser object now converted into a GenericObject:

<ref>wsGenericObj.waveset.accountId</ref>

Basically, GenericObjects, such as views, can be much easier to work with than the WSUser object. Consider checking out the view of the associated object when dealing directly with the object is cumbersome.


Note –

Some operations will result in the repository locking the underlying PersistentObject. Typically, methods that begin with the phrase “checkout” will lock the object, “checkin” will unlock it), and methods that being with “get” will not lock the object.


Using getResourceObject to Fetch Objects from a Resource

The getResourceObject operation returns the specified object from the specified resource as a GenericObject. See the Resource Reference for an explanation of which objects can be fetched and which attributes are supported in the list. This method results in a call to the corresponding resource adapter.

Using the getUnassigned* Methods

The getUnassigned* methods retrieve features that are not currently assigned to the provided user (through the lh context). These methods are handy when you must create a User form that offers the user to select, and thus request access to, a feature they currently do not have. For example:


<Field name=’waveset.resources’>
   <Display class=’MultiSelect’ action=’true’>
     <Property name=’title’ value=’_FM_PRIVATE_RESOURCES’/>
     <Property name=’availableTitle’ value=’_FM_AVAILABLE_RESOURCES’/>
     <Property name=’selectedTitle’ value=’_FM_SELECTED_RESOURCES’/>
     <Property name=’allowedValues’>
       <invoke name=’getUnassignedResources’ class=’com.waveset.ui.FormUtil’>
           <ref>:display.session</ref>
           <map>
             <s>current</s>
             <ref>waveset.resources</ref>
           </map>
       </invoke>
    </Property>
   </Display>
</Field>

Using listResourceObject Method

There are ten versions of the listResourceObject method. Some versions require that you supply a single resource ID, or a list of resources, or a Boolean to clear the cache or other caching details. Other versions provide the ability to specify that the method to run as a different user.

When implementing this method within a form or rule, clarify in comments which version of this method you are using. For example,

Lists the Groups on the AD-Austin resource starting at the OurGroups OU.
It will leverage the server cache should this list be found there.
Additional details in the Identity Manager formUtil javadocs under:
public static java.util.List listResourceObjects(java.lang.String subjectString,
java.lang.String objectType,
java.lang.String resourceId,
java.util.Map options,
java.lang.String cacheList)