Example: Item Validation Oracle Fusion Middleware Online Documentation Library

16-30 Oracle Fusion Middleware Developers Guide for Oracle Portal For example, calling the wwsbr_api.approve API triggers an INSERT event with an action of APPROVE_ITEM. wwsbr_api.approve p_item_id = l_thing.id, p_site_id = l_thing.siteid, p_comment = Approved ; For an example of how to add a subscriber to the WWSBR_EVENT_Q queue, refer to Example 16–10 . For an example of how to run a subscriber, refer to Example 16–11 .

16.8 Example: Integrating External Workflow

Organizations often find that they want to integrate their business processes into their enterprise portal. Using the capabilities of Oracle Workflow, you can implement portals to route information of any type according to the compliance rules defined for your organization. With CMEF, you can integrate both traditional, applications-based workflow and e-business integration workflow with your Oracle Portal content management system. This section provides an example of how to integrate external workflow with the Oracle Portal content management system.

16.8.1 Integrating Workflow with Oracle Portal

Oracle Workflow is a component of Oracle Application Server and Oracle E-Business Suite that enables you to design internal business processes and store them in a central repository. You can use Oracle Workflow to support a wide variety of compliance mandates, designing processes that are both auditable and repeatable, and enforce pre-set approvals and limits. Oracles newest compliance solution, Oracle Internal Controls Manager Oracle ICM works in conjunction with Oracle Workflow to monitor internal business processes and ensure they are performed as designed. In general, there are five steps involved in integrating Oracle Workflow with the Oracle Portal content management system for content approval, and these steps are as follows: 1. Enable approvals and notifications in Oracle Portal. 2. Grant users the Manage Items With Approval privileges. 3. Create a portal user that will be used by the Oracle Workflow process to either approve or reject items and add that user to the portal approval process. 4. Register the workflow process with Oracle Workflow. This workflow process calls your compliance process, or it may perform your actual compliance process. 5. Create subscriber code and add the subscriber to WWSBR_EVENT_Q to process CMEF events. This subscriber initializes the workflow engine and then calls the workflow process. We can see how this works by modifying the item validation example described in Section 16.7, Example: Item Validation to call a workflow process to perform the item validation. Lets take a look at how this process would work, based on the diagram in Figure 16–7 . Using the Content Management Event Framework 16-31 Figure 16–7 Process Flow for Workflow Integration with Oracle Portal

16.8.2 Example Overview

Figure 16–7 shows the process flow diagram for using CMEF to integrate Oracle Workflow with the Oracle Portal content management system. When a user with Manage Items With Approval privileges adds an item to the portal, that item is marked as pending. Just as with the ITEM_VALIDATION subscriber in Example 16–16 , an Oracle Streams Advanced Queuing subscriber is required to listen for events on the WWSBR_EVENT_Q queue see Example 16–17 . If the event is of type SUBMIT_ ITEM_FOR_APPROVAL, the subscriber launches the workflow engine process, WF_ CHECKURL, and passes the parameters for the portal item to the workflow process. The workflow process calls an external PLSQL procedure see Example 16–18 to perform its business logic, which in this case includes either approving or rejecting the portal item. If the user specifies a URL, then Oracle Workflow approves the item using the wwsbr_ api.approve API. Otherwise, Oracle Workflow rejects the item using the wwsbr_ api.reject API. This example assumes the following prerequisites: ■ The CMEFSAMPLES schema exists in the same database as the portal schema. ■ The Oracle OWF_MGR workflow schema is installed in the same database as the portal schema. ■ The AQ_TM_PROCESSES parameter should be set to at least five. To check this, log in to the database as the SYS user and execute the following query: select value from vparameter where name = aq_tm_processes; If the value is less than five, then set the value as follows: 16-32 Oracle Fusion Middleware Developers Guide for Oracle Portal alter system set aq_tm_processes=5; ■ Restart your database. ■ Oracle Portal 11g has been installed.

16.8.3 Detailed Example Description

When a portal user with Manage Items With Approval privileges adds an item to a page, a SUBMIT_ITEM_FOR_APPROVAL event is added to the WWSBR_EVENT_Q queue. The item is marked as pending on the portal page. This users items must be approved before they are made visible on the page. The Streams Advanced Queuing subscriber CMEF_WORKFLOW listens for events on WWSBR_EVENT_Q. If the event is of type SUBMIT_ITEM_FOR_APPROVAL, then it launches the workflow engine process and passes the parameters for the portal item to the workflow process. The workflow process WF_CHECKURL performs its business logic, which in this case includes either approving or rejecting portal items.WF_ CHECKURL uses the views and APIs to approve or reject the item. If it approves the item, then an APPROVE_ ITEM event is added to WWSBR_EVENT_Q. If it rejects the item, then a REJECT_ ITEM event is added to WWSBR_EVENT_Q. When the user refreshes the page, he or she will either see the item published on the page if it was approved, or removed if it was rejected. The following six steps occur within this example: 1. Section 16.8.3.1, Enable Approvals and Notifications in Oracle Portal

2. Section 16.8.3.2, Grant Users the Manage Items With Approval Privileges

3. Section 16.8.3.3, Run Scripts Required for the CMEF Workflow Integration Example

4. Section 16.8.3.4, Create Subscriber and Check Procedures

5. Section 16.8.3.5, Register the WF_CHECKURL Process with Oracle Workflow

6. Section 16.8.3.6, Add the CMEF_WORKFLOW Subscriber to the WWSBR_ EVENT_Q Queue Each of these steps is described in more detail in the following sections.

16.8.3.1 Enable Approvals and Notifications in Oracle Portal

The first thing you need to do is enable approvals and notifications in the page group. To enable approvals and notifications, perform the following steps: 1. Go to any page of the page group and switch to Edit mode.

2. In the toolbar at the top of the page, click the Properties link next to Page Group.

3. Click the Configure tab to bring it forward.

4. In the Approvals and Notifications section you can see whether approvals and notifications are enabled or disabled. If you want to change this setting, click the Edit link Figure 16–8 . Note: Make sure you click the link next to Page Group and not the one next to Page Figure 16–2 . Using the Content Management Event Framework 16-33 Figure 16–8 Status of Approvals and Notifications for a Page Group

5. To enable approvals and notifications, select the Enable Approvals and

Notifications check box Figure 16–9 . Figure 16–9 Enabling or Disabling Approvals and Notifications for a Page Group

6. Click OK to save your changes.

7. Click Close to return to the page.

16.8.3.2 Grant Users the Manage Items With Approval Privileges

The next step is to grant Manage Items With Approval privileges to all users who need approval for their items. For the purposes of this example, lets specify that all users require approval for their items. To specify that all users require approval for their items, perform the following steps:

1. Go to any page in the page group and switch to Edit mode.

2. In the toolbar at the top of the page, click the Properties link next to Page Group.

3. Click the Approval tab to bring it forward.

4. Select the Require Approval for All Users check box

Figure 16–10 . Note: You can skip this step if your external workflow process does not require the approval or rejection of portal items. Note: Make sure you click the link next to Page Group and not the one next to Page Figure 16–2 .