001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.rice.web;
017:
018: import java.util.ArrayList;
019: import java.util.Arrays;
020: import java.util.Collection;
021: import java.util.Iterator;
022: import java.util.List;
023:
024: import org.apache.log4j.Logger;
025: import org.kuali.core.bo.user.KualiGroup;
026: import org.kuali.core.bo.user.UniversalUser;
027: import org.kuali.core.service.impl.KualiGroupServiceImpl;
028:
029: import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
030: import edu.iu.uis.eden.clientapp.vo.UserVO;
031: import edu.iu.uis.eden.clientapp.vo.WorkgroupVO;
032: import edu.iu.uis.eden.exception.WorkflowException;
033:
034: /**
035: * Override kuali workgroup service because it's going directly against the workflow group service but
036: * toUppering every networkid witch is messing things up.
037: *
038: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
039: */
040: public class RiceGroupServiceImpl extends KualiGroupServiceImpl {
041:
042: private static final Logger LOG = Logger
043: .getLogger(RiceGroupServiceImpl.class);
044:
045: /**
046: * @see org.kuali.core.service.KualiGroupService#getUsersGroups(org.kuali.bo.KualiUser)
047: */
048: public List getUsersGroups(UniversalUser universalUser) {
049: List usersGroups = null;
050:
051: String userId = universalUser.getPersonUserIdentifier();
052:
053: try {
054:
055: Collection workflowUsersGroups = getWorkflowGroupService()
056: .getWorkflowUsersGroups(
057: new NetworkIdVO(universalUser
058: .getPersonUserIdentifier()));
059: if (workflowUsersGroups != null) {
060: usersGroups = new ArrayList(workflowUsersGroups.size());
061:
062: Iterator iter = workflowUsersGroups.iterator();
063: while (iter.hasNext()) {
064: WorkgroupVO workgroup = (WorkgroupVO) iter.next();
065: KualiGroup kualiGroup = new KualiGroup();
066: kualiGroup.setGroupDescription(workgroup
067: .getDescription());
068: kualiGroup.setGroupName(workgroup
069: .getWorkgroupName());
070:
071: List groupUsers = getGroupUsers(workgroup);
072:
073: kualiGroup.setGroupUsers(groupUsers);
074: usersGroups.add(kualiGroup);
075: }
076:
077: usersGroups.add(KualiGroup.KUALI_UNIVERSAL_GROUP);
078: }
079: } catch (WorkflowException e) {
080: LOG.error("Caught a WorkflowException: " + userId, e);
081: throw new RuntimeException("EdenException: ", e);
082: }
083:
084: return usersGroups;
085: }
086:
087: private List getGroupUsers(WorkgroupVO workgroup) {
088: // TODO do we want empty list here instead of null groupUsers attribute?
089: List groupUsers = new ArrayList();
090:
091: List members = Arrays.asList(workgroup.getMembers());
092: if (members != null) {
093: Iterator iter = members.iterator();
094: while (iter.hasNext()) {
095: groupUsers.add(((UserVO) iter.next()).getNetworkId());
096: }
097: }
098: return groupUsers;
099:
100: }
101:
102: }
|