01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.module.chart.lookup.valuefinder;
17:
18: import java.util.Map;
19:
20: import org.kuali.core.bo.user.KualiModuleUser;
21: import org.kuali.core.bo.user.UniversalUser;
22: import org.kuali.core.service.UniversalUserService;
23: import org.kuali.core.util.GlobalVariables;
24: import org.kuali.kfs.context.SpringContext;
25: import org.kuali.module.chart.bo.ChartUser;
26:
27: /**
28: * This class holds utilities to assist with finding current chart and universal users
29: */
30: public class ValueFinderUtil {
31:
32: /**
33: * This method returns the currently logged in Chart User.
34: *
35: * @return the currently logged in Chart User
36: * @see ChartUser
37: */
38: public static ChartUser getCurrentChartUser() {
39: UniversalUser currentUser = ValueFinderUtil
40: .getCurrentUniversalUser();
41: if (currentUser != null) {
42: Map<String, KualiModuleUser> moduleUsers = SpringContext
43: .getBean(UniversalUserService.class)
44: .getModuleUsers(currentUser);
45: return (ChartUser) moduleUsers.get(ChartUser.MODULE_ID);
46: } else {
47: return null;
48: }
49: }
50:
51: /**
52: * This method returns the currently logged in Universal User.
53: *
54: * @return the currently logged in Universal User
55: * @see UniversalUser
56: */
57: private static UniversalUser getCurrentUniversalUser() {
58: if (GlobalVariables.getUserSession() != null) {
59: return GlobalVariables.getUserSession().getUniversalUser();
60: } else {
61: return null;
62: }
63: }
64: }
|