create or replace package body odwapred is /***************************************************************************************** Purpose To implement the privilege palettes for odwapred Usage Remarks Revision history When Who Construct Revision What ------------------------------------------------------------------------------------------ $REVISION_HISTORY$ 27-Mar-2003 Kannan Parthasarathy -B713248: Fixed. 10-Dec-2002 Kannan Parthasarathy -B2663635: Fixed Javascript function. 15-oct-2002 Kannan Parthasarathy - Hide Role management features that aren't possible in Designer 26-feb-2001 Lucas Jellema 1.6 - issue 213: cannot edit Role Grant [odwa project/213%] - added a close_palette to procedure editRoleGrant 23-feb-2001 Lucas Jellema 1.4 - issue 210 - revoke privs under All Containers from PUBLIC - hard to reproduce, hard coded delete from sdw_access_rights as a last resort. 14-feb-2001 Lucas Jellema 1.3 - when you select folder or application system in All Containers node, no property palette is shown 07-feb-2001 Lucas Jellema 1.2 - slightly improved logging 29-jan-2001 Lucas Jellema 1.1 - role cannot be granted to itself 19-jan-2001 Lucas Jellema 1.0 *****************************************************************************************/ -- -- private constants -- REVISION_LABEL constant varchar2(30) := '$x.y::1.6 $'; PACKAGE_NAME constant varchar2(30) := 'ODWAPRED'; check_gif constant varchar2(200):= cdwp.add_images ('{check_mark.gif}'); g_action_report varchar2(32000); procedure reset_report is begin g_action_report:= ''; end; -- reset_report procedure add_line ( p_text in varchar2 ) is begin if length( p_text) > 0 then g_action_report:= g_action_report||p_text||chr(13)||chr(10); end if; end; -- add_line procedure add ( p_text in varchar2 ) is begin g_action_report:= g_action_report||p_text; end; -- add function handle_exception return varchar2 is l_oracle_error_message varchar2(4000); l_message varchar2(100); l_stack varchar2(16000); arg0 varchar2(5000); arg1 varchar2(5000); arg2 varchar2(5000); arg3 varchar2(5000); arg4 varchar2(5000); arg5 varchar2(5000); arg6 varchar2(5000); arg7 varchar2(5000); arg8 varchar2(5000); msg_fac varchar2(100); msg_code varchar2(100); procedure write( p_text in varchar2) is begin l_stack:= l_stack ||chr(10)||chr(13)||p_text ; end; -- write begin if cdapi.stacksize > 0 then while cdapi.stacksize > 0 loop cdapi.get_message ( cdapi.stacksize , msg_fac , msg_code ,arg1 ,arg2,arg3,arg4,arg5,arg6,arg7,arg8 ); if instr( arg8, 'UDM') > 0 -- User Defined Message then -- now pop the message to remove it from the message stack! cdapi.pop_message ( msg_fac , msg_code ,arg1 ,arg2,arg3,arg4,arg5,arg6,arg7,arg8 ); write( msg_fac||'-'||msg_code||':'||arg7||arg6||arg5 ||cdwpbase.ifThenElse( arg6 <> '', ', '||arg6) ||cdwpbase.ifThenElse( arg5 <> '', ', '||arg5) ||cdwpbase.ifThenElse( arg4 <> '', ', '||arg6) ||cdwpbase.ifThenElse( arg3 <> '', ', '||arg7) ); else write(cdapi.pop_instantiated_message); end if; end loop; if cdapi.activity is not null then cdapi.abort_activity; write('Activity aborted with API errors.'); else write('API Session aborted with API errors.'); end if; else l_oracle_error_message := sqlcode||' '||sqlerrm; if cdapi.activity is not null then cdapi.abort_activity; l_message := 'Activity aborted'; else l_message := 'API Session aborted'; end if; if l_oracle_error_message = '1 User-Defined Exception' then write(l_message||'.'); else write(l_message||' with ORACLE internal errors.'); write(l_oracle_error_message ); end if; end if; return l_stack; end handle_exception; procedure open_palette ( p_title in varchar2 , p_him_id in number default null ) is begin htp.tableopen( cattributes => 'WIDTH="100%" BORDER="0" CELLSPACING=0 CELLPADDING=0 BGCOLOR="#CCCC99"'); -- 1.4 bgcolor="88DDF9" htp.tablerowopen; htp.p(''); htp.tableopen( cattributes => 'WIDTH="100%" BORDER=0 CELLSPACING="1" BGCOLOR="#FFFFFF"'); -- 1.4 bgcolor="88DDF9" htp.p(''); htp.p ( '' ||p_title ||cdwpbase.ifThenElse ( p_him_id is not null , cdwpbase.nbsp(5) ||odwahelp.help_url(p_him_id => p_him_id, p_top => true) ) ||' '); htp.p(''); end; -- open_palette procedure close_palette is begin htp.tableclose; htp.tableclose; end; -- close_palette procedure print_property ( p_property_name in varchar2 ,p_property_value in varchar2 ,p_property_display_value in varchar2 default null ,p_mandatory in varchar2 default 'N' ,p_property_value2 in varchar2 default null ,p_property_value3 in varchar2 default null ,p_two_columns in boolean default true ) is begin htp.tableRowOpen; htp.p ( '' ||'' ||cdwpbase.ifThenElse ( (nvl(p_mandatory,'N')='Y') , '' -- red for mandatory properties , '' -- black for optional properties ) ||replace( substr( p_property_name, 1, 14),' ', cdwpbase.nbsp(1)) ||substr( p_property_name, 15) ||'' ||'' ||'' ); htp.TableData ( cvalue=> '' ||'' || nvl ( nvl ( p_property_display_value , p_property_value ) , cdwpbase.nbsp ) ||'' ||'' ); if not p_two_columns or p_property_value2 is not null then htp.TableData ( cvalue=> '' ||'' || nvl ( p_property_value2 , cdwpbase.nbsp ) ||'' ||'' ); end if; if not p_two_columns or p_property_value3 is not null then htp.TableData ( cvalue=> '' ||'' || nvl ( p_property_value3 , cdwpbase.nbsp ) ||'' ||'' ); end if; htp.tableRowClose; end; --print_property procedure print_privilege ( p_privilege in varchar2 , p_value in varchar2 -- Y or something else ) is begin print_property ( p_property_name => p_privilege , p_property_value => cdwpbase.ifThenElse ( p_value = 'Y' , cdwp.add_images ('{check_mark.gif}') , '-' ) ); end; -- print_privilege -- 'DEL' , 'ADM', 'INS', 'SEL', 'UPD', 'VER', 'CMP', 'UPD_SPEC'; procedure role_privs ( p_grantee in varchar2 , p_role in varchar2 ) is l_grantee_acc_privs varchar2(20); l_role_name varchar2(30) := odwapriv.proper( p_role); l_role_irid number(38) := odwapriv.get_role_irid( p_role_name => l_role_name); l_grantee varchar2(30) := odwapriv.proper( p_grantee); l_grantee_type varchar2(1) := odwapriv.get_grantee_type( p_grantee => p_grantee); -- R(ole) or U(ser) cursor c_acc ( b_role_name in varchar2 , b_grantee in varchar2 ) is select rle.username role_name , acc.object_reference role_irid , acc.grantor_reference , acc.date_created , acc.date_changed , acc.access_privs , rle.created_by from sdw_users rle , sdw_access_rights acc where acc.grantee_reference = b_grantee and acc.object_reference = rle.irid and rle.username = b_role_name ; begin print_property( Rob_msg.getMsg(Rob_msg.CAP329_ODWAPRED_ROLE, '', '', '', ''), l_role_name ); print_property ( Rob_msg.getMsg(Rob_msg.CAP330_ODWAPRED_GRANTEE, '', '', '', '') , cdwpbase.ifThenElse ( l_grantee_type = 'U' , cdwp.add_images('{user.gif}') , cdwp.add_images('{role.gif}') ) ||l_grantee ); for r_acc in c_acc ( b_role_name => l_role_name , b_grantee => l_grantee ) loop l_grantee_acc_privs:= jr_acc_rights.ar_to_str ( r_acc.access_privs ); if l_grantee_type = 'U' then print_privilege(Rob_msg.getMsg(Rob_msg.CAP331_ODWAPRED_GROPTION, '', '', '', ''), substr(l_grantee_acc_privs, 2,1)); print_privilege(Rob_msg.getMsg(Rob_msg.CAP332_ODWAPRED_DELOPTION, '', '', '', ''), substr(l_grantee_acc_privs, 1,1)); print_privilege(Rob_msg.getMsg(Rob_msg.CAP333_ODWAPRED_RECOPTION, '', '', '', ''), substr(l_grantee_acc_privs, 7,1)); if l_grantee = r_acc.grantor_reference then print_privilege(Rob_msg.getMsg(Rob_msg.CAP334_ODWAPRED_ISOWNER, '', '', '', ''), 'Y'); else print_privilege(Rob_msg.getMsg(Rob_msg.CAP334_ODWAPRED_ISOWNER, '', '', '', ''), '-'); end if; end if; print_property( Rob_msg.getMsg(Rob_msg.CAP335_ODWAPRED_GRANTOR, '', '', '', ''), r_acc.grantor_reference); print_property( Rob_msg.getMsg(Rob_msg.CAP336_ODWAPRED_ROWNER, '', '', '', ''), nvl( odwapriv.get_role_owner(l_role_name ),odwapriv.get_role_owner(l_role_name )) ); print_property( Rob_msg.getMsg(Rob_msg.CAP337_ODWAPRED_DATECR, '', '', '', ''), to_char( r_acc.date_created, 'dd-mon-yyyy hh24:mi')); print_property( Rob_msg.getMsg(Rob_msg.CAP338_ODWAPRED_DATECH, '', '', '', ''), to_char( r_acc.date_changed, 'dd-mon-yyyy hh24:mi')); end loop; -- r_acc end; -- role_privs procedure object_privs ( p_grantee in varchar2 , p_irid in varchar2 ) is l_grantee_acc_privs varchar2(20); l_grantee varchar2(30) := odwapriv.proper( p_grantee); l_grantee_type varchar2(1) := odwapriv.get_grantee_type( p_grantee => p_grantee); -- R(ole) or U(ser) cursor c_acc ( b_irid in number , b_grantee in varchar2 ) is select acc.object_reference role_irid , acc.grantor_reference , acc.date_created , acc.date_changed , acc.access_privs , acc.object_type from sdw_access_rights acc where acc.grantee_reference = b_grantee and acc.object_reference = b_irid ; begin print_property ( Rob_msg.getMsg(Rob_msg.CAP330_ODWAPRED_GRANTEE, '', '', '', '') , cdwpbase.ifThenElse ( l_grantee_type='U' , cdwp.add_images('{user.gif}') , cdwp.add_images('{role.gif}') ) ||p_grantee ); print_property ( Rob_msg.getMsg(Rob_msg.CAP339_ODWAPRED_OBJECT, '', '', '', '') , odwapriv.get_object_label( p_irid) ); for r_acc in c_acc ( b_irid => p_irid , b_grantee => l_grantee ) loop l_grantee_acc_privs:= jr_acc_rights.ar_to_str ( r_acc.access_privs ); -- 'DEL' , 'ADM', 'INS', 'SEL', 'UPD', 'VER', 'CMP', 'UPD_SPEC'; print_privilege(Rob_msg.getMsg(Rob_msg.CAP340_ODWAPRED_SELECT, '', '', '', ''), substr(l_grantee_acc_privs, 4,1)); print_privilege(Rob_msg.getMsg(Rob_msg.CAP342_ODWAPRED_INSERT, '', '', '', ''), substr(l_grantee_acc_privs, 3,1)); print_privilege(Rob_msg.getMsg(Rob_msg.CAP341_ODWAPRED_UPDATE, '', '', '', ''), substr(l_grantee_acc_privs, 5,1)); print_privilege(Rob_msg.getMsg(Rob_msg.CAP343_ODWAPRED_DELETE, '', '', '', ''), substr(l_grantee_acc_privs, 1,1)); print_privilege(Rob_msg.getMsg(Rob_msg.CAP344_ODWAPRED_VERSION, '', '', '', ''), substr(l_grantee_acc_privs, 6,1)); print_privilege(Rob_msg.getMsg(Rob_msg.CAP345_ODWAPRED_ADMIN, '', '', '', ''), substr(l_grantee_acc_privs, 2,1)); if r_acc.object_type ='WA' then print_privilege(Rob_msg.getMsg(Rob_msg.CAP346_ODWAPRED_COMPILE, '', '', '', ''), substr(l_grantee_acc_privs, 7,1)); print_privilege(Rob_msg.getMsg(Rob_msg.CAP347_ODWAPRED_EDITSPEC, '', '', '', ''), substr(l_grantee_acc_privs, 8,1)); end if; if l_grantee_type = 'U' then if l_grantee = r_acc.grantor_reference then print_privilege(Rob_msg.getMsg(Rob_msg.CAP334_ODWAPRED_ISOWNER, '', '', '', ''), 'Y'); end if; end if; print_property( Rob_msg.getMsg(Rob_msg.CAP335_ODWAPRED_GRANTOR, '', '', '', ''), r_acc.grantor_reference); print_property( Rob_msg.getMsg(Rob_msg.CAP206_ODWAPROP_OWNER, '', '', '', ''), odwapriv.get_governor(p_irid )); print_property( Rob_msg.getMsg(Rob_msg.CAP337_ODWAPRED_DATECR, '', '', '', ''), to_char( r_acc.date_created, 'dd-mon-yyyy hh24:mi')); print_property( Rob_msg.getMsg(Rob_msg.CAP338_ODWAPRED_DATECH, '', '', '', ''), to_char( r_acc.date_changed, 'dd-mon-yyyy hh24:mi')); end loop; -- r_acc end; -- object_privs procedure object_in_wa_privs ( p_grantee in varchar2 , p_irid in number , p_wa_irid in number ) is l_object_acc_privs varchar2(20); l_wa_acc_privs varchar2(20); l_grantee_acc_privs varchar2(20); l_grantee varchar2(30) := odwapriv.proper( p_grantee); l_grantee_type varchar2(1) := odwapriv.get_grantee_type( p_grantee => p_grantee); -- R(ole) or U(ser) cursor c_acc ( b_irid in number , b_grantee in varchar2 ) is select acc.object_reference role_irid , acc.grantor_reference , acc.date_created , acc.date_changed , acc.access_privs , acc.object_type from sdw_access_rights acc where acc.grantee_reference = b_grantee and acc.object_reference = b_irid ; r_acc_wa c_acc%rowtype; r_acc_object c_acc%rowtype; begin open c_acc ( b_irid => p_irid , b_grantee => l_grantee ); fetch c_acc into r_acc_object ; close c_acc; open c_acc ( b_irid => p_wa_irid , b_grantee => l_grantee ); fetch c_acc into r_acc_wa ; close c_acc; l_object_acc_privs:= jr_acc_rights.ar_to_str ( r_acc_object.access_privs ); l_wa_acc_privs := jr_acc_rights.ar_to_str ( r_acc_wa.access_privs ); for i in 1..length(l_object_acc_privs) loop if substr( l_object_acc_privs, i, 1) = 'Y' and substr( l_wa_acc_privs, i, 1) = 'Y' then l_grantee_acc_privs:= l_grantee_acc_privs||'Y'; else l_grantee_acc_privs:= l_grantee_acc_privs||'N'; end if; end loop; -- 'DEL' , 'ADM', 'INS', 'SEL', 'UPD', 'VER', 'CMP', 'UPD_SPEC'; print_property ( Rob_msg.getMsg(Rob_msg.CAP330_ODWAPRED_GRANTEE, '', '', '', '') , cdwpbase.ifThenElse ( l_grantee_type='U' , cdwp.add_images('{user.gif}') , cdwp.add_images('{role.gif}') ) ||p_grantee , p_two_columns => false ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP043_CDWP_CONTEXT, '', '', '', '') , p_property_value => Rob_msg.getMsg(Rob_msg.CAP077_ODWACHCK_WA, '', '', '', '') , p_property_value2 => Rob_msg.getMsg(Rob_msg.CAP348_ODWAPRED_CON, '', '', '', '') , p_two_columns => false ); print_property ( p_property_name =>cdwpbase.nbsp(1) , p_property_value => odwapriv.get_object_label( p_wa_irid) , p_property_value2 => odwapriv.get_object_label( p_irid) , p_property_value3 => cdwp.add_images('{folder.gif}') ||' in ' ||cdwp.add_images('{workarea.gif}') , p_two_columns => false ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP340_ODWAPRED_SELECT, '', '', '', '') , p_property_value => substr(l_wa_acc_privs, 4,1) , p_property_value2 => substr(l_object_acc_privs, 4,1) , p_property_value3 => cdwpbase.ifThenElse ( substr(l_grantee_acc_privs, 4,1) = 'Y' , check_gif , '-' ) , p_two_columns => false ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP342_ODWAPRED_INSERT, '', '', '', '') , p_property_value => substr(l_wa_acc_privs, 3,1) , p_property_value2 => substr(l_object_acc_privs, 3,1) , p_property_value3 => cdwpbase.ifThenElse ( substr(l_grantee_acc_privs, 3,1) = 'Y' , check_gif , '-' ) , p_two_columns => false ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP341_ODWAPRED_UPDATE, '', '', '', '') , p_property_value => substr(l_wa_acc_privs, 5,1) , p_property_value2 => substr(l_object_acc_privs, 5,1) , p_property_value3 => cdwpbase.ifThenElse ( substr(l_grantee_acc_privs, 5,1) = 'Y' , check_gif , '-' ) , p_two_columns => false ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP343_ODWAPRED_DELETE, '', '', '', '') , p_property_value => substr(l_wa_acc_privs, 1,1) , p_property_value2 => substr(l_object_acc_privs, 1,1) , p_property_value3 => cdwpbase.ifThenElse ( substr(l_grantee_acc_privs, 1,1) = 'Y' , check_gif , '-' ) , p_two_columns => false ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP344_ODWAPRED_VERSION, '', '', '', '') , p_property_value => substr(l_wa_acc_privs, 6,1) , p_property_value2 => substr(l_object_acc_privs, 6,1) , p_property_value3 => cdwpbase.ifThenElse ( substr(l_grantee_acc_privs, 6,1) = 'Y' , check_gif , '-' ) , p_two_columns => false ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP345_ODWAPRED_ADMIN, '', '', '', '') , p_property_value => substr(l_wa_acc_privs, 2,1) , p_property_value2 => substr(l_object_acc_privs, 2,1) , p_property_value3 => cdwpbase.ifThenElse ( substr(l_grantee_acc_privs, 2,1) = 'Y' , check_gif , '-' ) , p_two_columns => false ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP335_ODWAPRED_GRANTOR, '', '', '', '') , p_property_value => r_acc_wa.grantor_reference , p_property_value2 => r_acc_object.grantor_reference , p_two_columns => false ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP206_ODWAPROP_OWNER, '', '', '', '') , p_property_value => odwapriv.get_governor(p_wa_irid ) , p_property_value2 => odwapriv.get_governor(p_irid ) , p_two_columns => false ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP337_ODWAPRED_DATECR, '', '', '', '') , p_property_value => to_char( r_acc_wa.date_created, 'dd-mon-yyyy hh24:mi') , p_property_value2 => to_char( r_acc_object.date_created, 'dd-mon-yyyy hh24:mi') , p_two_columns => false ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP338_ODWAPRED_DATECH, '', '', '', '') , p_property_value => to_char( r_acc_wa.date_changed, 'dd-mon-yyyy hh24:mi') , p_property_value2 => to_char( r_acc_object.date_changed, 'dd-mon-yyyy hh24:mi') , p_two_columns => false ); end; -- object_in_wa_privs procedure fol_props ( p_fol_irid in number ) is cursor c_fol ( b_fol_irid in number ) is select fol.date_created , fol.created_by , fol.date_changed , fol.changed_by , fol.owning_user , fol.remark from i$sdd_folders fol where fol.irid = b_fol_irid and fol.ivid = cdwpbase.get_best_ivid( fol.irid) ; r_fol c_fol%rowtype; begin open c_fol( b_fol_irid => p_fol_irid); fetch c_fol into r_fol; close c_fol; print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP019_CDWP_NAME, '', '', '', '') , p_property_value => odwapriv.get_object_label( p_fol_irid) ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP206_ODWAPROP_OWNER, '', '', '', '') , p_property_value => r_fol.owning_user ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP023_CDWP_COMMENT, '', '', '', '') , p_property_value => r_fol.remark ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP337_ODWAPRED_DATECR, '', '', '', '') , p_property_value => to_char( r_fol.date_created, 'dd-mon-yyyy hh24:mi') ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP349_ODWAPRED_CREATOR, '', '', '', '') , p_property_value => r_fol.created_by ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP338_ODWAPRED_DATECH, '', '', '', '') , p_property_value => to_char( r_fol.date_changed, 'dd-mon-yyyy hh24:mi') ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.DSP250_ODWAINFO_MODBY, '', '', '', '') , p_property_value => r_fol.changed_by ); end; -- fol_props procedure wa_props ( p_wa_irid in number ) is cursor c_wa ( b_wa_irid in number ) is select wa.owner , wa.name , wa.date_created , wa.created_by , wa.date_changed , wa.changed_by , wa.description from i$sdd_workareas wa where wa.irid = b_wa_irid ; r_wa c_wa%rowtype; begin open c_wa( b_wa_irid => p_wa_irid); fetch c_wa into r_wa; close c_wa; print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP019_CDWP_NAME, '', '', '', '') , p_property_value => cdwp.add_images('{workarea.gif}') ||r_wa.name ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP206_ODWAPROP_OWNER, '', '', '', '') , p_property_value => r_wa.owner ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP008_CDWP_DESC, '', '', '', '') , p_property_value => r_wa.description ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP337_ODWAPRED_DATECR, '', '', '', '') , p_property_value => to_char( r_wa.date_created, 'dd-mon-yyyy hh24:mi') ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP349_ODWAPRED_CREATOR, '', '', '', '') , p_property_value => r_wa.created_by ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP338_ODWAPRED_DATECH, '', '', '', '') , p_property_value => to_char( r_wa.date_changed, 'dd-mon-yyyy hh24:mi') ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.DSP250_ODWAINFO_MODBY, '', '', '', '') , p_property_value => r_wa.changed_by ); end; -- wa_props procedure cfg_props ( p_cfg_irid in number ) is cursor c_cfg ( b_cfg_irid in number ) is select cfg.date_created , cfg.created_by , cfg.date_changed , cfg.changed_by , cfg.description , cfg.name , acc.grantor_reference owner from i$sdd_configurations cfg , sdw_access_rights acc where cfg.irid = b_cfg_irid and cfg.ivid = cdwpbase.get_best_ivid( cfg.irid) and acc.object_reference = cfg.irid and acc.grantor_reference = acc.grantee_reference ; r_cfg c_cfg%rowtype; begin open c_cfg( b_cfg_irid => p_cfg_irid); fetch c_cfg into r_cfg; close c_cfg; print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP019_CDWP_NAME, '', '', '', '') , p_property_value => cdwp.add_images('{configuration.gif}') ||r_cfg.name ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP206_ODWAPROP_OWNER, '', '', '', '') , p_property_value => r_cfg.owner ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP008_CDWP_DESC, '', '', '', '') , p_property_value => r_cfg.description ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP337_ODWAPRED_DATECR, '', '', '', '') , p_property_value => to_char( r_cfg.date_created, 'dd-mon-yyyy hh24:mi') ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP349_ODWAPRED_CREATOR, '', '', '', '') , p_property_value => r_cfg.created_by ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP338_ODWAPRED_DATECH, '', '', '', '') , p_property_value => to_char( r_cfg.date_changed, 'dd-mon-yyyy hh24:mi') ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.DSP250_ODWAINFO_MODBY, '', '', '', '') , p_property_value => r_cfg.changed_by ); end; -- cfg_props procedure user_props ( p_username in varchar2 ) is cursor c_usr ( b_username in varchar2 ) is select usr.full_user_name , usr.date_created , usr.date_changed , usr.created_by , usr.changed_by , usr.description , usr.sdd_owner , usr.status -- , jr_sys_privs.ar_to_str(usr.system_privs) from sdw_users usr where usr.username = b_username ; r_usr c_usr%rowtype; begin open c_usr( b_username => p_username); fetch c_usr into r_usr; close c_usr; print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP350_ODWAPRED_USER, '', '', '', '') , p_property_value => p_username ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP351_ODWAPRED_FULLUSER, '', '', '', '') , p_property_value => r_usr.full_user_name ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP008_CDWP_DESC, '', '', '', '') , p_property_value => r_usr.description ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP337_ODWAPRED_DATECR, '', '', '', '') , p_property_value => to_char( r_usr.date_created, 'dd-mon-yyyy hh24:mi') ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP349_ODWAPRED_CREATOR, '', '', '', '') , p_property_value => r_usr.created_by ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.CAP338_ODWAPRED_DATECH, '', '', '', '') , p_property_value => to_char( r_usr.date_changed, 'dd-mon-yyyy hh24:mi') ); print_property ( p_property_name => Rob_msg.getMsg(Rob_msg.DSP250_ODWAINFO_MODBY, '', '', '', '') , p_property_value => r_usr.changed_by ); end; -- user_props function check_upd_users return boolean IS repos_owner VARCHAR2(30); curr_user VARCHAR2(30):=USER; BEGIN repos_owner:=jr_sys_privs.get_repos_owner; IF (curr_user!=repos_owner) AND NOT jr_sys_privs.has_privilege(curr_user,'MANAGE_USERS') THEN --Insufficient privileges to manage users. return false; ELSE return true; END IF; exception when others then return false; END; procedure saveRoleGrant ( p_session_id in number default null , p_role_name in varchar2 , p_grantee in varchar2 , p_grant_option in varchar2 default 'N' , p_delete_option in varchar2 default 'N' , p_reconcile_option in varchar2 default 'N' , p_reconcile in varchar2 default 'N' ) is l_grantee_type varchar2(1):= odwapriv.get_grantee_type(p_grantee => p_grantee); begin odwactxt.update_context ( p_session_id => p_session_id , p_package_name => PACKAGE_NAME , p_procedure_name=> 'saveRoleGrant' ); reset_report; add_line ( 'Granting role ' ||p_role_name ||' to ' ||p_grantee); -- try to perform the roleGrant. If this does not succeed, return with -- error message to the grant role page -- else move on to the node_selected page begin add_line('... granting '||p_role_name); jr_role.grant_role ( p_role_to_grant => p_role_name , p_grantee => p_grantee , p_grant_option => p_grant_option ='Y' , p_delete_option => p_delete_option ='Y' , p_reconcile_option => p_reconcile_option ='Y' , p_reconcile => p_reconcile ='Y' , p_override => true ); add_line(' Successfully Granted access roles to ' ||cdwpbase.ifThenElse( l_grantee_type='U','USER','ROLE') ||' '||p_grantee ); action_report ( p_session_id => p_session_id , p_node_value => p_grantee , p_node_type => '{TYPE='||cdwpbase.ifThenElse( l_grantee_type='U','USER','ROLE')||'}' , p_root_value => '{TYPE='||cdwpbase.ifThenElse( l_grantee_type='U','USER','ROLE')||'}' , p_root_classification => '{TYPE='||cdwpbase.ifThenElse( l_grantee_type='U','USER','ROLE')||'}' , p_refresh_tree => true , p_action_report => g_action_report , p_display_label => 'Granted role '||p_role_name||' to ' ||cdwpbase.ifThenElse( l_grantee_type='U','USER','ROLE') ||' '||p_grantee ); exception when others then odwapred.grantRole ( p_session_id => odwactxt.get_session_id , p_role_name => p_role_name , p_grantee => p_grantee , p_grant_option => p_grant_option , p_delete_option => p_delete_option , p_reconcile_option => p_reconcile_option , p_reconcile => p_reconcile , p_error_message => sqlerrm ); end; end; -- saveRoleGrant procedure saveNewRoleGrant ( p_session_id in number default null , p_role_name in varchar2 , p_grantee in owa_util.ident_arr , p_grant_option in varchar2 default 'N' , p_delete_option in varchar2 default 'N' , p_reconcile_option in varchar2 default 'N' , p_reconcile in varchar2 default 'N' ) is begin odwactxt.update_context ( p_session_id => p_session_id , p_package_name => PACKAGE_NAME , p_procedure_name=> 'saveRoleGrant' ); reset_report; add_line (' Granting Role '||p_role_name||' to Users/Roles' ); if p_grant_option = 'Y' then add_line(' - with Grant option'); end if; if p_delete_option = 'Y' then add_line(' - with Delete option'); end if; if p_reconcile_option = 'Y' then add_line(' - with Reconcile option'); end if; if p_reconcile = 'Y' then add_line('---------------------------------------------------'); add_line('Perform reconcile of all new Role/User combinations'); end if; -- try to perform the roleGrant. If this does not succeed, return with -- error message to the grant role page -- else move on to the node_selected page for i in 1..p_grantee.count loop begin jr_role.grant_role ( p_role_to_grant => p_role_name , p_grantee => p_grantee(i) , p_grant_option => p_grant_option ='Y' , p_delete_option => p_delete_option ='Y' , p_reconcile_option => p_reconcile_option ='Y' , p_reconcile => p_reconcile ='Y' , p_override => true ); add_line(' to '||p_grantee(i)); exception when others then odwapred.grantRole ( p_session_id => odwactxt.get_session_id , p_role_name => p_role_name , p_grantee => p_grantee(i) , p_grant_option => p_grant_option , p_delete_option => p_delete_option , p_reconcile_option => p_reconcile_option , p_reconcile => p_reconcile , p_error_message => sqlerrm ); end; end loop; -- i in 1..p_grantee.count loop add_line(' Successfully Granted access privileges'); action_report ( p_session_id => p_session_id , p_node_value => p_role_name , p_node_type => '{TYPE=ROLE}' , p_root_value => '{TYPE=ROLE}' , p_root_classification => '{TYPE=ROLE}' , p_refresh_tree => true , p_action_report => g_action_report , p_display_label => 'Granted role '||p_role_name||' to Users/Roles' ); end; -- saveNewRoleGrant procedure saveGranteesNewRoleGrants ( p_session_id in number default null , p_role_name in owa_util.ident_arr , p_grantee in varchar2 , p_grant_option in varchar2 default 'N' , p_delete_option in varchar2 default 'N' , p_reconcile_option in varchar2 default 'N' , p_reconcile in varchar2 default 'N' ) is l_grantee_type varchar2(1):= odwapriv.get_grantee_type(p_grantee => p_grantee); begin odwactxt.update_context ( p_session_id => p_session_id , p_package_name => PACKAGE_NAME , p_procedure_name=> 'saveRoleGrant' ); reset_report; -- try to perform the roleGrant. If this does not succeed, return with -- error message to the grant role page -- else move on to the node_selected page add_line ( 'Granting role' ||cdwpbase.ifThenElse ( p_role_name.count > 1 ,'s' ) ||' to ' ||p_grantee); for i in 1..p_role_name.count loop begin add_line('... granting '||p_role_name(i)); jr_role.grant_role ( p_role_to_grant => p_role_name(i) , p_grantee => p_grantee , p_grant_option => p_grant_option ='Y' , p_delete_option => p_delete_option ='Y' , p_reconcile_option => p_reconcile_option ='Y' , p_reconcile => p_reconcile ='Y' , p_override => true ); exception when others then odwapred.grantRole ( p_session_id => odwactxt.get_session_id , p_role_name => p_role_name(1) , p_grantee => p_grantee , p_grant_option => p_grant_option , p_delete_option => p_delete_option , p_reconcile_option => p_reconcile_option , p_reconcile => p_reconcile , p_error_message => sqlerrm ); end; end loop; -- i in 1..p_role_name.count loop add_line(' Successfully Granted access roles to ' ||cdwpbase.ifThenElse( l_grantee_type='U','USER','ROLE') ||' '||p_grantee ); action_report ( p_session_id => p_session_id , p_node_value => p_grantee , p_node_type => '{TYPE='||cdwpbase.ifThenElse( l_grantee_type='U','USER','ROLE')||'}' , p_root_value => '{TYPE='||cdwpbase.ifThenElse( l_grantee_type='U','USER','ROLE')||'}' , p_root_classification => '{TYPE='||cdwpbase.ifThenElse( l_grantee_type='U','USER','ROLE')||'}' , p_refresh_tree => true , p_action_report => g_action_report , p_display_label => 'Granted roles to ' ||cdwpbase.ifThenElse( l_grantee_type='U','USER','ROLE') ||' '||p_grantee ); end; -- saveGranteesNewRoleGrants procedure grantToGrantee ( p_session_id in number default null , p_role_name in varchar2 default null , p_grantee in varchar2 , p_grant_option in varchar2 default null , p_delete_option in varchar2 default null , p_reconcile_option in varchar2 default null , p_reconcile in varchar2 default null , p_error_message in varchar2 default null ) is l_role_list varchar2(10000); cursor c_rle( b_grantee in varchar2) is select usr.username role_name , usr.irid role_irid from sdw_users usr where usr.user_type = 0 and usr.username <> 'PUBLIC' and usr.username <> b_grantee -- do not grant role to itself and not exists ( select 'x' from sdw_access_rights acc where acc.object_reference = usr.irid and acc.grantee_reference = b_grantee ) order by usr.username ; begin odwactxt.update_context ( p_session_id => p_session_id , p_package_name => PACKAGE_NAME , p_procedure_name=> 'grantToGrantee' ); htp.htmlOpen; htp.headOpen; cdwp.write_about(package_name, revision_label); htp.headClose; htp.bodyOpen(cattributes=>'BGCOLOR="#FFFFFF"'); open_palette ( 'Grant role '||p_role_name ||' to '||p_grantee , p_him_id => 686 ); if p_error_message is not null then -- errorMessage print_property ( 'Error' , 'Try Again: '||p_error_message||'' , p_mandatory=> 'Y' ); end if; -- p_error_message is not null htp.formopen ( curl => 'odwapred.saveGranteesNewRoleGrants' , cmethod => 'POST' , cattributes => 'NAME="roleGrantForm" ' , ctarget => '' ); htp.p ( ' ' ); -- Roles l_role_list:= htf.formselectopen ( cname => 'p_role_name' , cprompt => '' , nsize => 5 , cattributes => 'MULTIPLE' ); for r_rle in c_rle( b_grantee => p_grantee) loop if jr_acc_rights.has_access ( object_irid => r_rle.role_irid , grantee => USER , privilege => 'ADM' ) OR odwapriv.get_role_owner( r_rle.role_name) = USER -- user must have reconcile privilege on the role then l_role_list:= l_role_list ||'