KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > policyframework > actions > PoliciesDispatchAction


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.policyframework.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.struts.action.ActionForm;
28 import org.apache.struts.action.ActionForward;
29 import org.apache.struts.action.ActionMapping;
30
31 import com.sslexplorer.navigation.MenuTree;
32 import com.sslexplorer.policyframework.PolicyConstants;
33 import com.sslexplorer.policyframework.PolicyDatabaseFactory;
34 import com.sslexplorer.policyframework.ResourceItem;
35 import com.sslexplorer.policyframework.forms.PoliciesForm;
36 import com.sslexplorer.security.LogonControllerFactory;
37 import com.sslexplorer.security.SessionInfo;
38
39
40 /**
41  * Implementation of an {@link com.sslexplorer.policyframework.actions.AbstractResourcesDispatchAction}
42  * that lists all manageable policies.
43  *
44  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
45  */

46 public class PoliciesDispatchAction extends AbstractResourcesDispatchAction {
47
48     /**
49      * Constructor
50      */

51     public PoliciesDispatchAction() {
52         super(PolicyConstants.POLICY_RESOURCE_TYPE, PolicyConstants.POLICY_RESOURCE_TYPE);
53     }
54
55     /* (non-Javadoc)
56      * @see com.sslexplorer.policyframework.actions.AbstractResourcesDispatchAction#list(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
57      */

58     public ActionForward list(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
59                     throws Exception JavaDoc {
60         PoliciesForm policyForm = (PoliciesForm) form;
61         List JavaDoc policies = PolicyDatabaseFactory.getInstance().getPolicies(getSessionInfo(request).getUser().getRealm());
62         policyForm.initialize(policies, ResourceItem.class, request.getSession(), "name");
63         return super.list(mapping, form, request, response);
64     }
65
66     /* (non-Javadoc)
67      * @see com.sslexplorer.core.actions.CoreAction#getNavigationContext(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
68      */

69     public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) {
70         return SessionInfo.MANAGEMENT_CONSOLE_CONTEXT | SessionInfo.USER_CONSOLE_CONTEXT;
71     }
72     
73     @Override JavaDoc
74     protected void doRemove(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws Exception JavaDoc {
75         super.doRemove(mapping, form, request, response);
76         // we now need to rebuild any menus, as more or less could be visable.
77
LogonControllerFactory.getInstance().applyMenuItemChanges(request);
78     }
79
80 }
Popular Tags