Because most workflow processing involves views, the most common view-related methods used in workflows are the checkoutView and checkinView methods. Checking out a view object will lock the underlying object such that no other user can write to it. This is especially important in workflow processing because a workflow may check out (lock) a user, and then suspend due to a manual action, leaving the user locked until the manual action is serviced (which could be hours or days later). By default, locks on objects expire in 5 minutes, which poses a second concern for workflows. A check in of an object requires that the caller already have the object locked. So a workflow that checks out a view (implicitly locking the object), suspends for 10 minutes, and the checks in the view will fail because the callers lock will have been aborted due to the 10 minute delay.
The following example shows a typical checkout operation:
<Action id=’-1’ application=’com.waveset.session.WorkflowServices’> <Argument name=’op’ value=’checkoutView’/> <Argument name=’type’ value=’User’/> <Argument name=’id’ value=’mfairfield’/> <Variable name=’view’/> <Return from=’view’ to=’user’/> </Action>
It can be challenging to determining which options you can use as optional arguments (which are defined as part of the UserViewConstants class) for these check out and check in calls. The Javadocs list options in this format:
Instead of hard-coding these literal strings in your code when checking for options, Identity Manager provides constants that you can use throughout your code to represent a string. While this is a good coding practice, you cannot reference the static fields of UserViewConstants, such as OP_TARGET_RESOURCES, through XPRESS or workflow.
To identify valid strings that you can pass in the correct value, you can write a test rule that reveals the true string. For example, the following rule returns TargetResources.
<block> <set name=’wf_srv’> <new class=’com.waveset.provision.WorkflowServices’/> </set> <script> var wfSvc = env.get( ’wf_srv’ ); var constant = wfSvc.OP_TARGETS; constant; </script> </block>
Although handy for finding out a string, this rule is not appropriate for production deployment because it returns the same string for every call made to it. To minimize this problem, Identity Manager constants that are used in view processing are never changed. Once you have coded the constant in your workflow, the view’s interpretation of that constant will not change from release to release.
One you have identified valid strings, you can update your checkout view call as follows. The following code checks out a view that propagates only changes to Identity Manager and Active Directory.
<Action id=’-1’ application=’com.waveset.session.WorkflowServices’> <Argument name=’op’ value=’checkoutView’/> <Argument name=’type’ value=’User’/> <Argument name=’id’ value=’mfairfield’/> <Argument name=’options’> <map> <s>TargetResources</s> <list> <s>Lighthouse</s> <s>AD</s> </list> </map> </Argument> <Variable name=’view’/> <Return from=’view’ to=’user’/> </Action>