Providing Access to the APIs and Secure Views

9-6 Oracle Fusion Middleware Developers Guide for Oracle Portal l_new_item_master_id2 := wwsbr_api.add_item p_caid = l_caid, p_folder_id = l_folder_id, ... ; wwsbr_api.clear_cmef_context; ... For more information about CMEF, refer to Chapter 16, Using the Content Management Event Framework .

9.4.6 Using Predefined Exceptions

The API packages contain many predefined exceptions. When coding with the content management APIs, it is good practice to include the appropriate predefined exceptions rather than relying on the WHEN OTHERS exception to pick up all errors. This also has the advantage that any error messages generated by the code can be more specific to the actual problem. Example 9–2 shows some of the exceptions you might include when calling the wwsbr_api.set_attribute API. Example 9–2 Using Predefined Exceptions begin wwsbr_api.set_attribute p_site_id = 37, p_thing_id = 8056, p_attribute_site_id = wwsbr_api.SHARED_OBJECTS, p_attribute_id = wwsbr_api.ATTRIBUTE_TITLE, p_attribute_value = New Display Name ; -- Process cache invalidation messages. wwpro_api_invalidation.execute_cache_invalidation; exception when wwsbr_api.ITEM_NOT_FOUND_ERROR then dbms_output.put_lineItem does not exist; when wwsbr_api.ATTRIBUTE_NOT_FOUND then dbms_output.put_lineAttribute does not exist; when wwsbr_api.ITEM_NOT_FOR_UPDATE then dbms_output.put_lineCannot update an item with a status of Rejected, Deleted or Marked for Delete; when wwsbr_api.NOT_AUTHORIZED_USER then dbms_output.put_lineUser trying to update the item is not the current user or the user who checked the item out; when wwsbr_api.EDIT_CUSTOM_ATTR then dbms_output.put_lineError while trying to update a custom attribute; when OTHERS then dbms_output.put_lineError ||to_charsqlcode||: ||sqlerrm; end; For a full list of the exceptions available in each API package, refer to the Oracle Portal PLSQL API Reference on Portal Center: http:portalcenter.oracle.com Tip: When using predefined exceptions, remember to include the name of the package that owns it, for example wwsbr_api.PAGE_ NOT_FOUND. Content Management API Introduction 9-7 In the Portal Focus Areas section, click Portlet Development, then in the APIs and References section, click PLSQL API Reference.

9.4.7 Naming Objects

When creating page groups and page group objects, you specify a unique internal name for the object p_name. Internal names must: ■ be no more than 60 characters in length. ■ not contain spaces or special characters other than the underscore character _.

9.5 Guidelines for Using the Secure Views

When using the secure views described in this manual, you should follow the best practice guidelines described in the following sections.

9.5.1 Identifying Primary Keys

The primary key for most objects contains the object id, the page group id caid, and the language. When joining between views, always use these columns in the JOIN clause. Example 9–3 shows the JOIN when joining an item to its page. Example 9–3 Joining an Item to Its Page select ... from wwsbr_all_items i, wwsbr_all_folders p where i.folder_id = p.id and i.caid = p.caid and i.language = p.language

9.5.2 Querying Translatable Objects

If an object is translatable that is, it resides in a page group for which translations are enabled and it includes languages in its key, you must observe the following rules: ■ If the object or its current version is translated, a row will exist for the translation. To select the row for the current session language, compare the value of the language column to the function wwctx_api.get_nls_language. ■ If the object is not translated, select the row for the page groups default language. Example 9–4 selects the translated page display name for all pages in a given page group. Example 9–4 Selecting a Translated Page Display Name select p.display_name title from wwsbr_all_folders p where p.caid = 53 and p.language = wwctx_api.get_nls_language -- The current language. or exists -- A row for the page in the page group default language. Note: In this release, there is no supported view of the document table in the repository. A secure view of the document table is planned for a future release.