KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > workflow > util > OSUserGroupCondition


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.workflow.util;
6
7 import com.opensymphony.module.propertyset.PropertySet;
8
9 import com.opensymphony.user.*;
10
11 import com.opensymphony.workflow.*;
12
13 import java.util.Map JavaDoc;
14
15
16 /**
17  * Simple utility class that uses OSUser to determine if the caller is in
18  * the required argument "group".
19  *
20  * @author <a HREF="mailto:plightbo@hotmail.com">Pat Lightbody</a>
21  */

22 public class OSUserGroupCondition implements Condition {
23     //~ Methods ////////////////////////////////////////////////////////////////
24

25     public boolean passesCondition(Map JavaDoc transientVars, Map JavaDoc args, PropertySet ps) {
26         try {
27             WorkflowContext context = (WorkflowContext) transientVars.get("context");
28             User user = UserManager.getInstance().getUser(context.getCaller());
29
30             return user.inGroup((String JavaDoc) args.get("group"));
31         } catch (EntityNotFoundException e) {
32             return false;
33         }
34     }
35 }
36
Popular Tags