KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > navigation > NavigationBean


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: NavigationBean.java,v $
31  * Revision 1.3 2005/04/10 20:09:39 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:09 colinmacleod
38  * Changed copyright text to GPL v2 explicitly.
39  *
40  * Revision 1.1.1.1 2005/03/10 17:50:35 colinmacleod
41  * Restructured ivata op around Hibernate/PicoContainer.
42  * Renamed ivata groupware.
43  *
44  * Revision 1.6 2004/11/12 18:17:10 colinmacleod
45  * Ordered imports.
46  *
47  * Revision 1.5 2004/11/12 15:57:07 colinmacleod
48  * Removed dependencies on SSLEXT.
49  * Moved Persistence classes to ivata masks.
50  *
51  * Revision 1.4 2004/07/13 19:41:16 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/03/21 21:16:18 colinmacleod
57  * Shortened name to ivata op.
58  *
59  * Revision 1.2 2004/02/01 22:00:34 colinmacleod
60  * Added full names to author tags
61  *
62  * Revision 1.1.1.1 2004/01/27 20:57:58 colinmacleod
63  * Moved ivata openportal 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:13 jano
70  * fixing problems with building
71  * converting intranet -> portal
72  * Eclipse building
73  *
74  * Revision 1.3 2003/10/15 13:55:15 jano
75  * converting to XDoclet
76  *
77  * Revision 1.2 2003/10/15 13:49:57 colin
78  * fixing fo Xdoclet
79  *
80  * Revision 1.12 2003/02/25 14:38:13 colin
81  * implemented setModified methods on entity beans thro IvataEntityBean superclass
82  *
83  * Revision 1.11 2003/02/24 19:27:17 colin
84  * restructured file paths
85  *
86  * Revision 1.10 2003/02/04 17:43:50 colin
87  * copyright notice
88  *
89  * Revision 1.9 2002/09/30 08:26:32 peter
90  * fixed 2 errors when testing for user equality
91  *
92  * Revision 1.8 2002/09/30 07:53:52 peter
93  * added amendMenuItem and removeMenuItem methods
94  *
95  * Revision 1.7 2002/09/11 14:59:14 colin
96  * added code to add a menu item
97  *
98  * Revision 1.6 2002/08/11 11:46:24 colin
99  * 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
115 import java.util.Collection JavaDoc;
116
117 import javax.ejb.CreateException JavaDoc;
118 import javax.ejb.EJBException JavaDoc;
119 import javax.ejb.SessionBean JavaDoc;
120 import javax.ejb.SessionContext JavaDoc;
121
122 import org.picocontainer.PicoContainer;
123
124 import com.ivata.groupware.admin.security.server.SecuritySession;
125 import com.ivata.groupware.container.PicoContainerFactory;
126 import com.ivata.groupware.navigation.menu.item.MenuItemDO;
127 import com.ivata.mask.util.SystemException;
128
129
130 /**
131  * <p><code>SessionBean</code> to let you access the menues and folders in
132  * the system and generally get around.</p>
133  *
134  * @since 2002-05-07
135  * @author Colin MacLeod
136  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
137  * @version $Revision: 1.3 $
138  *
139  * @ejb.bean
140  * name="Navigation"
141  * display-name="Navigation"
142  * type="Stateless"
143  * view-type="remote"
144  * jndi-name="NavigationRemote"
145  *
146  * @ejb.transaction
147  * type = "Required"
148  *
149  * @ejb.home
150  * generate="false"
151  * remote-class="com.ivata.groupware.navigation.NavigationRemoteHome"
152  *
153  * @ejb.interface
154  * remote-class="com.ivata.groupware.navigation.NavigationRemote"
155  */

156 public class NavigationBean implements SessionBean JavaDoc, Navigation {
157
158
159     /**
160      * <p>Provides the session bean with container-specific information.</p>
161      */

162     SessionContext JavaDoc sessionContext;
163
164     /**
165      * <p>Add a new menu item, with no image associated with it initially.</p>
166      *
167      * @param menuId the unique identifier of the menu into which the new item
168      * will be inserted.
169      * @param text human-readable english language text for the menu item.
170      * Should be unique within the menu it is in though this is not enforced
171      * server-side.
172      * @param URL the <code>URL</code> the new menu item links to.
173      * @param userName the user for whom to insert the new menu item, or
174      * <code>null</code> if everyone should see it.
175      *
176      * @ejb.interface-method
177      * view-type="remote"
178      */

179     public void addMenuItem(final SecuritySession securitySession,
180             final MenuItemDO menuItem)
181             throws SystemException {
182         getNavigation().addMenuItem(securitySession, menuItem);
183     }
184
185     /**
186      * <p>changes a menu item, if it belongs to the given user</p>
187      *
188      * @param menuItemId the unique identifier of the menu item to change.
189      * @param text human-readable english language text for the menu item.
190      * Should be unique within the menu it is in though this is not enforced
191      * server-side.
192      * @param URL the <code>URL</code> the new menu item links to.
193      * @param userName the user for whom the menu item should belong
194      *
195      * @ejb.interface-method
196      * view-type="remote"
197      */

198     public void amendMenuItem(final SecuritySession securitySession,
199             final MenuItemDO menuItem)
200             throws SystemException {
201         getNavigation().addMenuItem(securitySession, menuItem);
202     }
203
204     /**
205      * <p>Called by the container to notify a stateful session object it has been
206      * activated.</p>
207      */

208     public void ejbActivate() {}
209
210     /**
211      * <p>Provides the session bean with container-specific information.</p>
212      *
213      * @ejb.create-method
214      */

215     public void ejbCreate() throws CreateException JavaDoc {}
216
217     /**
218      * <p>Called by the container to notify a stateful session object it will be
219      * deactivated. Called just before deactivation.</p>
220      */

221     public void ejbPassivate() {}
222
223     /**
224      * <p>This method is called by the container when the session bean is about
225      * to be removed.</p>
226      *
227      * <p>This method will be called after a client calls the <code>remove</code>
228      * method of the remote/local home interface.</p>
229      */

230     public void ejbRemove() {}
231
232     /**
233      * <p>Find all the menues for a given user.</p>
234      *
235      * @param userName the user to search for
236      * @return a <code>Collection</code>Containing all the user's menues, as
237      * instances of {@link com.ivata.groupware.menu.MenuDO MenuDO}
238      * @see com.ivata.groupware.menu.MenuLocalHome#findByUserName( String sUserName )
239      * @throws EJBException if there is a <code>FinderException</code> calling
240      * <code>MenuLocalHome.findByUserName</code>
241      * @throws EJBException if there is a <code>NamingException</code> setting
242      * looking up the MenuHome
243      *
244      * @ejb.interface-method
245      * view-type="remote"
246      */

247     public Collection JavaDoc findMenues(final SecuritySession securitySession)
248             throws SystemException {
249         return getNavigation().findMenues(securitySession);
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.getComponentInstance(Navigation.class);
260     }
261
262     /**
263      * <p>removes a menu item, if it belongs to the given user</p>
264      *
265      * @param menuItemId the unique identifier of the menu item to remove.
266      * @param userName the user for whom the menu item should belong
267      *
268      * @ejb.interface-method
269      * view-type="remote"
270      */

271     public void removeMenuItem(final SecuritySession securitySession,
272             final String JavaDoc id)
273             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(final SessionContext JavaDoc sessionContext) {
286         this.sessionContext = sessionContext;
287     }
288 }
289
Popular Tags