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;
017:
018: import java.util.List;
019:
020: import org.apache.log4j.Logger;
021: import org.kuali.core.bo.user.UniversalUser;
022: import org.kuali.core.bo.user.UserId;
023: import org.kuali.core.dao.UniversalUserDao;
024: import org.kuali.core.exceptions.UserNotFoundException;
025:
026: import edu.iu.uis.eden.KEWServiceLocator;
027: import edu.iu.uis.eden.clientapp.vo.EmplIdVO;
028: import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
029: import edu.iu.uis.eden.clientapp.vo.UuIdVO;
030: import edu.iu.uis.eden.exception.EdenUserNotFoundException;
031: import edu.iu.uis.eden.user.WorkflowUser;
032:
033: /**
034: * Used to eliminate kauli user table and delegate user fetches to workflow User service. Wired in the CoreServiceOverride.xml file.
035: *
036: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
037: */
038: public class RiceKNSDefaultUserDAOImpl implements UniversalUserDao {
039:
040: private static final Logger LOG = Logger
041: .getLogger(RiceKNSDefaultUserDAOImpl.class);
042:
043: public UniversalUser getUser(UserId userId)
044: throws UserNotFoundException {
045:
046: try {
047: if (userId instanceof org.kuali.core.bo.user.AuthenticationUserId) {
048: return convertWorkflowUser(KEWServiceLocator
049: .getUserService().getWorkflowUser(
050: new NetworkIdVO(userId.toString())));
051: }
052: if (userId instanceof org.kuali.core.bo.user.PersonPayrollId) {
053: return convertWorkflowUser(KEWServiceLocator
054: .getUserService().getWorkflowUser(
055: new EmplIdVO(userId.toString())));
056: }
057: if (userId instanceof org.kuali.core.bo.user.UuId) {
058: return convertWorkflowUser(KEWServiceLocator
059: .getUserService().getWorkflowUser(
060: new UuIdVO(userId.toString())));
061: }
062: } catch (EdenUserNotFoundException eunfe) {
063: return null;
064: } catch (Exception e) {
065: LOG.error("Exception caught fetching user from workflow.",
066: e);
067: throw new UserNotFoundException(e.getMessage());
068: }
069: throw new UnsupportedOperationException(
070: "Id type given to dao that is not supported. " + userId);
071: }
072:
073: public WorkflowUser getWorkflowUser(
074: edu.iu.uis.eden.user.UserId userId)
075: throws EdenUserNotFoundException {
076: return KEWServiceLocator.getUserService().getWorkflowUser(
077: userId);
078: }
079:
080: public void save(WorkflowUser workflowUser) {
081: throw new UnsupportedOperationException(
082: "RiceKNSDefaultUserDAOImpl doesn't support saving users");
083: }
084:
085: public List search(WorkflowUser user, boolean useWildCards) {
086: throw new UnsupportedOperationException(
087: "RiceKNSDefaultUserDAOImpl doesn't support searching for users");
088: }
089:
090: private UniversalUser convertWorkflowUser(WorkflowUser user) {
091: UniversalUser kUser = new UniversalUser();
092: kUser.setPersonPayrollIdentifier(user.getEmplId().getEmplId());
093: kUser.setPersonEmailAddress(user.getEmailAddress());
094: kUser.setPersonName(user.getGivenName());
095: kUser.setPersonUserIdentifier(user.getAuthenticationUserId()
096: .getAuthenticationId());
097: kUser.setPersonUniversalIdentifier(user.getWorkflowId());
098: return kUser;
099: }
100:
101: }
|