001: /*
002: * NEMESIS-FORUM.
003: * Copyright (C) 2002 David Laurent(lithium2@free.fr). All rights reserved.
004: *
005: * Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
006: *
007: * Copyright (C) 2001 Yasna.com. All rights reserved.
008: *
009: * Copyright (C) 2000 CoolServlets.com. All rights reserved.
010: *
011: * NEMESIS-FORUM. is free software; you can redistribute it and/or
012: * modify it under the terms of the Apache Software License, Version 1.1,
013: * or (at your option) any later version.
014: *
015: * NEMESIS-FORUM core framework, NEMESIS-FORUM backoffice, NEMESIS-FORUM frontoffice
016: * application are parts of NEMESIS-FORUM and are distributed under
017: * same terms of licence.
018: *
019: *
020: * NEMESIS-FORUM includes software developed by the Apache Software Foundation (http://www.apache.org/)
021: * and software developed by CoolServlets.com (http://www.coolservlets.com).
022: * and software developed by Yasna.com (http://www.yasna.com).
023: *
024: */
025:
026: package org.nemesis.forum;
027:
028: import java.util.Iterator;
029:
030: import org.nemesis.forum.exception.UnauthorizedException;
031:
032: /**
033: * Organizes Users into a group for easier permissions management at the
034: * Forum level. In this way, Groups essentially serve the same purpose that
035: * they do in Unix or Windows.<p>
036: *
037: * For example, CREATE_THREAD permissions can be set per forum. A forum
038: * administrator may wish to create a "Thread Posters" group that has
039: * CREATE_THREAD permissions in the forum. Then, users can be added to that
040: * group and will automatically receive CREATE_THREAD permissions in that forum.
041: * <p>
042: *
043: * Security for Group objects is provide by GroupProxy protection proxy objects.
044: *
045: * @see User
046: */
047: public interface Group {
048:
049: /**
050: * Returns the id of the group.
051: *
052: * @return the id of the group.
053: */
054: public int getID();
055:
056: /**
057: * Returns the name of the group. For example, 'XYZ Admins'.
058: *
059: * @return the name of the group.
060: */
061: public String getName();
062:
063: /**
064: * Sets the name of the group. For example, 'XYZ Admins'.<p>
065: *
066: * This method is restricted to those with group administration permission.
067: *
068: * @param name the name for the group.
069: * @throws UnauthorizedException if does not have group admin permissions.
070: */
071: public void setName(String name) throws UnauthorizedException;
072:
073: /**
074: * Returns the description of the group. The description often summarizes
075: * a group's function, such as 'Administrators of the XYZ forum'.
076: *
077: * @return the description of the group.
078: */
079: public String getDescription();
080:
081: /**
082: * Sets the description of the group.
083: *
084: * The description often summarizes a group's function, such as
085: * 'Administrators of the XYZ forum'.<p>
086: *
087: * This method is restricted to those with group administration permission.
088: *
089: * @param name the description of the group.
090: * @throws UnauthorizedException if does not have group admin permissions.
091: */
092: public void setDescription(String description)
093: throws UnauthorizedException;
094:
095: /**
096: * Grants administrator privileges of the group to a user.<p>
097: *
098: * This method is restricted to those with group administration permission.
099: *
100: * @param user the User to grant adminstrative privileges to.
101: * @throws UnauthorizedException if does not have group admin permissions.
102: */
103: public void addAdministrator(User user)
104: throws UnauthorizedException;
105:
106: /**
107: * Revokes administrator privileges of the group to a user.<p>
108: *
109: * This method is restricted to those with group administration permission.
110: *
111: * @param user the User to grant adminstrative privileges to.
112: * @throws UnauthorizedException if does not have group admin permissions.
113: */
114: public void removeAdministrator(User user)
115: throws UnauthorizedException;
116:
117: /**
118: * Adds a member to the group.<p>
119: *
120: * This method is restricted to those with group administration permission.
121: *
122: * @param user the User to add to the group.
123: * @throws UnauthorizedException if does not have group admin permissions.
124: */
125: public void addMember(User user) throws UnauthorizedException;
126:
127: /**
128: * Removes a member from the group. If the User is not in the group, this
129: * method does nothing.<p>
130: *
131: * This method is restricted to those with group administration permission.
132: *
133: * @param user the User to remove from the group.
134: * @throws UnauthorizedException if does not have group admin permissions.
135: */
136: public void removeMember(User user) throws UnauthorizedException;
137:
138: /**
139: * Returns true if the User has group administrator permissions. Group
140: * administrators are also considered to be members.
141: *
142: * @return true if the User is an administrator of the group.
143: */
144: public boolean isAdministrator(User user);
145:
146: /**
147: * Returns true if if the User is a member of the group.
148: *
149: * @return true if the User is a member of the group.
150: */
151: public boolean isMember(User user);
152:
153: /**
154: * Returns the number of group administrators.
155: *
156: * @return the number of group administrators.
157: */
158: public int getAdministratorCount();
159:
160: /**
161: * Returns the number of group members.
162: *
163: * @return the number of group members.
164: */
165: public int getMemberCount();
166:
167: /**
168: * An iterator for all the users that are members of the group.
169: *
170: * @return an Iterator for all members of the group.
171: */
172: public Iterator members();
173:
174: /**
175: * An iterator for all the users that are administrators of the group.
176: *
177: * @return an Iterator for all administrators of the group.
178: */
179: public Iterator administrators();
180:
181: /**
182: * Returns the permissions for the group that correspond to the
183: * passed-in Authorization.
184: *
185: * @param authorization the auth token to lookup permissions for.
186: */
187: public abstract ForumPermissions getPermissions(
188: Authorization authorization);
189:
190: /**
191: * Returns true if the handle on the object has the permission specified.
192: * A list of possible permissions can be found in the ForumPermissions
193: * class. Certain methods of this class are restricted to certain
194: * permissions as specified in the method comments.
195: *
196: * @param type a permission type.
197: * @return true if the specified permission is valid.
198: * @see ForumPermissions
199: */
200: public boolean hasPermission(int type);
201: }
|