KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > sample > actions > ShowSamplesAction


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.sample.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.action.ActionForm;
30 import org.apache.struts.action.ActionForward;
31 import org.apache.struts.action.ActionMapping;
32
33 import com.sslexplorer.policyframework.ResourceUtil;
34 import com.sslexplorer.policyframework.actions.AbstractFavoriteResourcesDispatchAction;
35 import com.sslexplorer.sample.Sample;
36 import com.sslexplorer.sample.SamplePlugin;
37 import com.sslexplorer.sample.forms.SamplesForm;
38 import com.sslexplorer.security.SessionInfo;
39
40 /**
41  * <p>
42  * The actions performed on the list of operations.
43  *
44  * @author James D Robinson <a HREF="mailto:james@3sp.com">&lt;james@3sp.com&gt;</a>
45  *
46  */

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

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

66     public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request,
67                     HttpServletResponse JavaDoc response) throws Exception JavaDoc {
68         ActionForward fwd = super.unspecified(mapping, form, request, response);
69         SamplesForm samplesForm = (SamplesForm) form;
70
71         // TODO get the samples and initialise the Form with the Items.
72

73         List JavaDoc samples = getSessionInfo(request).getNavigationContext() == SessionInfo.MANAGEMENT_CONSOLE_CONTEXT ? ResourceUtil
74                         .filterManageableResources(SamplePlugin.getDatabase().getSamples(), getSessionInfo(request).getUser())
75                         : ResourceUtil.getGrantedResource(getSessionInfo(request), getResourceType());
76         samplesForm.initialise(samples, getSessionInfo(request), ".name");
77
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 }
Popular Tags