01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.workflow.util;
06:
07: import com.opensymphony.module.propertyset.PropertySet;
08:
09: import com.opensymphony.user.*;
10:
11: import com.opensymphony.workflow.*;
12:
13: import java.util.Map;
14:
15: /**
16: * Simple utility class that uses OSUser to determine if the caller is in
17: * the required argument "group".
18: *
19: * @author <a href="mailto:plightbo@hotmail.com">Pat Lightbody</a>
20: */
21: public class OSUserGroupCondition implements Condition {
22: //~ Methods ////////////////////////////////////////////////////////////////
23:
24: public boolean passesCondition(Map transientVars, Map args,
25: PropertySet ps) {
26: try {
27: WorkflowContext context = (WorkflowContext) transientVars
28: .get("context");
29: User user = UserManager.getInstance().getUser(
30: context.getCaller());
31:
32: return user.inGroup((String) args.get("group"));
33: } catch (EntityNotFoundException e) {
34: return false;
35: }
36: }
37: }
|