1 PACKAGE BODY pos_url_pkg AS
2 /* $Header: POSURLB.pls 120.4.12010000.1 2008/07/25 12:06:39 appldev ship $ */
3
4 FUNCTION get_menu_function_context (p_notif_performer IN VARCHAR2) RETURN menu_function_parameter_rec
5
6 IS
7 l_menu_function_parameter_rec menu_function_parameter_rec;
8
9 BEGIN
10 IF p_notif_performer = 'BUYER' THEN
11 l_menu_function_parameter_rec.OAHP := 'POS_HT_SP_HP';
12 l_menu_function_parameter_rec.OASF := 'POS_HT_SP_B_SUPP';
13 ELSE
14 l_menu_function_parameter_rec.OAHP := 'ISP_HOMEPAGE_MENU';
15 l_menu_function_parameter_rec.OASF := 'POS_HOME';
16 END IF;
17 RETURN l_menu_function_parameter_rec;
18
19 END get_menu_function_context;
20
21
22 FUNCTION get_base_buyer_url RETURN VARCHAR2
23 IS
24 l_base_url VARCHAR2(240);
25 BEGIN
26
27 l_base_url := get_internal_url;
28 IF ( substr(l_base_url, -1, 1) = '/' ) THEN
29 RETURN l_base_url || 'OA_HTML/OA.jsp';
30 ELSE
31 RETURN l_base_url || '/' || 'OA_HTML/OA.jsp';
32 END IF;
33
34 RETURN l_base_url || 'OA_HTML/OA.jsp';
35
36 END get_base_buyer_url;
37
38 FUNCTION get_page_url (p_url_parameters_tab url_parameters_tab
39 ,p_notif_performer VARCHAR2) RETURN VARCHAR2
40 IS
41 i PLS_INTEGER;
42 l_page_url VARCHAR2(2000);
43
44 BEGIN
45
46 IF p_notif_performer = 'BUYER' THEN
47 l_page_url := get_base_buyer_url;
48 ELSE
49 l_page_url := get_base_buyer_url;
50 END IF;
51
52 -- appending each parameter as passed in
53 FOR i IN p_url_parameters_tab.FIRST..p_url_parameters_tab.LAST
54 LOOP
55 IF (i = 1) THEN
56 l_page_url := l_page_url || '?';
57 ELSE
58 l_page_url := l_page_url || '&';
59 END IF;
60
61 l_page_url := l_page_url || p_url_parameters_tab(i).name || '=' || p_url_parameters_tab (i).value;
62 END LOOP;
63
64 RETURN l_page_url;
65
66 END get_page_url;
67
68 FUNCTION get_dest_page_url ( p_dest_func IN VARCHAR2,
69 p_notif_performer IN VARCHAR2)
70
71 RETURN VARCHAR2
72 IS
73
74 l_url_parameters_tab url_parameters_tab;
75 l_menu_function_parameter_rec menu_function_parameter_rec;
76
77 BEGIN
78
79 l_menu_function_parameter_rec := get_menu_function_context(p_notif_performer => p_notif_performer);
80
81 -- This is the redirect page which will get these parameters and redirect
82 -- to the final page
83 l_url_parameters_tab(1).name := 'OAFunc';
84 l_url_parameters_tab(1).value := 'POS_NOTIF_LINK_REDIRECT';
85 l_url_parameters_tab(2).name := 'OAHP';
86 l_url_parameters_tab(2).value := l_menu_function_parameter_rec.OAHP;
87 l_url_parameters_tab(3).name := 'OASF';
88 l_url_parameters_tab(3).value := l_menu_function_parameter_rec.OASF;
89 l_url_parameters_tab(4).name := 'destFunc';
90 l_url_parameters_tab(4).value := p_dest_func;
91
92 -- This will be replaced by the actual notification id during runtime
93 l_url_parameters_tab(5).name := 'notificationId';
94 l_url_parameters_tab(5).value := 'NID';
95
96 RETURN get_page_url(p_url_parameters_tab => l_url_parameters_tab
97 ,p_notif_performer => p_notif_performer);
98 END get_dest_page_url;
99
100 -- Get the vendor id for the
101 FUNCTION get_ntf_vendor_id (p_ntf_id IN NUMBER) RETURN NUMBER
102 IS
103 CURSOR wf_item_cur IS
104 SELECT item_type,
105 item_key
106 FROM wf_item_activity_statuses
107 WHERE notification_id = p_ntf_id;
108
109 CURSOR wf_notif_context_cur IS
110 SELECT SUBSTR(context,1,INSTR(context,':',1)-1),
111 SUBSTR(context,INSTR(context,':')+1,
112 (INSTR(context,':',1,2) - INSTR(context,':')-1))
113 FROM wf_notifications
114 WHERE notification_id = p_ntf_id;
115
116 l_itemtype WF_ITEM_ACTIVITY_STATUSES.item_type%TYPE;
117 l_itemkey WF_ITEM_ACTIVITY_STATUSES.item_key%TYPE;
118
119 BEGIN
120
121 -- Fetch the item_type and item_key values from
122 -- wf_item_activity_statuses for a given notification_id.
123 OPEN wf_item_cur;
124 FETCH wf_item_cur INTO l_itemtype, l_itemkey;
125 CLOSE wf_item_cur;
126
127 -- If the wf_item_activity_statuses does not contain an entry,
128 -- then parse the wf_notifications.context field to
129 -- get the item_type and item_key values for a given notification_id.
130 IF ((l_itemtype IS NULL) AND (l_itemkey IS NULL))
131 THEN
132 OPEN wf_notif_context_cur;
133 FETCH wf_notif_context_cur INTO l_itemtype, l_itemkey;
134 CLOSE wf_notif_context_cur;
135 END IF;
136
137 if( l_itemkey is not null) then
138
139 return wf_engine.GetItemAttrNumber (itemtype => l_itemtype,
140 itemkey => l_itemkey,
141 aname => 'VENDOR_ID');
142 end if;
143
144 -- No Valid value found.
145 return -1;
146
147 END get_ntf_vendor_id;
148
149 -- this is a private package function
150 FUNCTION get_protocol_host_port (p_url IN VARCHAR2)
151 RETURN VARCHAR2
152 IS
153 l_position NUMBER;
154 l_value VARCHAR2(500);
155 BEGIN
156 l_value := p_url;
157
158 IF l_value IS NULL THEN
159 RETURN NULL;
160 END IF;
161
162 IF NOT owa_pattern.match(l_value, '^https?://.*', '') THEN
163 -- The url in the value of the profile option
164 -- is not a valid url. l_value is returned without further processing.
165 RETURN l_value;
166 END IF;
167
168 l_position:= Instr(l_value, '/', 1, 3);
169 IF l_position = 0 THEN
170 -- missing the last /
171 l_value := l_value || '/';
172 ELSE
173 l_value := Substr(l_value, 1, l_position);
174 END IF;
175
176 RETURN l_value;
177
178 END get_protocol_host_port;
179
180 -- Return the url for the external web server for suppliers.
181 -- Example: http://host.example.com:8888/
182 FUNCTION get_external_url RETURN VARCHAR2
183 IS
184 -- the size of l_value is larger than the size 240 of
185 -- the profile_option_value column in
186 -- fnd_profile_option_values table
187 l_value VARCHAR2(500);
188 l_position NUMBER;
189 BEGIN
190 l_value := fnd_profile.value('POS_EXTERNAL_URL');
191 RETURN get_protocol_host_port(l_value);
192 END get_external_url;
193
194 FUNCTION get_site_apps_servlet_agent
195 RETURN VARCHAR2
196 IS
197 CURSOR l_cur IS
198 SELECT fpov.profile_option_value
199 FROM fnd_profile_options fpo,
200 fnd_profile_option_values fpov
201 WHERE fpo.application_id = 0
202 AND fpo.profile_option_name = 'APPS_SERVLET_AGENT'
203 AND fpo.profile_option_id = fpov.profile_option_id
204 AND fpov.level_id = 10001
205 AND fpov.application_id = 0;
206
207 l_value fnd_profile_option_values.profile_option_value%TYPE;
208
209 BEGIN
210 OPEN l_cur;
211 IF l_cur%notfound THEN
212 CLOSE l_cur;
213 RETURN NULL;
214 END IF;
215
216 FETCH l_cur INTO l_value;
217 CLOSE l_cur;
218 RETURN l_value;
219
220 END get_site_apps_servlet_agent;
221
222 -- Return the url for an internal web server.
223 -- Example value, http://host.example.com:8888/
224 FUNCTION get_internal_url RETURN VARCHAR2
225 IS
226 -- the size of l_value is larger than the size 240 of
227 -- the profile_option_value column in
228 -- fnd_profile_option_values table
229 l_value VARCHAR2(500);
230 l_position NUMBER;
231
232 BEGIN
233 l_value := fnd_profile.value('POS_INTERNAL_URL');
234 IF l_value IS NULL THEN
235 l_value := get_site_apps_servlet_agent;
236 END IF;
237
238 l_value := get_protocol_host_port(l_value);
239 RETURN l_value;
240
241 END get_internal_url;
242
243 -- Return the login url at the external web server for suppliers.
244 FUNCTION get_external_login_url RETURN VARCHAR2
245 IS
246 l_url VARCHAR2(3000);
247 l_path VARCHAR2(500);
248 BEGIN
249 l_path := fnd_profile.value('POS_EXTERNAL_LOGON_PATH');
250 IF l_path IS NULL THEN
251 l_url := fnd_sso_manager.getloginurl;
252 l_url := regexp_replace(l_url,'https?://[^/]+/',get_external_url);
253 ELSE
254 l_url := get_external_url || l_path;
255 END IF;
256 RETURN l_url;
257 END get_external_login_url;
258
259 -- Return the login url at an internal web server
260 FUNCTION get_internal_login_url RETURN VARCHAR2
261 IS
262 BEGIN
263 RETURN fnd_sso_manager.getloginurl;
264 END get_internal_login_url;
265
266 END pos_url_pkg;