View Javadoc

1   /**
2    * Copyright 2005-2012 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.util;
17  
18  import org.kuali.rice.kew.actionrequest.Recipient;
19  import org.kuali.rice.kim.api.identity.Person;
20  
21  /**
22   * Class was declared multiple times in different classes.  Removed
23   * from classes and placed here.  Also changed some of the logic
24   * so that we can stop using workflowUser
25   *
26   * @author Kuali Rice Team (rice.collab@kuali.org)
27   *
28   */
29  public class WebFriendlyRecipient implements Recipient{
30  
31  	private static final long serialVersionUID = 2259350039081951688L;
32  
33  	private String displayName;
34  	private String recipientId;
35  
36       public WebFriendlyRecipient(String recipientId, String displayName) {
37      	 this.recipientId = recipientId;
38      	 this.displayName = displayName;
39       }
40  
41       public WebFriendlyRecipient(Object recipient) {
42      	 if (recipient instanceof WebFriendlyRecipient) {
43               recipientId = ((WebFriendlyRecipient) recipient).getRecipientId();
44               displayName = ((WebFriendlyRecipient) recipient).getDisplayName();
45           } else if(recipient instanceof Person){
46           	recipientId = ((Person)recipient).getPrincipalId();
47          	displayName = ((Person)recipient).getLastName() + ", " + ((Person)recipient).getFirstName();
48          }else {
49          	throw new IllegalArgumentException("Must pass in type Recipient or Person");
50          }
51       }
52  
53       public String getRecipientId() {
54           return recipientId;
55       }
56  
57  	/**
58  	 *
59  	 * @see org.kuali.rice.kew.actionrequest.Recipient#getDisplayName()
60  	 */
61  	public String getDisplayName() {
62  		return this.displayName;
63  	}
64  
65  }