/*=======================================================================+ | Copyright (c) 2000 Oracle Corporation Redwood Shores, California, USA| | All rights reserved. | +=======================================================================+ | FILENAME | wfevsetb.pls | DESCRIPTION | PL/SQL body for package: WF_SETUP | NOTE | | MODIFICATION LOG: | 01/2002 JWSMITH BUG 2001012 - Increased username, admin_role to | varchar2(320) *=======================================================================*/ REM Added driver autogenrate instructions REM dbdrv: sql ~PROD ~PATH ~FILE none none none package &phase=plb \ REM dbdrv: checkfile:~PROD:~PATH:~FILE set arraysize 1 set scan off SET VERIFY OFF WHENEVER SQLERROR EXIT FAILURE ROLLBACK; WHENEVER OSERROR EXIT FAILURE ROLLBACK; create or replace package body WF_SETUP as /* $Header: wfevsetb.pls 26.26 2004/06/02 17:41:53 dlam ship $ */ function GetLocalSystemGUID return raw is lguid varchar2(32); begin select substr(TEXT, 1, 32) into lguid from WF_RESOURCES where NAME = 'WF_SYSTEM_GUID' and LANGUAGE = userenv('LANG'); return hextoraw(lguid); exception when no_data_found then wf_core.raise('WFE_NO_SYSTEM'); when OTHERS then wf_core.context('WF_SETUP', 'GetLocalSystemGUID'); raise; end GetLocalSystemGUID; function GetLocalSystem return varchar2 is lsys varchar2(30); begin select S.NAME into lsys from WF_SYSTEMS S, WF_RESOURCES R where R.NAME = 'WF_SYSTEM_GUID' and R.LANGUAGE = userenv('LANG') and S.GUID = hextoraw(R.TEXT); return (lsys); exception when OTHERS then wf_core.context('WF_SETUP', 'GetLocalSystem'); raise; end GetLocalSystem; procedure Check_InitParameters is cursor pcurs is select NAME, VALUE from v$parameter where NAME in ('aq_tm_processes', 'job_queue_processes', 'job_queue_interval') order by NAME; hTab wfe_html_util.headerTabType; dTab wfe_html_util.dataTabType; i pls_integer; vTab wfe_html_util.tmpTabType; begin -- set the recommended values i := 1; vTab(i) := '1'; -- for aq_tm_processes i := i+1; vTab(i) := '5'; -- for job_queue_interval i := i+1; vTab(i) := '2'; -- for job_queue_processes i := 0; for pr in pcurs loop i := i+1; dTab(i).col01 := pr.name; dTab(i).col02 := pr.value; if (i <= 3) then dTab(i).col03 := vTab(i); end if; dTab(i).selectable := FALSE; dTab(i).deletable := FALSE; dTab(i).hasdetail := FALSE; end loop; -- popluate the header table i := 1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('NAME'); hTab(i).attr := 'id="t_name"'; i := i+1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('VALUE'); hTab(i).attr := 'ALIGN=RIGHT id="t_value"'; i := i+1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('VALUE_RECOMMENDED'); hTab(i).attr := 'ALIGN=RIGHT id="t_value_rec"'; htp.p('
'||wf_core.translate('WFE_INITPARAMS')||''); -- ### Database Init.ora Parameters -- render table Wfe_Html_Util.Simple_Table(hTab, dTab); exception when OTHERS then wf_core.context('WF_SETUP', 'Check_InitParameters'); wfe_html_util.Error; end Check_InitParameters; procedure Check_Dblinks( localsguid raw ) is -- all db link cursor dblcurs is select distinct substr(ADDRESS, instr(ADDRESS, '@')+1) NAME from WF_AGENTS where PROTOCOL = 'SQLNET' and DIRECTION = 'IN' and SYSTEM_GUID <> localsguid; hTab wfe_html_util.headerTabType; dTab wfe_html_util.dataTabType; i pls_integer; begin -- populate the data table i := 0; for dblr in dblcurs loop i := i+1; dTab(i).guid := null; dTab(i).col01:= dblr.name; -- find out if such dblr.name exists begin select 'EXIST' into dTab(i).col02 from sys.dual where upper(dblr.name) in ( select DB_LINK from USER_DB_LINKS union all select DB_LINK from ALL_DB_LINKS where OWNER = 'PUBLIC'); exception when NO_DATA_FOUND then dTab(i).col02 := 'NOT_EXIST'; when OTHERS then raise; end; dTab(i).col02 := wf_core.translate(dTab(i).col02); dTab(i).selectable := FALSE; dTab(i).deletable := FALSE; dTab(i).hasdetail := FALSE; end loop; -- popluate the header table i := 1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('NAME'); hTab(i).attr := 'id="t_name"'; i := i+1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('STATUS'); hTab(i).attr := 'id="t_status"'; htp.p('
'||wf_core.translate('WFE_DBLINKS')||''); -- ### Database Links -- render table Wfe_Html_Util.Simple_Table(hTab, dTab); exception when OTHERS then rollback; wf_core.context('WF_SETUP', 'Check_Dblinks'); wfe_html_util.Error; end Check_Dblinks; procedure Check_Queues( localsguid raw ) is cursor lquecurs is select A.GUID, A.NAME, A.DIRECTION, A.QUEUE_NAME from WF_AGENTS A where A.SYSTEM_GUID = localsguid and A.PROTOCOL = 'SQLNET'; hTab wfe_html_util.headerTabType; dTab wfe_html_util.dataTabType; i pls_integer; include_create boolean := FALSE; creatable boolean; l_qid number; begin null; -- populate the data table i := 0; for lquer in lquecurs loop i := i+1; dTab(i).guid := lquer.guid; dTab(i).col01:= lquer.name; if (lquer.direction is null) then dTab(i).col02:= ' '; else dTab(i).col02:= wf_core.translate(lquer.direction); end if; dTab(i).col03:= nvl(lquer.queue_name, ' '); -- check existence creatable := FALSE; begin select DQ.QID into l_qid from ALL_QUEUES DQ where lquer.queue_name = DQ.OWNER||'.'||DQ.NAME and QUEUE_TYPE = 'NORMAL_QUEUE'; dTab(i).col04 := 'YES'; exception when NO_DATA_FOUND then dTab(i).col04 := 'NO'; creatable := TRUE; when OTHERS then raise; end; dTab(i).col04 := wf_core.translate(dTab(i).col04); -- if queue not exist, do not count message if (creatable) then dTab(i).col05 := '-'; dTab(i).col06 := '-'; -- find out the message count else begin select to_char(v.ready), to_char(v.waiting) into dTab(i).col05, dTab(i).col06 from gv$aq v where v.qid = l_qid; exception when NO_DATA_FOUND then dTab(i).col05 := '-'; dTab(i).col06 := '-'; end; end if; dTab(i).selectable := FALSE; dTab(i).deletable := FALSE; dTab(i).hasdetail := FALSE; end loop; -- popluate the header table i := 1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('AGENT'); hTab(i).attr := 'id="t_agent"'; i := i+1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('DIRECTION'); hTab(i).attr := 'id="t_direction"'; i := i+1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('QUEUE_NAME'); hTab(i).attr := 'id="t_queue"'; i := i + 1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('QUEUE_CREATED'); hTab(i).attr := 'id="t_queue_created"'; i := i + 1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('MESSAGE_READY'); hTab(i).attr := 'ALIGN=RIGHT id="t_message_ready"'; i := i + 1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('MESSAGE_WAIT'); hTab(i).attr := 'ALIGN=RIGHT id="t_message_wait"'; htp.p('
'||wf_core.translate('WFE_LOCAL_QUEUES')||''); -- ### Local Agents -- render table Wfe_Html_Util.Simple_Table(hTab, dTab); exception when OTHERS then rollback; wf_core.context('WF_SETUP', 'Check_Queues'); wfe_html_util.Error; end Check_Queues; procedure Check_Listeners( localsguid raw )is -- find all local queues that have direction of IN, ANY or undefined cursor lqcurs is select A.GUID, A.NAME from WF_AGENTS A where A.SYSTEM_GUID = localsguid and A.PROTOCOL = 'SQLNET' and A.STATUS = 'ENABLED' and (A.DIRECTION is null or A.DIRECTION in ('IN', 'ANY')); hTab wfe_html_util.headerTabType; dTab wfe_html_util.dataTabType; i pls_integer; creatable boolean; jobnum number; begin null; -- populate the data table i := 0; for lqr in lqcurs loop i := i + 1; dTab(i).guid := lqr.guid; dTab(i).col01:= lqr.name; -- check existence creatable := FALSE; begin -- lqr.name came from WF_AGENTS.NAME -- BINDVAR_SCAN_IGNORE[6] select 'YES' into dTab(i).col02 from WF_ALL_JOBS where upper(substr(WHAT, 1, 60)) like 'WF_EVENT.LISTEN('''||lqr.name||''')%' and rownum < 2; exception when NO_DATA_FOUND then dTab(i).col02 := 'NO'; creatable := TRUE; when OTHERS then raise; end; dTab(i).col02 := wf_core.translate(dTab(i).col02); -- append creation function if (creatable) then dTab(i).col03 := dTab(i).col03|| ''|| wf_core.translate('CREATE')|| ''; else dTab(i).col03 := dTab(i).col03|| ''|| wf_core.translate('EDIT')|| ''; end if; dTab(i).selectable := FALSE; dTab(i).deletable := FALSE; dTab(i).hasdetail := FALSE; end loop; -- popluate the header table i := 1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('AGENT'); hTab(i).attr := 'id="t_agent"'; i := i+1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('SCHEDULED'); hTab(i).attr := 'id="t_scheduled"'; i := i+1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('ACTION'); hTab(i).attr := 'id="t_action"'; htp.p('
'||wf_core.translate('WFE_LISTENERS')||''); -- ### Listeners for local queues. -- render table Wfe_Html_Util.Simple_Table(hTab, dTab); exception when OTHERS then rollback; wf_core.context('WF_SETUP', 'Check_Listeners'); wfe_html_util.Error; end Check_Listeners; procedure Check_Propagations( localsguid raw )is -- propagation for local system cursor ppgcurs is select OA.GUID OGUID, OA.NAME, OA.QUEUE_NAME OQUEUE, upper(substr(TA.ADDRESS, instr(TA.ADDRESS, '@')+1)) TOSYSTEM from WF_AGENTS OA, WF_AGENTS TA where OA.SYSTEM_GUID = localsguid and OA.PROTOCOL = 'SQLNET' and OA.DIRECTION = 'OUT' and TA.SYSTEM_GUID <> localsguid and TA.PROTOCOL = 'SQLNET' and TA.DIRECTION = 'IN' and TA.ADDRESS IS NOT NULL and TA.NAME <> 'WF_ERROR' and TA.SYSTEM_GUID in (select GUID from WF_SYSTEMS) union -- propgation to a local queue select A.GUID OGUID, A.NAME, A.QUEUE_NAME OQUEUE, NULL TOSYSTEM from WF_AGENTS A where A.SYSTEM_GUID = localsguid and A.PROTOCOL = 'SQLNET' and A.DIRECTION = 'OUT' order by TOSYSTEM; hTab wfe_html_util.headerTabType; dTab wfe_html_util.dataTabType; i pls_integer; creatable boolean; begin -- populate the data table i := 0; for ppgr in ppgcurs loop i := i + 1; dTab(i).guid := ppgr.oguid; dTab(i).col01:= ppgr.name; dTab(i).col02:= nvl(ppgr.tosystem,wf_core.translate('LOCAL')); -- in reality it is a db link --dTab(i).col02:= nvl(ppgr.tosystem, ' '); -- in reality it is a db link -- check out queue begin select NAME into dTab(i).col03 from WF_AGENTS where GUID = ppgr.oguid and (PROTOCOL <> 'SQLNET' or (DIRECTION is not null and DIRECTION = 'IN')); wf_core.token('NAME', dTab(i).col03); dTab(i).col03 := wf_core.translate('WFE_NOT_OUTAGENT'); exception when NO_DATA_FOUND then null; end; -- check system (dblink) exist -- ### maybe in the future. Assume it exists for now. -- check existence creatable := FALSE; if (dTab(i).col03 is null) then begin select null into dTab(i).col03 from sys.dual where exists ( select NULL from DBA_QUEUE_SCHEDULES QS where QS.DESTINATION = nvl(ppgr.tosystem, 'AQ$_LOCAL') and QS.SCHEMA||'.'||QS.QNAME = ppgr.oqueue); exception when NO_DATA_FOUND then creatable := TRUE; end; --if ppgr.tosystem = wf_core.translate('LOCAL') then -- ppgr.tosystem := null; --end if; if (creatable) then dTab(i).col03 := ''|| wf_core.translate('CREATE')|| ''; else dTab(i).col03 := ''|| wf_core.translate('EDIT')|| ''; end if; end if; dTab(i).selectable := FALSE; dTab(i).deletable := FALSE; dTab(i).hasdetail := FALSE; end loop; -- popluate the header table i := 1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('OUT_AGENT'); hTab(i).attr := 'id="t_out_agent"'; i := i + 1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('WFE_DBLINK'); hTab(i).attr := 'id="t_dblink"'; i := i + 1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('SCHEDULE'); hTab(i).attr := 'id="t_schedule"'; htp.p('
'||wf_core.translate('WFE_PROPAGATIONS')||''); -- ### Propagations for local out agents. -- render table Wfe_Html_Util.Simple_Table(hTab, dTab); exception when OTHERS then rollback; wf_core.context('WF_SETUP', 'Check_Propagations'); wfe_html_util.Error; end Check_Propagations; procedure Check_All is username varchar2(320); -- Username to query admin_role varchar2(320); -- Role for admin mode l_systems number; lguid raw(16); lsys varchar2(30); begin -- Check session and current user wfa_sec.GetSession(username); username := upper(username); -- Check Admin Priviledge admin_role := wf_core.translate('WF_ADMIN_ROLE'); if (admin_role = '*' or Wf_Directory.IsPerformer(username, admin_role)) then -- Have admin privledge, do nothing. null; else wf_core.raise('WF_NOTADMIN'); end if; -- Check if Accessible wf_event_html.isAccessible('SYSTEM'); lguid := Wf_Setup.GetLocalSystemGUID; lsys := Wf_Setup.GetLocalSystem; -- Render page htp.htmlOpen; -- Set page title htp.headOpen; -- list does not get updated after edit, so we add the -- following tag to force the reload of page. htp.p(''); htp.title(wf_core.translate('WFE_CHECK_ALL_TITLE')||'('||lsys||')'); wfa_html.create_help_function('wf/links/evt.htm?'||'EVTSETUP'); fnd_document_management.get_open_dm_display_window; Wfe_Html_Util.generate_confirm; htp.headClose; -- Page header wfa_sec.Header(FALSE, NULL, wf_core.translate('WFE_CHECK_ALL_TITLE')||'('||lsys||')', TRUE); htp.br; -- add some space between header and table Wf_Setup.Check_InitParameters; htp.br; Wf_Setup.Check_Dblinks(lguid); htp.br; Wf_Setup.Check_Queues(lguid); htp.br; Wf_Setup.Check_Listeners(lguid); htp.br; Wf_Setup.Check_Propagations(lguid); htp.br; wfa_sec.Footer; htp.htmlClose; exception when OTHERS then rollback; wf_core.context('WF_SETUP', 'Check_All'); wfe_html_util.Error; end Check_All; -- ### -- Create_Queue is not used for now -- procedure Create_Queue( aguid in raw )is lguid raw(16); sguid raw(16); qname varchar2(30); qtable varchar2(30); l_msg varchar2(4000); username varchar2(320); -- Username to query admin_role varchar2(320); -- Role for admin mode begin -- Check session and current user wfa_sec.GetSession(username); username := upper(username); -- Check Admin Priviledge admin_role := wf_core.translate('WF_ADMIN_ROLE'); if (admin_role = '*' or Wf_Directory.IsPerformer(username, admin_role)) then -- Have admin privledge, do nothing. null; else wf_core.raise('WF_NOTADMIN'); end if; -- check system is local lguid := Wf_Setup.GetLocalSystemGUID; begin select SYSTEM_GUID, substr(QUEUE_NAME,1,30) into sguid, qname from WF_AGENTS where GUID = aguid; exception when OTHERS then wf_core.raise('WFE_AGENT_NOTEXIST'); end; qtable := substr(qname,1,24)||'_TABLE'; if (lguid <> sguid) then wf_core.token('ENTITY', 'QUEUE'); wf_core.raise('WFE_SYSTEM_NOTLOCAL'); end if; -- create queue table dbms_aqadm.create_queue_table ( queue_table => qtable, queue_payload_type => wf_core.translate('WF_SCHEMA')||'.WF_EVENT_T', sort_list => 'ENQ_TIME', comment => 'Workflow event system default queue', compatible => '8.1', multiple_consumers => TRUE ); -- create queue dbms_aqadm.create_queue ( queue_name => qname, queue_table => qtable ); -- start queue dbms_aqadm.start_queue ( queue_name => qname ); commit; -- go back to check_all Wfe_Html_Util.gotoURL(p_url=>wfa_html.base_url||'/Wf_Setup.Check_All'); exception when OTHERS then rollback; wf_core.context('WF_SETUP', 'Create_Queue', rawtohex(aguid), qname, qtable); wfe_html_util.Error; end Create_Queue; -- -- List_Listener -- List the content of DBMS_JOB for a local agent -- procedure List_Listener( aguid in raw ) is -- nm came from WF_AGENTS.NAME -- BINDVAR_SCAN_IGNORE[4] cursor jobc(nm varchar2) is select JOB, WHAT, upper(INTERVAL) interval from WF_ALL_JOBS where upper(WHAT) like 'WF_EVENT.LISTEN('''||nm||''');'; username varchar2(320); -- Username to query admin_role varchar2(320); -- Role for admin mode aname varchar2(30); lguid raw(16); hTab wfe_html_util.headerTabType; dTab wfe_html_util.dataTabType; i pls_integer; l_url varchar2(2000); l_aguid raw(16); cookie owa_cookie.cookie; -- bad_cookie exception; -- Syntax error in cookie begin -- Check session and current user wfa_sec.GetSession(username); username := upper(username); -- Check Admin Priviledge admin_role := wf_core.translate('WF_ADMIN_ROLE'); if (admin_role = '*' or Wf_Directory.IsPerformer(username, admin_role)) then -- Have admin privledge, do nothing. null; else wf_core.raise('WF_NOTADMIN'); end if; -- get it from the cookie if aguid is not set if (aguid is null) then cookie := owa_cookie.get('WF_AGENT_GUID'); if (cookie.num_vals <> 1) then wf_core.raise('WFE_NO_COOKIE'); end if; l_aguid := hextoraw(cookie.vals(1)); else l_aguid := aguid; -- Send parameter values back to cookie. owa_util.mime_header('text/html', FALSE); owa_cookie.send('WF_AGENT_GUID', l_aguid); owa_util.http_header_close; end if; -- get local system lguid := Wf_Setup.GetLocalSystemGUID; -- check agent is local begin select NAME into aname from WF_AGENTS where GUID = l_aguid and SYSTEM_GUID = lguid; exception when OTHERS then wf_core.raise('WFE_AGENT_NOTEXIST'); end; i := 0; for jobr in jobc(aname) loop i := i+1; dTab(i).guid := hextoraw(to_char(jobr.JOB)); dTab(i).col01 := jobr.WHAT; dTab(i).col02 := jobr.INTERVAL; dTab(i).selectable := FALSE; dTab(i).deletable := TRUE; dTab(i).hasdetail := FALSE; end loop; i := 1; hTab(i).def_type := 'FUNCTION'; hTab(i).value := 'Wf_Setup.DeleteJob?h_url='|| wfa_html.base_url||'/Wf_Setup.List_Listener&h_job='; i := i+1; hTab(i).def_type := 'FUNCTION'; hTab(i).value := null; i := i+1; hTab(i).def_type := 'FUNCTION'; hTab(i).value := 'Wf_Setup.Edit_Listener?aguid='||rawtohex(l_aguid) ||'&url=' ||wfa_html.base_url||'/Wf_Setup.List_Listener&jobnum='; i := i+1; hTab(i).def_type := 'TITLE'; hTab(i).value := null; -- no detail title i := i+1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('EDIT'); hTab(i).attr := 'id="t_edit"'; i := i+1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('WHAT'); hTab(i).attr := 'id="t_what"'; i := i+1; hTab(i).def_type := 'TITLE'; hTab(i).value := wf_core.translate('INTERVAL'); hTab(i).attr := 'id="t_interval"'; -- Render page htp.htmlOpen; -- Set page title htp.headOpen; -- List does not get updated after edit, so we add the -- following tag to force the reload of page. -- Note that we do not expire the first page where the cookie is set. -- Setting cookie will refresh the page upon next visit. if (aguid is null) then htp.p(''); end if; htp.title(wf_core.translate('WFE_LIST_LISTENERS_TITLE')); wfa_html.create_help_function('wf/links/def.htm?'||'DEFLSNR'); fnd_document_management.get_open_dm_display_window; Wfe_Html_Util.generate_confirm; htp.headClose; -- Page header wfa_sec.Header(FALSE, NULL, wf_core.translate('WFE_LIST_LISTENERS_TITLE'), TRUE); htp.br; -- add some space between header and table Wfe_Html_Util.Simple_Table(headerTab=>hTab, dataTab=>dTab); htp.tableopen (calign=>'CENTER summary=""'); htp.tableRowOpen; htp.p('