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 a document's user who routed the document
28: *
29: * @author delyea
30: */
31: public class RoutedByUserRoleAttribute extends UnqualifiedRoleAttribute {
32: private static final String ROUTED_BY_USER_ROLE_KEY = "ROUTED_BY_USER";
33: private static final String ROUTED_BY_USER_ROLE_LABEL = "Routed By User";
34:
35: private static final Role ROLE = new Role(
36: RoutedByUserRoleAttribute.class, ROUTED_BY_USER_ROLE_KEY,
37: ROUTED_BY_USER_ROLE_LABEL);
38: private static final List<Role> ROLES;
39: static {
40: ArrayList<Role> roles = new ArrayList<Role>(1);
41: roles.add(ROLE);
42: ROLES = Collections.unmodifiableList(roles);
43: }
44:
45: public RoutedByUserRoleAttribute() {
46: super (ROLES);
47: }
48:
49: public ResolvedQualifiedRole resolveRole(RouteContext routeContext,
50: String roleName) throws EdenUserNotFoundException {
51: // sounds like the role label should be specified as the first parameter here,
52: // but I'll follow AccountAttribute's lead and specify the role key
53: List members = new ArrayList(1);
54: members.add(routeContext.getDocument().getRoutedByUser()
55: .getWorkflowUserId());
56: return new ResolvedQualifiedRole(ROUTED_BY_USER_ROLE_LABEL,
57: members);
58: }
59: }
|