DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_UTIL_WEB

Source


1 package body hr_util_web as
2 /* $Header: hrutlweb.pkb 120.2.12000000.2 2007/04/12 11:36:58 vkaduban ship $ */
3 
4   g_debug             boolean := hr_utility.debug_enabled;
5   g_package           varchar2(31)   := 'hr_util_web.';
6   g_owa_package       varchar2(2000) := hr_util_web.g_owa||g_package;
7   --
8 -- ------------------------------------------------------------------------
9 -- name:
10 --   prepare_parameter
11 -- description:
12 --   makes a parameter ready for html calls.  In other words, replaces
13 --   paces with '+' and places a '&' at the front of the parmameter name
14 --   when p_prefix is true (the parameter is not first in the list).
15 -- ------------------------------------------------------------------------
16 function prepare_parameter
17            (p_name   in varchar2
18            ,p_value  in varchar2
19            ,p_prefix in boolean default true) return varchar2 is
20 --
21   l_prefix varchar2(1);
22 --
23 begin
24   if p_value is not null then
25     if p_prefix then
26        l_prefix := '&';
27     end if;
28     return(l_prefix||p_name||'='||replace(p_value, ' ', '+'));
29   else
30     return(null);
31   end if;
32 end prepare_parameter;
33 
34 --
35 -- PRIVATE FUNCTION
36 --   in_exclusion_list
37 --
38 -- DESCRIPTION
39 --   Returns TRUE if the argument p_url_target is in p_exclusion_list, FALSE
40 --   otherwise.  Used to determine whether or not to use a proxy.  This
41 --   functionality can only be used with fixed-length character set
42 --   exclusion lists and targets, which is okay since these are URLs.
43 --
44 -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
45 --
46 -- ARGUMENTS
47 --   IN:
48 --     p_target_url
49 --     p_exclusion_list
50 --
51 -- NOTES
52 --
53 --   Could potentially use caching to boost performance.
54 --   Sync or replace with HZ version at appropriate time
55 --
56 -- MODIFICATION HISTORY
57 --
58 --   03-28-2002   DKERR    Created
59 --                         Taken HZ_GEOCODE_PKG from J. del Callar
60 --
61 FUNCTION in_exclusion_list (
62     p_url_target        IN      VARCHAR2,
63     p_exclusion_list    IN      VARCHAR2
64   ) RETURN BOOLEAN IS
65     l_exclusion_list    VARCHAR2(2000) := LOWER(p_exclusion_list);
66     l_excluded_domain   VARCHAR2(240);
67     l_delimiter         VARCHAR2(1);
68     l_pos               NUMBER;
69     l_url_domain        VARCHAR2(2000);
70   BEGIN
71     -- First determine what the delimiter in the exclusion list is.  We support
72     -- both "|" (Java-style) and ";" (Microsoft-style) delimiters.  Java-style
73     -- is given priority.
74     IF INSTRB(l_exclusion_list, '|') > 0 THEN
75       l_delimiter := '|';
76     ELSIF INSTRB(l_exclusion_list, ';') > 0 THEN
77       l_delimiter := ';';
78     END IF;
79 
80     -- get the domain portion of the URL.
81     -- first, put the domain in the same case as the exclusion list.
82     l_url_domain := LOWER(p_url_target);
83     -- second, remove the protocol specifier.
84     l_url_domain := SUBSTRB(l_url_domain, INSTRB(l_url_domain, '://')+3);
85 
86     l_pos := INSTRB(l_url_domain, ':/');
87     IF l_pos > 0 THEN
88         l_url_domain := SUBSTRB(l_url_domain,l_pos+2);
89     END IF;
90 
91     -- third, remove the trailing URL information.
92     l_pos := INSTRB(l_url_domain, '/');
93     IF l_pos > 0 THEN
94        l_url_domain := SUBSTRB(l_url_domain, 1, l_pos-1);
95     END IF;
96 
97     -- remove the port from the URL
98     l_pos := INSTRB(l_url_domain, ':');
99     IF l_pos > 0 THEN
100        l_url_domain := SUBSTRB(l_url_domain, 1, l_pos-1);
101     END IF;
102 
103     WHILE l_exclusion_list IS NOT NULL LOOP
104       -- get the position of the 1st delimiter in the remaining exclusion list
105       l_pos := INSTRB(l_exclusion_list, nvl(l_delimiter,chr(0)));
106 
107       IF l_pos = 0 THEN
108         -- no delimiters implies that this is the last domain to be checked.
109         l_excluded_domain := l_exclusion_list;
110       ELSE
111         -- need to do a SUBSTRB if there is a delimiter in the exclusion list
112         -- to get the first domain left in the exclusion list.
113         l_excluded_domain := SUBSTRB(l_exclusion_list, 1, l_pos-1);
114       END IF;
115 
116       -- The domain should not have a % sign in it because it should be a
117       -- domain name.  It may have a * sign in it depending on the syntax of
118       -- the exclusion list.  * signs should be treated as % signs in SQL.
119       l_excluded_domain := REPLACE(l_excluded_domain, '*', '%');
120 
121       -- check to see if the URL domain matches an excluded domain.
122       IF l_url_domain LIKE '%' || l_excluded_domain THEN
123         -- a match was found, return a positive result.
124         RETURN TRUE;
125       END IF;
126 
127       IF l_pos = 0 THEN
128         -- no more domains to be checked if no delimiters were found.
129         l_exclusion_list := NULL;
130       ELSE
131         -- get the remaining domain exclusions to be checked.
132         l_exclusion_list := SUBSTRB(l_exclusion_list, l_pos+1);
133       END IF;
134     END LOOP;
135 
136     -- no domain match was found, return false
137     RETURN FALSE;
138 END in_exclusion_list;
139 --
140 -- -------------------------------------------------------------------------
141 -- |-------------------------< proxyForURL>--------------------------------|
142 -- -------------------------------------------------------------------------
143 --
144 -- Returns the possibly null proxy string based on configuration stored
145 -- in profile options. The value returned can be passed to UTL_HTTP functions
146 -- for example. This or the utility method it calls could usefully
147 -- use caching - currently the routine seems fast enough as it is.
148 -- Ideally get AOL to provide this function.
149 --
150 function proxyForURL(p_url in varchar2) return varchar2 is
151 l_proxy varchar2(4000) := null;
152 l_proxy_server varchar2(400);
153 begin
154    l_proxy_server:=fnd_profile.value('WEB_PROXY_HOST');
155 
156    if(l_proxy_server is not null) then
157 
158      IF NOT in_exclusion_list(p_url,
159                               fnd_profile.value('WEB_PROXY_BYPASS_DOMAINS'))
160      THEN
161           l_proxy:=l_proxy_server
162                    ||':'||fnd_profile.value('WEB_PROXY_PORT');
163      END IF;
164   end if;
165 
166    RETURN (l_proxy);
167 
168 end proxyForURL;
169 
170 
171 
172 
173 end hr_util_web;