KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > admin > setting > right > SettingsRightsBean


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: SettingsRightsBean.java,v $
31  * Revision 1.3 2005/04/10 20:09:33 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:05 colinmacleod
38  * Changed copyright text to GPL v2 explicitly.
39  *
40  * Revision 1.1.1.1 2005/03/10 17:50:38 colinmacleod
41  * Restructured ivata op around Hibernate/PicoContainer.
42  * Renamed ivata groupware.
43  *
44  * Revision 1.7 2004/11/12 18:17:09 colinmacleod
45  * Ordered imports.
46  *
47  * Revision 1.6 2004/11/12 15:56:46 colinmacleod
48  * Removed dependencies on SSLEXT.
49  * Moved Persistence classes to ivata masks.
50  *
51  * Revision 1.5 2004/07/13 19:41:12 colinmacleod
52  * Moved project to POJOs from EJBs.
53  * Applied PicoContainer to services layer (replacing session EJBs).
54  * Applied Hibernate to persistence layer (replacing entity EJBs).
55  *
56  * Revision 1.3 2004/02/10 19:57:20 colinmacleod
57  * Changed email address.
58  *
59  * Revision 1.2 2004/02/01 22:00:32 colinmacleod
60  * Added full names to author tags
61  *
62  * Revision 1.1.1.1 2004/01/27 20:57:46 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:08:06 jano
75  * converting to XDoclet
76  *
77  * Revision 1.2 2003/10/15 13:04:21 colin
78  * fixing for XDoclet
79  *
80  * Revision 1.2 2003/02/25 14:38:13 colin
81  * implemented setModified methods on entity beans thro IvataEntityBean superclass
82  * -----------------------------------------------------------------------------
83  */

84 package com.ivata.groupware.admin.setting.right;
85
86 import javax.ejb.CreateException JavaDoc;
87 import javax.ejb.RemoveException JavaDoc;
88 import javax.ejb.SessionBean JavaDoc;
89 import javax.ejb.SessionContext JavaDoc;
90
91 import org.picocontainer.PicoContainer;
92
93 import com.ivata.groupware.admin.security.server.SecuritySession;
94 import com.ivata.groupware.container.PicoContainerFactory;
95 import com.ivata.mask.util.SystemException;
96
97
98 /**
99  * <p>This session bean manages rigths for changing settings.</p>
100  *
101  * @since 2003-02-11
102  * @author Peter Illes
103  * @version $Revision: 1.3 $
104  *
105  * @ejb.bean
106  * name="SettingsRights"
107  * display-name="SettingRights"
108  * type="Stateless"
109  * view-type="both"
110  * local-jndi-name="SettingsRightsLocal"
111  * jndi-name="SettingsRightsRemote"
112  *
113  *
114  * @ejb.home
115  * generate="false"
116  * remote-class="com.ivata.groupware.admin.setting.right.SettingsRightsRemoteHome"
117  *
118  * @ejb.interface
119  * remote-class="com.ivata.groupware.admin.setting.right.SettingsRightsRemote"
120  */

121 public class SettingsRightsBean implements SessionBean JavaDoc {
122
123
124     /**
125      * <p>Provides the session bean with container-specific information.</p>
126      */

127     SessionContext JavaDoc sessionContext;
128
129     /**
130      * <p>this method sets a setting to be allowed for users to override the
131      * system value</p>, {see canAmendSetting(name)}
132      * @param name the name of the setting
133      *
134      * @ejb.interface-method
135      * view-type="both"
136      */

137     public void addAmendRightForSetting(final SecuritySession securitySession,
138             final String JavaDoc settingName)
139             throws SystemException {
140         getSettingsRights().addAmendRightForSetting(securitySession, settingName);
141     }
142
143     /**
144      * <p>the method finds out whether a setting can be changed (overriden) by
145      * a user</p>
146      * @param name the name of the setting
147      * @return <code>true</code> when this setting can be overridden by user,
148      * <code>false</code> otherwise
149      *
150      * @ejb.interface-method
151      * view-type="both"
152      */

153     public boolean canAmendSetting(final SecuritySession securitySession,
154             final String JavaDoc settingName)
155             throws SystemException {
156         return getSettingsRights().canAmendSetting(securitySession, settingName);
157     }
158
159     /**
160      * <p>the method tells whether a user can amend system settings</p>
161      * @param userName the name of the user
162      * @return <code>true</code> when this user can amend system settings or
163      * <code>false</code> when he can't
164      *
165      * @ejb.interface-method
166      * view-type="both"
167      */

168     public boolean canAmendSystemSettings(final SecuritySession securitySession)
169             throws SystemException {
170         return getSettingsRights().canAmendSystemSettings(securitySession);
171     }
172
173     /**
174      * <p>Called by the container to notify an entity object it has been
175      * activated.</p>
176      */

177     public void ejbActivate() {}
178
179     /**
180      * <p>Called by the container just after the bean has been created.</p>
181      *
182      * @throws CreateException if any error occurs. Never thrown by this class.
183      *
184      * @ejb.create-method
185      */

186     public void ejbCreate() throws CreateException JavaDoc {}
187
188     /**
189      * <p>Called by the container to notify the entity object it will be
190      * deactivated. Called just before deactivation.</p>
191      */

192     public void ejbPassivate() {}
193
194     /**
195      * <p>This method is called by the container when the bean is about
196      * to be removed.</p>
197      *
198      * <p>This method will be called after a client calls the <code>remove</code>
199      * method of the remote/local home interface.</p>
200      *
201      * @throws RemoveException if any error occurs. Currently never thrown by
202      * this class.
203      */

204     public void ejbRemove() {}
205     /**
206      * Get the settings rights implementation.
207      *
208      * @return valid settings rights implementation.
209      */

210     private SettingsRights getSettingsRights() throws SystemException {
211         PicoContainer container = PicoContainerFactory.getInstance()
212             .getGlobalContainer();
213         return (SettingsRights) container.getComponentInstance(SettingsRights.class);
214     }
215
216     /**
217      * <p>this method disables overriding the system value of one setting,
218      * {see canAmendSetting(name)}
219      * @param name the name of the setting
220      *
221      * @ejb.interface-method
222      * view-type="both"
223      */

224     public void removeAmendRightForSetting(final SecuritySession securitySession,
225             final String JavaDoc settingName)
226             throws SystemException {
227         getSettingsRights().removeAmendRightForSetting(securitySession, settingName);
228     }
229
230     /**
231      * <p>Set up the context for this entity object. The session bean stores the
232      * context for later use.</p>
233      *
234      * @param sessionContext the new context which the session object should store.
235      */

236     public final void setSessionContext(final SessionContext JavaDoc sessionContext) {
237         this.sessionContext = sessionContext;
238     }
239 }
240
Popular Tags