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.GroupAlreadyExistsException;
031: import org.nemesis.forum.exception.GroupNotFoundException;
032: import org.nemesis.forum.exception.UnauthorizedException;
033: import org.nemesis.forum.exception.UserAlreadyExistsException;
034: import org.nemesis.forum.exception.UserNotFoundException;
035:
036: /**
037: * Manages Users and Groups.
038: */
039: public interface ProfileManager {
040:
041: /**
042: * Factory method for creating a new User. A password, email address, and
043: * unique username are all required fields to create a new User.
044: *
045: * @param username the new and unique username for the account.
046: * @param password the password for the account as plain text.
047: * @param email the email address for the account.
048: * @return a new User.
049: * @throws UserAlreadyExistsException if the username already exists in
050: * the system.
051: */
052: public User createUser(String username, String password,
053: String email) throws UserAlreadyExistsException;
054:
055: /**
056: * Factory method for creating a new Group. A unique name is the only
057: * required field.
058: *
059: * @param name the new and unique name for the group.
060: * @return a new Group.
061: * @throws GroupAlreadyExistsException if the group name already exists in
062: * the system.
063: */
064: public Group createGroup(String name) throws UnauthorizedException,
065: GroupAlreadyExistsException;
066:
067: /**
068: * Returns a User specified by their id.
069: *
070: * @param userid the id of the User to lookup.
071: * @return the User specified by the given id.
072: * @throws UserNotFoundException if the user does not exist.
073: */
074: public User getUser(int userID) throws UserNotFoundException;
075:
076: /**
077: * Returns a User specified by username.
078: *
079: * throws UserNotFoundException if the user does not exist.
080: */
081: public User getUser(String username) throws UserNotFoundException;
082:
083: /**
084: * Returns the special "anonymous user" object.
085: */
086: public User getAnonymousUser();
087:
088: /**
089: * Returns the "special user" object. The special user represents any
090: * valid user in the system. Getting a handle on this object is only
091: * really useful for setting permissions on forums. For example, if you
092: * want to allow any registered user to post messgages in a forum, add
093: * a user permission for posting messages with the special user as the
094: * User parameter.
095: */
096: public User getSpecialUser();
097:
098: /**
099: * Gets a Group by ID.
100: *
101: * throws GroupNotFoundException if the group does not exist.
102: */
103: public Group getGroup(int groupID) throws GroupNotFoundException;
104:
105: /**
106: * Gets a Group by name.
107: *
108: * throws GroupNotFoundException if the group does not exist.
109: */
110: public Group getGroup(String name) throws GroupNotFoundException;
111:
112: /**
113: * Deletes a User.
114: *
115: * @param user the user to delete.
116: * @throws UnauthorizedException
117: */
118: public void deleteUser(User user) throws UnauthorizedException;
119:
120: /**
121: * Deletes a Group.
122: *
123: * @param group the group to delete.
124: * @throws UnauthorizedException
125: */
126: public void deleteGroup(Group group) throws UnauthorizedException;
127:
128: /**
129: * Returns the numer of users in the system.
130: */
131: public int getUserCount();
132:
133: /**
134: * Returns the number of groups in the system.
135: */
136: public int getGroupCount();
137:
138: /**
139: * Retruns an iterator for all users.
140: */
141: public Iterator users();
142:
143: /**
144: * Returns an iterator for all users starting at startIndex with the
145: * given number of results. This is useful to support pagination in a GUI
146: * where you may only want to display a certain number of results per page.
147: * It is possible that the number of results returned will be less than
148: * that specified by numResults if numResults is greater than the number
149: * of records left in the system to display.
150: *
151: * @param startIndex the beginning index to start the results at.
152: * @param numResults the total number of results to return.
153: * @return an Iterator for all users in the specified range.
154: */
155: public Iterator users(int startIndex, int numResults);
156:
157: /**
158: * Returns an iterator for all groups in the system.
159: *
160: * @return an Iterator for all groups.
161: */
162: public Iterator groups();
163:
164: /**
165: * Returns an iterator for all groups starting at startIndex with the
166: * given number of results. This is useful to support pagination in a GUI
167: * where you may only want to display a certain number of results per page.
168: * It is possible that the number of results returned will be less than
169: * that specified by numResults if numResults is greater than the number
170: * of records left in the system to display.
171: *
172: * @param startIndex the beginning index to start the results at.
173: * @param numResults the total number of results to return.
174: * @return an Iterator for all groups in the specified range.
175: */
176: public Iterator groups(int startIndex, int numResults);
177:
178: /**
179: * Returns the number of messages a user has posted in a particular forum.
180: *
181: * @param user the user you want results for.
182: * @param forum the forum you want to check results in.
183: * @return the number of messages the user posted in the forum.
184: */
185: public int userMessageCount(User user, Forum forum);
186:
187: /**
188: * Returns an iterator for all the messages that a user posted in a
189: * particular forum.
190: */
191: public Iterator userMessages(User user, Forum forum);
192: }
|