OTNCMS_ADMIN.plb

REM Copyright (c) 2003 Oracle Corporation. All rights reserved.

SET VERIFY OFF

WHENEVER SQLERROR EXIT FAILURE ROLLBACK;

CREATE OR REPLACE PACKAGE BODY OTNCMS_ADMIN IS

-- Type Declarations

-- package global variables
unexpected_error EXCEPTION;

-- package body

FUNCTION enqueue_privilege_request ( xmlRequest IN SYS.XMLType ) RETURN RAW AS

------------------------------------------------------------------ -- Created by : Elangovan -- Date created : 16-Dec-2002 -- -- Purpose: Enqueues the specified xmlRequest into 'Privilege_Queue'. -- -- Change History: (who, when, what:!) -- Who When What ------------------------------------------------------------------- eopt DBMS_AQ.ENQUEUE_OPTIONS_T; mprop DBMS_AQ.MESSAGE_PROPERTIES_T; messageId RAW(16);
BEGIN

DBMS_AQ.ENQUEUE( queue_name => 'privilege_queue', enqueue_options => eopt, message_properties => mprop, payload => xmlRequest , msgid => messageId ); COMMIT; RETURN messageId;
END enqueue_privilege_request;

FUNCTION process_message( messageId RAW, acceptRequest VARCHAR2 ) RETURN BINARY_INTEGER AS

------------------------------------------------------------------ -- Created by : Elangovan -- Date created : 16-Dec-2002 -- -- Purpose: Dequeues the message with the specified by messageId and -- Grant/Revoke privileges based on acceptRequest parameter. -- -- Change History: (who, when, what:!) -- Who When What -------------------------------------------------------------------

dopt DBMS_AQ.DEQUEUE_OPTIONS_T; mprop DBMS_AQ.MESSAGE_PROPERTIES_T; resourceloc VARCHAR2(1000); ace VARCHAR2(4000); privXML XMLType; requestXML XMLType; deq_msgid RAW(16); status BINARY_INTEGER;

BEGIN -- -- Set the message id of the message to be dequeued and processed -- dopt.msgid := messageId; dopt.wait := DBMS_AQ.NO_WAIT; deq_msgid := messageId; -- -- Dequeue the message into requestXML -- DBMS_AQ.DEQUEUE( queue_name => 'privilege_queue', dequeue_options => dopt, message_properties => mprop, payload => requestXML, msgid => deq_msgid );

-- -- If acceptRequest is 'Y', then process message, else discard the message -- IF acceptRequest = 'Y' THEN -- -- Process message --

-- Build ACE (Access Control Element) from the xml message ace := '<ace xmlns="http://xmlns.oracle.com/xdb/acl.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dav="DAV:"
xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd
DAV:http://xmlns.oracle.com/xdb/dav.xsd">';
--
-- Get the privileges that have to be either granted or revoked
--

ace := ace || requestXML.extract('//Request/Ace/*').getStringval() || '</ace>';
-- Resource path
resourceloc := requestXML.extract('//Request/ResourceLoc/text()').getstringval();

privXML := SYS.XMLType.createXML( ace );

status := DBMS_XDB.changePrivileges( resourceloc, privXML );
END IF;

COMMIT;

RETURN STATUS;

END process_message;

END OTNCMS_ADMIN;

/

SHOW ERRORS

COMMIT

/

E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy