1 12 13 package com.openedit.util.strainer; 14 15 import java.util.Iterator ; 16 17 import com.openedit.WebPageRequest; 18 import com.openedit.users.Group; 19 import com.openedit.users.User; 20 21 22 27 public class GroupFilter implements Filter 28 { 29 protected String fieldGroupName; 30 31 36 public GroupFilter() 37 { 38 super(); 39 } 40 41 46 public GroupFilter(String inGroupName) 47 { 48 setGroupName(inGroupName); 49 } 50 51 56 public void setGroupName(String groupName) 57 { 58 fieldGroupName = groupName; 59 } 60 61 66 public String getGroupName() 67 { 68 return fieldGroupName; 69 } 70 71 74 public boolean passes(Object inObj) throws FilterException, ClassCastException 75 { 76 WebPageRequest req = (WebPageRequest) inObj; 77 78 User user = req.getUser(); 79 80 if (user == null) 81 { 82 return false; 83 } 84 85 if (getGroupName() == null) 86 { 87 return true; 88 } 89 90 for (Iterator iter = user.getGroups().iterator(); iter.hasNext();) 91 { 92 Group group = (Group) iter.next(); 93 94 if (group.getName().equals(getGroupName())) 95 { 96 return true; 97 } 98 } 99 100 return false; 101 } 102 103 public void accept( FilterVisitor inFilterVisitor ) throws FilterException 104 { 105 107 } 108 109 public Filter[] getFilters() 110 { 111 return null; 113 } 114 } 115 | Popular Tags |