001    /**
002     * Copyright 2005-2012 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.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/ecl2.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.kew.util;
017    
018    import org.kuali.rice.kew.actionrequest.Recipient;
019    import org.kuali.rice.kim.api.identity.Person;
020    
021    /**
022     * Class was declared multiple times in different classes.  Removed
023     * from classes and placed here.  Also changed some of the logic
024     * so that we can stop using workflowUser
025     *
026     * @author Kuali Rice Team (rice.collab@kuali.org)
027     *
028     */
029    public class WebFriendlyRecipient implements Recipient{
030    
031            private static final long serialVersionUID = 2259350039081951688L;
032    
033            private String displayName;
034            private String recipientId;
035    
036         public WebFriendlyRecipient(String recipientId, String displayName) {
037             this.recipientId = recipientId;
038             this.displayName = displayName;
039         }
040    
041         public WebFriendlyRecipient(Object recipient) {
042             if (recipient instanceof WebFriendlyRecipient) {
043                 recipientId = ((WebFriendlyRecipient) recipient).getRecipientId();
044                 displayName = ((WebFriendlyRecipient) recipient).getDisplayName();
045             } else if(recipient instanceof Person){
046                    recipientId = ((Person)recipient).getPrincipalId();
047                    displayName = ((Person)recipient).getLastName() + ", " + ((Person)recipient).getFirstName();
048            }else {
049                    throw new IllegalArgumentException("Must pass in type Recipient or Person");
050            }
051         }
052    
053         public String getRecipientId() {
054             return recipientId;
055         }
056    
057            /**
058             *
059             * @see org.kuali.rice.kew.actionrequest.Recipient#getDisplayName()
060             */
061            public String getDisplayName() {
062                    return this.displayName;
063            }
064    
065    }