Using Error Handling Implementing Error Handling

8-40 Oracle Fusion Middleware Developers Guide for Oracle Portal wwerr_api_error.add DOMAIN, SUBDOMAIN, securityerr, services_portlet.show; raise wwpro_api_provider.PORTLET_SECURITY_EXCEPTION; end if; 4. The show procedure also checks for any other kind of execution mode and generates an appropriate error message for an invalid display mode. if p_portlet_record.exec_mode = wwpro_api_provider.MODE_SHOW then ... elsif p_portlet_record.exec_mode = wwpro_api_provider.MODE_SHOW_EDIT ... else wwerr_api_error.addDOMAIN, SUBDOMAIN, invaliddispmode, services_portlet.show; raise wwpro_api_provider.PORTLET_EXECUTION_EXCEPTION; end if; 5. Lastly, the show procedure implements a general error message in the exception handler to catch any errors not trapped by the preceding conditions. exception when others then wwerr_api_error.add DOMAIN, SUBDOMAIN, generalerr, services_portlet.show; raise wwpro_api_provider.PORTLET_EXECUTION_EXCEPTION; end show; 6. Error handling is also implemented in the save_prefs and save_default_ prefs procedures. They check whether the error stack is empty and, if it is not, the portlet makes a call to wwerr_api_error.show_html to display the error in full screen mode. exception when INVALID_TEXT_EXCEPTION then l_information := l_user||||l_time ||INVALID_TEXT_EXCEPTION||p_string; l_action := LOG_FAILED; wwlog_api.log p_domain = DOMAIN, p_subdomain = SUBDOMAIN, p_name = l_user, p_action = l_action, p_information = l_information, p_url = l_url, p_row_count = 0, p_elapsed_time= l_elapsed_time; wwerr_api_error.addDOMAIN, SUBDOMAIN, invalid_text, services_portlet.save_prefs; if not wwerr_api_error.is_empty then wwerr_api_error_ui.show_html; end if; end save_prefs; 7. Optionally, if you want to see this portlet on a page and it is not already in the Portlet Repository, refer to the instructions in Section 8.3.2, Implementing the Provider Package for information on how to add it. Creating PLSQL Portlets 8-41 8. Once your portlet appears in the repository, you can add it to a page to test it. To add your portlet to a page, follow the instructions in Oracle Fusion Middleware Users Guide for Oracle Portal.

8.10 Implementing Event Logging

Oracle Portal can log events that occur during transactions with its objects. It stores these logs in the database, which makes them available through standard SQL calls and reporting tools. You can choose the events you would like to log and organize them categorically based on user-defined domains and subdomains. For the logged events, you can view information about the event, the time the event started and stopped, the host or IP address of the remote user, the browser type, and the language. Event logging services are available through the wwlog_api and wwlog_api_admin packages. These services include the following key features: ■ Event logs are useful for tracking specific usage of the portal. To track such information, you create a log event. Log events require a name space that consists of the following: – Name , which is the event name. – Domain , which is the area of the product where the event occurred. – Subdomain , which is the subsystem that generated the event. The default domains include the portal WWC, application WWV, and page group WWS. Each domain is further classified into subdomains that define the object types. The portal domain includes the portlet, page, and document object types. The application domain includes object types such as forms, menus, reports, and charts. The page group domain includes object types such as folders, items, categories, and perspectives. Events themselves could be of types such as add, delete, personalize, hide, copy, execute, and export. If you need to define an event that does not fall within these classifications, you can define your own domain with subdomains for your events. ■ Logs can track information in the following two ways: – Interval logging calculates the elapsed time for the action performed for example, the time taken to render a portlet. – Event logging logs the occurrence of a single step event you care about for example, whenever a user personalizes a portlet. ■ Log switching enables you to set a switch interval that defines how long you want to maintain your existing log records. The log information stored in the database uses two different tables. The log records are purged based on the value entered for the Activity Log Interval in the Configuration tab of Global Settings accessible from the Services portlet in the Portal subtab of the Administer tab. When the log interval in days is reached, the logging switches between the two logging tables in the database for example, A and B. Logs first go into A. When the log interval is reached the first time, the logs are written to B. When the log interval is reached again, the logs go back to A. A is emptied in preparation to store the new log records. If you set your log interval to 14 the default setting, the logs will switch every 14 days, thus preserving for you, at any point in time, records dated between 14 and 28 days old.