1 53 54 package com.Yasna.forum; 55 56 import java.util.Iterator ; 57 58 62 public class GroupProxy implements Group { 63 64 65 private Group group; 66 67 private Authorization authorization; 68 69 private ForumPermissions permissions; 70 71 public GroupProxy(Group group, Authorization authorization, 72 ForumPermissions permissions) 73 { 74 this.group = group; 75 this.authorization = authorization; 76 this.permissions = permissions; 77 } 78 79 public int getID() { 80 return group.getID(); 81 } 82 83 public String getName() { 84 return group.getName(); 85 } 86 87 public void setName(String name) throws UnauthorizedException { 88 if (permissions.get(ForumPermissions.SYSTEM_ADMIN) || 89 permissions.get(ForumPermissions.GROUP_ADMIN)) 90 { 91 group.setName(name); 92 } 93 else { 94 throw new UnauthorizedException(); 95 } 96 } 97 public boolean getAutoGroupMembership(){ 98 return group.getAutoGroupMembership(); 99 } 100 public void setAutoGroupMembership(boolean param) throws UnauthorizedException{ 101 if (permissions.get(ForumPermissions.SYSTEM_ADMIN) || 102 permissions.get(ForumPermissions.GROUP_ADMIN)) 103 { 104 group.setAutoGroupMembership(param); 105 } 106 else { 107 throw new UnauthorizedException(); 108 } 109 } 110 public String getDescription() { 111 return group.getDescription(); 112 } 113 114 public void setDescription(String description) throws UnauthorizedException 115 { 116 if (permissions.get(ForumPermissions.SYSTEM_ADMIN) || 117 permissions.get(ForumPermissions.GROUP_ADMIN)) 118 { 119 group.setDescription(description); 120 } 121 else { 122 throw new UnauthorizedException(); 123 } 124 } 125 126 public void addAdministrator(User user) throws UnauthorizedException { 127 if (permissions.get(ForumPermissions.SYSTEM_ADMIN) || 128 permissions.get(ForumPermissions.GROUP_ADMIN)) 129 { 130 group.addAdministrator(user); 131 } 132 else { 133 throw new UnauthorizedException(); 134 } 135 } 136 137 public void removeAdministrator(User user) throws UnauthorizedException { 138 if (permissions.get(ForumPermissions.SYSTEM_ADMIN) || 139 permissions.get(ForumPermissions.GROUP_ADMIN)) 140 { 141 group.removeAdministrator(user); 142 } 143 else { 144 throw new UnauthorizedException(); 145 } 146 } 147 148 public void addMember(User user) throws UnauthorizedException { 149 if (permissions.get(ForumPermissions.SYSTEM_ADMIN) || 150 permissions.get(ForumPermissions.GROUP_ADMIN)) 151 { 152 group.addMember(user); 153 } 154 else { 155 throw new UnauthorizedException(); 156 } 157 } 158 159 public void removeMember(User user) throws UnauthorizedException { 160 if (permissions.get(ForumPermissions.SYSTEM_ADMIN) || 161 permissions.get(ForumPermissions.GROUP_ADMIN)) 162 { 163 group.removeMember(user); 164 } 165 else { 166 throw new UnauthorizedException(); 167 } 168 } 169 170 public boolean isAdministrator(User user) { 171 return group.isAdministrator(user); 172 } 173 174 public boolean isMember(User user) { 175 return group.isMember(user); 176 } 177 178 public int getAdministratorCount() { 179 return group.getAdministratorCount(); 180 } 181 182 public int getMemberCount() { 183 return group.getMemberCount(); 184 } 185 186 public Iterator members() { 187 return group.members(); 188 } 189 190 public Iterator administrators() { 191 return group.administrators(); 192 } 193 194 public ForumPermissions getPermissions(Authorization authorization) { 195 return group.getPermissions(authorization); 196 } 197 198 public boolean hasPermission(int type) { 199 return permissions.get(type); 200 } 201 } 202 | Popular Tags |