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: NavigationBean.java,v $
031: * Revision 1.3 2005/04/10 20:09:39 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:09 colinmacleod
038: * Changed copyright text to GPL v2 explicitly.
039: *
040: * Revision 1.1.1.1 2005/03/10 17:50:35 colinmacleod
041: * Restructured ivata op around Hibernate/PicoContainer.
042: * Renamed ivata groupware.
043: *
044: * Revision 1.6 2004/11/12 18:17:10 colinmacleod
045: * Ordered imports.
046: *
047: * Revision 1.5 2004/11/12 15:57:07 colinmacleod
048: * Removed dependencies on SSLEXT.
049: * Moved Persistence classes to ivata masks.
050: *
051: * Revision 1.4 2004/07/13 19:41:16 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/03/21 21:16:18 colinmacleod
057: * Shortened name to ivata op.
058: *
059: * Revision 1.2 2004/02/01 22:00:34 colinmacleod
060: * Added full names to author tags
061: *
062: * Revision 1.1.1.1 2004/01/27 20:57:58 colinmacleod
063: * Moved ivata openportal 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:13 jano
070: * fixing problems with building
071: * converting intranet -> portal
072: * Eclipse building
073: *
074: * Revision 1.3 2003/10/15 13:55:15 jano
075: * converting to XDoclet
076: *
077: * Revision 1.2 2003/10/15 13:49:57 colin
078: * fixing fo Xdoclet
079: *
080: * Revision 1.12 2003/02/25 14:38:13 colin
081: * implemented setModified methods on entity beans thro IvataEntityBean superclass
082: *
083: * Revision 1.11 2003/02/24 19:27:17 colin
084: * restructured file paths
085: *
086: * Revision 1.10 2003/02/04 17:43:50 colin
087: * copyright notice
088: *
089: * Revision 1.9 2002/09/30 08:26:32 peter
090: * fixed 2 errors when testing for user equality
091: *
092: * Revision 1.8 2002/09/30 07:53:52 peter
093: * added amendMenuItem and removeMenuItem methods
094: *
095: * Revision 1.7 2002/09/11 14:59:14 colin
096: * added code to add a menu item
097: *
098: * Revision 1.6 2002/08/11 11:46:24 colin
099: * Changed isFolderOpen return from boolean to Boolean.
100: * This allows us to check if it has been set yet or not.
101: *
102: * Revision 1.5 2002/06/28 13:29:01 colin
103: * improved menu sorting routine so that texts are sorted if the priorities are the same.
104: *
105: * Revision 1.4 2002/06/21 13:10:48 colin
106: * restructured com.ivata.groupware.web
107: *
108: * Revision 1.3 2002/06/17 07:28:57 colin
109: * improved and extended javadoc documentation
110: * -----------------------------------------------------------------------------
111: */
112: package com.ivata.groupware.navigation;
113:
114: import java.util.Collection;
115:
116: import javax.ejb.CreateException;
117: import javax.ejb.EJBException;
118: import javax.ejb.SessionBean;
119: import javax.ejb.SessionContext;
120:
121: import org.picocontainer.PicoContainer;
122:
123: import com.ivata.groupware.admin.security.server.SecuritySession;
124: import com.ivata.groupware.container.PicoContainerFactory;
125: import com.ivata.groupware.navigation.menu.item.MenuItemDO;
126: import com.ivata.mask.util.SystemException;
127:
128: /**
129: * <p><code>SessionBean</code> to let you access the menues and folders in
130: * the system and generally get around.</p>
131: *
132: * @since 2002-05-07
133: * @author Colin MacLeod
134: * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
135: * @version $Revision: 1.3 $
136: *
137: * @ejb.bean
138: * name="Navigation"
139: * display-name="Navigation"
140: * type="Stateless"
141: * view-type="remote"
142: * jndi-name="NavigationRemote"
143: *
144: * @ejb.transaction
145: * type = "Required"
146: *
147: * @ejb.home
148: * generate="false"
149: * remote-class="com.ivata.groupware.navigation.NavigationRemoteHome"
150: *
151: * @ejb.interface
152: * remote-class="com.ivata.groupware.navigation.NavigationRemote"
153: */
154: public class NavigationBean implements SessionBean, Navigation {
155:
156: /**
157: * <p>Provides the session bean with container-specific information.</p>
158: */
159: SessionContext sessionContext;
160:
161: /**
162: * <p>Add a new menu item, with no image associated with it initially.</p>
163: *
164: * @param menuId the unique identifier of the menu into which the new item
165: * will be inserted.
166: * @param text human-readable english language text for the menu item.
167: * Should be unique within the menu it is in though this is not enforced
168: * server-side.
169: * @param URL the <code>URL</code> the new menu item links to.
170: * @param userName the user for whom to insert the new menu item, or
171: * <code>null</code> if everyone should see it.
172: *
173: * @ejb.interface-method
174: * view-type="remote"
175: */
176: public void addMenuItem(final SecuritySession securitySession,
177: final MenuItemDO menuItem) throws SystemException {
178: getNavigation().addMenuItem(securitySession, menuItem);
179: }
180:
181: /**
182: * <p>changes a menu item, if it belongs to the given user</p>
183: *
184: * @param menuItemId the unique identifier of the menu item to change.
185: * @param text human-readable english language text for the menu item.
186: * Should be unique within the menu it is in though this is not enforced
187: * server-side.
188: * @param URL the <code>URL</code> the new menu item links to.
189: * @param userName the user for whom the menu item should belong
190: *
191: * @ejb.interface-method
192: * view-type="remote"
193: */
194: public void amendMenuItem(final SecuritySession securitySession,
195: final MenuItemDO menuItem) throws SystemException {
196: getNavigation().addMenuItem(securitySession, menuItem);
197: }
198:
199: /**
200: * <p>Called by the container to notify a stateful session object it has been
201: * activated.</p>
202: */
203: public void ejbActivate() {
204: }
205:
206: /**
207: * <p>Provides the session bean with container-specific information.</p>
208: *
209: * @ejb.create-method
210: */
211: public void ejbCreate() throws CreateException {
212: }
213:
214: /**
215: * <p>Called by the container to notify a stateful session object it will be
216: * deactivated. Called just before deactivation.</p>
217: */
218: public void ejbPassivate() {
219: }
220:
221: /**
222: * <p>This method is called by the container when the session bean is about
223: * to be removed.</p>
224: *
225: * <p>This method will be called after a client calls the <code>remove</code>
226: * method of the remote/local home interface.</p>
227: */
228: public void ejbRemove() {
229: }
230:
231: /**
232: * <p>Find all the menues for a given user.</p>
233: *
234: * @param userName the user to search for
235: * @return a <code>Collection</code>Containing all the user's menues, as
236: * instances of {@link com.ivata.groupware.menu.MenuDO MenuDO}
237: * @see com.ivata.groupware.menu.MenuLocalHome#findByUserName( String sUserName )
238: * @throws EJBException if there is a <code>FinderException</code> calling
239: * <code>MenuLocalHome.findByUserName</code>
240: * @throws EJBException if there is a <code>NamingException</code> setting
241: * looking up the MenuHome
242: *
243: * @ejb.interface-method
244: * view-type="remote"
245: */
246: public Collection findMenues(final SecuritySession securitySession)
247: throws SystemException {
248: return getNavigation().findMenues(securitySession);
249: }
250:
251: /**
252: * Get the navigation implementation.
253: *
254: * @return valid security implementation.
255: */
256: private Navigation getNavigation() throws SystemException {
257: PicoContainer container = PicoContainerFactory.getInstance()
258: .getGlobalContainer();
259: return (Navigation) container
260: .getComponentInstance(Navigation.class);
261: }
262:
263: /**
264: * <p>removes a menu item, if it belongs to the given user</p>
265: *
266: * @param menuItemId the unique identifier of the menu item to remove.
267: * @param userName the user for whom the menu item should belong
268: *
269: * @ejb.interface-method
270: * view-type="remote"
271: */
272: public void removeMenuItem(final SecuritySession securitySession,
273: final String id) throws SystemException {
274: getNavigation().removeMenuItem(securitySession, id);
275: }
276:
277: /**
278: * <p>Provides access to the runtime properties of the context in which this
279: * session bean is running.</p>
280: *
281: * <p>Is usually stored by the bean internally.</p>
282: *
283: * @param sessionContext new value for the session context. Is usually stored internally
284: */
285: public final void setSessionContext(
286: final SessionContext sessionContext) {
287: this.sessionContext = sessionContext;
288: }
289: }
|