KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > business > addressbook > right > AddressBookRightsBean


1 /*
2  * Copyright (c) 2001 - 2005 ivata limited.
3  * All rights reserved.
4  * -----------------------------------------------------------------------------
5  * ivata groupware may be redistributed under the GNU General Public
6  * License as published by the Free Software Foundation;
7  * version 2 of the License.
8  *
9  * These programs are free software; you can redistribute them and/or
10  * modify them under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; version 2 of the License.
12  *
13  * These programs are distributed in the hope that they will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License in the file LICENSE.txt for more
18  * details.
19  *
20  * If you would like a copy of the GNU General Public License write to
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place - Suite 330
24  * Boston, MA 02111-1307, USA.
25  *
26  *
27  * To arrange commercial support and licensing, contact ivata at
28  * http://www.ivata.com/contact.jsp
29  * -----------------------------------------------------------------------------
30  * $Log: AddressBookRightsBean.java,v $
31  * Revision 1.3 2005/04/10 20:09:37 colinmacleod
32  * Added new themes.
33  * Changed id type to String.
34  * Changed i tag to em and b tag to strong.
35  * Improved PicoContainerFactory with NanoContainer scripts.
36  *
37  * Revision 1.2 2005/04/09 17:19:08 colinmacleod
38  * Changed copyright text to GPL v2 explicitly.
39  *
40  * Revision 1.1.1.1 2005/03/10 17:50:21 colinmacleod
41  * Restructured ivata op around Hibernate/PicoContainer.
42  * Renamed ivata groupware.
43  *
44  * Revision 1.7 2004/11/12 18:17:10 colinmacleod
45  * Ordered imports.
46  *
47  * Revision 1.6 2004/11/12 15:57:06 colinmacleod
48  * Removed dependencies on SSLEXT.
49  * Moved Persistence classes to ivata masks.
50  *
51  * Revision 1.5 2004/11/03 15:34:42 colinmacleod
52  * Changed todo comments to all caps.
53  *
54  * Revision 1.4 2004/07/13 19:41:14 colinmacleod
55  * Moved project to POJOs from EJBs.
56  * Applied PicoContainer to services layer (replacing session EJBs).
57  * Applied Hibernate to persistence layer (replacing entity EJBs).
58  *
59  * Revision 1.2 2004/02/01 22:00:33 colinmacleod
60  * Added full names to author tags
61  *
62  * Revision 1.1.1.1 2004/01/27 20:57:52 colinmacleod
63  * Moved open portal to sourceforge.
64  *
65  * Revision 1.5 2003/11/03 11:28:24 jano
66  * commiting addressbook,
67  * tryinjg to fix deploying problem
68  *
69  * Revision 1.4 2003/10/17 12:36:12 jano
70  * fixing problems with building
71  * converting intranet -> portal
72  * Eclipse building
73  *
74  * Revision 1.3 2003/10/15 13:47:36 jano
75  * converting to XDoclet
76  *
77  * Revision 1.2 2003/10/15 13:18:02 colin
78  * fixing for XDoclet
79  *
80  * Revision 1.6 2003/08/19 14:53:30 jano
81  * *** empty log message ***
82  *
83  * Revision 1.5 2003/08/13 13:33:34 jano
84  * addressBook exttension: next level
85  *
86  * Revision 1.4 2003/08/05 14:57:35 jano
87  * addressBook extension
88  *
89  * Revision 1.3 2003/05/27 14:08:41 colin
90  * added amendRightsForGroup
91  *
92  * Revision 1.2 2003/05/12 13:46:16 colin
93  * added new methods for finding rights
94  *
95  * Revision 1.1 2003/02/24 19:09:21 colin
96  * moved to business
97  *
98  * Revision 1.9 2003/02/04 17:43:45 colin
99  * copyright notice
100  *
101  * Revision 1.8 2003/01/09 10:51:25 jano
102  * I need only one method for finding right for group
103  *
104  * Revision 1.7 2003/01/08 17:15:12 jano
105  * We will use new methods for finding and changing rights for GROUP
106  *
107  * Revision 1.6 2003/01/03 17:16:56 jano
108  * fixing findr problem in canUser
109  *
110  * Revision 1.5 2003/01/02 16:41:00 jano
111  * taking VIEW of
112  *
113  * Revision 1.4 2002/12/12 15:03:41 jano
114  * rights for groups
115  *
116  * Revision 1.3 2002/09/09 08:38:31 colin
117  * moved user handling to new security bean
118  *
119  * Revision 1.2 2002/08/30 09:49:45 colin
120  * changed canUser... methods to just can...
121  *
122  * Revision 1.1 2002/07/26 13:06:56 colin
123  * first compiling version of address book rights
124  * mail server methods currently all return false
125  * -----------------------------------------------------------------------------
126  */

