KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > extensions > actions > ExtensionBundleInformationAction


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.extensions.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.action.ActionForm;
28 import org.apache.struts.action.ActionForward;
29 import org.apache.struts.action.ActionMapping;
30
31 import com.sslexplorer.core.actions.AuthenticatedDispatchAction;
32 import com.sslexplorer.extensions.ExtensionBundle;
33 import com.sslexplorer.extensions.forms.ExtensionBundleInformationForm;
34 import com.sslexplorer.extensions.store.ExtensionStore;
35 import com.sslexplorer.security.Constants;
36 import com.sslexplorer.security.SessionInfo;
37
38 /**
39  * Action that display details about a {@link ExtensionBundle}.
40  *
41  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
42  */

43 public class ExtensionBundleInformationAction extends AuthenticatedDispatchAction {
44
45     final static Log log = LogFactory.getLog(ExtensionBundleInformationAction.class);
46
47     /**
48      * Constructor
49      */

50     public ExtensionBundleInformationAction() {
51         super();
52     }
53
54     /*
55      * (non-Javadoc)
56      *
57      * @see org.apache.struts.actions.DispatchAction#unspecified(org.apache.struts.action.ActionMapping,
58      * org.apache.struts.action.ActionForm,
59      * javax.servlet.http.HttpServletRequest,
60      * javax.servlet.http.HttpServletResponse)
61      */

62     public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request,
63                                      HttpServletResponse JavaDoc response) throws Exception JavaDoc {
64         try {
65             String JavaDoc bundleId = request.getParameter("bundleId");
66             ExtensionBundle bundle;
67             try {
68                 bundle = ExtensionStore.getInstance().getExtensionBundle(bundleId);
69             }
70             catch(Exception JavaDoc e) {
71                 bundle = ExtensionStore.getInstance().getDownloadableExtensionStoreDescriptor(true).getApplicationBundle(bundleId);
72             }
73             request.setAttribute(Constants.REQ_ATTR_INFO_RESOURCE, bundle);
74             return extensionBundleInformation(mapping, form, request, response);
75         } catch (Exception JavaDoc e) {
76             log.error("Failed to get extension information. ", e);
77             response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
78             return null;
79         }
80     }
81
82     /**
83      * Display information about an extension bundle
84      *
85      * @param mapping mapping
86      * @param form form
87      * @param request request
88      * @param response response
89      * @return forward
90      * @throws Exception on any error
91      */

92     public ActionForward extensionBundleInformation(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request,
93                                                     HttpServletResponse JavaDoc response) throws Exception JavaDoc {
94         ((ExtensionBundleInformationForm) form).initialise((ExtensionBundle) request.getAttribute(Constants.REQ_ATTR_INFO_RESOURCE));
95         return mapping.findForward("display");
96     }
97
98     /*
99      * (non-Javadoc)
100      *
101      * @see com.sslexplorer.core.actions.CoreAction#getNavigationContext(org.apache.struts.action.ActionMapping,
102      * org.apache.struts.action.ActionForm,
103      * javax.servlet.http.HttpServletRequest,
104      * javax.servlet.http.HttpServletResponse)
105      */

106     public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) {
107         return SessionInfo.MANAGEMENT_CONSOLE_CONTEXT;
108     }
109 }
Popular Tags