1 PACKAGE BODY UMX_USERNAME_POLICY_PVT AS
2 /* $Header: UMXVUNPB.pls 120.5 2005/09/01 23:18:04 kching noship $ */
3
4 --
5 -- Procedure : get_suggested_username
6 -- Type : Public
7 -- Pre_reqs : None
8 -- Description : This API will return the suggested user name for a person.
9 -- The user name will be generated via the
10 -- oracle.apps.fnd.umx.username.generate Business Event
11 -- which will be raised by this API. The event could
12 -- return a null value as the user name if the user name
13 -- could not be generated.
14 -- Input Parameters :
15 -- @param p_person_party_id
16 -- Description: Person Party ID of the person who to generate
17 -- a username for.
18 -- Required : N
19 -- Output Parameters :
20 -- x_suggested_username: Username generated by the Username Policy. May return null.
21 --
22 --
23 procedure get_suggested_username (p_person_party_id in HZ_PARTIES.PARTY_ID%TYPE default null,
24 x_suggested_username out nocopy FND_USER.USER_NAME%TYPE) is
25
26 l_parameter_list wf_parameter_list_t;
27 l_event_key varchar2 (240);
28
29 begin
30
31 if (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_PROCEDURE) then
32 FND_LOG.STRING (FND_LOG.LEVEL_PROCEDURE,
33 'fnd.plsql.UMXVUNPB.get_suggested_username.begin',
34 'p_person_party_id: ' || p_person_party_id);
35 end if;
36
37 -- Raising the Business Event
38 -- p_person_party_id could be null. In this case, we expect the subscription to handle
39 -- the null party id.
40 wf_event.addParametertoList('UMX_PERSON_PARTY_ID', p_person_party_id, l_parameter_list);
41 select UMX_USERNAME_POLICY_S.nextval into l_event_key from dual;
42
43 -- Log the event key
44 if (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_PROCEDURE) then
45 FND_LOG.STRING (FND_LOG.LEVEL_PROCEDURE,
46 'fnd.plsql.UMXVUNPB.run_policy',
47 'Raising event with event key: ' || l_event_key);
48 end if;
49
50 -- Raise the generate user name event.
51 -- Calling raise3 because l_parameter_list is an in/out parameter.
52 wf_event.raise3('oracle.apps.fnd.umx.username.generate', l_event_key, null, l_parameter_list, sysdate);
53 x_suggested_username := wf_event.getValueForParameter ('UMX_GENERATED_USERNAME', l_parameter_list);
54
55 if (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_PROCEDURE) then
56 FND_LOG.STRING (FND_LOG.LEVEL_PROCEDURE,
57 'fnd.plsql.UMXVUNPB.get_suggested_username.end',
58 'x_suggested_username: ' || x_suggested_username);
59 end if;
60
61 end get_suggested_username;
62
63 --
64 -- Procedure : get_username_policy_desc
65 -- Type : Public
66 -- Pre_reqs : None
67 -- Description : This API will return the description of the user name
68 -- policy. The return parameters / user name policy is
69 -- based on the UMX: User Name Policy (UMX_USERNAME_POLICY)
70 -- profile option, which points to a LOOKUP TYPE that
71 -- should include the following:
72 --
73 -- LOOKUP CODES: DESCRIPTION, PROMPT, HINT
74 --
75 -- with the appropriate LOOKUP MEANING defined. Example:
76 --
77 -- LOOKUP TYPE: UMX_USERNAME_POLICY:EMAIL
78 --
79 -- LOOKUP CODE MEANING DESCRIPTION
80 -- ----------- -------------------------- -------------------------------
81 -- PROMPT User Name Prompt of the user name text
82 -- input field.
83 --
84 -- DESCRIPTION User Names must be based Description of the policy
85 -- on Email Address
86 --
87 -- HINT example: [email protected] Example of what the username should
88 -- look like.
89 --
90 -- Input Parameters :
91 -- Output Parameters :
92 -- x_policy_code: User Name Policy code. Preseeded policies are:
93 --
94 -- Code: UMX_USERNAME_POLICY:EMAIL
95 -- Meaning: User name should be defined as Email Address.
96 -- Product teams may choose to hide the email
97 -- field in any account creation / registration
98 -- UI's as long as the entered username (email)
99 -- is copied into the fnd_user.email_address field
100 -- as well.
101 --
102 -- Code: UMX_USERNAME_POLICY:NONE
103 -- Meaning: No username policy / format defined, freetext
104 --
105 -- Code: Anything else, this would be a custom policy defined
106 -- at a client site.
107 --
108 -- x_description: User Name Policy description. May be null. For example:
109 --
110 -- "User Names must be based on <b>Email Address</b>".
111 -- The description can be displayed as a quick tip in
112 -- the user account creation/registration page.
113 --
114 -- x_prompt: Prompt of the User Name field. Defaults to "User Name" if
115 -- none is defined in the policy.
116 --
117 -- x_hint: An example of the user name format. May be null. For
118 -- example:
119 --
120 -- "(example: [email protected])"
121 --
122 -- The hint can be displayed as an inline hint below the
123 -- User Name field in any user account creation/registration
124 -- page.
125 --
126 --
127 procedure get_username_policy_desc
128 (x_policy_code out nocopy FND_LOOKUP_TYPES.LOOKUP_TYPE%TYPE,
129 x_description out nocopy FND_LOOKUP_VALUES.MEANING%TYPE,
130 x_prompt out nocopy FND_LOOKUP_VALUES.MEANING%TYPE,
131 x_hint out nocopy FND_LOOKUP_VALUES.MEANING%TYPE) is
132
133 cursor getPolicyDesc (p_lookup_type in varchar2) is
134 select lookup_code, meaning
135 from fnd_lookups
136 where lookup_type = p_lookup_type
137 and lookup_code in ('DESCRIPTION', 'PROMPT', 'HINT')
138 and enabled_flag = 'Y'
139 and start_date_active < sysdate
140 and nvl (end_date_active, sysdate + 1) > sysdate;
141
142 cursor get_none_policy_prompt is
143 select meaning
144 from fnd_lookups
145 where lookup_type = 'UMX_USERNAME_POLICY:NONE'
146 and lookup_code = 'PROMPT'
147 and enabled_flag = 'Y'
148 and start_date_active < sysdate
149 and nvl (end_date_active, sysdate + 1) > sysdate;
150
151 begin
152
153 if (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_PROCEDURE) then
154 FND_LOG.STRING (FND_LOG.LEVEL_PROCEDURE,
155 'fnd.plsql.UMXVUNPB.get_username_policy_desc.begin', null);
156 end if;
157
158 -- First, get the Policy Code
159 fnd_profile.get (name => 'UMX_USERNAME_POLICY',
160 val => x_policy_code);
161
162 -- Now, get the of the Policy
163 if (x_policy_code is null) then
164 -- Get the default policy: UMX_USERNAME_POLICY:NONE
165 for lookup_code in getPolicyDesc ('UMX_USERNAME_POLICY:NONE') loop
166 if (lookup_code.lookup_code = 'DESCRIPTION') then
167 x_description := lookup_code.meaning;
168 elsif (lookup_code.lookup_code = 'PROMPT') then
169 x_prompt := lookup_code.meaning;
170 else
171 x_hint := lookup_code.meaning;
172 end if;
173 end loop;
174 else
175 for lookup_code in getPolicyDesc (x_policy_code) loop
176 if (lookup_code.lookup_code = 'DESCRIPTION') then
177 x_description := lookup_code.meaning;
178 elsif (lookup_code.lookup_code = 'PROMPT') then
179 x_prompt := lookup_code.meaning;
180 else
181 x_hint := lookup_code.meaning;
182 end if;
183 end loop;
184
185 -- If x_prompt is missing, we have to defualt to the no policy ('User Name').
186 if (x_prompt is null) then
187 open get_none_policy_prompt;
188 fetch get_none_policy_prompt into x_prompt;
189 close get_none_policy_prompt;
190 end if;
191 end if;
192
193 if (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_PROCEDURE) then
194 FND_LOG.STRING (FND_LOG.LEVEL_PROCEDURE,
195 'fnd.plsql.UMXVUNPB.get_username_policy_desc.end',
196 'x_policy_code: ' || x_policy_code ||
197 ' | x_description: ' || x_description ||
198 ' | x_prompt: ' || x_prompt ||
199 ' | x_hint: ' || x_hint);
200 end if;
201
202 end get_username_policy_desc;
203
204 --
205 -- Procedure : policy_subscription
206 -- Type : Private
207 -- Pre_reqs : None
208 -- Description : The is the subscription API which registers to the
209 -- oracle.apps.fnd.umx.username.generate Workflow Business
210 -- Event. This subscription will generate the suggested
211 -- user name by querying the email address stored in TCA.
212 -- This API is intented to be called as a Business Subscription
213 -- Rule Function.
214 -- Input Parameters :
215 -- @param p_subscription_guid
216 -- Description: Workflow Business Subscription GUID
217 -- Required : Y
218 -- @param p_event
219 -- Description: The event message.
220 -- Required : Y
221 -- Output Parameters :
222 --
223 function policy_subscription (p_subscription_guid in raw,
224 p_event in out nocopy WF_EVENT_T) return varchar2 is
225
226 l_person_party_id HZ_PARTIES.PARTY_ID%type;
227 l_username fnd_user.user_name%type;
228
229 begin
230
231 l_person_party_id := p_event.getValueForParameter ('UMX_PERSON_PARTY_ID');
232
233 if (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_PROCEDURE) then
234 FND_LOG.STRING (FND_LOG.LEVEL_PROCEDURE,
235 'fnd.plsql.UMXVUNPB.policy_subscription.begin',
236 'p_subscription_guid: ' || p_subscription_guid ||
237 ' | l_person_party_id: ' || l_person_party_id);
238 end if;
239
240
241 UMX_REGISTER_USER_PVT.Get_Party_Email_Address (
242 p_person_party_id => l_person_party_id,
243 x_email_address => l_username);
244
245 p_event.addParametertoList('UMX_GENERATED_USERNAME', l_username);
246
247 if (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_PROCEDURE) then
248 FND_LOG.STRING (FND_LOG.LEVEL_PROCEDURE,
249 'fnd.plsql.UMXVUNPB.policy_subscription.end',
250 'l_username: ' || l_username);
251 end if;
252
253 return 'SUCCESS';
254
255 end policy_subscription;
256
257 /* =========================START OBSOLETE IMPLEMENTATION======================*/
258 --
259 -- Procedure : run_policy
260 -- Type : Private
261 -- Pre_reqs : None
262 -- Description : (OBSOLETED, please use the "GET" API)
263 -- This API will invoke the Username Policy
264 -- workflow process and return the generated
265 -- username and status "SUCCESS". It will
266 -- return error message and status "FAIL"
267 -- if error occurs.
268 -- Input Parameters :
269 -- @param p_reg_serv_code
270 -- Description: Registration Service Code
271 -- Required : Y
272 -- @param p_person_party_id
273 -- Description: Person Party ID of the person who generate
274 -- a username for.
275 -- Required : Y
276 -- Output Parameters :
277 -- x_generated_username: Username generated by the Username Policy
278 -- x_policy_override: The Username Policy determine if this policy
279 -- can be overridden by the caller.
280 -- Y - caller can override the policy
281 -- N - caller cannot override the policy
282 -- x_result_code: Result code from running the Username Policy
283 -- (SUCCESS/FAIL)
284 -- x_policy_code: Policy Type (Example: EMAIL)
285 -- x_policy_name: Policy Name (Example: Email Address)
286 -- x_policy_desc: A brief description of the format used to generate
287 -- the username. (Example: "(exameple: [email protected])")
288 -- x_error_msg: Description why the Username Policy failed
289 --
290 --
291 Procedure run_policy (
292 p_reg_serv_code in UMX_REG_SERVICES_B.REG_SERVICE_CODE%TYPE,
293 p_person_party_id in HZ_PARTIES.PARTY_ID%TYPE,
294 x_generated_username out NOCOPY FND_USER.USER_NAME%TYPE,
295 x_policy_override out NOCOPY varchar2,
296 x_policy_code out NOCOPY varchar2,
297 x_policy_name out NOCOPY varchar2,
298 x_policy_desc out NOCOPY varchar2,
299 x_result_code out NOCOPY varchar2,
300 x_error_msg out NOCOPY varchar2
301 ) is
302
303 l_user_id FND_USER.USER_ID%type;
304 l_person_party_id FND_USER.PERSON_PARTY_ID%type;
305
306 begin
307
308 run_policy (p_reg_serv_code, p_person_party_id, x_generated_username,
309 x_policy_override, x_policy_code, x_policy_name, x_policy_desc,
310 x_result_code, x_error_msg, l_user_id, l_person_party_id);
311
312 end run_policy;
313
314 --
315 -- Procedure : run_policy
316 -- Type : Private
317 -- Pre_reqs : None
318 -- Description : (OBSOLETED, please use the "GET" API)
319 -- workflow process and return the generated
320 -- username and status "SUCCESS". It will
321 -- return error message and status "FAIL"
322 -- if error occurs.
323 -- Input Parameters :
324 -- @param p_reg_serv_code
325 -- Description: Registration Service Code
326 -- Required : Y
327 -- @param p_person_party_id
328 -- Description: Person Party ID of the person who generate
329 -- a username for.
330 -- Required : Y
331 -- Output Parameters :
332 -- x_generated_username: Username generated by the Username Policy
333 -- x_policy_override: The Username Policy determine if this policy
334 -- can be overridden by the caller.
335 -- Y - caller can override the policy
336 -- N - caller cannot override the policy
337 -- x_result_code: Result code from running the Username Policy
338 -- (SUCCESS/FAIL)
339 -- x_policy_code: Policy Type (Example: EMAIL)
340 -- x_policy_name: Policy Name (Example: Email Address)
341 -- x_policy_desc: A brief description of the format used to generate
342 -- the username. (Example: "(exameple: [email protected])")
343 -- x_error_msg: Description why the Username Policy failed
344 -- x_exist_user_id: User ID of the existing person.
345 -- x_exist_per_party_id: Person party ID of the existing person.
346 --
347 --
348 Procedure run_policy (
349 p_reg_serv_code in UMX_REG_SERVICES_B.REG_SERVICE_CODE%TYPE,
350 p_person_party_id in HZ_PARTIES.PARTY_ID%TYPE,
351 x_generated_username out NOCOPY FND_USER.USER_NAME%TYPE,
352 x_policy_override out NOCOPY varchar2,
353 x_policy_code out NOCOPY varchar2,
354 x_policy_name out NOCOPY varchar2,
355 x_policy_desc out NOCOPY varchar2,
356 x_result_code out NOCOPY varchar2,
357 x_error_msg out NOCOPY varchar2,
358 x_exist_user_id out NOCOPY FND_USER.USER_ID%TYPE,
359 x_exist_per_party_id out NOCOPY FND_USER.PERSON_PARTY_ID%TYPE
360 ) is
361 cursor getRegTypeCode (l_reg_serv_code in UMX_reg_services_b.reg_service_code%type) is
362 select reg_service_type
363 from UMX_reg_services_b
364 where reg_service_code = l_reg_serv_code;
365
366 cursor get_person_party_id (p_user_name in FND_USER.USER_NAME%type) is
367 select user_id, person_party_id
368 from fnd_user
369 where user_name = p_user_name;
370
371 l_reg_type_code UMX_reg_services_b.reg_service_type%type;
372 l_itemkey varchar2 (6) := '#SYNCH';
373
374 begin
375
376 if (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_PROCEDURE) then
377 FND_LOG.STRING (FND_LOG.LEVEL_PROCEDURE,
378 'fnd.plsql.UMXVUNPB.run_policy.begin',
379 'p_reg_serv_code: ' || p_reg_serv_code ||
380 ' | p_person_party_id: ' || p_person_party_id);
381 end if;
382
383 -- Get the Registration Type Code from UMX_REG_SERVICES_B
384 open getRegTypeCode (p_reg_serv_code);
385 fetch getRegTypeCode into l_reg_type_code;
386 if (getRegTypeCode%notfound) then
387 -- Cannot find the Registration Type Code, raise error
388 close getRegTypeCode;
389 fnd_message.set_name('FND','UMX_COMMON_MISS_PARAM_MSG');
390 fnd_message.set_token('PARAM', 'Registration Type Code');
391 fnd_message.set_token('API', 'JTF_UM_WF_APPROVAL.CreateProcess');
392 raise_application_error ('-20000', fnd_message.get);
393 end if;
394 close getRegTypeCode;
395
396 -- Start Process
397 wf_engine.CreateProcess (itemtype => g_itemtype,
398 itemkey => l_itemkey);
399
400 -- Initialize workflow item attributes
401 wf_engine.SetItemAttrText (itemtype => g_itemtype,
402 itemkey => l_itemkey,
403 aname => 'REG_SERV_CODE',
404 avalue => p_reg_serv_code);
405
406 wf_engine.SetItemAttrText (itemtype => g_itemtype,
407 itemkey => l_itemkey,
408 aname => 'REG_TYPE_CODE',
409 avalue => l_reg_type_code);
410
411 wf_engine.SetItemAttrNumber (itemtype => g_itemtype,
412 itemkey => l_itemkey,
413 aname => 'PERSON_PARTY_ID',
414 avalue => p_person_party_id);
415
416 wf_engine.StartProcess (itemtype => g_itemtype,
417 itemkey => l_itemkey);
418
419 x_generated_username := wf_engine.GetItemAttrText (
420 itemtype => g_itemtype,
421 itemkey => l_itemkey,
422 aname => 'GENERATED_USERNAME');
423
424 x_policy_override := wf_engine.GetItemAttrText (
425 itemtype => g_itemtype,
426 itemkey => l_itemkey,
427 aname => 'POLICY_OVERRIDE');
428
429 -- For Testing
430 -- x_policy_override := 'N';
431
432 x_policy_code := wf_engine.GetItemAttrText (
433 itemtype => g_itemtype,
434 itemkey => l_itemkey,
435 aname => 'POLICY_CODE');
436
437 x_policy_name := wf_engine.GetItemAttrText (
438 itemtype => g_itemtype,
439 itemkey => l_itemkey,
440 aname => 'POLICY_NAME');
441
442 x_policy_desc := wf_engine.GetItemAttrText (
443 itemtype => g_itemtype,
444 itemkey => l_itemkey,
445 aname => 'POLICY_DESC');
446
447 x_result_code := wf_engine.GetItemAttrText (
448 itemtype => g_itemtype,
449 itemkey => l_itemkey,
450 aname => 'RESULT_CODE');
451
452 x_error_msg := wf_engine.GetItemAttrText (
453 itemtype => g_itemtype,
454 itemkey => l_itemkey,
455 aname => 'ERROR_MSG');
456
457 if (x_error_msg = 'UMX_CREATEUSERACCT_ACC_EXIS_ER') then
458 -- We need to get the person party id of the existing user
459 open get_person_party_id (p_user_name => x_generated_username);
460 fetch get_person_party_id into x_exist_user_id, x_exist_per_party_id;
461 close get_person_party_id;
462 end if;
463
464 if (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_PROCEDURE) then
465 FND_LOG.STRING (FND_LOG.LEVEL_PROCEDURE,
466 'fnd.plsql.UMXVUNPB.run_policy.end',
467 'x_generated_username: ' || x_generated_username ||
468 ' | x_policy_override: ' || x_policy_override ||
469 ' | x_policy_code: ' || x_policy_code ||
470 ' | x_policy_name: ' || x_policy_name ||
471 ' | x_policy_desc: ' || x_policy_desc ||
472 ' | x_result_code: ' || x_result_code ||
473 ' | x_error_msg: ' || x_error_msg);
474 end if;
475
476 end run_policy;
477
478 --
479 -- Procedure
480 -- Selector
481 --
482 -- Description
483 -- (OBSOLETED) Determine which process to run
484 -- IN
485 -- itemtype - A valid item type from (WF_ITEM_TYPES table).
486 -- itemkey - A string generated from the application object's primary key.
487 -- actid - The function activity(instance id).
488 -- funcmode - Run/Cancel/Timeout
489 -- OUT
490 -- resultout - Name of workflow process to run
491 --
492 procedure Selector (item_type in varchar2,
493 item_key in varchar2,
494 activity_id in number,
495 command in varchar2,
496 resultout out NOCOPY varchar2) is
497
498 begin
499
500 -- RUN mode - normal process execution
501 if (command = 'RUN') then
502 -- Return process to run
503 resultout := 'UMX_USERNAME_POLICY';
504 end if;
505
506 exception
507 when others then
508 wf_core.context ('UMX_USERNAME_POLICY_PVT', 'Selector', item_type,
509 item_key, to_char (activity_id), command);
510 raise;
511 end selector;
512
513 --
514 -- Procedure
515 -- gen_username
516 --
517 -- Description
518 -- (OBSOLETED) Generate the username
519 -- IN
520 -- itemtype - A valid item type from (WF_ITEM_TYPES table).
521 -- itemkey - A string generated from the application object's primary key.
522 -- actid - The function activity(instance id).
523 -- funcmode - Run/Cancel/Timeout
524 -- OUT
525 -- resultout - Name of workflow process to run
526 --
527 procedure gen_username (item_type in varchar2,
528 item_key in varchar2,
529 activity_id in number,
530 command in varchar2,
531 resultout out NOCOPY varchar2) is
532
533 l_person_party_id HZ_PARTIES.PARTY_ID%type;
534 l_username wf_item_attribute_values.text_value%type;
535
536 begin
537
538 -- RUN mode - normal process execution
539 if (command = 'RUN') then
540
541 l_person_party_id := wf_engine.GetItemAttrNumber (
542 itemtype => item_type,
543 itemkey => item_key,
544 aname => 'PERSON_PARTY_ID');
545
546 -- We need to get email address from TCA
547 -- Email will be the username in this policy
548 UMX_REGISTER_USER_PVT.Get_Party_Email_Address (
549 p_person_party_id => l_person_party_id,
550 x_email_address => l_username);
551
552 -- For testing
553 -- l_username := null;
554 if (l_username is null) then
555 -- No email address, error occur
556 resultout := 'FAIL';
557
558 wf_engine.SetItemAttrText (
559 itemtype => item_type,
560 itemkey => item_key,
561 aname => 'ERROR_MSG',
562 avalue => 'UMX_CREATEUSERACCT_NOEMAIL_ERR');
563
564 else
565
566 resultout := 'SUCCESS';
567
568 -- Write the username to the WF Attribute
569 wf_engine.SetItemAttrText (
570 itemtype => item_type,
571 itemkey => item_key,
572 aname => 'GENERATED_USERNAME',
573 avalue => upper(l_username));
574
575 end if;
576
577 wf_engine.SetItemAttrText (
578 itemtype => item_type,
579 itemkey => item_key,
580 aname => 'RESULT_CODE',
581 avalue => resultout);
582
583 end if;
584
585 exception
586 when others then
587 wf_core.context ('UMX_USERNAME_POLICY_PVT', 'gen_username',
588 item_type, item_key, to_char (activity_id), command);
589 raise;
590 end gen_username;
591
592 --
593 -- Procedure
594 -- chk_username_avail
595 --
596 -- Description
597 -- (OBSOLETED) Check if the username is available in FND_USER table
598 -- IN
599 -- itemtype - A valid item type from (WF_ITEM_TYPES table).
600 -- itemkey - A string generated from the application object's primary key.
601 -- actid - The function activity(instance id).
602 -- funcmode - Run/Cancel/Timeout
603 -- OUT
604 -- resultout - Name of workflow process to run
605 --
606 procedure chk_username_avail (item_type in varchar2,
607 item_key in varchar2,
608 activity_id in number,
609 command in varchar2,
610 resultout out NOCOPY varchar2) is
611
612 l_username wf_item_attribute_values.text_value%type;
613 errorMess varchar2 (30) := null;
614
615 cursor checkUsername (l_username in fnd_user.user_name%type)is
616 select 1
617 from fnd_user
618 where user_name = l_username;
619
620 begin
621
622 -- RUN mode - normal process execution
623 if (command = 'RUN') then
624
625 -- Set the default WF attribute
626 resultout := 'SUCCESS';
627
628 l_username := wf_engine.GetActivityAttrText (
629 itemtype => item_type,
630 itemkey => item_key,
631 actid => activity_id,
632 aname => 'USERNAME');
633
634 -- Check the length of the username.
635 -- Username could be as big as 4000 characters
636 if (LENGTH (l_username) > 100) then
637 -- username is greater than the size of the available space for username
638 errorMess := 'UMX_CREATEUSERACCT_LONG_EML_ER';
639
640 else
641
642 -- Check if this username is being used.
643 open checkUsername (l_username);
644 fetch checkUsername into l_username;
645 if (checkUsername%found) then
646 -- For testing
647 -- if (checkUsername%notfound) then
648 -- Username is already being taken. Return failed.
649 errorMess := 'UMX_CREATEUSERACCT_ACC_EXIS_ER';
650 end if;
651 close checkUsername;
652
653 end if;
654
655 if (errorMess is not null) then
656
657 resultout := 'FAIL';
658
659 -- Error occurs, set the error message.
660 wf_engine.SetItemAttrText (
661 itemtype => item_type,
662 itemkey => item_key,
663 aname => 'ERROR_MSG',
664 avalue => errorMess);
665
666 wf_engine.SetItemAttrText (
667 itemtype => item_type,
668 itemkey => item_key,
669 aname => 'RESULT_CODE',
670 avalue => resultout);
671
672 end if;
673 end if;
674
675 exception
676 when others then
677 wf_core.context ('UMX_USERNAME_POLICY_PVT', 'chk_username_avail',
678 item_type, item_key, to_char (activity_id), command);
679 raise;
680 end chk_username_avail;
681
682 --
683 -- Procedure
684 -- collision_resolution
685 --
686 -- Description
687 -- (OBSOLETED) Template to resolve collision of username
688 -- IN
689 -- itemtype - A valid item type from (WF_ITEM_TYPES table).
690 -- itemkey - A string generated from the application object's primary key.
691 -- actid - The function activity(instance id).
692 -- funcmode - Run/Cancel/Timeout
693 -- OUT
694 -- resultout - Name of workflow process to run
695 --
696 procedure collision_resolution (item_type in varchar2,
697 item_key in varchar2,
698 activity_id in number,
699 command in varchar2,
700 resultout out NOCOPY varchar2) is
701
702 begin
703
704 -- RUN mode - normal process execution
705 if (command = 'RUN') then
706
707 raise_application_error ('-20000', 'User name cannot be generated; email address not found.');
708
709 end if;
710
711 exception
712 when others then
713 wf_core.context ('UMX_USERNAME_POLICY_PVT', 'collision_resolution',
714 item_type, item_key, to_char (activity_id), command);
715 raise;
716 end collision_resolution;
717 /* =========================END OBSOLETE IMPLEMENTATION======================*/
718 end UMX_USERNAME_POLICY_PVT;