001: /*
002: * Copyright (c) 2001 - 2005 ivata limited.
003: * All rights reserved.
004: * -----------------------------------------------------------------------------
005: * ivata groupware may be redistributed under the GNU General Public
006: * License as published by the Free Software Foundation;
007: * version 2 of the License.
008: *
009: * These programs are free software; you can redistribute them and/or
010: * modify them under the terms of the GNU General Public License
011: * as published by the Free Software Foundation; version 2 of the License.
012: *
013: * These programs are distributed in the hope that they will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: *
017: * See the GNU General Public License in the file LICENSE.txt for more
018: * details.
019: *
020: * If you would like a copy of the GNU General Public License write to
021: *
022: * Free Software Foundation, Inc.
023: * 59 Temple Place - Suite 330
024: * Boston, MA 02111-1307, USA.
025: *
026: *
027: * To arrange commercial support and licensing, contact ivata at
028: * http://www.ivata.com/contact.jsp
029: * -----------------------------------------------------------------------------
030: * $Log: SettingsRightsBean.java,v $
031: * Revision 1.3 2005/04/10 20:09:33 colinmacleod
032: * Added new themes.
033: * Changed id type to String.
034: * Changed i tag to em and b tag to strong.
035: * Improved PicoContainerFactory with NanoContainer scripts.
036: *
037: * Revision 1.2 2005/04/09 17:19:05 colinmacleod
038: * Changed copyright text to GPL v2 explicitly.
039: *
040: * Revision 1.1.1.1 2005/03/10 17:50:38 colinmacleod
041: * Restructured ivata op around Hibernate/PicoContainer.
042: * Renamed ivata groupware.
043: *
044: * Revision 1.7 2004/11/12 18:17:09 colinmacleod
045: * Ordered imports.
046: *
047: * Revision 1.6 2004/11/12 15:56:46 colinmacleod
048: * Removed dependencies on SSLEXT.
049: * Moved Persistence classes to ivata masks.
050: *
051: * Revision 1.5 2004/07/13 19:41:12 colinmacleod
052: * Moved project to POJOs from EJBs.
053: * Applied PicoContainer to services layer (replacing session EJBs).
054: * Applied Hibernate to persistence layer (replacing entity EJBs).
055: *
056: * Revision 1.3 2004/02/10 19:57:20 colinmacleod
057: * Changed email address.
058: *
059: * Revision 1.2 2004/02/01 22:00:32 colinmacleod
060: * Added full names to author tags
061: *
062: * Revision 1.1.1.1 2004/01/27 20:57:46 colinmacleod
063: * Moved open portal to sourceforge.
064: *
065: * Revision 1.5 2003/11/03 11:28:24 jano
066: * commiting addressbook,
067: * tryinjg to fix deploying problem
068: *
069: * Revision 1.4 2003/10/17 12:36:12 jano
070: * fixing problems with building
071: * converting intranet -> portal
072: * Eclipse building
073: *
074: * Revision 1.3 2003/10/15 13:08:06 jano
075: * converting to XDoclet
076: *
077: * Revision 1.2 2003/10/15 13:04:21 colin
078: * fixing for XDoclet
079: *
080: * Revision 1.2 2003/02/25 14:38:13 colin
081: * implemented setModified methods on entity beans thro IvataEntityBean superclass
082: * -----------------------------------------------------------------------------
083: */
084: package com.ivata.groupware.admin.setting.right;
085:
086: import javax.ejb.CreateException;
087: import javax.ejb.RemoveException;
088: import javax.ejb.SessionBean;
089: import javax.ejb.SessionContext;
090:
091: import org.picocontainer.PicoContainer;
092:
093: import com.ivata.groupware.admin.security.server.SecuritySession;
094: import com.ivata.groupware.container.PicoContainerFactory;
095: import com.ivata.mask.util.SystemException;
096:
097: /**
098: * <p>This session bean manages rigths for changing settings.</p>
099: *
100: * @since 2003-02-11
101: * @author Peter Illes
102: * @version $Revision: 1.3 $
103: *
104: * @ejb.bean
105: * name="SettingsRights"
106: * display-name="SettingRights"
107: * type="Stateless"
108: * view-type="both"
109: * local-jndi-name="SettingsRightsLocal"
110: * jndi-name="SettingsRightsRemote"
111: *
112: *
113: * @ejb.home
114: * generate="false"
115: * remote-class="com.ivata.groupware.admin.setting.right.SettingsRightsRemoteHome"
116: *
117: * @ejb.interface
118: * remote-class="com.ivata.groupware.admin.setting.right.SettingsRightsRemote"
119: */
120: public class SettingsRightsBean implements SessionBean {
121:
122: /**
123: * <p>Provides the session bean with container-specific information.</p>
124: */
125: SessionContext sessionContext;
126:
127: /**
128: * <p>this method sets a setting to be allowed for users to override the
129: * system value</p>, {see canAmendSetting(name)}
130: * @param name the name of the setting
131: *
132: * @ejb.interface-method
133: * view-type="both"
134: */
135: public void addAmendRightForSetting(
136: final SecuritySession securitySession,
137: final String settingName) throws SystemException {
138: getSettingsRights().addAmendRightForSetting(securitySession,
139: settingName);
140: }
141:
142: /**
143: * <p>the method finds out whether a setting can be changed (overriden) by
144: * a user</p>
145: * @param name the name of the setting
146: * @return <code>true</code> when this setting can be overridden by user,
147: * <code>false</code> otherwise
148: *
149: * @ejb.interface-method
150: * view-type="both"
151: */
152: public boolean canAmendSetting(
153: final SecuritySession securitySession,
154: final String settingName) throws SystemException {
155: return getSettingsRights().canAmendSetting(securitySession,
156: 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(
169: final SecuritySession securitySession)
170: throws SystemException {
171: return getSettingsRights().canAmendSystemSettings(
172: securitySession);
173: }
174:
175: /**
176: * <p>Called by the container to notify an entity object it has been
177: * activated.</p>
178: */
179: public void ejbActivate() {
180: }
181:
182: /**
183: * <p>Called by the container just after the bean has been created.</p>
184: *
185: * @throws CreateException if any error occurs. Never thrown by this class.
186: *
187: * @ejb.create-method
188: */
189: public void ejbCreate() throws CreateException {
190: }
191:
192: /**
193: * <p>Called by the container to notify the entity object it will be
194: * deactivated. Called just before deactivation.</p>
195: */
196: public void ejbPassivate() {
197: }
198:
199: /**
200: * <p>This method is called by the container when the bean is about
201: * to be removed.</p>
202: *
203: * <p>This method will be called after a client calls the <code>remove</code>
204: * method of the remote/local home interface.</p>
205: *
206: * @throws RemoveException if any error occurs. Currently never thrown by
207: * this class.
208: */
209: public void ejbRemove() {
210: }
211:
212: /**
213: * Get the settings rights implementation.
214: *
215: * @return valid settings rights implementation.
216: */
217: private SettingsRights getSettingsRights() throws SystemException {
218: PicoContainer container = PicoContainerFactory.getInstance()
219: .getGlobalContainer();
220: return (SettingsRights) container
221: .getComponentInstance(SettingsRights.class);
222: }
223:
224: /**
225: * <p>this method disables overriding the system value of one setting,
226: * {see canAmendSetting(name)}
227: * @param name the name of the setting
228: *
229: * @ejb.interface-method
230: * view-type="both"
231: */
232: public void removeAmendRightForSetting(
233: final SecuritySession securitySession,
234: final String settingName) throws SystemException {
235: getSettingsRights().removeAmendRightForSetting(securitySession,
236: settingName);
237: }
238:
239: /**
240: * <p>Set up the context for this entity object. The session bean stores the
241: * context for later use.</p>
242: *
243: * @param sessionContext the new context which the session object should store.
244: */
245: public final void setSessionContext(
246: final SessionContext sessionContext) {
247: this.sessionContext = sessionContext;
248: }
249: }
|