01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.actions;
18:
19: import java.util.ArrayList;
20: import java.util.Arrays;
21: import java.util.List;
22:
23: import edu.iu.uis.eden.Id;
24: import edu.iu.uis.eden.engine.RouteContext;
25: import edu.iu.uis.eden.exception.EdenUserNotFoundException;
26: import edu.iu.uis.eden.routeheader.DocumentContent;
27: import edu.iu.uis.eden.routetemplate.AbstractRoleAttribute;
28: import edu.iu.uis.eden.routetemplate.ResolvedQualifiedRole;
29: import edu.iu.uis.eden.routetemplate.Role;
30: import edu.iu.uis.eden.user.AuthenticationUserId;
31:
32: /**
33: * Current state of affairs
34: *
35: * jitrue -> primary recipient
36: * natjohns -> delegate (type dictated by rule setup)
37: * shenl -> delegate (type dictated by rule setup)
38: *
39: */
40: public class BANotificationRoleAttribute extends AbstractRoleAttribute {
41:
42: public List getRoleNames() {
43: return Arrays
44: .asList(new Role[] {
45: new Role(getClass(), "Notify", "Notify"),
46: new Role(getClass(), "Notify2", "Notify2"),
47: new Role(getClass(), "NotifyDelegate",
48: "NotifyDelegate") });
49: }
50:
51: public List getQualifiedRoleNames(String roleName,
52: DocumentContent documentContent)
53: throws EdenUserNotFoundException {
54: List qualifiedRoleNames = new ArrayList();
55: if (roleName.equals("Notify") || roleName.equals("Notify2")) {
56: qualifiedRoleNames.add("jitrue");
57: } else
58: throw new RuntimeException("Bad Role " + roleName);
59: return qualifiedRoleNames;
60: }
61:
62: public ResolvedQualifiedRole resolveQualifiedRole(
63: RouteContext routeContext, String roleName,
64: String qualifiedRole) throws EdenUserNotFoundException {
65: if (roleName.equals("Notify") || roleName.equals("Notify2")) {
66: return new ResolvedQualifiedRole(roleName, Arrays
67: .asList(new Id[] { new AuthenticationUserId(
68: qualifiedRole) }));
69: } else if (roleName.equals("NotifyDelegate")) {
70: List recipients = new ArrayList();
71: recipients.add(new AuthenticationUserId("natjohns"));
72: recipients.add(new AuthenticationUserId("shenl"));
73: return new ResolvedQualifiedRole(roleName, recipients);
74: }
75: throw new RuntimeException("Bad Role " + roleName);
76: }
77:
78: }
|