01: /*
02: * Copyright 2005-2006 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.routetemplate;
18:
19: import java.util.ArrayList;
20: import java.util.Collections;
21: import java.util.List;
22:
23: import edu.iu.uis.eden.engine.RouteContext;
24: import edu.iu.uis.eden.exception.EdenUserNotFoundException;
25:
26: /**
27: * RoleAttribute that exposes an INITIATOR abstract role which resolves to the
28: * initiator of the document.
29: *
30: * @author Aaron Hamid (arh14 at cornell dot edu)
31: */
32: public class InitiatorRoleAttribute extends UnqualifiedRoleAttribute {
33: private static final String INITIATOR_ROLE_KEY = "INITIATOR";
34: private static final String INITIATOR_ROLE_LABEL = "Initiator";
35:
36: private static final Role ROLE = new Role(
37: InitiatorRoleAttribute.class, INITIATOR_ROLE_KEY,
38: INITIATOR_ROLE_LABEL);
39: private static final List<Role> ROLES;
40: static {
41: ArrayList<Role> roles = new ArrayList<Role>(1);
42: roles.add(ROLE);
43: ROLES = Collections.unmodifiableList(roles);
44: }
45:
46: public InitiatorRoleAttribute() {
47: super (ROLES);
48: }
49:
50: public ResolvedQualifiedRole resolveRole(RouteContext routeContext,
51: String roleName) throws EdenUserNotFoundException {
52: // sounds like the role label should be specified as the first parameter here,
53: // but I'll follow AccountAttribute's lead and specify the role key
54: List members = new ArrayList(1);
55: members.add(routeContext.getDocument().getInitiatorUser()
56: .getWorkflowUserId());
57: return new ResolvedQualifiedRole(INITIATOR_ROLE_LABEL, members);
58: }
59: }
|