KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > applications > actions > ShowApplicationShortcutsDispatchAction


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.applications.actions;
21
22 import java.util.List JavaDoc;
23
24 import javax.servlet.http.HttpServletRequest JavaDoc;
25 import javax.servlet.http.HttpServletResponse JavaDoc;
26
27 import org.apache.commons.logging.Log;
28 import org.apache.commons.logging.LogFactory;
29 import org.apache.struts.Globals;
30 import org.apache.struts.action.ActionForm;
31 import org.apache.struts.action.ActionForward;
32 import org.apache.struts.action.ActionMapping;
33 import org.apache.struts.action.ActionMessage;
34 import org.apache.struts.action.ActionMessages;
35
36 import com.sslexplorer.applications.ApplicationShortcutDatabaseFactory;
37 import com.sslexplorer.applications.ApplicationsPlugin;
38 import com.sslexplorer.applications.forms.ApplicationShortcutsForm;
39 import com.sslexplorer.policyframework.ResourceUtil;
40 import com.sslexplorer.policyframework.actions.AbstractFavoriteResourcesDispatchAction;
41 import com.sslexplorer.security.SessionInfo;
42
43 /**
44  * Implementation of a
45  * {@link com.sslexplorer.policyframework.actions.AbstractFavoriteResourcesDispatchAction}
46  * that provides a list of <i>Application Shortucts</i>, one of SSL-Explorer's
47  * main resource types.
48  *
49  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
50  */

51 public class ShowApplicationShortcutsDispatchAction extends AbstractFavoriteResourcesDispatchAction {
52
53     final static Log log = LogFactory.getLog(ShowApplicationShortcutsDispatchAction.class);
54
55     /**
56      * Constructor
57      */

58     public ShowApplicationShortcutsDispatchAction() {
59         super(ApplicationsPlugin.APPLICATION_SHORTCUT_RESOURCE_TYPE, ApplicationsPlugin.APPLICATION_SHORTCUT_RESOURCE_TYPE);
60     }
61
62     /*
63      * (non-Javadoc)
64      *
65      * @see org.apache.struts.actions.DispatchAction#unspecified(org.apache.struts.action.ActionMapping,
66      * org.apache.struts.action.ActionForm,
67      * javax.servlet.http.HttpServletRequest,
68      * javax.servlet.http.HttpServletResponse)
69      */

70     public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request,
71                     HttpServletResponse JavaDoc response) throws Exception JavaDoc {
72         ActionForward fwd = super.unspecified(mapping, form, request, response);
73         List JavaDoc resources = getSessionInfo(request).getNavigationContext() == SessionInfo.MANAGEMENT_CONSOLE_CONTEXT ? ApplicationShortcutDatabaseFactory
74                         .getInstance().getShortcuts(getSessionInfo(request).getUser().getRealm().getRealmID())
75                         : ResourceUtil.getGrantedResource(getSessionInfo(request), getResourceType());
76         ((ApplicationShortcutsForm) form).initialise(resources, getSessionInfo(request), "name", request);
77         ((ApplicationShortcutsForm) form).checkSelectedView(request, response);
78         return fwd;
79     }
80
81     /*
82      * (non-Javadoc)
83      *
84      * @see com.sslexplorer.core.actions.CoreAction#getNavigationContext(org.apache.struts.action.ActionMapping,
85      * org.apache.struts.action.ActionForm,
86      * javax.servlet.http.HttpServletRequest,
87      * javax.servlet.http.HttpServletResponse)
88      */

89     public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) {
90         return SessionInfo.MANAGEMENT_CONSOLE_CONTEXT | SessionInfo.USER_CONSOLE_CONTEXT;
91     }
92
93     /*
94      * (non-Javadoc)
95      *
96      * @see com.sslexplorer.policyframework.actions.AbstractResourcesDispatchAction#remove(org.apache.struts.action.ActionMapping,
97      * org.apache.struts.action.ActionForm,
98      * javax.servlet.http.HttpServletRequest,
99      * javax.servlet.http.HttpServletResponse)
100      */

101     public ActionForward remove(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
102                     throws Exception JavaDoc {
103         ActionForward fwd = super.remove(mapping, form, request, response);
104         ActionMessages msgs = new ActionMessages();
105         msgs.add(Globals.MESSAGE_KEY, new ActionMessage("tunnels.message.tunnelsRemoved", "1"));
106         saveMessages(request, msgs);
107         return fwd;
108
109     }
110 }
Popular Tags