| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| UserUtils |
|
| 4.25;4.25 |
| 1 | /* | |
| 2 | * Copyright 2007-2009 The Kuali Foundation | |
| 3 | * | |
| 4 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.opensource.org/licenses/ecl2.php | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | */ | |
| 16 | package org.kuali.rice.kew.user; | |
| 17 | ||
| 18 | import org.kuali.rice.kim.bo.Person; | |
| 19 | import org.kuali.rice.kim.bo.entity.KimPrincipal; | |
| 20 | import org.kuali.rice.kim.service.KIMServiceLocator; | |
| 21 | import org.kuali.rice.kim.service.PersonService; | |
| 22 | import org.kuali.rice.kns.UserSession; | |
| 23 | ||
| 24 | /** | |
| 25 | * Provides some utility methods for translating user ID types. | |
| 26 | * | |
| 27 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 28 | */ | |
| 29 | public final class UserUtils { | |
| 30 | ||
| 31 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(UserUtils.class); |
| 32 | ||
| 33 | private static PersonService personService; | |
| 34 | ||
| 35 | 0 | private UserUtils() { |
| 36 | 0 | throw new UnsupportedOperationException("do not call"); |
| 37 | } | |
| 38 | ||
| 39 | public static String getIdValue(String idType, Person user) { | |
| 40 | 0 | if ("workflowId".equalsIgnoreCase(idType) || "w".equalsIgnoreCase(idType) || "principalId".equalsIgnoreCase(idType)) { |
| 41 | 0 | return user.getPrincipalId(); |
| 42 | 0 | } else if ("authenticationId".equalsIgnoreCase(idType) || "a".equalsIgnoreCase(idType) || "principalName".equalsIgnoreCase(idType)) { |
| 43 | 0 | return user.getPrincipalName(); |
| 44 | 0 | } else if ("emplId".equalsIgnoreCase(idType) || "e".equalsIgnoreCase(idType)) { |
| 45 | 0 | return user.getEmployeeId(); |
| 46 | } else { | |
| 47 | 0 | LOG.error("Could not determine ID Value for given id type!" + idType); |
| 48 | } | |
| 49 | 0 | return null; |
| 50 | } | |
| 51 | ||
| 52 | public static String getTransposedName(UserSession userSession, KimPrincipal principal) { | |
| 53 | 0 | Person person = getPersonService().getPerson(principal.getPrincipalId()); |
| 54 | 0 | return person.getName(); //contructTransposedName(person); |
| 55 | } | |
| 56 | ||
| 57 | /** | |
| 58 | * @return the personService | |
| 59 | */ | |
| 60 | public static PersonService getPersonService() { | |
| 61 | 0 | if ( personService == null ) { |
| 62 | 0 | personService = KIMServiceLocator.getPersonService(); |
| 63 | } | |
| 64 | 0 | return personService; |
| 65 | } | |
| 66 | } |