Create Subscriber and Check Procedures

Using the Content Management Event Framework 16-37 l_portal_user_name varchar230 := portal; l_portal_password varchar230 := portal password; begin -- Get the values for the attributes stored in the procedure. l_url := wf_engine.getitemattrtextitemtype,itemkey,PORTAL_URL,l_ignore; l_itemid := wf_engine.getitemattrnumberitemtype,itemkey,PORTAL_ITEM_ID,l_ ignore; l_siteid := wf_engine.getitemattrnumberitemtype,itemkey,PORTAL_SITE_ID,l_ ignore; -- Set the portal context. portal.wwctx_api.set_contextl_portal_user_name, l_portal_password; -- If the item type is a URL item and no URL is specified. if l_url is null then begin -- Update the item to indicate that the URL needs to be specified. l_desc := font color=REDNO URL SPECIFIEDfont; -- Reset the CMEF global variables. wwsbr_api.clear_cmef_context; wwsbr_api.set_attribute p_site_id = l_siteid, p_thing_id = l_itemid, p_attribute_site_id = l_attribute_site_id, p_attribute_id = wwsbr_api.attribute_description, p_attribute_value = l_desc p_log_cmef_message = FALSE ; -- Reject the item. wwsbr_api.reject p_item_id = l_itemid, p_site_id = l_siteid, p_is_indirect = l_is_indirect, p_comment = Rejected ; -- Reset the CMEF global variables. wwsbr_api.clear_cmef_context; end; else -- Approve the item. begin wwsbr_api.approve p_item_id = l_itemid, p_site_id = l_siteid, p_comment = Approved ; -- Reset the CMEF global variables. wwsbr_api.clear_cmef_context; end; end if; commit; -- Process cache invalidation messages. wwpro_api_invalidation.execute_cache_invalidation; exception when OTHERS then dbms_output.put_linesqlerrm; end check_url; 16-38 Oracle Fusion Middleware Developers Guide for Oracle Portal

16.8.3.5 Register the WF_CHECKURL Process with Oracle Workflow

The WF_CHECKURL process actually approves or rejects the portal item and sends the e-mail notification. You need to register this process with Oracle Workflow using the Oracle Workflow Builder Figure 16–11 . Figure 16–11 The CHECK_FILE Oracle Workflow Process Use the following steps to install the WF_CHECKURL process into the OWF_MGR schema: 1. Open the Oracle Workflow Builder.

2. Start a new workflow project.

3. Save the workflow project as wf_checkurl.wft.

4. Close the Oracle Workflow Builder.

5. Open wf_checkurl.wft in a text editor, for example, Notepad.

6. Copy and paste the WF_CHECKURL code into the file. You can download this

code from Portal Center: http:www.oracle.comtechnologyproductsiasportalfilescm_ overview_10g1014_cmef_samples.zip

7. Save the file and close the text editor.

8. Open wf_checkurl.wft in Oracle Workflow Builder.

9. Save wf_checkurl.wft into your portal database using the OWF_MGR schema.

Note: CMEFSAMPLES will need to grant execute on WORKFLOW_ APPROVAL and CHECK_URL to OWF_MGR: grant execute on workflow_approval to owf_mgr; grant execute on check_filename to owf_mgr; Tip: After installing the Workflow Builder, you may have to run it from the command line because you will have to set the ORACLE_ HOME environment variable to that of the Workflow Builder. For example: set ORACLE_HOME=c:\oraclewf Using the Content Management Event Framework 16-39

16.8.3.6 Add the CMEF_WORKFLOW Subscriber to the WWSBR_EVENT_Q Queue

Next, you need to add the CMEF_WORKFLOW subscriber to the WWSBR_EVENT_Q queue so that it can process the CMEF events and trigger the WF_CHECKURL Oracle Workflow process, as shown in Example 16–19 . Example 16–19 Adding the CMEF_WORKFLOW Subscriber to WWSBR_EVENT_Q declare subscriber sys.aq_agent; begin 1_subscriber := sys.aq_agentCMEF_WORKFLOW, null, null; dbms_aqadm.add_subscriber queue_name = portal.wwsbr_event_q, 1_subscriber = subscriber ; end; Now, when a user with Manage Items With Approval privileges add an item to a page, it is marked as Pending and a single INSERT event occurs, with a state of NOT_ PUBLISHED: The CMEF_WORKFLOW_APPROVAL subscriber responds to this action and invokes the PORTAL_ITEM_WORKFLOW Oracle Workflow process. The PORTAL_ITEM_APPROVAL Oracle Workflow process performs its business logic and calls the Oracle Portal approve or reject API to approve or reject the item. It also sends an e-mail notification to the specified e-mail ID indicating the approval status. Tip: If you do not know the OWF_MGR password, see MetaLink Note 198800.1. Action Event State Object Class SUBMIT_ITEM_FOR_ APPROVAL INSERT NOT_PUBLISHED ITEM 16-40 Oracle Fusion Middleware Developers Guide for Oracle Portal Part IV Part IV Appendixes Part IV contains the following appendixes: ■ Appendix A, Creating Portlets with the Portlet Builder ■ Appendix B, Troubleshooting Portlets and Providers ■ Appendix C, Mapping Profile Items to Attributes ■ Appendix D, Manually Packaging and Deploying PDK-Java Providers ■ Appendix E, Oracle Portal Provider Test Suite ■ Appendix F, Content Management APIs and Views ■ Appendix G, Content Management Event Framework Events