rem rem $Header: L:\\\\model\\repman40\\api\\RCS\\ciapp.hpb 1.7 1999/01/05 20:24:24 cvanes Exp $ rem Rem Copyright (c) 1994 by Oracle Corporation Rem NAME Rem ciapp.hpb - Rem DESCRIPTION Rem Rem RETURNS Rem Rem NOTES Rem Rem MODIFIED (MM/DD/YY) Rem CvE 11/09/98 - added cihapp.set_access_rights Rem spatanka 07/18/96 - populate genertable_flag for Languages Rem CvE 09/07/95 - Maintain context on update Rem pscragg 10/14/94 - Major revisions, oh boy Rem jwetherb 09/08/94 - substr -> substrb Rem jwetherb 08/23/94 - provide default version for get_app_sys_ref() Rem jwetherb 08/23/94 - reset context appsys globals to null Rem aheath 07/08/94 - Creation CREATE OR REPLACE PACKAGE BODY cihapp IS Type t_Value_Type is record (name varchar2(20) ,datatype varchar2(20) ,lob_flag varchar2(1) ,derived_from binary_integer -- index number of source record ,el_id number -- store el_id for later use ); Type tt_Value_Type is table of t_Value_Type index by binary_integer; -- returns true if user has ADMIN privs on the given application-system FUNCTION app_admin_privs(bappid IN rm.reference) RETURN boolean; PROCEDURE check_delete(id number); -- Type-specific pre-process routines -- Type-specific post-process routines pac_type varchar2(10) := 'CEL'; pac_sub_type varchar2(10) := 'APP'; app_new_name varchar2(256); app_rename_app boolean; init_value_types tt_Value_Type; max_default_value_types number; --======================== PRE-PROCESS (INS,UPD) ============================-- PROCEDURE pre_process(operation varchar2,id rm.reference, pl in out NOCOPY cioapplication_system.data) IS dummy_cnt integer; app_id rm.reference; dummy_app_ver integer; parent_app rm.reference; -- ID of 'this' APP's parent app (used in update) app_cnt number; -- number of apps with same name as me BEGIN -- Access control checks (check for ORACLE Container "Manager" privileges) if not jr_sys_privs.has_privilege(USER,'MANAGE_CONTAINER') then ciierr.fatal(6064); end if; -- Validate user-defined properties if cieval.is_extended then cieval.check_element(id,pl.v.types,(operation='UPD') ,pl.v.user_defined_property_0,pl.i.user_defined_property_0 ,pl.v.user_defined_property_1,pl.i.user_defined_property_1 ,pl.v.user_defined_property_2,pl.i.user_defined_property_2 ,pl.v.user_defined_property_3,pl.i.user_defined_property_3 ,pl.v.user_defined_property_4,pl.i.user_defined_property_4 ,pl.v.user_defined_property_5,pl.i.user_defined_property_5 ,pl.v.user_defined_property_6,pl.i.user_defined_property_6 ,pl.v.user_defined_property_7,pl.i.user_defined_property_7 ,pl.v.user_defined_property_8,pl.i.user_defined_property_8 ,pl.v.user_defined_property_9,pl.i.user_defined_property_9 ,pl.v.user_defined_property_10,pl.i.user_defined_property_10 ,pl.v.user_defined_property_11,pl.i.user_defined_property_11 ,pl.v.user_defined_property_12,pl.i.user_defined_property_12 ,pl.v.user_defined_property_13,pl.i.user_defined_property_13 ,pl.v.user_defined_property_14,pl.i.user_defined_property_14 ,pl.v.user_defined_property_15,pl.i.user_defined_property_15 ,pl.v.user_defined_property_16,pl.i.user_defined_property_16 ,pl.v.user_defined_property_17,pl.i.user_defined_property_17 ,pl.v.user_defined_property_18,pl.i.user_defined_property_18 ,pl.v.user_defined_property_19,pl.i.user_defined_property_19 ); end if; -- Cannot have null or only spaces in NAME if (rtrim(pl.v.name) IS NULL) then ciierr.fatal(1301,'NAME'); end if; /* -- Commented out as this must be done on cloase activity to allow copy to work -- CvE 10Feb00 -- Uniqueness check CvE 13Aug98 if operation = 'INS' or pl.i.name then if operation = 'INS' then parent_app := cdapi.app_sys_ref; -- context app sys else -- parent_app may be null if top level select max(fm.folder_reference) into parent_app from sdd_folder_members fm where fm.member_object = pre_process.id; end if; -- Name uniqueness on application system if parent_app is null then -- top level app sys, so must be unique among other top level ones select count(*) into app_cnt from ci_application_systems app where not exists (select null from sdd_folder_members fm where fm.member_object = app.irid) and app.name = pl.v.name and app.irid != pre_process.id ; else -- ordinary app sys, so must be unique within its parent select count(*) into app_cnt from ci_application_systems app ,sdd_folder_members fm where fm.member_object = app.irid and fm.folder_reference = parent_app and app.name = pl.v.name and app.irid != pre_process.id ; end if; if app_cnt >= 1 then ciierr.fatal(6015,pl.v.name); end if; end if; */ -- Initialize unassigned properties with default values on INSERT if operation = 'INS' then -- assign_insert_defaults(pl); pl.v.element_type_name := pac_type; pl.i.element_type_name := true; pl.v.container_subtype := pac_sub_type; pl.i.container_subtype := true; pl.v.owning_user := USER; pl.i.owning_user := true; if cdapi.app_sys_ref is null then pl.v.root_flag := 'Y'; else pl.v.root_flag := 'N'; end if; pl.i.root_flag := true; -- Name uniqueness on application system now done in APPCEL code Cve 13Aug98 elsif operation = 'UPD' then if (pl.i.owning_user) then select count(1) into dummy_app_ver from ci_application_systems where id = pl.v.id and owning_user = user ; if (dummy_app_ver != 1) then ciierr.fatal(6017); -- only application owner can transfer end if; end if; -- no longer require ADMIN priv to update APP name CvE 13Aug98 app_rename_app := false; if (pl.i.name) then -- no longer require ADMIN priv to update APP name CvE 13Aug98 app_rename_app := true; app_new_name := pl.v.name; end if; end if; -- Check to see if Dictionary owners namehas changed if (operation in ('INS','UPD') and pl.i.owning_user) then select count(*) into dummy_app_ver from sdw_users where username = pl.v.owning_user ; if dummy_app_ver != 1 then ciierr.fatal(6016,pl.v.owning_user); --invalid dict user end if; end if; END; --======================== PRE-PROCESS (DEL,SEL) ============================-- PROCEDURE pre_process(operation varchar2,id rm.reference) IS dummy_cnt integer; BEGIN -- Access control checks (check for "Manager Container" privilege) if not jr_sys_privs.has_privilege(USER,'MANAGE_CONTAINER') then ciierr.fatal(6064); end if; -- Cannot delete application systems through CDAPI; use CASE Dictionary -- This is no longer the case CvE 09Nov98 --if operation = 'DEL' then -- ciierr.fatal(703); --end if; -- if operation is 'DELETE', make sure no non-cascading references exist if operation = 'DEL' then check_delete(id); end if; END; --===================== POST-PROCESS (INS,UPD,SEL) ==========================-- PROCEDURE post_process(operation varchar2,id rm.reference,pl cioapplication_system.data) IS app_id number; vat_types number; appstr_id number; appstr_ty number; BEGIN if operation = 'SEL' then return; end if; if operation = 'INS' then if cdapi.app_sys_ref is not null then ciiutl.create_appxxx('CEL',pl.v.id,pl.v.name); else -- check top level containers rmdbg.trace('Calling log_change'); rmman.log_change('CIHAPPCONU1',id); end if; elsif operation = 'UPD' and (pl.i.name) then if pl.v.root_flag = 'N' then rmdbg.trace('root flag is : '||pl.v.root_flag); cioapp_con_interface.traverse('CIHAPPCONU1',id,'APPCEL'); else -- check top level containers rmdbg.trace('Calling log_change'); rmman.log_change('CIHAPPCONU1',id); end if; end if; cihapp.set_access_rights(operation, 'APP', pl.v.id, pl.v.owning_user, pl.i.owning_user); if operation = 'UPD' and app_rename_app then cdapi.app_sys_name := app_new_name; end if; END; --========================= POST PROCESS (DEL) ==============================-- PROCEDURE post_process(operation varchar2,id rm.reference) IS BEGIN null; END; --======================= SET ACCESS RIGHTS ========================-- -- Called by APP, FOL and PCK PROCEDURE set_access_rights(operation varchar2, pac_sub_type varchar2, id number, owning_user varchar2, i_owning_user boolean) IS ar_irid number; context_cel_subtype varchar2(10); BEGIN if operation = 'INS' then if pac_sub_type in ('APP', 'PRJ', 'FOL') and cdapi.app_sys_ref is not null then select cel.container_subtype into context_cel_subtype from sdd_folders cel where cel.irid = cdapi.app_sys_ref; if context_cel_subtype = 'PCK' then -- %!0s : %!1s cannot own Containers which are not Packages ciierr.fatal(2205, ciiutl.identify(id, 'CEL'), ciiutl.identify(cdapi.app_sys_ref, 'CEL')); end if; end if; -- Create new entry in SDW_ACCESS_RIGHTS table ar_irid:=jr_acc_rights.ins(id,'CEL',jr_acc_rights.full_access_rights); elsif operation = 'UPD' then if i_owning_user then --If we're changing the owner of the app sys, then change the --governor of the object to be the new owner.... jr_acc_rights.change_governor(id ,owning_user); end if; end if; end set_access_rights; --============================= CHECK DELETE ================================-- PROCEDURE check_delete(id number) IS dummy number; error_count number := 0; BEGIN -- 4.0.12 Removed all simple delete checking -- Check if any elements are connected to me -- Bug 871125 - remove this check as this is handled by the delete triggers null; END; --==================== GET APPLICATION SYSTEM REFERENCE =====================-- FUNCTION get_app_sys_ref(app_name varchar2,app_version number default 1) RETURN rm.reference IS app_id rm.reference; BEGIN select min(id) into app_id from ci_application_systems where name = nls_upper(app_name); --and version = app_version; return(app_id); EXCEPTION when no_data_found then return(null); END; FUNCTION app_admin_privs(bappid IN rm.reference) RETURN boolean IS user_admin_priv varchar2(1); BEGIN --Check if current user has 'Manage Container' privilege return jr_sys_privs.has_privilege(USER,'MANAGE_CONTAINER'); /* select max(AR_ADMIN_ALLW) into user_admin_priv from sdw_access_rights where AR_USR_GRANTED_TO = user and AR_APPID_FOR = bappid ; if (user_admin_priv = 'Y') then return (true); end if; return(false);*/ END; FUNCTION is_app_empty(appid IN number) RETURN boolean IS cnt number(38); BEGIN -- Must check all owned and shared objects. Most caught in the APPXXX trap, -- but there are a few non-shareable PACs, which must be dealt with -- separately. FUNs have APPFUNs even though they are non-shareable! cnt := 0; select count(*) into cnt from sys.dual where exists (select null from sdd_folder_members -- was sdd_str_elements CvE 13Aug98 where folder_reference = appid ); /* Removed following conditions from above where clause Don't think they are still valid as LANs and ABTs will go into system folder now and element_type_name != 'APPLAN' and element_type_name != 'APPABT' */ if cnt > 0 then return false; else return true; end if; END; FUNCTION is_app_parent(appid IN number) RETURN boolean IS cnt number(38); BEGIN return false; /* cnt := 0; select count(*) into cnt from ci_application_systems aps where aps.parent_reference = appid; if cnt > 0 then return true; else return false; end if; */ END; --================================== END ====================================-- -- -- Package instantiation block -- BEGIN is_installed := true; -- Initialise Value Types init_value_types(1).name := 'Binary'; init_value_types(2).name := 'Boolean'; init_value_types(3).name := 'Date'; init_value_types(4).name := 'DateTime'; init_value_types(5).name := 'Integer'; init_value_types(6).name := 'Real'; init_value_types(7).name := 'String'; init_value_types(8).name := 'LargeString'; init_value_types(8).derived_from := 7; init_value_types(9).name := 'LargeBinary'; init_value_types(9).derived_from := 1; max_default_value_types := 9; for i in 1..7 loop init_value_types(i).datatype := upper(init_value_types(i).name); init_value_types(i).lob_flag := 'N'; init_value_types(i).derived_from := null; end loop; for i in 8..9 loop init_value_types(i).datatype := null; init_value_types(i).lob_flag := 'Y'; end loop; END; /