127 package com.ivata.groupware.business.addressbook.right;
128
129 import java.util.Collection JavaDoc;
130
131 import javax.ejb.CreateException JavaDoc;
132 import javax.ejb.RemoveException JavaDoc;
133 import javax.ejb.SessionBean JavaDoc;
134 import javax.ejb.SessionContext JavaDoc;
135
136 import org.picocontainer.PicoContainer;
137
138 import com.ivata.groupware.admin.security.server.SecuritySession;
139 import com.ivata.groupware.business.addressbook.person.PersonDO;
140 import com.ivata.groupware.business.addressbook.person.employee.EmployeeDO;
141 import com.ivata.groupware.business.addressbook.person.group.GroupDO;
142 import com.ivata.groupware.container.PicoContainerFactory;
143 import com.ivata.mask.util.SystemException;
144
145
146 /**
147  * <p>Address book rights determine what each user can and cannot do within the
148  * address book subsystem.</p>
149  *
150  * @since 2002-07-22
151  * @author Colin MacLeod
152  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
153  * @version $Revision: 1.3 $
154  *
155  * @ejb.bean
156  * name="AddressBookRights"
157  * display-name="AddressBookRights"
158  * type="Stateless"
159  * view-type="both"
160  * local-jndi-name="AddressBookRightsLocal"
161  * jndi-name="AddressBookRightsRemote"
162  *
163  * @ejb.transaction
164  * type = "Required"
165  *
166  * @ejb.home
167  * generate="false"
168  * remote-class="com.ivata.groupware.business.addressbook.right.AddressBookRightsRemoteHome"
169  *
170  * @ejb.interface
171  * remote-class="com.ivata.groupware.business.addressbook.right.AddressBookRightsRemote"
172  */

