KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > webforwards > actions > ShowWebForwardsAction


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.webforwards.actions;
21
22 import javax.servlet.http.HttpServletRequest JavaDoc;
23 import javax.servlet.http.HttpServletResponse JavaDoc;
24
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27 import org.apache.struts.Globals;
28 import org.apache.struts.action.ActionForm;
29 import org.apache.struts.action.ActionForward;
30 import org.apache.struts.action.ActionMapping;
31 import org.apache.struts.action.ActionMessage;
32 import org.apache.struts.action.ActionMessages;
33
34 import com.sslexplorer.boot.HostService;
35 import com.sslexplorer.policyframework.ResourceUtil;
36 import com.sslexplorer.policyframework.actions.AbstractFavoriteResourcesDispatchAction;
37 import com.sslexplorer.security.SessionInfo;
38 import com.sslexplorer.webforwards.WebForwardDatabaseFactory;
39 import com.sslexplorer.webforwards.WebForwardPlugin;
40 import com.sslexplorer.webforwards.forms.WebForwardsForm;
41
42 /**
43  * Implementation of {@link com.sslexplorer.policyframework.actions.AbstractFavoriteResourcesDispatchAction}
44  * that lists all assigned or manageable <i>Web Forwards</i>.
45  *
46  * @author James D Robinson <a HREF="mailto:james@3sp.com">&lt;james@3sp.com&gt;</a>
47  *
48  */

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

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

68     public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request,
69                     HttpServletResponse JavaDoc response) throws Exception JavaDoc {
70         ActionForward fwd = super.unspecified(mapping, form, request, response);
71         String JavaDoc hostField = request.getHeader("Host");
72         ((WebForwardsForm) form).initialise(getSessionInfo(request).getNavigationContext() == SessionInfo.MANAGEMENT_CONSOLE_CONTEXT ?
73                         WebForwardDatabaseFactory.getInstance().getWebForwards(getSessionInfo(request).getUser().getRealm().getRealmID()) :
74                             ResourceUtil.getGrantedResource(getSessionInfo(request), getResourceType()), hostField == null ? null : new HostService(hostField), this.getSessionInfo(request));
75         ((WebForwardsForm) form).checkSelectedView(request, response);
76         return fwd;
77     }
78
79     /*
80      * (non-Javadoc)
81      *
82      * @see com.sslexplorer.core.actions.CoreAction#getNavigationContext(org.apache.struts.action.ActionMapping,
83      * org.apache.struts.action.ActionForm,
84      * javax.servlet.http.HttpServletRequest,
85      * javax.servlet.http.HttpServletResponse)
86      */

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

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