001: /*
002: * $Header: /export/home/cvsroot/MyPersonalizerRepository/MyPersonalizer/Subsystems/Kernel/Sources/es/udc/mypersonalizer/kernel/model/repository/interfaces/UserGroupAccessor.java,v 1.1.1.1 2004/03/25 12:08:36 fbellas Exp $
003: * $Revision: 1.1.1.1 $
004: * $Date: 2004/03/25 12:08:36 $
005: *
006: * =============================================================================
007: *
008: * Copyright (c) 2003, The MyPersonalizer Development Group
009: * (http://www.tic.udc.es/~fbellas/mypersonalizer/index.html) at
010: * University Of A Coruna
011: * All rights reserved.
012: *
013: * Redistribution and use in source and binary forms, with or without
014: * modification, are permitted provided that the following conditions are met:
015: *
016: * - Redistributions of source code must retain the above copyright notice,
017: * this list of conditions and the following disclaimer.
018: *
019: * - Redistributions in binary form must reproduce the above copyright notice,
020: * this list of conditions and the following disclaimer in the documentation
021: * and/or other materials provided with the distribution.
022: *
023: * - Neither the name of the University Of A Coruna nor the names of its
024: * contributors may be used to endorse or promote products derived from
025: * this software without specific prior written permission.
026: *
027: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
028: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
029: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
030: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
031: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
032: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
033: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
034: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
035: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
036: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
037: * POSSIBILITY OF SUCH DAMAGE.
038: *
039: */
040:
041: package es.udc.mypersonalizer.kernel.model.repository.interfaces;
042:
043: import java.util.Collection;
044:
045: import es.udc.mypersonalizer.kernel.util.exceptions.InstanceNotFoundException;
046: import es.udc.mypersonalizer.kernel.util.exceptions.DuplicateInstanceException;
047: import es.udc.mypersonalizer.kernel.util.exceptions.InternalErrorException;
048: import es.udc.mypersonalizer.kernel.model.repository.interfaces.UserAlreadyExistsInGroupException;
049: import es.udc.mypersonalizer.kernel.model.repository.interfaces.UserDoesNotExistInGroupException;
050:
051: /**
052: * This interface specifies the methods required to store and retrieve
053: * instances of the <code>UserGroup</code> class.
054: *
055: * @author Abel Iago Toral Quiroga
056: * @see UserGroup
057: * @since 1.0
058: */
059: public interface UserGroupAccessor {
060:
061: /**
062: * Finds all groups assigned to a user. Implements Page-by-Page Iterator
063: * design pattern.
064: * @param loginName the user's login name.
065: * @param startIndex the index of the group assigned to this user from
066: * which start to retrive groups.
067: * @param count the number of groups to retrive begining in the
068: * <code>startIndex</code> group.
069: * @throws <code>InternalErrorException</code> if a severe failure occured
070: * @return a <code>Collection</code> of <code>UserGroup</code> objects
071: * representing groups assigned to this user.
072: */
073: public Collection findAllGroupsAssignedToUser(String loginName,
074: int startIndex, int count) throws InternalErrorException;
075:
076: /**
077: * Finds all groups assigned to a user.
078: * @param loginName the user's login name.
079: * @throws <code>InternalErrorException</code> if a severe failure occured
080: * @return a <code>Collection</code> of <code>UserGroup</code> objects
081: * representing groups assigned to this user.
082: */
083: public Collection findAllGroupsAssignedToUser(String loginName)
084: throws InternalErrorException;
085:
086: /**
087: * Finds all users assigned to a group. Implements Page-by-Page Iterator
088: * design pattern.
089: * @param groupId the group identifier.
090: * @param startIndex the index of the user assigned to this group from
091: * which start to retrive users.
092: * @param count the number of users to retrive begining in the
093: * <code>startIndex</code> user.
094: * @throws <code>InternalErrorException</code> if a severe failure occured
095: * @return a <code>Collection</code> with the login names of the users
096: * assigned to the group.
097: */
098: public Collection findAllUsersAssignedToGroup(Long groupId,
099: int startIndex, int count) throws InternalErrorException;
100:
101: /**
102: * Finds all groups. Implements Page-by-Page Iterator design pattern.
103: * @param startIndex the index of the group from
104: * which start to retrive groups.
105: * @param count the number of groups to retrive begining in the
106: * <code>startIndex</code> group.
107: * @throws <code>InternalErrorException</code> if a severe failure occured
108: * @return a <code>Collection</code> of <code>UserGroup</code> objects.
109: */
110: public Collection findAllGroups(int startIndex, int count)
111: throws InternalErrorException;
112:
113: /**
114: * Finds all groups.
115: * @throws <code>InternalErrorException</code> if a severe failure occured
116: * @return a <code>Collection</code> of <code>UserGroup</code> objects.
117: */
118: public Collection findAllGroups() throws InternalErrorException;
119:
120: /**
121: * Finds a specific group by its identifier.
122: * @param userGroupIdentifier the user group identifier
123: * @throws <code>InternalErrorException</code> if a severe failure occured
124: * @throws <code>InstanceNotFoundException</code> if the user group
125: * does not exist.
126: * @return a <code>UserGroup</code> with the group information
127: */
128: public UserGroup findGroup(Long userGroupIdentifier)
129: throws InternalErrorException, InstanceNotFoundException;
130:
131: /**
132: * Finds a specific group by its name.
133: * @param userGroupName the user group name.
134: * @throws <code>InternalErrorException</code> if a severe failure occured
135: * @throws <code>InstanceNotFoundException</code> if the user group does
136: * not exist.
137: * @return a <code>UserGroup</code> with the group information
138: */
139: public UserGroup findGroupByName(String userGroupName)
140: throws InternalErrorException, InstanceNotFoundException;
141:
142: /**
143: * Adds a user to a group.
144: * @param loginName the user's login name.
145: * @param userGroupIdentifier the group where to add the user.
146: * @throws <code>InternalErrorException</code> if a severe failure occured
147: * @throws <code>InstanceNotFoundException</code> if the user group
148: * does not exist.
149: * @throws <code>UserAlreadyExistsInGroupException</code> if the user
150: * was previously assigned to this group.
151: */
152: public void addUserToGroup(String loginName,
153: Long userGroupIdentifier) throws InternalErrorException,
154: InstanceNotFoundException,
155: UserAlreadyExistsInGroupException;
156:
157: /**
158: * Adds a new group of users.
159: * @param userGroup a <code>UserGroup</code> representating the new group
160: * of users
161: * @throws <code>InternalErrorException</code> if a severe failure occured
162: * @throws <code>DuplicateInstanceException</code> if the group already
163: * exists.
164: * @return a <code>UserGroup</code> with the added group, including its
165: * identifier.
166: */
167: public UserGroup addGroup(UserGroup userGroup)
168: throws InternalErrorException, DuplicateInstanceException;
169:
170: /**
171: * Removes a user from a group
172: * @param loginName the user's login name.
173: * @param userGroupIdentifier the group where to remove the user
174: * @throws <code>InternalErrorException</code> if a severe failure occured
175: * @throws <code>InstanceNotFoundException</code> if the user group
176: * does not exist.
177: * @throws <code>UserDoesNotExistInGroupException</code>
178: * if the user is not assigned to this group.
179: */
180: public void removeUserFromGroup(String loginName,
181: Long userGroupIdentifier) throws InternalErrorException,
182: InstanceNotFoundException, UserDoesNotExistInGroupException;
183:
184: /**
185: * Removes a group of users
186: * @param userGroupIdentifier the group to remove
187: * @throws <code>InternalErrorException</code> if a severe failure occured
188: * @throws <code>InstanceNotFoundException</code> if the user group
189: * does not exist.
190: */
191: public void removeGroup(Long userGroupIdentifier)
192: throws InternalErrorException, InstanceNotFoundException;
193:
194: /**
195: * Removes all groups assignments for a given user.
196: * @param loginName the user login name.
197: * @throws <code>InternalErrorException</code> if a severe failure occured
198: */
199: public void removeAllGroupAssignments(String loginName)
200: throws InternalErrorException;
201:
202: /**
203: * Updates a group of users.
204: * @param userGroup the modified group
205: * @throws <code>InternalErrorException</code> if a severe failure occured
206: * @throws <code>InstanceNotFoundException</code> if the user group
207: * does not exist.
208: */
209: public void updateGroup(UserGroup userGroup)
210: throws InternalErrorException, DuplicateInstanceException,
211: InstanceNotFoundException;
212:
213: }
|