1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.user;
17
18 import org.kuali.rice.kim.api.identity.Person;
19 import org.kuali.rice.kim.api.identity.principal.PrincipalContract;
20
21 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
22 import org.kuali.rice.kim.api.identity.PersonService;
23 import org.kuali.rice.krad.UserSession;
24
25
26
27
28
29
30 public final class UserUtils {
31
32 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(UserUtils.class);
33
34 private static PersonService personService;
35
36 private UserUtils() {
37 throw new UnsupportedOperationException("do not call");
38 }
39
40 public static String getIdValue(String idType, Person user) {
41 if ("workflowId".equalsIgnoreCase(idType) || "w".equalsIgnoreCase(idType) || "principalId".equalsIgnoreCase(idType)) {
42 return user.getPrincipalId();
43 } else if ("authenticationId".equalsIgnoreCase(idType) || "a".equalsIgnoreCase(idType) || "principalName".equalsIgnoreCase(idType)) {
44 return user.getPrincipalName();
45 } else if ("emplId".equalsIgnoreCase(idType) || "e".equalsIgnoreCase(idType)) {
46 return user.getEmployeeId();
47 } else {
48 LOG.error("Could not determine ID Value for given id type!" + idType);
49 }
50 return null;
51 }
52
53 public static String getTransposedName(UserSession userSession, PrincipalContract principal) {
54 Person person = getPersonService().getPerson(principal.getPrincipalId());
55 return person.getName();
56 }
57
58
59
60
61 public static PersonService getPersonService() {
62 if ( personService == null ) {
63 personService = KimApiServiceLocator.getPersonService();
64 }
65 return personService;
66 }
67 }