DBA Data[Home] [Help]

PACKAGE BODY: APPS.FND_OID_BULKLOAD

Source


1 package body fnd_oid_bulkload as
2 /* $Header: AFSCOBLB.pls 120.6.12020000.2 2012/07/19 17:03:04 ctilley ship $ */
3 --
4 -- Start of Package Globals
5 
6   G_MODULE_SOURCE  constant varchar2(80) := 'fnd.plsql.oid.fnd_oid_bulkload.';
7   G_CREATED	   constant varchar2(1) := 'Y';
8   G_LINKED	   constant varchar2(1) := 'L';
9   G_FAILED	   constant varchar2(1) := 'N';
10   G_NOT_LINKED	   constant varchar2(1) := 'D';
11   G_ALREADY_LINKED constant varchar2(1) := 'G';
12   G_DUP_TRUE	   constant varchar2(1) := 'T';
13 
14 -- End of Package Globals
15 --
16 -------------------------------------------------------------------------------
17 procedure import_user(p_ldap_user in fnd_oid_util.ldap_message_type,
18 		      p_duplicate in varchar2,
19                       x_ret_status out nocopy varchar2,
20                       p_tca_record  in varchar2 default 'Y',
21                       p_add_def_resp in varchar2 default 'Y') is
22 
23   l_module_source varchar2(256);
24   l_user_count number;
25   l_user_id number;
26   l_user_name fnd_user.user_name%type;
27   l_description fnd_user.description%type;
28   l_fax fnd_user.fax%type;
29   l_email_address fnd_user.email_address%type;
30   l_user_guid fnd_user.user_guid%type;
31   l_found boolean;
32 
33 begin
34 
35   fnd_global.apps_initialize(0, -1, -1);
36 
37   l_module_source := G_MODULE_SOURCE || 'import_user: ';
38   x_ret_status := G_FAILED;
39 
40   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
41   then
42     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Begin');
43   end if;
44 
45   l_user_name := p_ldap_user.object_name;
46   l_description := p_ldap_user.description;
47   l_fax := p_ldap_user.facsimileTelephoneNumber;
48   l_email_address := p_ldap_user.mail;
49   l_user_guid := p_ldap_user.orclGUID;
50 
51 
52   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL) then
53     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'user name = ' || l_user_name);
54     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'desc = ' || l_description);
55     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'fax = ' || l_fax);
56     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'email = ' || l_email_address);
57     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'user guid = ' || l_user_guid);
58   end if;
59 
60   select count(user_name) into l_user_count
61   from fnd_user
62   where user_name = l_user_name;
63 
64   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL) then
65     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'user count for ' || l_user_name || ' = ' || l_user_count);
66   end if;
67 
68   if (l_user_count = 0) then
69     fnd_user_pkg.CreateUser(x_user_name => l_user_name,
70 			    x_owner => 'CUST',
71 			    x_unencrypted_password => fnd_web_sec.EXTERNAL_PWD,
72 			    x_description => l_description,
73 			    x_fax => l_fax,
74 			    x_email_address => l_email_address,
75 			    x_user_guid => l_user_guid,
76 			    x_change_source =>  fnd_user_pkg.change_source_oid);
77 
78     /* Set the APPS_SSO_LOCAL_LOGIN to have consistency when creating a new FND
79      * user from OID */
80      select user_id into l_user_id from fnd_user where user_name = l_user_name;
81 
82      l_found := fnd_profile.save(x_name => 'APPS_SSO_LOCAL_LOGIN'
83                                , x_value => 'SSO'
84                                , x_level_name => 'USER'
85                                , x_level_value => l_user_id);
86 
87 /*  fnd_oid_util.send_subscription_add_to_OID(p_orcl_guid=>l_user_guid); */
88     if(p_add_def_resp='N') then
89        /* Do nothing - log call*/
90        if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL) then
91           fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Not adding responsibility');
92        end if;
93     else
94 
95        if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL) then
96           fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Flag defresp=Y adding responsibility');
97        end if;
98        /* add default responsibility*/
99        fnd_oid_subscriptions.assign_default_resp(p_user_name => l_user_name);
100     end if;
101 
102 
103     if(p_tca_record= 'N') then
104 	x_ret_status := G_CREATED;
105     else
106 	fnd_oid_users.hz_create(p_ldap_message => p_ldap_user,
107 			    x_return_status => x_ret_status);
108 
109     	if (x_ret_status = fnd_api.G_RET_STS_SUCCESS) then
110       		x_ret_status := G_CREATED;
111     	end if;
112     end if;
113   else /* count_user <> 0 */
114     select count(user_name) into l_user_count
115     from fnd_user
116     where user_name = l_user_name
117     and   user_guid is not null;
118 
119     if (l_user_count = 0) then
120       if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL) then
121         fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'user guid for ' || l_user_name || ' is null');
122       end if;
123       if (p_duplicate = G_DUP_TRUE) then
124 
125         -- Updating the user_guid if the duplicate option is explicitly passed.
126         -- APPS_SSO_LOCAL_LOGIN is not being set to SSO - consistent with the
127         -- APPS_SSO_LINK_SAME_NAMES flow
128         fnd_user_pkg.UpdateUser(x_user_name => l_user_name,
129      			        x_owner => 'CUST',
130    			        x_description => l_description,
131 			        x_fax => l_fax,
132 			        x_email_address => l_email_address,
133 			        x_user_guid => l_user_guid,
134 				x_change_source =>  fnd_user_pkg.change_source_oid);
135 	x_ret_status := G_LINKED;
136       else
137         x_ret_status := G_NOT_LINKED;
138       end if;
139     else
140       x_ret_status := G_ALREADY_LINKED;
141     end if;
142 
143   end if;
144 
145   if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL) then
146     fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, 'x_ret_status =' || x_ret_status);
147   end if;
148 
149 end import_user;
150 --
151 -------------------------------------------------------------------------------
152 
153 end fnd_oid_bulkload;
154