173 public class AddressBookRightsBean implements SessionBean JavaDoc {
174
175
176     /**
177      * <p>Provides the session bean with container-specific information.</p>
178      */

179     SessionContext JavaDoc sessionContext;
180
181     /**
182      * <p>Change user rights for group.</p>
183      *
184      * @param id of group
185      * @param userName user which trying to change rights
186      * @param rights collection of group ids which will have ACCESS right to that group
187      * @param set to one of the <code>ACCESS_...</code> constants in <code>RightConstants</code>.
188      *
189      * @ejb.interface-method
190      * view-type = "both"
191      */

192     public void amendRightsForGroup(final SecuritySession securitySession,
193             final GroupDO group,
194             final Collection JavaDoc rights,
195             final Integer JavaDoc access) throws SystemException {
196         getAddressBookRights().amendRightsForGroup(securitySession, group, rights, access);
197     }
198
199     /**
200      * <p>TODO: add a comment here.</p>
201      *
202      * @ejb.interface-method
203      * view-type = "both"
204      */

205     public boolean canAddEmployeeToPerson(final SecuritySession securitySession,
206             final PersonDO person) throws SystemException {
207         return getAddressBookRights().canAddEmployeeToPerson(securitySession, person);
208     }
209
210     /**
211      * <p>Find out if a used is allowed to add entries to a given group.</p>
212      *
213      * @param userName the name of the user to check the user rights for.
214      * @param groupId the unique identifier of the group to check.
215      * @return <code>true</code> if the user is entitled to add to the group,
216      * otherwise <code>false</code>.
217      *
218      * @ejb.interface-method
219      * view-type = "both"
220      */

221     public boolean canAddToGroup(final SecuritySession securitySession,
222             final GroupDO group) throws SystemException {
223         return getAddressBookRights().canAddToGroup(securitySession, group);
224     }
225
226     /**
227      * <p>TODO: add a comment here.</p>
228      *
229      * @ejb.interface-method
230      * view-type = "both"
231      */

232     public boolean canAmendEmployee(final SecuritySession securitySession,
233             final EmployeeDO employeeDO) throws SystemException {
234         return getAddressBookRights().canAmendEmployee(securitySession, employeeDO);
235     }
236
237     /**
238      * <p>Find out if a used is allowed to amend entries in a given group.</p>
239      *
240      * @param userName the name of the user to check the user rights for.
241      * @param groupId the unique identifier of the group to check.
242      * @return <code>true</code> if the user is entitled to amend entries in the
243      * group, otherwise <code>false</code>.
244      *
245      * @ejb.interface-method
246      * view-type = "both"
247      */

248     public boolean canAmendInGroup(final SecuritySession securitySession,
249             final GroupDO group) throws SystemException {
250         return getAddressBookRights().canAmendInGroup(securitySession, group);
251     }
252
253     /**
254      * <p>TODO: add a comment here.</p>
255      *
256      * @ejb.interface-method
257      * view-type = "both"
258      */

259     public boolean canRemoveEmployee(final SecuritySession securitySession,
260             final EmployeeDO employeeDO) throws SystemException {
261         return getAddressBookRights().canRemoveEmployee(securitySession, employeeDO);
262     }
263
264     /**
265      * <p>Find out if a used is allowed to remove entries from a given group.</p>
266      *
267      * @param userName the name of the user to check the user rights for.
268      * @param groupId the unique identifier of the group to check.
269      * @return <code>true</code> if the user is entitled to remove from the
270      * group, otherwise <code>false</code>.
271      *
272      * @ejb.interface-method
273      * view-type = "both"
274      */

275     public boolean canRemoveFromGroup(final SecuritySession securitySession,
276             final GroupDO group) throws SystemException {
277         return getAddressBookRights().canRemoveFromGroup(securitySession, group);
278     }
279
280
281     /**
282      * <p>Internal helper method. Find out if a user is allowed to access
283      * entries in a given group.</p>
284      *
285      * @param userName the name of the user to check the user rights for.
286      * @param groupId the unique identifier of the group to check.
287      * @param access the access level as defined in {@link
288      * com.ivata.groupware.business.addressbook.person.group.right.RightConstants
289      * RightConstants}.
290      * @return <code>true</code> if the user is entitled to access entries in the
291      * group, otherwise <code>false</code>.
292      */

293     public boolean canUser(final SecuritySession securitySession,
294             final GroupDO group,
295             final Integer JavaDoc access) throws SystemException {
296         return getAddressBookRights().canUser(securitySession, group, access);
297     }
298
299     /**
300      * <p>Called by the container to notify an entity object it has been
301      * activated.</p>
302      */

303     public void ejbActivate() {}
304
305     /**
306      * <p>Called by the container just after the bean has been created.</p>
307      *
308      * @exception CreateException if any error occurs. Never thrown by this
309      * class.
310      *
311      * @ejb.create-method
312      */

313     public void ejbCreate() throws CreateException JavaDoc {}
314
315     /**
316      * <p>Called by the container to notify the entity object it will be
317      * deactivated. Called just before deactivation.</p>
318      */

319     public void ejbPassivate() {}
320
321     /**
322      * <p>This method is called by the container when the bean is about
323      * to be removed.</p>
324      *
325      * <p>This method will be called after a client calls the <code>remove</code>
326      * method of the remote/local home interface.</p>
327      *
328      * @throws RemoveException if any error occurs. Currently never thrown by
329      * this class.
330      */

331     public void ejbRemove() {}
332     /**
333      * <p>Find the unique identifiers of all addressBooks which can be accessed by the
334      * group specified, with the access level given.</p>
335      *
336      * @param groupId unique identifier of the group for which to search for
337      * other groups.
338      * @param access the access level as defined in {@link
339      * com.ivata.groupware.business.addressbook.person.group.right.RightConstants
340      * RightConstants}.
341      * @return a <code>Collection</code> of <code>Integer</code> instances,
342      * matching all groups which can be access with this level of access
343      * by the group specified.
344      *
345      * @ejb.interface-method
346      * view-type = "both"
347      */

348     public Collection JavaDoc findAddressBooksByGroupAccess(final SecuritySession securitySession,
349             final GroupDO group,
350             final Integer JavaDoc access) throws SystemException {
351         return getAddressBookRights().findAddressBooksByGroupAccess(securitySession, group, access);
352     }
353
354     /**
355      * <p>Find groups which have <code>access</code> to group.
356      * Return only those groups which can be see by that user.</p>
357      *
358      * @param userName user which is trying find rights
359      * @param id of group which we are interesting
360      * @param access find rights with this access
361      * @return Collection of IDS of groups which have <code>access</code> to that group
362      *
363      * @ejb.interface-method
364      * view-type = "both"
365      */

366     public Collection JavaDoc findRightsForGroup(final SecuritySession securitySession,
367             final GroupDO group,
368             final Integer JavaDoc access) throws SystemException {
369         return getAddressBookRights().findRightsForGroup(securitySession, group, access);
370     }
371     /**
372      * Get the addressbook implementation from the <code>PicoContainer</code>.
373      */

374     private AddressBookRights getAddressBookRights()
375             throws SystemException {
376         PicoContainer container = PicoContainerFactory.getInstance()
377             .getGlobalContainer();
378         return (AddressBookRights) container.getComponentInstance(AddressBookRights.class);
379     }
380
381     /**
382      * <p>Set up the context for this entity object. The session bean stores the
383      * context for later use.</p>
384      *
385      * @param sessionContext the new context which the session object should
386      * store.
387      */

388     public final void setSessionContext(final SessionContext JavaDoc sessionContext) {
389         this.sessionContext = sessionContext;
390     }
391 }
392
Popular Tags